From f5cc47742dd3d2f2ffd8443ffc82a912683f7824 Mon Sep 17 00:00:00 2001 From: xinyb <574600396@qq.com> Date: 星期五, 30 八月 2024 17:48:01 +0800 Subject: [PATCH] CRM邮件功能调整 --- src/com/yc/crm/mail/action/MailAccount.java | 32 ++ src/com/yc/crm/mail/action/MailController.java | 76 ++++--- src/com/yc/crm/mail/action/MailQuickText.java | 49 +++- src/com/yc/crm/mail/service/MailFolderIfc.java | 2 src/com/yc/crm/mail/service/MailBlackListIfc.java | 4 src/com/yc/crm/mail/service/MailQuickTextImpl.java | 22 +- src/com/yc/crm/mail/service/MailIfc.java | 20 + src/com/yc/crm/mail/service/MailSignatureImpl.java | 16 src/com/yc/crm/mail/service/MailQuickTextIfc.java | 2 src/com/yc/crm/mail/service/MailAccountImpl.java | 14 src/com/yc/crm/mail/service/MailBlackListImpl.java | 31 +- src/com/yc/crm/mail/action/MailFolder.java | 49 +++- src/com/yc/crm/mail/action/MailBlacklist.java | 38 ++- src/com/yc/crm/mail/action/MailSignature.java | 42 ++- src/com/yc/crm/mail/entity/t482101HEntity.java | 5 src/com/yc/crm/mail/service/MailImpl.java | 127 +++++++++--- src/com/yc/crm/mail/util/AllBackMsg.java | 5 src/com/yc/crm/mail/service/MailFolderImpl.java | 12 src/com/yc/crm/mail/service/MailSignatureIfc.java | 4 19 files changed, 361 insertions(+), 189 deletions(-) diff --git a/src/com/yc/crm/mail/action/MailAccount.java b/src/com/yc/crm/mail/action/MailAccount.java index bee49bf..541b328 100644 --- a/src/com/yc/crm/mail/action/MailAccount.java +++ b/src/com/yc/crm/mail/action/MailAccount.java @@ -62,9 +62,9 @@ DataSourceEntity dataSource = MultiDataSource.getDataSourceMap(request);//鑾峰彇鏁版嵁婧� SpObserver.setDBtoInstance("_" + dataSource.getDbId()); mailAccountIfc.addEmailAccount(account);//娣诲姞鏂扮殑閭閰嶇疆 - msg.setSuccess("鎵ц鎴愬姛", "宸蹭繚瀛�"); + msg.setOk("宸蹭繚瀛�"); } catch (Exception e) { - msg.setError("鎵ц鍑洪敊", e.getCause() != null ? e.getCause().getMessage() : e.getMessage()); + msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage()); } finally { SpObserver.setDBtoInstance(); } @@ -83,13 +83,23 @@ public AllBackMsg updateAccount(@RequestBody T482102Entity account, HttpServletRequest request, HttpServletResponse response) { AllBackMsg msg = new AllBackMsg(); try { + if(account.getAccountId()==0){ + msg.setFail("鑾峰彇涓嶅埌閭閰嶇疆ID锛岃妫�鏌�"); + return msg; + } HttpSession session = request.getSession(); + String userCode = (String) session.getAttribute(SessionKey.USERCODE); + if(StringUtils.isBlank(userCode)){ + msg.setFail("鐧诲綍鐢ㄦ埛宸茶繃鏈燂紝璇锋鏌�"); + return msg; + } + account.setUserCode(userCode); DataSourceEntity dataSource = MultiDataSource.getDataSourceMap(request);//鑾峰彇鏁版嵁婧� SpObserver.setDBtoInstance("_" + dataSource.getDbId()); mailAccountIfc.updateEmailAccount(account); - msg.setSuccess("鎵ц鎴愬姛", "宸叉洿鏂�"); + msg.setOk("宸叉洿鏂�"); } catch (Exception e) { - msg.setError("鎵ц鍑洪敊", e.getCause() != null ? e.getCause().getMessage() : e.getMessage()); + msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage()); } finally { SpObserver.setDBtoInstance(); } @@ -114,14 +124,18 @@ } HttpSession session = request.getSession(); String userCode = (String) session.getAttribute(SessionKey.USERCODE); + if(StringUtils.isBlank(userCode)){ + msg.setFail("鐧诲綍鐢ㄦ埛宸茶繃鏈燂紝璇锋鏌�"); + return msg; + } DataSourceEntity dataSource = MultiDataSource.getDataSourceMap(request);//鑾峰彇鏁版嵁婧� SpObserver.setDBtoInstance("_" + dataSource.getDbId()); Integer cont = mailAccountIfc.deleteEmailAccount(userCode, accountId); if (cont > 0) { - msg.setSuccess("鎵ц鎴愬姛", "宸插垹闄�"); + msg.setOk("宸插垹闄�"); } } catch (Exception e) { - msg.setError("鎵ц鍑洪敊", e.getCause() != null ? e.getCause().getMessage() : e.getMessage()); + msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage()); } finally { SpObserver.setDBtoInstance(); } @@ -146,10 +160,12 @@ SpObserver.setDBtoInstance("_" + dataSource.getDbId()); List<T482102Entity> t482102Entities = mailAccountIfc.getAccount(userCode, mail); if (t482102Entities.size() > 0) { - msg.setSuccess("鎿嶄綔鎴愬姛", t482102Entities.get(0)); + msg.setSuccess("鎵ц鎴愬姛", t482102Entities.get(0)); + }else{ + msg.setFail("鏈壘鍒伴厤缃俊鎭紝0鏉℃暟鎹�"); } } catch (Exception e) { - msg.setError("鎵ц鍑洪敊", e.getCause() != null ? e.getCause().getMessage() : e.getMessage()); + msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage()); } finally { SpObserver.setDBtoInstance(); } diff --git a/src/com/yc/crm/mail/action/MailBlacklist.java b/src/com/yc/crm/mail/action/MailBlacklist.java index c0797c5..353f822 100644 --- a/src/com/yc/crm/mail/action/MailBlacklist.java +++ b/src/com/yc/crm/mail/action/MailBlacklist.java @@ -77,13 +77,23 @@ public AllBackMsg updateBlackList(@RequestBody T482106Entity BlackList, HttpServletRequest request, HttpServletResponse response) { AllBackMsg msg = new AllBackMsg(); try { + if(BlackList.getBlackId()==0){ + msg.setFail("鑾峰彇涓嶅埌榛戝悕鍗旾D锛岃妫�鏌�"); + return msg; + } HttpSession session = request.getSession(); + String userCode = (String) session.getAttribute(SessionKey.USERCODE); + if(StringUtils.isBlank(userCode)){ + msg.setFail("鐧诲綍鐢ㄦ埛宸茶繃鏈燂紝璇锋鏌�"); + return msg; + } + BlackList.setUserCode(userCode); DataSourceEntity dataSource = MultiDataSource.getDataSourceMap(request);//鑾峰彇鏁版嵁婧� SpObserver.setDBtoInstance("_" + dataSource.getDbId()); mailBlackListIfc.updateBlackList(BlackList); - msg.setSuccess("鎵ц鎴愬姛", "宸叉洿鏂�"); + msg.setOk("宸叉洿鏂�"); } catch (Exception e) { - msg.setError("鎵ц鍑洪敊", e.getCause() != null ? e.getCause().getMessage() : e.getMessage()); + msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage()); } finally { SpObserver.setDBtoInstance(); } @@ -98,7 +108,7 @@ * @param response * @return */ - @GetMapping("/deleteBlackList.do") + @PostMapping("/deleteBlackList.do") public AllBackMsg deleteBlackList(@RequestParam(defaultValue = "0") Integer blackId, HttpServletRequest request, HttpServletResponse response) { AllBackMsg msg = new AllBackMsg(); try { @@ -108,14 +118,18 @@ } HttpSession session = request.getSession(); String userCode = (String) session.getAttribute(SessionKey.USERCODE); + if(StringUtils.isBlank(userCode)){ + msg.setFail("鐧诲綍鐢ㄦ埛宸茶繃鏈燂紝璇锋鏌�"); + return msg; + } DataSourceEntity dataSource = MultiDataSource.getDataSourceMap(request);//鑾峰彇鏁版嵁婧� SpObserver.setDBtoInstance("_" + dataSource.getDbId()); - Integer cont = mailBlackListIfc.deleteBlackList(blackId + ""); + Integer cont = mailBlackListIfc.deleteBlackList(userCode,blackId); if (cont > 0) { - msg.setSuccess("鎵ц鎴愬姛", "宸插垹闄�"); + msg.setOk("宸插垹闄�"); } } catch (Exception e) { - msg.setError("鎵ц鍑洪敊", e.getCause() != null ? e.getCause().getMessage() : e.getMessage()); + msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage()); } finally { SpObserver.setDBtoInstance(); } @@ -132,18 +146,18 @@ public AllBackMsg getSignature(String search, HttpServletRequest request, HttpServletResponse response) { AllBackMsg msg = new AllBackMsg(); try { - if (StringUtils.isBlank(search)) { - msg.setFail("璇疯緭鍏ユ悳绱㈠悕绉�"); - return msg; - } HttpSession session = request.getSession(); String userCode = (String) session.getAttribute(SessionKey.USERCODE); + if(StringUtils.isBlank(userCode)){ + msg.setFail("鐧诲綍鐢ㄦ埛宸茶繃鏈燂紝璇锋鏌�"); + return msg; + } DataSourceEntity dataSource = MultiDataSource.getDataSourceMap(request);//鑾峰彇鏁版嵁婧� SpObserver.setDBtoInstance("_" + dataSource.getDbId()); - List<T482106Entity> list = mailBlackListIfc.getBlackList(search); + List<T482106Entity> list = mailBlackListIfc.getBlackList(userCode,search); msg.setSuccess("鎵ц鎴愬姛", list); } catch (Exception e) { - msg.setError("鎵ц鍑洪敊", e.getCause() != null ? e.getCause().getMessage() : e.getMessage()); + msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage()); } finally { SpObserver.setDBtoInstance(); } diff --git a/src/com/yc/crm/mail/action/MailController.java b/src/com/yc/crm/mail/action/MailController.java index 23c7349..ea24e62 100644 --- a/src/com/yc/crm/mail/action/MailController.java +++ b/src/com/yc/crm/mail/action/MailController.java @@ -16,7 +16,10 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; +import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.regex.Pattern; /** @@ -28,7 +31,7 @@ */ @CrossOrigin @RestController -@RequestMapping("/crm/mail/") +@RequestMapping("/crm/mail") public class MailController { @Autowired MailAccountIfc emailAccountIfc; @@ -48,12 +51,6 @@ public AllBackMsg getMailList(String mail, @RequestParam(defaultValue = "1") Integer mailType, boolean isNoRead, 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 (StringUtils.isNotBlank(mail)) { if (!EMAIL_PATTERN.matcher(mail).matches()) { msg.setFail("閭鐨勫悇寮忎笉浜夊彇"); @@ -64,10 +61,10 @@ SpObserver.setDBtoInstance("_" + dataSourceEntity.getDbId());//鍒囨崲鏁版嵁婧� List<t482101HEntity> t482101HEntityList = emailIfc.getReceivingMailList(mail, mailType, isNoRead); if (t482101HEntityList.size() > 0) { - msg.setSuccess("鎿嶄綔瀹屾垚", t482101HEntityList); + msg.setSuccess("鎵ц瀹屾垚", t482101HEntityList); } } catch (Exception e) { - msg.setError("鎵ц鍑洪敊", e.getCause() != null ? e.getCause().getMessage() : e.getMessage()); + msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage()); } finally { SpObserver.setDBtoInstance(); } @@ -83,12 +80,6 @@ public AllBackMsg getMailInfo(String mail, String docCode, 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 (StringUtils.isBlank(docCode)) {//鑾峰彇涓嶅埌褰撳墠鐢ㄦ埛鐩存帴缁撴潫 msg.setFail("缂哄皯閭鍞竴鐮乨ocCode,璇锋鏌�"); return msg; @@ -103,10 +94,10 @@ SpObserver.setDBtoInstance("_" + dataSourceEntity.getDbId());//鍒囨崲鏁版嵁婧� t482101HEntity t482101HEntity = emailIfc.getReceivingMailInfo(mail, docCode); if (t482101HEntity != null) { - msg.setSuccess("鎿嶄綔瀹屾垚", t482101HEntity); + msg.setSuccess("鎵ц瀹屾垚", t482101HEntity); } } catch (Exception e) { - msg.setError("鎵ц鍑洪敊", e.getCause() != null ? e.getCause().getMessage() : e.getMessage()); + msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage()); } finally { SpObserver.setDBtoInstance(); } @@ -126,14 +117,20 @@ msg.setFail("缂哄皯閭鍞竴鐮乨ocCode,璇锋鏌�"); return msg; } + 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());//鍒囨崲鏁版嵁婧� - Integer cont = emailIfc.deleteReceivingMail(docCode); + Integer cont = emailIfc.deleteReceivingMail(userCode, docCode); if (cont > 0) { - msg.setSuccess("鎿嶄綔瀹屾垚", "閭欢宸插垹闄�"); + msg.setOk("閭欢宸插垹闄�"); } } catch (Exception e) { - msg.setError("鎵ц鍑洪敊", e.getCause() != null ? e.getCause().getMessage() : e.getMessage()); + msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage()); } finally { SpObserver.setDBtoInstance(); } @@ -178,9 +175,12 @@ DataSourceEntity dataSourceEntity = MultiDataSource.getDataSourceMap(request);//鑾峰彇鏁版嵁婧愪俊鎭� SpObserver.setDBtoInstance("_" + dataSourceEntity.getDbId());//鍒囨崲鏁版嵁婧� t482101H = emailIfc.saveReceivingMail(t482101H); - msg.setSuccess("鎿嶄綔瀹屾垚", "鎵ц鎴愬姛"); + Map<String, Object> map = new HashMap<>(); + map.put("docCode", t482101H.getDocCode()); + msg.setSuccess("鎵ц鎴愬姛", map); +// msg.setOk("鎵ц鎴愬姛"); } catch (Exception e) { - msg.setError("鎵ц鍑洪敊", e.getCause() != null ? e.getCause().getMessage() : e.getMessage()); + msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage()); } finally { SpObserver.setDBtoInstance(); } @@ -204,10 +204,10 @@ SpObserver.setDBtoInstance("_" + dataSourceEntity.getDbId());//鍒囨崲鏁版嵁婧� int cont = emailIfc.deleteMailDrafts(docCode); if (cont > 0) { - msg.setSuccess("鎿嶄綔瀹屾垚", "鍒犻櫎鎴愬姛"); + msg.setOk("鍒犻櫎鎴愬姛"); } } catch (Exception e) { - msg.setError("鎵ц鍑洪敊", e.getCause() != null ? e.getCause().getMessage() : e.getMessage()); + msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage()); } finally { SpObserver.setDBtoInstance(); } @@ -253,13 +253,19 @@ t482101H.setMailType(2);//鍙戜欢 DataSourceEntity dataSourceEntity = MultiDataSource.getDataSourceMap(request);//鑾峰彇鏁版嵁婧愪俊鎭� SpObserver.setDBtoInstance("_" + dataSourceEntity.getDbId());//鍒囨崲鏁版嵁婧� - //鏈夊彂閫佺殑閭欢淇濆瓨鍒板悗鍙版暟鎹簱 - t482101H = emailIfc.saveReceivingMail(t482101H); //鍙戦�� emailIfc.sendingMail(t482101H, request); - msg.setSuccess("鎵ц鎴愬姛", "鍙戦�佹垚鍔�"); + msg.setOk("鍙戦�佹垚鍔�"); } catch (Exception e) { - msg.setError("鎵ц鍑洪敊", e.getCause() != null ? e.getCause().getMessage() : e.getMessage()); + String error = e.getCause() != null ? e.getCause().getMessage() : e.getMessage(); + String[] arrayError = error.split("#"); + if (arrayError.length == 2) { + Map<String, Object> map = new HashMap<>(); + map.put("docCode", arrayError[1]); + msg.setError(arrayError[0], map); + } else { + msg.setFail(error); + } } finally { SpObserver.setDBtoInstance(); } @@ -295,16 +301,22 @@ //鏍规嵁褰撳墠鐢ㄦ埛鏌ヨ缁戝畾鐨勯偖绠变俊鎭� List<T482102Entity> emailEntities = emailAccountIfc.getAccount(userCode, mail);//杩斿洖閭鐨勮处鍙蜂俊鎭� if (emailEntities.size() > 0) { + List<t482101HEntity> mails = new ArrayList<>(); for (T482102Entity e : emailEntities) {//閬嶅巻鐢ㄦ埛缁戝畾閭 - List<t482101HEntity> mails = emailIfc.getMailReceiving(e, request); - emailIfc.saveReceivingMailList(mails);//淇濆瓨 + //鏀堕偖浠朵俊鎭� + mails.addAll(emailIfc.getMailReceiving(e, request)); } - msg.setSuccess("鎿嶄綔瀹屾垚", "淇濆瓨鎴愬姛"); + if (mails.size() > 0) { + emailIfc.saveReceivingMailList(mails);//淇濆瓨 + msg.setOk("淇濆瓨鎴愬姛"); + } else { + msg.setOk("鏈彂鐜版柊閭欢"); + } } else { msg.setFail("娌℃湁鎵惧埌缁戝畾鐨勯偖绠变俊鎭�"); } } catch (Exception e) { - msg.setError("鎵ц鍑洪敊", e.getCause() != null ? e.getCause().getMessage() : e.getMessage()); + msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage()); } finally { SpObserver.setDBtoInstance(); } diff --git a/src/com/yc/crm/mail/action/MailFolder.java b/src/com/yc/crm/mail/action/MailFolder.java index fa41ebd..3110068 100644 --- a/src/com/yc/crm/mail/action/MailFolder.java +++ b/src/com/yc/crm/mail/action/MailFolder.java @@ -7,6 +7,7 @@ import com.yc.multiData.MultiDataSource; import com.yc.multiData.SpObserver; import com.yc.utils.SessionKey; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -24,13 +25,13 @@ */ @CrossOrigin @RestController -@RequestMapping("/crm/mail/Folder") +@RequestMapping("/crm/mail/folder") public class MailFolder { @Autowired MailFolderIfc mailFolderIfc; /** - *娣诲姞閭欢鏂囦欢澶� + * 娣诲姞閭欢鏂囦欢澶� * * @param folder * @param request @@ -54,9 +55,9 @@ DataSourceEntity dataSource = MultiDataSource.getDataSourceMap(request);//鑾峰彇鏁版嵁婧� SpObserver.setDBtoInstance("_" + dataSource.getDbId()); mailFolderIfc.saveFolder(folder); - msg.setSuccess("鎵ц鎴愬姛", "宸蹭繚瀛�"); + msg.setOk("宸蹭繚瀛�"); } catch (Exception e) { - msg.setError("鎵ц鍑洪敊", e.getCause() != null ? e.getCause().getMessage() : e.getMessage()); + msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage()); } finally { SpObserver.setDBtoInstance(); } @@ -64,7 +65,7 @@ } /** - *淇敼閭欢鏂囦欢澶� + * 淇敼閭欢鏂囦欢澶� * * @param folder * @param request @@ -75,13 +76,23 @@ public AllBackMsg updateFolder(@RequestBody T482107Entity folder, HttpServletRequest request, HttpServletResponse response) { AllBackMsg msg = new AllBackMsg(); try { + if (folder.getFolderId() == 0) { + msg.setFail("缂哄皯鏂囨湰澶笽D鍊硷紝璇锋鏌�"); + return msg; + } HttpSession session = request.getSession(); + String userCode = (String) session.getAttribute(SessionKey.USERCODE); + if (StringUtils.isBlank(userCode)) { + msg.setFail("鐧诲綍鐢ㄦ埛宸茶繃鏈燂紝璇锋鏌�"); + return msg; + } + folder.setUserCode(userCode); DataSourceEntity dataSource = MultiDataSource.getDataSourceMap(request);//鑾峰彇鏁版嵁婧� SpObserver.setDBtoInstance("_" + dataSource.getDbId()); mailFolderIfc.updateFolder(folder); - msg.setSuccess("鎵ц鎴愬姛", "宸叉洿鏂�"); + msg.setOk("宸叉洿鏂�"); } catch (Exception e) { - msg.setError("鎵ц鍑洪敊", e.getCause() != null ? e.getCause().getMessage() : e.getMessage()); + msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage()); } finally { SpObserver.setDBtoInstance(); } @@ -89,7 +100,7 @@ } /** - *鍒犻櫎閭欢鏂囦欢澶� + * 鍒犻櫎閭欢鏂囦欢澶� * * @param account * @param request @@ -106,14 +117,18 @@ } HttpSession session = request.getSession(); String userCode = (String) session.getAttribute(SessionKey.USERCODE); + if (StringUtils.isBlank(userCode)) { + msg.setFail("鐧诲綍鐢ㄦ埛宸茶繃鏈燂紝璇锋鏌�"); + return msg; + } DataSourceEntity dataSource = MultiDataSource.getDataSourceMap(request);//鑾峰彇鏁版嵁婧� SpObserver.setDBtoInstance("_" + dataSource.getDbId()); Integer cont = mailFolderIfc.deleteFolder(userCode, folderId); if (cont > 0) { - msg.setSuccess("鎵ц鎴愬姛", "宸插垹闄�"); + msg.setOk("宸插垹闄�"); } } catch (Exception e) { - msg.setError("鎵ц鍑洪敊", e.getCause() != null ? e.getCause().getMessage() : e.getMessage()); + msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage()); } finally { SpObserver.setDBtoInstance(); } @@ -121,27 +136,29 @@ } /** - * - * * @param search 鎼滅储 * @param request * @param response * @return */ @GetMapping("/getFolder.do") - public AllBackMsg getFolder(String folderName, HttpServletRequest request, HttpServletResponse response) { + public AllBackMsg getFolder(String search, HttpServletRequest request, HttpServletResponse response) { 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 dataSource = MultiDataSource.getDataSourceMap(request);//鑾峰彇鏁版嵁婧� SpObserver.setDBtoInstance("_" + dataSource.getDbId()); - List<T482107Entity> t482107Entities = mailFolderIfc.getMailFolder(folderName); + List<T482107Entity> t482107Entities = mailFolderIfc.getMailFolder(userCode, search); if (t482107Entities.size() > 0) { - msg.setSuccess("鎿嶄綔鎴愬姛", t482107Entities); + msg.setSuccess("鎵ц鎴愬姛", t482107Entities); } } catch (Exception e) { - msg.setError("鎵ц鍑洪敊", e.getCause() != null ? e.getCause().getMessage() : e.getMessage()); + msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage()); } finally { SpObserver.setDBtoInstance(); } diff --git a/src/com/yc/crm/mail/action/MailQuickText.java b/src/com/yc/crm/mail/action/MailQuickText.java index aad431d..74c33ea 100644 --- a/src/com/yc/crm/mail/action/MailQuickText.java +++ b/src/com/yc/crm/mail/action/MailQuickText.java @@ -7,6 +7,7 @@ import com.yc.multiData.MultiDataSource; import com.yc.multiData.SpObserver; import com.yc.utils.SessionKey; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -24,14 +25,14 @@ */ @CrossOrigin @RestController -@RequestMapping("/crm/mail/QuickText") +@RequestMapping("/crm/mail/quickText") public class MailQuickText { @Autowired MailQuickTextIfc mailQuickTextIfc; /** - *娣诲姞蹇�熸枃鏈� + * 娣诲姞蹇�熸枃鏈� * * @param account * @param request @@ -43,6 +44,10 @@ AllBackMsg msg = new AllBackMsg(); try { + if (StringUtils.isBlank(quickText.getTextName())) { + msg.setFail("蹇�熸枃鏈唴瀹逛笉鑳戒负绌�"); + return msg; + } HttpSession session = request.getSession(); String companyId = (String) session.getAttribute(SessionKey.COMPANY_ID); String companyName = (String) session.getAttribute(SessionKey.COMPANY_NAME); @@ -55,9 +60,9 @@ DataSourceEntity dataSource = MultiDataSource.getDataSourceMap(request);//鑾峰彇鏁版嵁婧� SpObserver.setDBtoInstance("_" + dataSource.getDbId()); mailQuickTextIfc.saveQuickText(quickText); - msg.setSuccess("鎵ц鎴愬姛", "宸蹭繚瀛�"); + msg.setOk("宸蹭繚瀛�"); } catch (Exception e) { - msg.setError("鎵ц鍑洪敊", e.getCause() != null ? e.getCause().getMessage() : e.getMessage()); + msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage()); } finally { SpObserver.setDBtoInstance(); } @@ -65,7 +70,7 @@ } /** - *鏇存柊蹇�熸枃鏈� + * 鏇存柊蹇�熸枃鏈� * * @param account * @param request @@ -76,13 +81,23 @@ public AllBackMsg updateQuickText(@RequestBody T482108Entity quickText, HttpServletRequest request, HttpServletResponse response) { AllBackMsg msg = new AllBackMsg(); try { + if (quickText.getTextId() == 0) { + msg.setFail("缂哄皯蹇�熸枃鏈琁D鍊硷紝璇锋鏌�"); + return msg; + } HttpSession session = request.getSession(); + String userCode = (String) session.getAttribute(SessionKey.USERCODE); + if (StringUtils.isBlank(userCode)) { + msg.setFail("鐧诲綍鐢ㄦ埛宸茶繃鏈燂紝璇锋鏌�"); + return msg; + } + quickText.setUserCode(userCode); DataSourceEntity dataSource = MultiDataSource.getDataSourceMap(request);//鑾峰彇鏁版嵁婧� SpObserver.setDBtoInstance("_" + dataSource.getDbId()); mailQuickTextIfc.updateQuickText(quickText); - msg.setSuccess("鎵ц鎴愬姛", "宸叉洿鏂�"); + msg.setOk("宸叉洿鏂�"); } catch (Exception e) { - msg.setError("鎵ц鍑洪敊", e.getCause() != null ? e.getCause().getMessage() : e.getMessage()); + msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage()); } finally { SpObserver.setDBtoInstance(); } @@ -90,8 +105,8 @@ } /** + * 鍒犻櫎蹇�熸枃鏈� * - *鍒犻櫎蹇�熸枃鏈� * @param account * @param request * @param response @@ -111,10 +126,10 @@ SpObserver.setDBtoInstance("_" + dataSource.getDbId()); Integer cont = mailQuickTextIfc.deleteQuickText(userCode, textId); if (cont > 0) { - msg.setSuccess("鎵ц鎴愬姛", "宸插垹闄�"); + msg.setOk("宸插垹闄�"); } } catch (Exception e) { - msg.setError("鎵ц鍑洪敊", e.getCause() != null ? e.getCause().getMessage() : e.getMessage()); + msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage()); } finally { SpObserver.setDBtoInstance(); } @@ -122,27 +137,31 @@ } /** + * 鏌ヨ蹇�熸枃鏈� * - *鏌ヨ蹇�熸枃鏈� * @param search 鎼滅储 * @param request * @param response * @return */ @GetMapping("/getQuickText.do") - public AllBackMsg getQuickText(String text, HttpServletRequest request, HttpServletResponse response) { + public AllBackMsg getQuickText(String search, HttpServletRequest request, HttpServletResponse response) { 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 dataSource = MultiDataSource.getDataSourceMap(request);//鑾峰彇鏁版嵁婧� SpObserver.setDBtoInstance("_" + dataSource.getDbId()); - List<T482108Entity> t482102Entities = mailQuickTextIfc.getMailQuickText(text); + List<T482108Entity> t482102Entities = mailQuickTextIfc.getMailQuickText(userCode, search); if (t482102Entities.size() > 0) { - msg.setSuccess("鎿嶄綔鎴愬姛", t482102Entities); + msg.setSuccess("鎵ц鎴愬姛", t482102Entities); } } catch (Exception e) { - msg.setError("鎵ц鍑洪敊", e.getCause() != null ? e.getCause().getMessage() : e.getMessage()); + msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage()); } finally { SpObserver.setDBtoInstance(); } diff --git a/src/com/yc/crm/mail/action/MailSignature.java b/src/com/yc/crm/mail/action/MailSignature.java index 71d229e..3f9fda8 100644 --- a/src/com/yc/crm/mail/action/MailSignature.java +++ b/src/com/yc/crm/mail/action/MailSignature.java @@ -25,7 +25,7 @@ */ @CrossOrigin @RestController -@RequestMapping("/crm/mail/Signature") +@RequestMapping("/crm/mail/signature") public class MailSignature { @Autowired MailSignatureIfc mailSignatureIfc; @@ -56,9 +56,9 @@ SpObserver.setDBtoInstance("_" + dataSource.getDbId()); //淇濆瓨 mailSignatureIfc.saveSignature(signature); - msg.setSuccess("鎵ц鎴愬姛", "宸蹭繚瀛�"); + msg.setOk("宸蹭繚瀛�"); } catch (Exception e) { - msg.setError("鎵ц鍑洪敊", e.getCause() != null ? e.getCause().getMessage() : e.getMessage()); + msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage()); } finally { SpObserver.setDBtoInstance(); } @@ -77,17 +77,23 @@ public AllBackMsg updateSignature(@RequestBody T482109Entity signature, HttpServletRequest request, HttpServletResponse response) { AllBackMsg msg = new AllBackMsg(); try { - if(signature.getSignId()==null){ + if (signature.getSignId() == null) { msg.setFail("缂哄皯SignId鍊硷紝璇锋鏌�"); return msg; } HttpSession session = request.getSession(); + String userCode = (String) session.getAttribute(SessionKey.USERCODE); + if (StringUtils.isBlank(userCode)) { + msg.setFail("鐧诲綍鐢ㄦ埛宸茶繃鏈燂紝璇锋鏌�"); + return msg; + } + signature.setUserCode(userCode); DataSourceEntity dataSource = MultiDataSource.getDataSourceMap(request);//鑾峰彇鏁版嵁婧� SpObserver.setDBtoInstance("_" + dataSource.getDbId()); mailSignatureIfc.updateSignature(signature); - msg.setSuccess("鎵ц鎴愬姛", "宸叉洿鏂�"); + msg.setOk("宸叉洿鏂�"); } catch (Exception e) { - msg.setError("鎵ц鍑洪敊", e.getCause() != null ? e.getCause().getMessage() : e.getMessage()); + msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage()); } finally { SpObserver.setDBtoInstance(); } @@ -112,14 +118,18 @@ } HttpSession session = request.getSession(); String userCode = (String) session.getAttribute(SessionKey.USERCODE); + if (StringUtils.isBlank(userCode)) { + msg.setFail("鐧诲綍鐢ㄦ埛宸茶繃鏈燂紝璇锋鏌�"); + return msg; + } DataSourceEntity dataSource = MultiDataSource.getDataSourceMap(request);//鑾峰彇鏁版嵁婧� SpObserver.setDBtoInstance("_" + dataSource.getDbId()); - Integer cont = mailSignatureIfc.deleteSignature(signId + ""); + Integer cont = mailSignatureIfc.deleteSignature(userCode, signId); if (cont > 0) { - msg.setSuccess("鎵ц鎴愬姛", "宸插垹闄�"); + msg.setOk("宸插垹闄�"); } } catch (Exception e) { - msg.setError("鎵ц鍑洪敊", e.getCause() != null ? e.getCause().getMessage() : e.getMessage()); + msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage()); } finally { SpObserver.setDBtoInstance(); } @@ -133,21 +143,21 @@ * @return */ @GetMapping("/getSignature.do") - public AllBackMsg getSignature(String name, HttpServletRequest request, HttpServletResponse response) { + public AllBackMsg getSignature(String search, HttpServletRequest request, HttpServletResponse response) { AllBackMsg msg = new AllBackMsg(); try { - if (StringUtils.isBlank(name)) { - msg.setFail("璇疯緭鍏ユ悳绱㈠悕绉�"); - return msg; - } HttpSession session = request.getSession(); String userCode = (String) session.getAttribute(SessionKey.USERCODE); + if (StringUtils.isBlank(userCode)) { + msg.setFail("鐧诲綍鐢ㄦ埛宸茶繃鏈燂紝璇锋鏌�"); + return msg; + } DataSourceEntity dataSource = MultiDataSource.getDataSourceMap(request);//鑾峰彇鏁版嵁婧� SpObserver.setDBtoInstance("_" + dataSource.getDbId()); - List<T482109Entity> list = mailSignatureIfc.getSignature(name); + List<T482109Entity> list = mailSignatureIfc.getSignature(userCode, search); msg.setSuccess("鎵ц鎴愬姛", list); } catch (Exception e) { - msg.setError("鎵ц鍑洪敊", e.getCause() != null ? e.getCause().getMessage() : e.getMessage()); + msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage()); } finally { SpObserver.setDBtoInstance(); } diff --git a/src/com/yc/crm/mail/entity/t482101HEntity.java b/src/com/yc/crm/mail/entity/t482101HEntity.java index b83422b..d4f6950 100644 --- a/src/com/yc/crm/mail/entity/t482101HEntity.java +++ b/src/com/yc/crm/mail/entity/t482101HEntity.java @@ -19,8 +19,8 @@ private String sender;// [note:'鍙戦�佷汉'] private String receiver;// [note:'鎺ユ敹浜�'] private Integer folderId;// [note:'鏂囦欢澶筰d'] - private Integer deleteFlag; //[note:'鏄惁宸插垹闄�'] - private Integer readFlag;// [note:'鏄惁宸茶'] + private Integer deleteFlag=0; //[note:'鏄惁宸插垹闄�'] + private Integer readFlag=0;// [note:'鏄惁宸茶'] private String cc;// [note:'鎶勯�佷汉鍒楄〃'] private String bcc;// [note:'瀵嗛�佷汉鍒楄〃'] private String subject;// [note:'涓婚'] @@ -79,6 +79,7 @@ private boolean canUnlock; private String remark;// [note: '澶囨敞'] private String fileUNID;//闄勪欢鐨剈nId + private String messageId;//閭欢鍞竴Id private Integer docVersion; } diff --git a/src/com/yc/crm/mail/service/MailAccountImpl.java b/src/com/yc/crm/mail/service/MailAccountImpl.java index 249ed43..f550851 100644 --- a/src/com/yc/crm/mail/service/MailAccountImpl.java +++ b/src/com/yc/crm/mail/service/MailAccountImpl.java @@ -22,8 +22,9 @@ public void addEmailAccount(T482102Entity account) { String sql = "set nocount on\n"; try { - sql += "insert into t482102(companyId,companyName,email,alias_email,userCode,userName,receiveProtocol,receiveSSL,receivePort,receiveHost,smtpSSL,smtpPort,smtpHost,invalid,create_time,update_time)\n" + + sql += "insert into t482102(companyId,companyName,email,password,alias_email,userCode,userName,receiveProtocol,receiveSSL,receivePort,receiveHost,smtpSSL,smtpPort,smtpHost,invalid,create_time,update_time)\n" + "values(" + GridUtils.prossSqlParm(account.getCompanyId()) + "," + GridUtils.prossSqlParm(account.getCompanyName()) + "," + GridUtils.prossSqlParm(account.getEmail()) + "," + + GridUtils.prossSqlParm(account.getPassword()) + "," + GridUtils.prossSqlParm(account.getAliasEmail()) + "," + GridUtils.prossSqlParm(account.getUserCode()) + "," + GridUtils.prossSqlParm(account.getUserName()) + "," + GridUtils.prossSqlParm(account.getReceiveProtocol()) + ",'" + account.isReceiveSSL() + "'," + account.getReceivePort() + "," + GridUtils.prossSqlParm(account.getReceiveHost()) + ",'" + account.isSmtpSSL() + "'," + account.getSmtpPort() + "," + GridUtils.prossSqlParm(account.getSmtpHost()) + ",'" + account.isInvalid() + "'," + @@ -39,14 +40,15 @@ String sql = "set nocount on\n"; try { sql += "update t482102 set alias_email=" + GridUtils.prossSqlParm(account.getAliasEmail()) + "," + + "password=" + GridUtils.prossSqlParm(account.getPassword()) + "," + " receiveProtocol=" + GridUtils.prossSqlParm(account.getReceiveProtocol()) + "," + - " receiveSSL=" + account.isReceiveSSL() + ",receivePort=" + account.getReceivePort() + ", " + - " receiveHost=" + GridUtils.prossSqlParm(account.getReceiveHost()) + ",smtpSSL=" + account.isSmtpSSL() + "," + + " receiveSSL='" + account.isReceiveSSL() + "',receivePort=" + account.getReceivePort() + ", " + + " receiveHost=" + GridUtils.prossSqlParm(account.getReceiveHost()) + ",smtpSSL='" + account.isSmtpSSL() + "'," + " smtpPort=" + account.getSmtpPort() + ",smtpHost=" + GridUtils.prossSqlParm(account.getSmtpHost()) + "," + - " invalid=" + account.isInvalid() + ",update_time=convert(varchar(19),getdate(),120)) " + + " invalid='" + account.isInvalid() + "',update_time=convert(varchar(19),getdate(),120) " + " where userCode=" + GridUtils.prossSqlParm(account.getUserCode()) + " and accountId=" + account.getAccountId(); sql += "select @@ROWCOUNT"; - return jdbcTemplate.update(sql, Integer.class); + return jdbcTemplate.queryForObject(sql, Integer.class); } catch (Exception e) { throw e; } @@ -58,7 +60,7 @@ try { sql += "delete t482102 where userCode='" + userCode + "' and accountId=" + accountId + "\n"; sql += "select @@ROWCOUNT"; - return jdbcTemplate.update(sql, Integer.class); + return jdbcTemplate.queryForObject(sql, Integer.class); } catch (Exception e) { throw e; } diff --git a/src/com/yc/crm/mail/service/MailBlackListIfc.java b/src/com/yc/crm/mail/service/MailBlackListIfc.java index 245a500..c752b94 100644 --- a/src/com/yc/crm/mail/service/MailBlackListIfc.java +++ b/src/com/yc/crm/mail/service/MailBlackListIfc.java @@ -24,12 +24,12 @@ * @param textId * @return */ - Integer deleteBlackList(String blackId); + Integer deleteBlackList(String userCode,Integer blackId); /** * 鏌ヨ榛戝悕鍗� * @param name * @return */ - List<T482106Entity> getBlackList(String BlackName); + List<T482106Entity> getBlackList(String userCode,String search); } diff --git a/src/com/yc/crm/mail/service/MailBlackListImpl.java b/src/com/yc/crm/mail/service/MailBlackListImpl.java index a641064..da3cca0 100644 --- a/src/com/yc/crm/mail/service/MailBlackListImpl.java +++ b/src/com/yc/crm/mail/service/MailBlackListImpl.java @@ -22,9 +22,10 @@ public void saveBlackList(T482106Entity black) { String sql = "set nocount on\n"; try { - sql += "insert into t482106(companyId,companyName,blackContent,userCode,userName,createTime,updateTime,blackType,DocVersion) values " + - "(" + GridUtils.prossSqlParm(black.getCompanyId()) + "," + GridUtils.prossSqlParm(black.getCompanyName()) + "," + GridUtils.prossSqlParm(black.getUserCode()) + "," + - GridUtils.prossSqlParm(black.getUserName()) + ",getdate(),getdate()," + black.isBlackType() + ",1)"; + sql += "insert into t482106(companyId,companyName,black_content,userCode,userName,create_time,update_time,black_type) values " + + "(" + GridUtils.prossSqlParm(black.getCompanyId()) + "," + GridUtils.prossSqlParm(black.getCompanyName()) + "," + + GridUtils.prossSqlParm(black.getBlackContent())+","+GridUtils.prossSqlParm(black.getUserCode()) + "," + + GridUtils.prossSqlParm(black.getUserName()) + ",getdate(),getdate(),'" + black.isBlackType() + "')"; jdbcTemplate.update(sql); } catch (Exception e) { throw e; @@ -35,37 +36,37 @@ public Integer updateBlackList(T482106Entity black) { String sql = "set nocount on \n"; try { - sql += "update t482106 set blackContent=" + GridUtils.prossSqlParm(black.getBlackContent()) + ",blackType=" + black.isBlackType() + "," + - "updateTime=getdate() where blackId=" + black.getBlackId() + "\n"; + sql += "update t482106 set black_content=" + GridUtils.prossSqlParm(black.getBlackContent()) + ",black_type='" + black.isBlackType() + "'," + + "update_time=getdate() where black_id=" + black.getBlackId() + " and userCode=" + GridUtils.prossSqlParm(black.getUserCode()) + "\n"; sql += "select @@ROWCOUNT"; - return jdbcTemplate.update(sql, Integer.class); + return jdbcTemplate.queryForObject(sql, Integer.class); } catch (Exception e) { throw e; } } @Override - public Integer deleteBlackList(String blackId) { + public Integer deleteBlackList(String userCode,Integer blackId) { String sql = "set nocount on \n"; try { - sql += "delete t482106 where blackId=" + blackId + "\n"; + sql += "delete t482106 where black_id=" + blackId + " and userCode=" + userCode + "\n"; sql += "select @@ROWCOUNT"; - return jdbcTemplate.update(sql, Integer.class); + return jdbcTemplate.queryForObject(sql, Integer.class); } catch (Exception e) { throw e; } } @Override - public List<T482106Entity> getBlackList(String BlackName) { + public List<T482106Entity> getBlackList(String userCode,String search) { String sql = "set nocount on \n"; try { - sql += "select companyId,companyName,blackContent,blackId,userCode,userName,createTime,updateTime,blackType,DocVersion " + - "from t482106 "; - if (StringUtils.isNotBlank(BlackName)) { - sql += "where blackContent=" + BlackName; + sql += "select companyId,companyName,black_id,black_content,userCode,userName,create_time,update_time,black_type,DocVersion " + + "from t482106 where userCode="+GridUtils.prossSqlParm(userCode); + if (StringUtils.isNotBlank(search)) { + sql += " and black_content like '%" + search+"%'"; } - sql += "order by blackId \n"; + sql += "order by black_id \n"; return jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(T482106Entity.class)); } catch (Exception e) { throw e; diff --git a/src/com/yc/crm/mail/service/MailFolderIfc.java b/src/com/yc/crm/mail/service/MailFolderIfc.java index ecc16f2..1530fa3 100644 --- a/src/com/yc/crm/mail/service/MailFolderIfc.java +++ b/src/com/yc/crm/mail/service/MailFolderIfc.java @@ -31,5 +31,5 @@ * @param TextName * @return */ - List<T482107Entity> getMailFolder(String folderName); + List<T482107Entity> getMailFolder(String userCode,String search); } diff --git a/src/com/yc/crm/mail/service/MailFolderImpl.java b/src/com/yc/crm/mail/service/MailFolderImpl.java index 544fef7..50cf69f 100644 --- a/src/com/yc/crm/mail/service/MailFolderImpl.java +++ b/src/com/yc/crm/mail/service/MailFolderImpl.java @@ -39,7 +39,7 @@ ",sortId=" + folder.getSortId() + ",updateTime=getdate() " + "where folderId=" + folder.getFolderId() + " and userCode=" + GridUtils.prossSqlParm(folder.getUserCode()) + "\n"; sql += "select @@ROWCOUNT"; - return jdbcTemplate.update(sql, Integer.class); + return jdbcTemplate.queryForObject(sql, Integer.class); } catch (Exception e) { throw e; } @@ -51,20 +51,20 @@ try { sql += "delete t482107 where userCode='" + userCode + "' and folderId=" + folderId + "\n"; sql += "select @@ROWCOUNT"; - return jdbcTemplate.update(sql, Integer.class); + return jdbcTemplate.queryForObject(sql, Integer.class); } catch (Exception e) { throw e; } } @Override - public List<T482107Entity> getMailFolder(String folderName) { + public List<T482107Entity> getMailFolder(String userCode, String search) { String sql = "set nocount on\n"; try { sql += "select companyId,companyName,folderName,userCode,userName,content,sortId,createTime,updateTime " + - "from t482107 "; - if (StringUtils.isNotBlank(folderName)) { - sql += "where content=" + folderName; + "from t482107 where userCode=" + GridUtils.prossSqlParm(userCode); + if (StringUtils.isNotBlank(search)) { + sql += " and content like '%" + search + "%'"; } sql += " order by folderId \n"; return jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(T482107Entity.class)); diff --git a/src/com/yc/crm/mail/service/MailIfc.java b/src/com/yc/crm/mail/service/MailIfc.java index 77326d6..80be1ac 100644 --- a/src/com/yc/crm/mail/service/MailIfc.java +++ b/src/com/yc/crm/mail/service/MailIfc.java @@ -41,11 +41,18 @@ Integer updateReceivingMail(t482101HEntity mail); /** - * 鍒犻櫎閭欢锛堟爣璁颁负宸茶锛� + * 鍒犻櫎閭欢锛堢郴缁熷唴鍒犻櫎锛� * @param docCode * @return */ - Integer deleteReceivingMail(String docCode); + Integer deleteReceivingMail(String userCode,String docCode); + + /** + * 鍒犻櫎閭欢(鏍规嵁messageId鍒犻櫎) + * @param messagesId + * @return + */ + Integer deleteReceivingMail(String messageId); /** * 鑾峰彇閭欢鐨勮鎯呭唴瀹� @@ -101,5 +108,12 @@ * @param unid * @return */ - public List<AttachmentEntity> getAttachmentEntityList(String unIdSeq); + abstract List<AttachmentEntity> getAttachmentEntityList(String unIdSeq); + + /** + * 鑾峰彇鏀朵欢閭宸茬粡瀛樺湪鐨凪essageId闆嗗悎 + * @param receiver + * @return + */ + abstract List<String> getMessageIdList(String receiver); } diff --git a/src/com/yc/crm/mail/service/MailImpl.java b/src/com/yc/crm/mail/service/MailImpl.java index 59275a5..73187b7 100644 --- a/src/com/yc/crm/mail/service/MailImpl.java +++ b/src/com/yc/crm/mail/service/MailImpl.java @@ -31,6 +31,7 @@ import java.io.InputStream; import java.util.*; import java.util.regex.Pattern; +import java.util.stream.Collectors; /** * @BelongsProject: eCoWorksV3 @@ -56,14 +57,16 @@ if (StringUtils.isBlank(m.getDocCode())) { sql += "declare @docCode varchar(50) \n"; sql += "exec sp_newdoccode 482101," + GridUtils.prossSqlParm(m.getUserCode()) + ",@docCode output \n"; - sql += "insert into t482101H(companyId,companyName,formId,docCode,docdate,PeriodID,postCode,postname,mailType,sender,receiver,cc,bcc,subject,userCode,userName,content,file_unid) values "; + sql += "insert into t482101H(companyId,companyName,formId,docCode,docdate,PeriodID,postCode,postname,mailType,sender,receiver," + + "cc,bcc,subject,userCode,userName,content,file_unid,messageId,read_flag,delete_flag) values "; sql += "(" + GridUtils.prossSqlParm(m.getCompanyId()) + "," + GridUtils.prossSqlParm(m.getCompanyName()) + ",482101," + "@docCode,convert(varchar(10),getdate(),120),convert(varchar(7),getdate(),120)," + GridUtils.prossSqlParm(m.getUserCode()) + "," + GridUtils.prossSqlParm(m.getUserName()) + "," + +m.getMailType() + "," + GridUtils.prossSqlParm(m.getSender()) + "," + GridUtils.prossSqlParm(m.getReceiver()) + "," + GridUtils.prossSqlParm(m.getCc()) + "," + GridUtils.prossSqlParm(m.getBcc()) + "," + GridUtils.prossSqlParm(m.getSubject()) + "," + GridUtils.prossSqlParm(m.getUserCode()) + "," + GridUtils.prossSqlParm(m.getUserName()) + "," + - GridUtils.prossSqlParm(m.getContent()) + "," + GridUtils.prossSqlParm(m.getFileUNID()) + ") \n"; + GridUtils.prossSqlParm(m.getContent()) + "," + GridUtils.prossSqlParm(m.getFileUNID()) + "," + GridUtils.prossSqlParm(m.getMessageId()) + "," + + m.getReadFlag() + "," + m.getDeleteFlag() + ") \n"; sql += "select @docCode as docCode"; String docCode = jdbcTemplate.queryForObject(sql, String.class); if (StringUtils.isNotBlank(docCode)) { @@ -85,14 +88,16 @@ sql += "declare @docCode varchar(50) \n"; for (t482101HEntity m : mail) {//閬嶅巻鍐呭 sql += "exec sp_newdoccode 482101," + GridUtils.prossSqlParm(m.getUserCode()) + ",@docCode output \n"; - sql += "insert into t482101H(companyId,companyName,formId,docCode,docdate,PeriodID,postCode,postname,mailType,sender,receiver,cc,bcc,subject,userCode,userName,content,file_unid) values "; + sql += "insert into t482101H(companyId,companyName,formId,docCode,docdate,PeriodID,postCode,postname,mailType,sender,receiver," + + "cc,bcc,subject,userCode,userName,content,file_unid,messageId,read_flag,delete_flag) values "; sql += "(" + GridUtils.prossSqlParm(m.getCompanyId()) + "," + GridUtils.prossSqlParm(m.getCompanyName()) + ",482101," + "@docCode,convert(varchar(10),getdate(),120),convert(varchar(7),getdate(),120)," + GridUtils.prossSqlParm(m.getUserCode()) + "," + GridUtils.prossSqlParm(m.getUserName()) + "," + +m.getMailType() + "," + GridUtils.prossSqlParm(m.getSender()) + "," + GridUtils.prossSqlParm(m.getReceiver()) + "," + GridUtils.prossSqlParm(m.getCc()) + "," + GridUtils.prossSqlParm(m.getBcc()) + "," + GridUtils.prossSqlParm(m.getSubject()) + "," + GridUtils.prossSqlParm(m.getUserCode()) + "," + GridUtils.prossSqlParm(m.getUserName()) + "," + - GridUtils.prossSqlParm(m.getContent()) + "," + GridUtils.prossSqlParm(m.getFileUNID()) + ") \n"; + GridUtils.prossSqlParm(m.getContent()) + "," + GridUtils.prossSqlParm(m.getFileUNID()) + "," + GridUtils.prossSqlParm(m.getMessageId()) + "," + + m.getReadFlag() + "," + m.getDeleteFlag() + ") \n"; // sql +="exec postt482101V3 '' ,'',''"; } jdbcTemplate.update(sql); @@ -118,10 +123,22 @@ } @Override - public Integer deleteReceivingMail(String docCode) { + public Integer deleteReceivingMail(String userCode, String docCode) { String sql = "set nocount on\n"; try { - sql += "update t482101H deleteFlag=1 where docCode=" + GridUtils.prossSqlParm(docCode) + "\n";//鏍囪涓哄凡鍒犻櫎 + sql += "update t482101H deleteFlag=1 where userCode=" + GridUtils.prossSqlParm(userCode) + " and docCode=" + GridUtils.prossSqlParm(docCode) + "\n";//鏍囪鍒犻櫎 + sql += "select select @@ROWCOUNT"; + return jdbcTemplate.update(sql, Integer.class); + } catch (Exception e) { + throw e; + } + } + + @Override + public Integer deleteReceivingMail(String messageId) { + String sql = "set nocount on\n"; + try { + sql += "delete t482101H where messageId=" + GridUtils.prossSqlParm(messageId) + "\n";//鍒犻櫎 sql += "select select @@ROWCOUNT"; return jdbcTemplate.update(sql, Integer.class); } catch (Exception e) { @@ -193,7 +210,7 @@ //鑾峰緱鏀朵欢绠辩殑閭欢鍒楄〃 Message[] messages = folder.search(flagTerm); //杩斿洖閭灏佽鍐呭 - return setMailContent(messages, request); + return setMailContent(messages, user, request); } catch (NoSuchProviderException e) { throw e; } catch (MessagingException e) { @@ -222,8 +239,13 @@ //鏍规嵁褰撳墠鐢ㄦ埛鏌ヨ缁戝畾鐨勯偖绠变俊鎭� T482102Entity emailEntity = emailAccountIfc.getAccountInfo(t482101H.getUserCode(), t482101H.getSender());//杩斿洖閭鐨勮处鍙蜂俊鎭� if (emailEntity == null || StringUtils.isBlank(emailEntity.getEmail())) { - throw new Exception("鎵句笉鍒伴偖绠憋細" + t482101H.getSender() + "閰嶇疆淇℃伅锛岃瀹屽杽锛�" + t482101H.getSender() + "閭閰嶇疆鍦ㄥ皾璇曞彂閫侀偖浠�"); + if (StringUtils.isBlank(t482101H.getDocCode())) { + t482101H.setMailType(0);//鑽夌绠辩姸鎬� + t482101H = saveReceivingMail(t482101H);//淇濆瓨鍒拌崏绋跨鍐� + } + throw new Exception("鎵句笉鍒伴偖绠憋細" + t482101H.getSender() + "閰嶇疆淇℃伅璇峰畬鍠勩�傞偖浠跺凡淇濆瓨鍒拌崏绋跨#" + t482101H.getDocCode()); } + //鏈夊彂閫佺殑閭欢淇濆瓨鍒板悗鍙版暟鎹簱 //閭鏈嶅姟鍣ㄩ厤缃� Properties properties = new Properties(); properties.setProperty("mail.smtp.host", emailEntity.getSmtpHost()); @@ -245,6 +267,11 @@ message.setFrom(new InternetAddress(sendEmail)); message.setRecipient(Message.RecipientType.TO, new InternetAddress(recipientEmail)); message.setSubject(t482101H.getSubject()); + + String Unique_ID = UUID.randomUUID().toString();//unId鐮� + String message_id = "<onBus_" + Unique_ID + "_" + t482101H.getDocCode() + ">";//绯荤粺鍗曞彿鍞竴鐮� + message.setHeader("Message-ID", message_id);//绯荤粺鍐呴儴鍞竴鐮� + t482101H.setMessageId(message_id);//messageId璧嬪�� if (StringUtils.isNotBlank(t482101H.getCc())) {//鎶勯�� String[] cc = t482101H.getCc().split(";"); @@ -280,8 +307,14 @@ } message.setContent(multipart); try { + if(StringUtils.isBlank(t482101H.getDocCode())){//涓嶅湪鑽夌绠辨湁鍗曞彿 + saveReceivingMail(t482101H);//淇濆瓨鍚庡彂閫� + }else{ + t482101H.setMailType(2);//鍙戜欢绠辩姸鎬� + updateMailDrafts(t482101H);//鏇存柊鎴愯崏绋跨 + } Transport.send(message);//鍙戦�� - } catch (MessagingException m) {//寮傚父澶勭悊 + } catch (MessagingException m) {//鍙戦�佸紓甯稿鐞� t482101H.setMailType(0);//鑽夌绠辩姸鎬� updateMailDrafts(t482101H);//鏇存柊鎴愯崏绋跨 throw new Exception("鍙戦�侀偖浠跺紓甯�,閭欢宸蹭繚瀛樺湪鑽夌绠便�傚紓甯稿師鍥狅細" + m.getCause() != null ? m.getCause().getMessage() : m.getMessage()); @@ -327,29 +360,40 @@ * @throws MessagingException * @throws IOException */ - public List<t482101HEntity> setMailContent(Message[] messages, HttpServletRequest request) throws Exception { + public List<t482101HEntity> setMailContent(Message[] messages, String receiver, HttpServletRequest request) throws Exception { try { List<t482101HEntity> t482101HEntityList = new ArrayList<>(); HttpSession session = request.getSession(); + List<String> messageIdList = getMessageIdList(receiver); Message m = null; for (int i = 0; i < messages.length; i++) { m = messages[i]; - String from = MimeUtility.decodeText(m.getFrom()[0].toString()); - InternetAddress internetAddress = new InternetAddress(from); + String messageId = m.getHeader("Message-ID")[0]; + if (messageIdList != null && messageIdList.contains(messageId)) { + if (m.isSet(Flags.Flag.DELETED)) {//閭欢鏄惁闇�瑕佸垹闄� + //鍒犻櫎绯荤粺閲岀殑閭欢 + deleteReceivingMail(messageId); + } + //宸茬粡瀛樺湪灏变笉闇�瑕佸啀娆″皝瑁呭鐞� + continue; + } + t482101HEntity mail = new t482101HEntity(); - if (m.isSet(Flags.Flag.SEEN)) { -// System.out.println("閭欢宸叉爣璁颁负宸茶銆�"); + mail.setMessageId(messageId);//鑾峰彇閭欢鍞竴ID + mail.setMailType(1);//鏀朵欢 + if (m.isSet(Flags.Flag.SEEN)) {//閭欢宸叉爣璁颁负宸茶 mail.setReadFlag(1);//宸茶 - } else { -// m.setFlag(Flags.Flag.SEEN, true);//鏍囪鎴愬凡璇� - mail.setReadFlag(0);//宸茶 } if (m.isExpunged()) {//妫�鏌ヤ竴涓秷鎭槸鍚﹀凡琚垹闄ゃ�傗�� mail.setDeleteFlag(1);//宸插垹闄� - } else { - mail.setDeleteFlag(0);//宸插垹闄� } - mail.setMailType(1);//鏀朵欢 + if (m.isSet(Flags.Flag.ANSWERED)) {//閭欢鏄惁宸插洖澶� + + } + if (m.isSet(Flags.Flag.DRAFT)) {//鏄惁鏄崏绋跨 + mail.setMailType(0);//鏄崏绋跨 + } + mail.setClassType(1); mail.setUserCode((String) session.getAttribute(SessionKey.USERCODE)); mail.setUserName((String) session.getAttribute(SessionKey.USERNAME)); @@ -365,7 +409,7 @@ List<String> fileSeq = new ArrayList<>(); MimeMultipart mimeMultipart = (MimeMultipart) m.getContent(); String uuId = UUID.randomUUID().toString().toUpperCase();//鐢熸垚uuid - result = getTextFromMimeMultipart(mimeMultipart, uuId, fileSeq,request); + result = getTextFromMimeMultipart(mimeMultipart, uuId, fileSeq, request); if (fileSeq.size() > 0) {//鏈夐檮浠跺唴瀹逛繚瀛� mail.setFileUNID(uuId + ";" + StringUtils.join(fileSeq, ";")); } @@ -373,12 +417,13 @@ result = m.getContent().toString(); } mail.setContent(result);//淇濆瓨鍐呭 + String from = MimeUtility.decodeText(m.getFrom()[0].toString()); + InternetAddress internetAddress = new InternetAddress(from); mail.setSender(internetAddress.getAddress());//鍙戜欢浜� - from = MimeUtility.decodeText(m.getRecipients(Message.RecipientType.TO)[0].toString()); internetAddress = new InternetAddress(from); mail.setReceiver(internetAddress.getAddress());//鏀朵欢浜� - + mail.setReceiver(receiver);//缁熶竴鎴愪竴涓敹浠朵汉 String cc = "";//鎶勯�佷汉 Address[] ccAddress = m.getRecipients(Message.RecipientType.CC); if (ccAddress != null && ccAddress.length > 0) { @@ -389,9 +434,8 @@ } cc = cc.substring(0, cc.lastIndexOf(";")); } - mail.setCc(cc);//鎶勯�佷汉 - - String bcc = "";//鎶勯�佷汉 + mail.setCc(cc); + String bcc = "";//瀵嗛�� Address[] bccAddress = m.getRecipients(Message.RecipientType.BCC); if (bccAddress != null && bccAddress.length > 0) { for (Address c : bccAddress) { @@ -411,7 +455,7 @@ } // 杈呭姪鏂规硶锛岀敤浜庨�掑綊鑾峰彇绾枃鏈偖浠跺唴瀹� - private String getTextFromMimeMultipart(MimeMultipart mimeMultipart, String uuId, List<String> fileSeq,HttpServletRequest request) throws Exception { + private String getTextFromMimeMultipart(MimeMultipart mimeMultipart, String uuId, List<String> fileSeq, HttpServletRequest request) throws Exception { int count = mimeMultipart.getCount(); if (count == 0) { throw new MessagingException("Multipart with no body parts"); @@ -432,11 +476,11 @@ if (bodyPart.isMimeType("text/plain")) { result.append(bodyPart.getContent()); } else if (bodyPart.isMimeType("image/*")) {//鍥剧墖 - result.append(saveFileAndImage(bodyPart, "image", uuId,request)); + result.append(saveFileAndImage(bodyPart, "image", uuId, request)); } else if (Part.ATTACHMENT.equalsIgnoreCase(bodyPart.getDisposition())) {//闄勪欢 - fileSeq.add(saveFileAndImage(bodyPart, Part.ATTACHMENT, uuId,request)); + fileSeq.add(saveFileAndImage(bodyPart, Part.ATTACHMENT, uuId, request)); } else if (bodyPart.isMimeType("multipart/*")) { - result.append(getTextFromMimeMultipart((MimeMultipart) bodyPart.getContent(), uuId, fileSeq,request)); + result.append(getTextFromMimeMultipart((MimeMultipart) bodyPart.getContent(), uuId, fileSeq, request)); } } } @@ -459,7 +503,7 @@ return textPlainFound && textHtmlFound; } - private String saveFileAndImage(BodyPart bodyPart, String type, String unId,HttpServletRequest request) throws Exception { + private String saveFileAndImage(BodyPart bodyPart, String type, String unId, HttpServletRequest request) throws Exception { try { String fileName = MimeUtility.decodeText(bodyPart.getFileName()); if (type.equals("image")) { @@ -484,7 +528,7 @@ //杈撳嚭 url // return imgData.getImageUrl(attachmentWhereEntity.getUnid() + ";" + attachmentWhereEntity.getSeq(), null, // null, true, true, null); - DataSourceEntity dataSourceEntity= MultiDataSource.getDataSourceMap(request); + DataSourceEntity dataSourceEntity = MultiDataSource.getDataSourceMap(request); return shoppingImageServer + "/uploads/attachment/" + dataSourceEntity.getDbId() + "/482101/" + attachmentWhereEntity.getUnid() + "@p@" + attachmentWhereEntity.getSeq() + ".jpg"; } else if (type.equals(Part.ATTACHMENT)) { return attachmentWhereEntity.getSeq() + ""; @@ -512,7 +556,7 @@ + " PhysicalPath,PhysicalFile,OriginalFileName,FileSize,FileType, \n" + " AuthorCode,AuthorName,SmallPicPath,UploadTime,OriginalPicture \n" + " from _sys_Attachment \n" - + " where unid = @unid " ; + + " where unid = @unid "; if (seqs.size() > 0) { sql += " and seq in(" + StringUtils.join(seqs, ",") + ")\n"; } @@ -527,4 +571,21 @@ } return attachmentList; } + + @Override + public List<String> getMessageIdList(String receiver) { + List<String> messageId = null; + String sql = " set nocount on \n"; + try { + sql += "select messageId from t482101H where receiver='" + receiver + "'"; + List<t482101HEntity> message = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(t482101HEntity.class)); + if (message != null && message.size() > 0) { + messageId = new ArrayList<>(); + messageId = message.stream().map(t482101HEntity::getMessageId).distinct().collect(Collectors.toList());//鍘婚噸 + } + return messageId; + } catch (Exception e) { + throw e; + } + } } diff --git a/src/com/yc/crm/mail/service/MailQuickTextIfc.java b/src/com/yc/crm/mail/service/MailQuickTextIfc.java index 7be5641..0a43442 100644 --- a/src/com/yc/crm/mail/service/MailQuickTextIfc.java +++ b/src/com/yc/crm/mail/service/MailQuickTextIfc.java @@ -31,5 +31,5 @@ * @param TextName * @return */ - List<T482108Entity> getMailQuickText(String TextName); + List<T482108Entity> getMailQuickText(String userCode,String search); } diff --git a/src/com/yc/crm/mail/service/MailQuickTextImpl.java b/src/com/yc/crm/mail/service/MailQuickTextImpl.java index 077737a..b2afff8 100644 --- a/src/com/yc/crm/mail/service/MailQuickTextImpl.java +++ b/src/com/yc/crm/mail/service/MailQuickTextImpl.java @@ -22,7 +22,7 @@ public void saveQuickText(T482108Entity quickText) { String sql = "set nocount on\n"; try { - sql += "insert into t482108(companyId,companyName,textName,userCode,userName,content,sortId,createTime,updateTime) " + + sql += "insert into t482108(companyId,companyName,text_Name,userCode,userName,content,sort_id,create_time,update_time) " + "values (" + GridUtils.prossSqlParm(quickText.getCompanyId()) + "," + GridUtils.prossSqlParm(quickText.getCompanyName()) + "," + GridUtils.prossSqlParm(quickText.getTextName()) + "," + GridUtils.prossSqlParm(quickText.getUserCode()) + "," + GridUtils.prossSqlParm(quickText.getUserName()) + "," + GridUtils.prossSqlParm(quickText.getContent()) + "," + @@ -37,11 +37,11 @@ public Integer updateQuickText(T482108Entity quickText) { String sql = "set nocount on\n"; try { - sql += "update t482108 set textName=" + GridUtils.prossSqlParm(quickText.getTextName()) + ",content=" + GridUtils.prossSqlParm(quickText.getContent()) + - ",sortId=" + quickText.getSortId() + ",updateTime=getdate() " + - "where textId=" + quickText.getTextId() + " and userCode=" + GridUtils.prossSqlParm(quickText.getUserCode()) + "\n"; + sql += "update t482108 set text_Name=" + GridUtils.prossSqlParm(quickText.getTextName()) + ",content=" + GridUtils.prossSqlParm(quickText.getContent()) + + ",sort_id=" + quickText.getSortId() + ",update_time=getdate() " + + "where text_id=" + quickText.getTextId() + " and userCode=" + GridUtils.prossSqlParm(quickText.getUserCode()) + "\n"; sql += "select @@ROWCOUNT"; - return jdbcTemplate.update(sql, Integer.class); + return jdbcTemplate.queryForObject(sql, Integer.class); } catch (Exception e) { throw e; } @@ -53,20 +53,20 @@ try { sql += "delete t482108 where userCode='" + userCode + "' and textId=" + textId + "\n"; sql += "select @@ROWCOUNT"; - return jdbcTemplate.update(sql, Integer.class); + return jdbcTemplate.queryForObject(sql, Integer.class); } catch (Exception e) { throw e; } } @Override - public List<T482108Entity> getMailQuickText(String TextName) { + public List<T482108Entity> getMailQuickText(String userCode,String search) { String sql = "set nocount on\n"; try { - sql += "select companyId,companyName,textName,userCode,userName,content,sortId,createTime,updateTime" + - "from t482108 "; - if (StringUtils.isNotBlank(TextName)) { - sql += " where TextName=" + TextName; + sql += "select companyId,companyName,textId,textName,userCode,userName,content,sortId,createTime,updateTime" + + "from t482108 where userCode=" + GridUtils.prossSqlParm(userCode); + if (StringUtils.isNotBlank(search)) { + sql += " and TextName like '%" + search+"%'"; } sql += " order by textId" + "\n"; return jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(T482108Entity.class)); diff --git a/src/com/yc/crm/mail/service/MailSignatureIfc.java b/src/com/yc/crm/mail/service/MailSignatureIfc.java index d1089d1..10ea4ff 100644 --- a/src/com/yc/crm/mail/service/MailSignatureIfc.java +++ b/src/com/yc/crm/mail/service/MailSignatureIfc.java @@ -24,12 +24,12 @@ * @param textId * @return */ - Integer deleteSignature(String SigId); + Integer deleteSignature(String userCode,Integer sigId); /** * 鏌ヨ涓汉绛惧悕 * @param name * @return */ - List<T482109Entity> getSignature(String name); + List<T482109Entity> getSignature(String userCode,String search); } diff --git a/src/com/yc/crm/mail/service/MailSignatureImpl.java b/src/com/yc/crm/mail/service/MailSignatureImpl.java index 81aebcb..d24f059 100644 --- a/src/com/yc/crm/mail/service/MailSignatureImpl.java +++ b/src/com/yc/crm/mail/service/MailSignatureImpl.java @@ -38,7 +38,7 @@ String sql = "set nocount on\n"; try { sql += "update t482109 set sign_name=" + GridUtils.prossSqlParm(Signature.getSignName()) + ",sign_content=" + GridUtils.prossSqlParm(Signature.getSignContent()) + "," + - "update_time=getdate() where sign_id=" + Signature.getSignId()+"\n"; + "update_time=getdate() where sign_id=" + Signature.getSignId()+ " and userCode=" + GridUtils.prossSqlParm(Signature.getUserCode()) + "\n"; sql += "select @@ROWCOUNT"; return jdbcTemplate.queryForObject(sql, Integer.class); } catch (Exception e) { @@ -47,10 +47,10 @@ } @Override - public Integer deleteSignature(String SigId) { + public Integer deleteSignature(String userCode,Integer sigId) { String sql = "set nocount on\n"; try { - sql += "delete t482109 where sign_id=" + SigId+"\n"; + sql += "delete t482109 where sign_id=" + sigId+ " and userCode=" + userCode + "\n"; sql += "select @@ROWCOUNT"; return jdbcTemplate.queryForObject(sql, Integer.class); } catch (Exception e) { @@ -59,13 +59,13 @@ } @Override - public List<T482109Entity> getSignature(String name) { + public List<T482109Entity> getSignature(String userCode,String search) { String sql = "set nocount on\n"; try { - sql += "select companyId,companyName,userCode,userName,sign_name,sign_content,create_time,update_time " + - "from t482109 "; - if (StringUtils.isNotBlank(name)) { - sql += " where sign_name=" + name; + sql += "select companyId,companyName,sign_id,userCode,userName,sign_name,sign_content,create_time,update_time " + + "from t482109 where userCode="+GridUtils.prossSqlParm(userCode); + if (StringUtils.isNotBlank(search)) { + sql += " and sign_name like '%" + search +"%'"; } sql += " order by sign_id \n"; return jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(T482109Entity.class)); diff --git a/src/com/yc/crm/mail/util/AllBackMsg.java b/src/com/yc/crm/mail/util/AllBackMsg.java index d1b4b34..43ceb71 100644 --- a/src/com/yc/crm/mail/util/AllBackMsg.java +++ b/src/com/yc/crm/mail/util/AllBackMsg.java @@ -15,6 +15,11 @@ private String msg; private Object data; + public AllBackMsg setOk(String msg) { + this.msg = msg; + return this; + } + public AllBackMsg setSuccess(String msg, Object data) { this.msg = msg; this.data = data; -- Gitblit v1.8.0