白蚁-防治点-防治部位
parent
4f8be3e0a6
commit
154a9e51d1
|
|
@ -73,7 +73,7 @@ public class PrePlaceController {
|
|||
@Operation(summary = "防治部位修改")
|
||||
@PostMapping("/detail/update")
|
||||
public R<PrePlaceDetail> detailUpdate(@Validated(Update.class) @RequestBody PrePlaceDetail dto) {
|
||||
boolean result = prePlaceDetailService.updateById(dto);
|
||||
boolean result = prePlaceDetailService.update(dto);
|
||||
return R.ok(result ? dto : null);
|
||||
}
|
||||
|
||||
|
|
@ -94,7 +94,7 @@ public class PrePlaceController {
|
|||
@Operation(summary = "防治部位删除")
|
||||
@GetMapping("/detail/del/{id}")
|
||||
public R<Boolean> detailDel(@Schema(name = "id") @PathVariable("id") Serializable id) {
|
||||
boolean b = prePlaceDetailService.removeById(id);
|
||||
boolean b = prePlaceDetailService.deleteById(id);
|
||||
return R.ok(b);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gunshi.project.hsz.entity.so.PrePlacePageSo;
|
||||
import com.gunshi.project.hsz.mapper.ByPlanDetailMapper;
|
||||
import com.gunshi.project.hsz.mapper.PrePlaceDetailMapper;
|
||||
import com.gunshi.project.hsz.mapper.PrePlaceMapper;
|
||||
import com.gunshi.project.hsz.model.PrePlace;
|
||||
|
|
@ -17,6 +18,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
|
|
@ -25,6 +28,9 @@ public class PrePlaceDetailService extends ServiceImpl<PrePlaceDetailMapper, Pre
|
|||
@Autowired
|
||||
private PrePlaceMapper prePlaceMapper;
|
||||
|
||||
@Autowired
|
||||
private ByPlanDetailMapper byPlanDetailMapper;
|
||||
|
||||
public Page<PrePlaceDetail> pageQuery(PrePlacePageSo pageSo) {
|
||||
if(StringUtils.isBlank(pageSo.getPreId())) {
|
||||
throw new RuntimeException("请选择防治点");
|
||||
|
|
@ -46,4 +52,23 @@ public class PrePlaceDetailService extends ServiceImpl<PrePlaceDetailMapper, Pre
|
|||
boolean save = save(dto);
|
||||
return save;
|
||||
}
|
||||
|
||||
public boolean deleteById(Serializable id) {
|
||||
//先在防治计划中查看是否被引用
|
||||
int count = byPlanDetailMapper.selectByPPDI(id);
|
||||
if(count > 0){
|
||||
throw new RuntimeException("该防治点在防治计划中已被选择,不能删除");
|
||||
}
|
||||
boolean b = removeById(id);
|
||||
return b;
|
||||
}
|
||||
|
||||
public boolean update(PrePlaceDetail dto) {
|
||||
int count = byPlanDetailMapper.selectByPPDI(dto.getId());
|
||||
if(count > 0){
|
||||
throw new RuntimeException("该防治点在防治计划中已被选择,不能编辑");
|
||||
}
|
||||
boolean b = updateById(dto);
|
||||
return b;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,8 +53,9 @@ public class PrePlaceService extends ServiceImpl<PrePlaceMapper, PrePlace> {
|
|||
if(!StringUtils.isBlank(dto.getPreName())){
|
||||
queryWrapper.like(PrePlaceDetail::getDetailName, dto.getPreName());
|
||||
}
|
||||
queryWrapper.eq(PrePlaceDetail::getPreId, prePlace.getId());
|
||||
List<PrePlaceDetail> prePlaceDetails = prePlaceDetailMapper.selectList(queryWrapper);
|
||||
if(prePlaceDetails.isEmpty() || !prePlaceDetails.get(0).getPreId().equals(prePlace.getId())){
|
||||
if(prePlaceDetails.isEmpty()){
|
||||
iterator.remove();
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue