Browse Source

修改决策事项管理的接口

hyx 2 years ago
parent
commit
afa838f134

+ 29 - 0
nngkxxdp/src/main/java/com/example/nngkxxdp/controller/PostManagementController.java

@@ -160,6 +160,35 @@ public class PostManagementController {
     }
 
     /**
+     * 通过后台管理系统修改决策事项
+     *
+     * @param postManagement
+     * @param file1          决策草案文件
+     * @param file2          草案解读文件
+     * @param file3          政策解读文件
+     * @param file4          决策文件文件
+     * @param file5          征集情况反馈文件
+     * @return
+     */
+    @PostMapping("/updatePostById")
+    public Map<String, Object> updatePostById(PostManagement postManagement,
+                                              @RequestParam(value = "file1", required = false) MultipartFile file1,
+                                              @RequestParam(value = "file2", required = false) MultipartFile file2,
+                                              @RequestParam(value = "file3", required = false) MultipartFile file3,
+                                              @RequestParam(value = "file4", required = false) MultipartFile file4,
+                                              @RequestParam(value = "file5", required = false) MultipartFile file5) {
+        try {
+            if (Blank.isEmpty(postManagement.getId())) {
+                return SendUtil.send(false, ConstStr.UPDATEUSER_FAILED, "id不能为空");
+            }
+            return postManagementService.updatePostById(postManagement, file1, file2, file3, file4, file5);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return SendUtil.send(false, ConstStr.UPDATEUSER_SUCCESS);
+    }
+
+    /**
      * 通过id查询postmanagement
      */
     @GetMapping("/getPostById/{id}")

+ 2 - 0
nngkxxdp/src/main/java/com/example/nngkxxdp/service/PostManagementService.java

@@ -55,4 +55,6 @@ public interface PostManagementService {
     Map<String, Object> deletePostById(Integer id);
 
     PostManagement getPostById(Integer id);
+
+    Map<String, Object> updatePostById(PostManagement postManagement, MultipartFile file1, MultipartFile file2, MultipartFile file3, MultipartFile file4, MultipartFile file5) throws IOException;
 }

+ 81 - 0
nngkxxdp/src/main/java/com/example/nngkxxdp/service/impl/PostManagementServiceImpl.java

@@ -264,6 +264,87 @@ public class PostManagementServiceImpl implements PostManagementService {
     }
 
     @Override
+    public Map<String, Object> updatePostById(PostManagement postManagement, MultipartFile file1, MultipartFile file2, MultipartFile file3, MultipartFile file4, MultipartFile file5) throws IOException {
+        List<String> stringList = new ArrayList<>();
+        if (Blank.isNotEmpty(file1.getOriginalFilename())) {
+            Map<String, Object> map = uploadOneDoc(file1, filePath);
+            if ((Boolean) map.get("result")) {
+                postManagement.setDraftInterpretation(map.get("data").toString());
+                stringList.add(map.get("data").toString());
+            } else {
+                return SendUtil.send(false, ConstStr.ADD_FAILED, map.get("msg").toString());
+            }
+        }
+        if (Blank.isNotEmpty(file2.getOriginalFilename())) {
+            Map<String, Object> map = uploadOneDoc(file2, filePath);
+            if ((Boolean) map.get("result")) {
+                postManagement.setDraftDecision(map.get("data").toString());
+                stringList.add(map.get("data").toString());
+            } else {
+                if (stringList != null && stringList.size() > 0) {
+                    for (String url : stringList) {
+                        File file = new File(filePath + "\\" + url);
+                        file.delete();
+                    }
+                }
+                return SendUtil.send(false, ConstStr.ADD_FAILED, map.get("msg").toString());
+            }
+        }
+        if (Blank.isNotEmpty(file3.getOriginalFilename())) {
+            Map<String, Object> map = uploadOneDoc(file3, filePath);
+            if ((Boolean) map.get("result")) {
+                postManagement.setPolicyInterpretation(map.get("data").toString());
+                stringList.add(map.get("data").toString());
+            } else {
+                if (stringList != null && stringList.size() > 0) {
+                    for (String url : stringList) {
+                        File file = new File(filePath + "\\" + url);
+                        file.delete();
+                    }
+                }
+            }
+        }
+        if (Blank.isNotEmpty(file4.getOriginalFilename())) {
+            Map<String, Object> map = uploadOneDoc(file4, filePath);
+            if ((Boolean) map.get("result")) {
+                postManagement.setMakePolicy(map.get("data").toString());
+                stringList.add(map.get("data").toString());
+            } else {
+                if (stringList != null && stringList.size() > 0) {
+                    for (String url : stringList) {
+                        File file = new File(filePath + "\\" + url);
+                        file.delete();
+                    }
+                }
+            }
+        }
+        if (Blank.isNotEmpty(file5.getOriginalFilename())) {
+            Map<String, Object> map = uploadOneDoc(file5, filePath);
+            if ((Boolean) map.get("result")) {
+                postManagement.setPdfContent(map.get("data").toString());
+                stringList.add(map.get("data").toString());
+            } else {
+                if (stringList != null && stringList.size() > 0) {
+                    for (String url : stringList) {
+                        File file = new File(filePath + "\\" + url);
+                        file.delete();
+                    }
+                }
+            }
+        }
+        if (postManagementDao.savePost(postManagement) <= 0) {
+            if (stringList != null && stringList.size() > 0) {
+                for (String url : stringList) {
+                    File file = new File(filePath + "\\" + url);
+                    file.delete();
+                }
+            }
+            return SendUtil.send(false, ConstStr.ADD_FAILED, "");
+        }
+        return SendUtil.send(true, ConstStr.ADD_SUCCESS, "");
+    }
+
+    @Override
     public Map<String, Object> deletePostById(Integer id) {
         PostManagement postManagement = postManagementDao.getPostById(id);
         if (Blank.isNotEmpty(postManagement.getDraftDecision())) {