瀏覽代碼

防疫检测

523096025 2 年之前
父節點
當前提交
d05078a1a6

+ 1 - 1
huimv-cattle/src/main/java/com/huimv/cattle/HuimvCattleApplication.java

@@ -5,7 +5,7 @@ import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 
 @SpringBootApplication
-@MapperScan(basePackages ="com.huimv.cattle.mapper")
+@MapperScan("com.huimv.cattle.mapper")
 public class HuimvCattleApplication {
 
     public static void main(String[] args) {

+ 34 - 2
huimv-cattle/src/main/java/com/huimv/cattle/controller/PreventDetectionController.java

@@ -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);
+    }
+
 
 }
 

+ 2 - 0
huimv-cattle/src/main/java/com/huimv/cattle/pojo/PreventDetection.java

@@ -28,6 +28,8 @@ public class PreventDetection implements Serializable {
 
     private Integer month;
 
+    private Integer year;
+
     private Integer detectionNum;
 
     private Integer acceptanceNum;