Просмотр исходного кода

增加账号新增和编辑时 团队ID 企微主体 客服名称的部分限制

leon 4 лет назад
Родитель
Сommit
c7635da724

+ 3 - 1
src/main/java/com/mokamrp/privates/config/ApiPanic.java

@@ -16,7 +16,9 @@ public class ApiPanic {
     public String exceptionHandler(Exception e) {
         if (env.equals("prod")) {
             //.正式环境捕获API异常 推送到飞书
-            Cmd.sendFeishuMsg(feishu, "[moka-private]:api panic " + e);
+            if (e.getMessage() != null){
+                Cmd.sendFeishuMsg(feishu, "[moka-private]:api panic " + e);
+            }
         }
         return e.getMessage();
     }

+ 49 - 2
src/main/java/com/mokamrp/privates/controller/pangu/FosterwxMobileController.java

@@ -155,6 +155,28 @@ public class FosterwxMobileController extends BaseController<FosterwxMobile> {
         if (fosterwxMobileService.count(fosterwxMobileLambdaQueryWrapper) > 0) {
             return AjaxResult.error("该站点中该手机编码已存在!请确认!");
         }
+        //.验证企微主体ID&客服昵称是否重复
+        if ((addHandle.getRaw().getWorkWxCorpId() != null || !addHandle.getRaw().getWorkWxCorpId().equals(0))
+                && (addHandle.getRaw().getCustserviceName() != null || !addHandle.getRaw().getCustserviceName().isEmpty())){
+            FosterwxMobile hasCorpIdAndCustServiceNm = fosterwxMobileService.getOne(
+                    new QueryWrapper<FosterwxMobile>()
+                            .eq("work_wx_corp_id",addHandle.getRaw().getWorkWxCorpId())
+                            .eq("custservice_name",addHandle.getRaw().getCustserviceName())
+            );
+            if (hasCorpIdAndCustServiceNm != null){
+                return AjaxResult.error("企微主体ID和客服昵称组合同时存在");
+            }
+        }
+        //.验证teamID是否为空
+        if (addHandle.getRaw().getTeamId() != null || !addHandle.getRaw().getTeamId().isEmpty()){
+            FosterwxMobile hasTeamId = fosterwxMobileService.getOne(
+                    new QueryWrapper<FosterwxMobile>()
+                            .eq("team_id",addHandle.getRaw().getTeamId())
+            );
+            if (hasTeamId != null){
+                return AjaxResult.error("团队ID已经存在");
+            }
+        }
         FosterwxStation stationInfo = fosterwxStationService.getOne(new QueryWrapper<FosterwxStation>()
                 .eq("id", addHandle.getRaw().getStationId()));
         // 新增账号
@@ -190,7 +212,32 @@ public class FosterwxMobileController extends BaseController<FosterwxMobile> {
             List<FosterwxMobileTaskTimeList> gwOldTimeList = fosterwxMobileTaskTimeListService.list(new LambdaQueryWrapper<FosterwxMobileTaskTimeList>().eq(FosterwxMobileTaskTimeList::getMobileUnioCode, oldVO.getMobileUnioCode()).eq(FosterwxMobileTaskTimeList::getType, 1).orderByAsc(FosterwxMobileTaskTimeList::getId));
             // 企微旧任务详情
             List<FosterwxMobileTaskTimeList> qwOldTimeList = fosterwxMobileTaskTimeListService.list(new LambdaQueryWrapper<FosterwxMobileTaskTimeList>().eq(FosterwxMobileTaskTimeList::getMobileUnioCode, oldVO.getMobileUnioCode()).eq(FosterwxMobileTaskTimeList::getType, 2).orderByAsc(FosterwxMobileTaskTimeList::getId));
-            // 新增账号
+
+            // 单独更新账号操作
+            //.验证企微主体ID&客服昵称是否重复
+            if (!editHandle.getRaw().getWorkWxCorpId().equals(0) &&
+                    (editHandle.getRaw().getCustserviceName() != null || !editHandle.getRaw().getCustserviceName().isEmpty())){
+                FosterwxMobile hasCorpIdAndCustServiceNm = fosterwxMobileService.getOne(
+                        new QueryWrapper<FosterwxMobile>()
+                                .ne("id",id)
+                                .eq("work_wx_corp_id",editHandle.getRaw().getWorkWxCorpId())
+                                .eq("custservice_name",editHandle.getRaw().getCustserviceName())
+                );
+                if (hasCorpIdAndCustServiceNm != null){
+                    return AjaxResult.error("企微主体ID和客服昵称组合同时存在");
+                }
+            }
+            //.验证teamID是否为空
+            if (editHandle.getRaw().getTeamId() != null || !editHandle.getRaw().getTeamId().isEmpty()){
+                FosterwxMobile hasTeamId = fosterwxMobileService.getOne(
+                        new QueryWrapper<FosterwxMobile>()
+                                .ne("id",id)
+                                .eq("team_id",editHandle.getRaw().getTeamId())
+                );
+                if (hasTeamId != null){
+                    return AjaxResult.error("团队ID已经存在");
+                }
+            }
             fosterwxMobileService.update(fosterwxMobile, new QueryWrapper<FosterwxMobile>().eq("id", id));
 
             fosterwxMobile = fosterwxMobileService.getById(id);
@@ -208,13 +255,13 @@ public class FosterwxMobileController extends BaseController<FosterwxMobile> {
             }
 
 
+
             AjaxResult ajaxResult = null;
             // 个微的任务相关操作
             if (null != editHandle.getRaw().getGwTaskTimeLists()) {
                 // 判断开始做任务时间是否设置了
                 // 获取最新的一条时间任务
                 FosterwxMobileTaskTimeList fosterwxMobileTaskTimeList = new FosterwxMobileTaskTimeList();
-
                 if (!editHandle.getRaw().getGwTaskTimeLists().isEmpty()) {
                     FosterwxMobileTaskTimeList sample = editHandle.getRaw().getGwTaskTimeLists().get(editHandle.getRaw().getGwTaskTimeLists().size() - 1);
                     fosterwxMobileTaskTimeList.setTaskStartAt(sample.getTaskStartAt());