From aad276da26b3b44b7622343fa0bf15583e803585 Mon Sep 17 00:00:00 2001
From: xinyb <574600396@qq.com>
Date: 星期五, 27 九月 2024 11:29:01 +0800
Subject: [PATCH] CRM邮件文件夹和标签

---
 src/com/yc/crm/mail/action/MailController.java |  149 +++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 136 insertions(+), 13 deletions(-)

diff --git a/src/com/yc/crm/mail/action/MailController.java b/src/com/yc/crm/mail/action/MailController.java
index 6bc36d7..fcfabb9 100644
--- a/src/com/yc/crm/mail/action/MailController.java
+++ b/src/com/yc/crm/mail/action/MailController.java
@@ -57,7 +57,7 @@
 
 
     /**
-     * 宸﹁竟缁撴瀯灞�
+     * 宸﹁竟缁撴瀯涓婂眰
      *
      * @return
      */
@@ -74,6 +74,33 @@
             DataSourceEntity dataSourceEntity = MultiDataSource.getDataSourceMap(request);//鑾峰彇鏁版嵁婧愪俊鎭�
             SpObserver.setDBtoInstance("_" + dataSourceEntity.getDbId());//鍒囨崲鏁版嵁婧�
             List<MailModuleEntity> list = emailIfc.getMailModuleList(userCode);
+            msg.setSuccess("鎵ц鎴愬姛", list);
+        } catch (Exception e) {
+            msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage());
+        } finally {
+            SpObserver.setDBtoInstance();
+        }
+        return msg;
+    }
+
+    /**
+     * 宸﹁竟缁撴瀯涓嬪眰
+     *
+     * @return
+     */
+    @GetMapping("/getEmailModuleBelow.do")
+    public AllBackMsg getEmailModuleBelow(HttpServletRequest request, HttpServletResponse response) throws Exception {
+        AllBackMsg msg = new AllBackMsg();
+        try {
+            HttpSession session = request.getSession();
+            String userCode = (String) session.getAttribute(SessionKey.USERCODE);//褰撳墠鐧诲綍鐢ㄦ埛
+            if (StringUtils.isBlank(userCode)) {//鑾峰彇涓嶅埌褰撳墠鐢ㄦ埛鐩存帴缁撴潫
+                msg.setFail("鑾峰彇涓嶅埌鐢ㄦ埛淇℃伅");
+                return msg;
+            }
+            DataSourceEntity dataSourceEntity = MultiDataSource.getDataSourceMap(request);//鑾峰彇鏁版嵁婧愪俊鎭�
+            SpObserver.setDBtoInstance("_" + dataSourceEntity.getDbId());//鍒囨崲鏁版嵁婧�
+            List<MailModuleBelowEntity> list = emailIfc.getMailModuleBelowList(userCode);
             msg.setSuccess("鎵ц鎴愬姛", list);
         } catch (Exception e) {
             msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage());
@@ -108,14 +135,16 @@
             DataSourceEntity dataSourceEntity = MultiDataSource.getDataSourceMap(request);//鑾峰彇鏁版嵁婧愪俊鎭�
             SpObserver.setDBtoInstance("_" + dataSourceEntity.getDbId());//鍒囨崲鏁版嵁婧�
             List<t482101HList> t482101HEntityList = emailIfc.getReceivingMailList(mail, mailType, isNoRead, userCode, page, limit);
+            Map<String, Object> map = new HashMap<>();
+            map.put("page", page);
+            map.put("limit", limit);
             if (t482101HEntityList.size() > 0) {
-                Map<String,Object> map=new HashMap<>();
-                map.put("page",page);
-                map.put("limit",limit);
-                map.put("total",emailIfc.getMailTotal(mail,mailType,isNoRead,userCode));
-                map.put("list",t482101HEntityList);
-                msg.setSuccess("鎵ц瀹屾垚", map);
+                map.put("total", emailIfc.getMailTotal(mail, mailType, isNoRead, null, userCode));
+                map.put("list", t482101HEntityList);
+            } else {
+                map.put("list", new ArrayList<>());
             }
+            msg.setSuccess("鎵ц瀹屾垚", map);
         } catch (Exception e) {
             msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage());
         } finally {
@@ -149,14 +178,16 @@
             DataSourceEntity dataSourceEntity = MultiDataSource.getDataSourceMap(request);//鑾峰彇鏁版嵁婧愪俊鎭�
             SpObserver.setDBtoInstance("_" + dataSourceEntity.getDbId());//鍒囨崲鏁版嵁婧�
             List<t482101HList> t482101HEntityList = emailIfc.getHandleMailList(mail, userCode, page, limit);
+            Map<String, Object> map = new HashMap<>();
+            map.put("page", page);
+            map.put("limit", limit);
             if (t482101HEntityList.size() > 0) {
-                Map<String,Object> map=new HashMap<>();
-                map.put("page",page);
-                map.put("limit",limit);
-                map.put("total",emailIfc.getMailTotal(mail,3,false,userCode));
-                map.put("list",t482101HEntityList);
-                msg.setSuccess("鎵ц瀹屾垚", map);
+                map.put("total", emailIfc.getMailTotal(mail, 3, false, null, userCode));
+                map.put("list", t482101HEntityList);
+            } else {
+                map.put("list", new ArrayList<>());
             }
+            msg.setSuccess("鎵ц瀹屾垚", map);
         } catch (Exception e) {
             msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage());
         } finally {
@@ -504,6 +535,98 @@
     }
 
     /**
+     * 绉诲姩閭欢鍒嗙被
+     *
+     * @param request
+     * @param response
+     * @return
+     */
+    @PostMapping("/updateMailType.do")
+    public AllBackMsg updateMailType(@RequestBody Map<String, Object> map, HttpServletRequest request, HttpServletResponse response) throws Exception {
+        AllBackMsg msg = new AllBackMsg();
+        try {
+            HttpSession session = request.getSession();
+            String userCode = (String) session.getAttribute(SessionKey.USERCODE);//褰撳墠鐧诲綍鐢ㄦ埛
+            if (StringUtils.isBlank(userCode)) {//鑾峰彇涓嶅埌褰撳墠鐢ㄦ埛鐩存帴缁撴潫
+                msg.setFail("鑾峰彇涓嶅埌鐢ㄦ埛淇℃伅");
+                return msg;
+            }
+            if (map.get("docCode") == null) {
+                msg.setFail("鑾峰彇涓嶅埌绉诲姩閭欢缂栧彿docCode");
+                return msg;
+            }
+            String docCode = (String) map.get("docCode");
+            Integer folderId = map.get("folderId") == null ? 0 : (Integer) map.get("folderId");
+            List<String> tagArray = (List<String>) map.get("tagId");
+            if (folderId.equals(0) && (tagArray == null || tagArray.size() == 0)) {
+                msg.setFail("绉诲姩閭欢鍒嗙被涓嶈兘涓虹┖");
+                return msg;
+            }
+            String tagId = "";
+            if (tagArray != null && tagArray.size() > 0) {
+                tagId = StringUtils.join(tagArray, ",");
+            }
+            DataSourceEntity dataSourceEntity = MultiDataSource.getDataSourceMap(request);//鑾峰彇鏁版嵁婧愪俊鎭�
+            SpObserver.setDBtoInstance("_" + dataSourceEntity.getDbId());//鍒囨崲鏁版嵁婧�
+            emailIfc.updateMailType(docCode, folderId, tagId);
+            msg.setOk("绉诲姩鎴愬姛");
+        } catch (Exception e) {
+            msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage());
+        } finally {
+            SpObserver.setDBtoInstance();
+        }
+        return msg;
+    }
+
+    /**
+     * 鍔犺浇涓嶅悓鐩綍閲岀殑閭欢
+     *
+     * @param request
+     * @param response
+     * @return
+     */
+    @GetMapping("/classificationMail.do")
+    public AllBackMsg classificationMail(@RequestParam(defaultValue = "-1") Integer id, String type, @RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "20") Integer limit,
+                                         HttpServletRequest request, HttpServletResponse response) throws Exception {
+        AllBackMsg msg = new AllBackMsg();
+        try {
+            HttpSession session = request.getSession();
+            String userCode = (String) session.getAttribute(SessionKey.USERCODE);//褰撳墠鐧诲綍鐢ㄦ埛
+            if (StringUtils.isBlank(userCode)) {//鑾峰彇涓嶅埌褰撳墠鐢ㄦ埛鐩存帴缁撴潫
+                msg.setFail("鑾峰彇涓嶅埌鐢ㄦ埛淇℃伅");
+                return msg;
+            }
+            if (id == null || id.equals(-1)) {
+                msg.setFail("鑾峰彇涓嶅埌鏂囦欢Id");
+                return msg;
+            }
+            if (StringUtils.isBlank(type)) {
+                msg.setFail("鑾峰彇涓嶅埌鏂囦欢绫诲瀷");
+                return msg;
+            }
+            type = type + "_" + id;//缁勮涓�
+            DataSourceEntity dataSourceEntity = MultiDataSource.getDataSourceMap(request);//鑾峰彇鏁版嵁婧愪俊鎭�
+            SpObserver.setDBtoInstance("_" + dataSourceEntity.getDbId());//鍒囨崲鏁版嵁婧�
+            List<t482101HList> t482101 = emailIfc.getFolderMailList(type, userCode, page, limit);
+            Map<String, Object> map = new HashMap<>();
+            map.put("page", page);
+            map.put("limit", limit);
+            if (t482101.size() > 0) {
+                map.put("total", emailIfc.getMailTotal(null, 6, false, type, userCode));
+                map.put("list", t482101);
+            } else {
+                map.put("list", new ArrayList<>());
+            }
+            msg.setSuccess("鎵ц瀹屾垚", map);
+        } catch (Exception e) {
+            msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage());
+        } finally {
+            SpObserver.setDBtoInstance();
+        }
+        return msg;
+    }
+
+    /**
      * 寰呭鐞嗛偖浠�
      *
      * @param request

--
Gitblit v1.8.0