Bladeren bron

fix 批量导入用户

he2802 3 jaren geleden
bovenliggende
commit
0636c5741f

+ 7 - 8
zhongzheng-framework/src/main/java/com/zhongzheng/framework/web/service/UserServiceImpl.java

@@ -855,9 +855,6 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
     public List<UserIdCardBatchVo> batchUserId(List<UserIdCardAddBo> list) {
         List<UserIdCardBatchVo> list1 = new ArrayList<>();
         for(UserIdCardAddBo bo : list){
-            if(Validator.isEmpty(bo.getIdCard())){
-                throw new CustomException("用户身份证缺失");
-            }
             if(Validator.isEmpty(bo.getTelphone())){
                 throw new CustomException("用户手机号码缺失");
             }
@@ -869,7 +866,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
             //手机号码存在
             if(Validator.isNotEmpty(user1)){
                 UserIdCardBatchVo user = BeanUtil.toBean(bo, UserIdCardBatchVo.class);
-                if(Validator.isNotEmpty(user1.getIdCard())&&!bo.getIdCard().equals(user1.getIdCard())){
+                if(Validator.isNotEmpty(bo.getIdCard())&&Validator.isNotEmpty(user1.getIdCard())&&!user1.getIdCard().equals(bo.getIdCard())){
                     throw new CustomException(bo.getRealname()+"身份证号码不一致");
                 }
                 if(Validator.isEmpty(user1.getIdCard())){
@@ -882,10 +879,12 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
                 list1.add(user);
                 continue;
             }else{
-                User user2 = getOne(new LambdaQueryWrapper<User>()
-                        .eq(User::getIdCard,bo.getIdCard()).last("limit 1"));
-                if(Validator.isNotEmpty(user2)){
-                    throw new CustomException(bo.getRealname()+"身份证号码已存在,创建失败");
+                if(Validator.isNotEmpty(bo.getIdCard())){
+                    User user2 = getOne(new LambdaQueryWrapper<User>()
+                            .eq(User::getIdCard,bo.getIdCard()).last("limit 1"));
+                    if(Validator.isNotEmpty(user2)){
+                        throw new CustomException(bo.getRealname()+"身份证号码已存在,创建失败");
+                    }
                 }
                 UserSystemRegisterBo registerBo = BeanUtil.toBean(bo, UserSystemRegisterBo.class);
                 registerBo.setTel(bo.getTelphone());