Kaynağa Gözat

多个更新

Reiskuchen 5 yıl önce
ebeveyn
işleme
363f24054a

+ 2 - 3
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/ReportController.java

@@ -50,15 +50,14 @@ public class ReportController {
     /**
     /**
      * 新增或编辑报告
      * 新增或编辑报告
      * id 报告id 编辑时传
      * id 报告id 编辑时传
-     * creatorId 报告上传者id 新增时不可为空
      * projectId 报告相关项目id 新增时不可为空
      * projectId 报告相关项目id 新增时不可为空
      * createDate 报告创建时间 新增时不可为空 yyyy-MM-dd
      * createDate 报告创建时间 新增时不可为空 yyyy-MM-dd
      * workingTime 工作时间
      * workingTime 工作时间
      * content 工作内容
      * content 工作内容
      */
      */
     @RequestMapping("/editReport")
     @RequestMapping("/editReport")
-    public HttpRespMsg editReport(Report report) {
-        return reportService.editReport(report);
+    public HttpRespMsg editReport(Report[] report) {
+        return reportService.editReport(report, request);
     }
     }
 
 
     /**
     /**

+ 1 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/ReportService.java

@@ -19,7 +19,7 @@ public interface ReportService extends IService<Report> {
 
 
     HttpRespMsg getReport(String date, HttpServletRequest request);
     HttpRespMsg getReport(String date, HttpServletRequest request);
 
 
-    HttpRespMsg editReport(Report report);
+    HttpRespMsg editReport(Report[] reportList, HttpServletRequest request);
 
 
     HttpRespMsg deleteReport(Integer reportId);
     HttpRespMsg deleteReport(Integer reportId);
 }
 }

+ 20 - 13
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ReportServiceImpl.java

@@ -67,7 +67,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
     public HttpRespMsg getReport(String date, HttpServletRequest request) {
     public HttpRespMsg getReport(String date, HttpServletRequest request) {
         HttpRespMsg httpRespMsg = new HttpRespMsg();
         HttpRespMsg httpRespMsg = new HttpRespMsg();
         try {
         try {
-            String userId = userMapper.selectById(request.getHeader("Token")).getId();
+            String userId = request.getHeader("Token");
             Map<String, Object> resultMap = new HashMap<>();
             Map<String, Object> resultMap = new HashMap<>();
             //获取某日本人的所有日志
             //获取某日本人的所有日志
             resultMap.put("report", reportMapper.selectList(new QueryWrapper<Report>()
             resultMap.put("report", reportMapper.selectList(new QueryWrapper<Report>()
@@ -93,21 +93,28 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
 
 
     //新增或编辑报告
     //新增或编辑报告
     @Override
     @Override
-    public HttpRespMsg editReport(Report report) {
+    public HttpRespMsg editReport(Report[] reportList, HttpServletRequest request) {
         HttpRespMsg httpRespMsg = new HttpRespMsg();
         HttpRespMsg httpRespMsg = new HttpRespMsg();
-        if (report.getId() == null) {
-            //新增报告时 需要检查项目和人员id
-            if (report.getCreatorId() == null || report.getProjectId() == null) {
-                httpRespMsg.setError("请填写完整信息");
-            } else {
-                if (reportMapper.insert(report) == 0) {
-                    httpRespMsg.setError("操作失败");
+        try {
+            for (Report report : reportList) {
+                report.setCreatorId(request.getHeader("Token"));
+                if (report.getId() == null) {
+                    //新增报告时 需要检查项目和人员id
+                    if (report.getProjectId() == null) {
+                        httpRespMsg.setError("请填写完整信息");
+                    } else {
+                        if (reportMapper.insert(report) == 0) {
+                            httpRespMsg.setError("操作失败");
+                        }
+                    }
+                } else {
+                    if (reportMapper.updateById(report) == 0) {
+                        httpRespMsg.setError("操作失败");
+                    }
                 }
                 }
             }
             }
-        } else {
-            if (reportMapper.updateById(report) == 0) {
-                httpRespMsg.setError("操作失败");
-            }
+        } catch (NullPointerException e) {
+            httpRespMsg.setError("验证失败");
         }
         }
         return httpRespMsg;
         return httpRespMsg;
     }
     }