‘linchangsheng’ há 5 meses atrás
pai
commit
bb08a341c7

+ 29 - 3
mall-server-api/src/main/java/com/gree/mall/manager/logic/common/SysDictCompanyLogic.java

@@ -233,7 +233,6 @@ public class SysDictCompanyLogic {
                 .eq(SysDictTypeCompany::getOpen, true)
                 .oneOpt()
                 .orElseThrow(() -> new RemoteServiceException("暂不开放该字典类型配置"));
-        checkRepeatDictCode(param.getDictType(), param.getDictValue(), param.getCompanyWechatId(),param.getDictCode());
         if(adminUser != null) {
             param.setCompanyName(adminUser.getCompanyName());
             param.setCompanyWechatId(adminUser.getCompanyWechatId());
@@ -242,6 +241,7 @@ public class SysDictCompanyLogic {
             param.setDictCode(IdWorker.getIdStr());
         }
 
+        checkRepeatDictCode(param.getDictType(), param.getDictValue(), param.getCompanyWechatId(),param.getDictCode());
         sysDictCompanyService.save(param);
     }
 
@@ -267,6 +267,26 @@ public class SysDictCompanyLogic {
                 }
             }
         }
+
+        Integer count = sysDictCompanyService.lambdaQuery()
+                .eq(SysDictCompany::getDictType, dictType)
+                .eq(SysDictCompany::getDictValue, param.getDictValue())
+                .eq(SysDictCompany::getDictCode, param.getDictCode())
+                .eq(SysDictCompany::getCompanyWechatId, sysDictCompany.getCompanyWechatId())
+                .ne(SysDictCompany::getSysDictId,param.getSysDictId())
+                .count();
+        if (count > 0) {
+            throw new RemoteServiceException(param.getDictValue() + "重复存在");
+        }
+
+        if (sysDictCompanyService.lambdaQuery()
+                .eq(SysDictCompany::getDictType, dictType)
+                .eq(SysDictCompany::getDictCode, param.getDictCode())
+                .eq(SysDictCompany::getCompanyWechatId, sysDictCompany.getCompanyWechatId())
+                .ne(SysDictCompany::getSysDictId,param.getSysDictId())
+                .count() > 0) {
+            throw new RemoteServiceException(param.getDictCode() + "重复存在");
+        }
         sysDictCompanyService.updateById(param);
     }
 
@@ -274,13 +294,19 @@ public class SysDictCompanyLogic {
         Integer count = sysDictCompanyService.lambdaQuery()
                 .eq(SysDictCompany::getDictType, dictType)
                 .eq(SysDictCompany::getDictValue, value)
-                .eq(SysDictCompany::getDictValue, value)
                 .eq(!StringUtil.isEmpty(code),SysDictCompany::getDictCode, code)
                 .eq(SysDictCompany::getCompanyWechatId, companyWechatId)
                 .count();
         if (count > 0) {
             throw new RemoteServiceException(value + "重复存在");
         }
+
+        if (sysDictCompanyService.lambdaQuery()
+                .eq(SysDictCompany::getDictType, dictType)
+                .eq(SysDictCompany::getDictCode, code)
+                .eq(SysDictCompany::getCompanyWechatId, companyWechatId).count() > 0) {
+            throw new RemoteServiceException(code + "重复存在");
+        }
     }
 
 
@@ -342,7 +368,7 @@ public class SysDictCompanyLogic {
             sysDictCompany.setCompanyWechatId(adminUser.getCompanyWechatId());
             sysDictCompany.setDictCode(IdWorker.getIdStr());
 
-            checkRepeatDictCode(sysDictCompany.getDictType(), sysDictCompany.getDictValue(), sysDictCompany.getCompanyWechatId(),null);
+            checkRepeatDictCode(sysDictCompany.getDictType(), sysDictCompany.getDictValue(), sysDictCompany.getCompanyWechatId(),sysDictCompany.getDictCode());
 
             sysDictCompanyList.add(sysDictCompany
             );