From dd571bf55de7f9a72d458adc179958ed2f9473c0 Mon Sep 17 00:00:00 2001
From: XiaoRuby <3114200645@qq.com>
Date: 星期一, 21 八月 2023 09:39:09 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 cnas-server/src/main/java/com/yuanchu/limslaboratory/controller/CnasAnnualPlanController.java |   47 +++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 41 insertions(+), 6 deletions(-)

diff --git a/cnas-server/src/main/java/com/yuanchu/limslaboratory/controller/CnasAnnualPlanController.java b/cnas-server/src/main/java/com/yuanchu/limslaboratory/controller/CnasAnnualPlanController.java
index 08f6654..4b410c5 100644
--- a/cnas-server/src/main/java/com/yuanchu/limslaboratory/controller/CnasAnnualPlanController.java
+++ b/cnas-server/src/main/java/com/yuanchu/limslaboratory/controller/CnasAnnualPlanController.java
@@ -5,6 +5,8 @@
 import com.yuanchu.limslaboratory.pojo.CnasAnnualPlan;
 import com.yuanchu.limslaboratory.pojo.vo.CnasAnnualPlanVo;
 import com.yuanchu.limslaboratory.service.CnasAnnualPlanService;
+import com.yuanchu.limslaboratory.utils.JackSonUtil;
+import com.yuanchu.limslaboratory.utils.RedisUtil;
 import com.yuanchu.limslaboratory.vo.Result;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
@@ -12,7 +14,7 @@
 import io.swagger.annotations.ApiOperation;
 import org.springframework.format.annotation.DateTimeFormat;
 import org.springframework.web.bind.annotation.*;
-import org.springframework.stereotype.Controller;
+import org.springframework.web.multipart.MultipartFile;
 
 import javax.annotation.Resource;
 import java.util.Date;
@@ -39,12 +41,11 @@
     @ApiImplicitParams(value = {
             @ApiImplicitParam(name = "page", value = "鍒濆椤�", dataTypeClass = Integer.class, required = true),
             @ApiImplicitParam(name = "pageSize", value = "姣忎竴椤垫暟閲�", dataTypeClass = Integer.class, required = true),
-            @ApiImplicitParam(name = "beginTime", value = "妫�楠屽紑濮嬫椂闂�", dataTypeClass = Date.class),
-            @ApiImplicitParam(name = "endTime", value = "妫�楠岀粨鏉熸椂闂�", dataTypeClass = Date.class),
+            @ApiImplicitParam(name = "planTime", value = "妫�楠屽紑濮嬫椂闂�", dataTypeClass = Date.class),
     })
     @GetMapping("/selectAllList")
-    public Result selectAllList(Integer page, Integer pageSize, @DateTimeFormat(pattern = "yyyy-MM-dd") Date beginTime, @DateTimeFormat(pattern = "yyyy-MM-dd") Date endTime) {
-        IPage<CnasAnnualPlanVo> reportPage = cnasAnnualPlanService.selectAllList(new Page(page, pageSize), beginTime, endTime);
+    public Result selectAllList(Integer page, Integer pageSize, @DateTimeFormat(pattern = "yyyy-MM") Date planTime) {
+        IPage<CnasAnnualPlanVo> reportPage = cnasAnnualPlanService.selectAllList(new Page(page, pageSize), planTime);
         Map<String, Object> map = new HashMap<>();
         map.put("total", reportPage.getTotal());
         map.put("row", reportPage.getRecords());
@@ -56,9 +57,43 @@
     @ApiImplicitParams(value = {
             @ApiImplicitParam(name = "CnasAnnualPlan", value = "瀹℃煡瀵硅薄", dataTypeClass = Integer.class, required = true)
     })
-    public Result addCnasAnnualPlan(@RequestBody CnasAnnualPlan cnasAnnualPlan) {
+    public Result addCnasAnnualPlan(@RequestHeader("X-Token") String token, @RequestBody CnasAnnualPlan cnasAnnualPlan) throws Exception {
+        Object object = RedisUtil.get(token);
+        Map<String, Object> unmarshal = JackSonUtil.unmarshal(JackSonUtil.marshal(object), Map.class);
+        String name = (String) unmarshal.get("name");
+        cnasAnnualPlan.setKeyboarder(name);
+        //todo:鑾峰彇name鏈夐棶棰�
         cnasAnnualPlanService.save(cnasAnnualPlan);
         return Result.success();
     }
 
+
+    @ApiOperation(value = "涓婁紶闄勪欢")
+    @PostMapping("/addAccessory")
+    @ApiImplicitParams(value = {
+            @ApiImplicitParam(name = "auditTime", value = "瀹℃牳鏃ユ湡", dataTypeClass = Date.class, required = true),
+            @ApiImplicitParam(name = "file", value = "闄勪欢鏂囦欢", dataTypeClass = MultipartFile.class, required = true)
+    })
+    public Result addAccessory(@RequestHeader("X-Token") String token, Date auditTime, MultipartFile file) throws Exception {
+        //瑙f瀽褰撳墠鐧诲綍鐢ㄦ埛
+        Object object = RedisUtil.get(token);
+        Map<String, Object> unmarshal = JackSonUtil.unmarshal(JackSonUtil.marshal(object), Map.class);
+        String name = (String) unmarshal.get("name");
+        cnasAnnualPlanService.addAccessory(name, auditTime, file);
+        return Result.success();
+    }
+
+    @ApiOperation(value = "鍒犻櫎骞村害璁″垝")
+    @GetMapping("/deleteCnasAnnualPlan")
+    @ApiImplicitParams(value = {
+            @ApiImplicitParam(name = "planId", value = "瀹℃牳鏃ユ湡", dataTypeClass = Integer.class, required = true)
+    })
+    public Result deleteCnasAnnualPlan(Integer planId) {
+        Integer isDeleteSuccess = cnasAnnualPlanService.deleteCnasAnnualPlan(planId);
+        if (isDeleteSuccess == 1){
+            return Result.success("鍒犻櫎鎴愬姛");
+        } else {
+            return Result.fail("鍒犻櫎澶辫触");
+        }
+    }
 }

--
Gitblit v1.9.3