czh 2 éve
szülő
commit
4a16242473

+ 2 - 1
sckw-auth/src/main/java/com/sckw/auth/service/impl/AuthServiceImpl.java

@@ -448,9 +448,10 @@ public class AuthServiceImpl implements IAuthService {
         loginRes.setRoleId(user.getRoleId());
         if (user.getSystemType().equals(SystemTypeEnum.MANAGE.getCode())) {
             loginRes.setValid(true);
+        } else {
+            loginRes.setValid(!Objects.isNull(enterprise) && enterprise.getValid());
         }
 
-        loginRes.setValid(Objects.isNull(enterprise) ? false : enterprise.getValid());
         return HttpResult.ok(loginRes);
     }
 

+ 1 - 3
sckw-common/sckw-common-core/src/main/java/com/sckw/core/web/constant/HttpStatus.java

@@ -183,11 +183,9 @@ public class HttpStatus {
     public static final String MSG_029 = "合同编号超长!";
     public static final String MSG_030 = "合同名称超长!";
     public static final String MSG_031 = "您与所选企业存在未完结销售订单,当前无法删除!";
-
     public static final String MSG_032 = "您与所选企业存在未完结托运承运订单,当前无法删除!";
-
     public static final String MSG_033 = "当前企业资质在审核中,无法删除!";
-
     public static final String MSG_034 = "您与所选企业存在未完结对账单,当前无法删除!";
+    public static final String MSG_035 = "地址信息已存在";
 
 }

+ 23 - 9
sckw-modules/sckw-manage/src/main/java/com/sckw/manage/service/KwmAddressService.java

@@ -270,6 +270,8 @@ public class KwmAddressService {
             throw new SystemException(HttpStatus.QUERY_FAIL_CODE, HttpStatus.ADDRESS_NOT_EXISTS);
         }
 
+        checkAddressRepeat(reqVo.getName(), reqVo.getDetailAddress(), kwmAddress.getId());
+
         BeanUtils.copyProperties(reqVo, kwmAddress);
         if (kwmAddressMapper.updateById(kwmAddress) <= 0) {
             throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.UPDATE_FAIL);
@@ -286,15 +288,7 @@ public class KwmAddressService {
      */
     @Transactional(rollbackFor = {})
     public void add(AddressAddReqVo reqVo) {
-        LambdaQueryWrapper<KwmAddress> wrapper = new LambdaQueryWrapper<>();
-        wrapper.eq(KwmAddress::getName, reqVo.getName()).
-                eq(KwmAddress::getDelFlag, Global.NO).
-                eq(KwmAddress::getStatus, Global.NO).
-                eq(KwmAddress::getEntId, LoginUserHolder.getEntId());
-        if (kwmAddressMapper.selectCount(wrapper).compareTo((long) Global.NUMERICAL_ZERO) > 0) {
-            throw new SystemException(HttpStatus.PARAMETERS_MISSING_CODE, HttpStatus.ADDRESS_EXISTS);
-        }
-
+        checkAddressRepeat(reqVo.getName(), reqVo.getDetailAddress(), null);
         KwmAddress kwmAddress = new KwmAddress();
         BeanUtils.copyProperties(reqVo, kwmAddress);
         Long userId = LoginUserHolder.getUserId();
@@ -313,6 +307,26 @@ public class KwmAddressService {
         }
     }
 
+    private void checkAddressRepeat(String name, String detailAddress, Long id) {
+        LambdaQueryWrapper<KwmAddress> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(KwmAddress::getDelFlag, Global.NO).
+                eq(KwmAddress::getStatus, Global.NO).
+                eq(KwmAddress::getEntId, LoginUserHolder.getEntId()).and(
+                        wp -> wp.eq(KwmAddress::getName, name).or().eq(KwmAddress::getDetailAddress, detailAddress)
+                );
+        List<KwmAddress> kwmAddressList = kwmAddressMapper.selectList(wrapper);
+        if (CollectionUtils.isNotEmpty(kwmAddressList) && Objects.isNull(id)) {
+            throw new SystemException(HttpStatus.CODE_10301, HttpStatus.MSG_035);
+        }
+
+        if (CollectionUtils.isNotEmpty(kwmAddressList) && Objects.nonNull(id)) {
+            List<KwmAddress> kwmAddressList1 = kwmAddressList.stream().filter(item -> !item.getId().equals(id)).toList();
+            if (CollectionUtils.isNotEmpty(kwmAddressList1)) {
+                throw new SystemException(HttpStatus.CODE_10301, HttpStatus.MSG_035);
+            }
+        }
+    }
+
 
     /**
      * @param ids 主键

+ 0 - 1
sckw-modules/sckw-system/src/main/java/com/sckw/system/controller/KwsDeptController.java

@@ -30,7 +30,6 @@ public class KwsDeptController {
      **/
     @GetMapping("/detail")
     public HttpResult selectByKey(@RequestParam Long id) {
-        int i = 1 / 0;
         KwsDept sysDict = kwsDeptService.selectByKey(id);
         return HttpResult.ok(sysDict);
     }