|
@@ -4,6 +4,9 @@ import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.huimv.management.entity.YearPigBaseEntity;
|
|
|
+import com.huimv.management.service.YearPigBaseService;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
@@ -29,6 +32,9 @@ public class UnitController {
|
|
|
@Autowired
|
|
|
private UnitService unitService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private YearPigBaseService baseService;
|
|
|
+
|
|
|
/**
|
|
|
* 列表
|
|
|
*/
|
|
@@ -65,7 +71,14 @@ public class UnitController {
|
|
|
*/
|
|
|
@RequestMapping("/update")
|
|
|
public R update(@RequestBody UnitEntity unit){
|
|
|
- unitService.updateById(unit);
|
|
|
+ Integer currentPeriodId = unit.getCurrentPeriodId();
|
|
|
+
|
|
|
+ Integer count = baseService.countByPeriodId(currentPeriodId);
|
|
|
+ if (count > 0){
|
|
|
+ return R.error("修改失败,栏期下面有未清理的小猪");
|
|
|
+ }
|
|
|
+
|
|
|
+ unitService.updateById(unit);
|
|
|
|
|
|
return R.ok();
|
|
|
}
|
|
@@ -75,6 +88,19 @@ public class UnitController {
|
|
|
*/
|
|
|
@RequestMapping("/delete")
|
|
|
public R delete(@RequestBody Integer[] ids){
|
|
|
+
|
|
|
+ for (Integer id : ids) {
|
|
|
+ UnitEntity unit = unitService.getById(id);
|
|
|
+ if (unit == null){
|
|
|
+ return R.error("删除失败,栏期信息有误");
|
|
|
+ }
|
|
|
+
|
|
|
+ Integer currentPeriodId = unit.getCurrentPeriodId();
|
|
|
+ Integer count = baseService.countByPeriodId(currentPeriodId);
|
|
|
+ if (count > 0){
|
|
|
+ return R.error("删除失败,栏期下有未清除的小猪");
|
|
|
+ }
|
|
|
+ }
|
|
|
unitService.removeByIds(Arrays.asList(ids));
|
|
|
|
|
|
return R.ok();
|