From 34abd07d1567dd0757113c822e9a7dfc4a4cc1d1 Mon Sep 17 00:00:00 2001 From: value <z1292839451@163.com> Date: 星期四, 31 八月 2023 17:29:26 +0800 Subject: [PATCH] 修改bug --- cnas-server/src/main/java/com/yuanchu/limslaboratory/controller/CnasAnnualPlanController.java | 52 ++++++++++++++++++++++++++++++++++++++++++++++------ 1 files changed, 46 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..7104cd1 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 @@ -2,9 +2,12 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.yuanchu.limslaboratory.annotation.AuthHandler; 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 +15,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 +42,12 @@ @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); + @AuthHandler + 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 +59,46 @@ @ApiImplicitParams(value = { @ApiImplicitParam(name = "CnasAnnualPlan", value = "瀹℃煡瀵硅薄", dataTypeClass = Integer.class, required = true) }) - public Result addCnasAnnualPlan(@RequestBody CnasAnnualPlan cnasAnnualPlan) { + @AuthHandler + 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) + }) + @AuthHandler + 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) + }) + @AuthHandler + public Result deleteCnasAnnualPlan(Integer planId) { + Integer isDeleteSuccess = cnasAnnualPlanService.deleteCnasAnnualPlan(planId); + if (isDeleteSuccess == 1){ + return Result.success("鍒犻櫎鎴愬姛"); + } else { + return Result.fail("鍒犻櫎澶辫触"); + } + } } -- Gitblit v1.9.3