|
@@ -1,8 +1,13 @@
|
|
|
package com.huimv.cattle.controller;
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
+import com.alibaba.druid.wall.violation.ErrorCode;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.huimv.cattle.pojo.PreventDetection;
|
|
|
import com.huimv.cattle.service.PreventDetectionService;
|
|
|
+import com.huimv.common.utils.Result;
|
|
|
+import com.huimv.common.utils.ResultCode;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
@@ -10,6 +15,10 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
/**
|
|
|
* <p>
|
|
|
* 前端控制器
|
|
@@ -25,10 +34,33 @@ public class PreventDetectionController {
|
|
|
private PreventDetectionService preventDetectionService;
|
|
|
|
|
|
@PostMapping("/add")
|
|
|
- public void add(@RequestBody PreventDetection preventDetection){
|
|
|
-// Validator.notNull(clientId, ErrorCode.INPUT_PARAMETERS_NULL);
|
|
|
+ public Result add(@RequestBody PreventDetection preventDetection){
|
|
|
preventDetectionService.save(preventDetection);
|
|
|
+ return new Result(10000,"添加成功",true);
|
|
|
+ }
|
|
|
+ @PostMapping("/update")
|
|
|
+ public Result update(@RequestBody PreventDetection preventDetection){
|
|
|
+ preventDetectionService.updateById(preventDetection);
|
|
|
+ return new Result(10000,"修改成功",true);
|
|
|
+ }
|
|
|
+ @PostMapping("/delete")
|
|
|
+ public Result delete(@RequestBody Map<String,String> paramMap){
|
|
|
+ String ids = paramMap.get("ids");
|
|
|
+ String[] split = ids.split(",");
|
|
|
+ for (String s : split) {
|
|
|
+ preventDetectionService.removeById(s);
|
|
|
+ }
|
|
|
+ return new Result(10000,"删除成功",true);
|
|
|
}
|
|
|
+ @PostMapping("/list")
|
|
|
+ public Result list(@RequestBody PreventDetection preventDetection){
|
|
|
+ List<PreventDetection> list = preventDetectionService.list(new QueryWrapper<PreventDetection>().orderByDesc("year").orderByDesc("month"));
|
|
|
+ if (ObjectUtil.isEmpty(list)){
|
|
|
+ return new Result(ResultCode.SUCCESS,new ArrayList<>());
|
|
|
+ }
|
|
|
+ return new Result(ResultCode.SUCCESS,list);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|
|
|
|