Commit fc9fe221d7bbd1b1d4a1aac0e0b955c675d56bb1

Authored by YunaiV
1 parent 08445f52

1487 fix: 修复导入用户的 username 为空时会异常问题

yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java
... ... @@ -36,7 +36,6 @@ import com.mzt.logapi.service.impl.DiffParseFunction;
36 36 import com.mzt.logapi.starter.annotation.LogRecord;
37 37 import jakarta.annotation.Resource;
38 38 import jakarta.validation.ConstraintViolationException;
39   -import java.util.concurrent.atomic.AtomicInteger;
40 39 import lombok.extern.slf4j.Slf4j;
41 40 import org.springframework.context.annotation.Lazy;
42 41 import org.springframework.security.crypto.password.PasswordEncoder;
... ... @@ -45,6 +44,7 @@ import org.springframework.transaction.annotation.Transactional;
45 44  
46 45 import java.time.LocalDateTime;
47 46 import java.util.*;
  47 +import java.util.concurrent.atomic.AtomicInteger;
48 48  
49 49 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
50 50 import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*;
... ... @@ -285,14 +285,12 @@ public class AdminUserServiceImpl implements AdminUserService {
285 285 @Override
286 286 public PageResult<AdminUserDO> getUserPage(UserPageReqVO reqVO) {
287 287 // 如果有角色编号,查询角色对应的用户编号
288   - Set<Long> userIds;
  288 + Set<Long> userIds = null;
289 289 if (reqVO.getRoleId() != null) {
290 290 userIds = permissionService.getUserRoleIdListByRoleId(singleton(reqVO.getRoleId()));
291 291 if (CollUtil.isEmpty(userIds)) {
292 292 return PageResult.empty();
293 293 }
294   - } else {
295   - userIds = null;
296 294 }
297 295  
298 296 // 分页查询
... ... @@ -497,8 +495,7 @@ public class AdminUserServiceImpl implements AdminUserService {
497 495 try {
498 496 ValidationUtils.validate(BeanUtils.toBean(importUser, UserSaveReqVO.class).setPassword(initPassword));
499 497 } catch (ConstraintViolationException ex) {
500   - String key = importUser.getUsername();
501   - if (StrUtil.isBlank(key)) key = "第" + currentIndex + "行";
  498 + String key = StrUtil.blankToDefault(importUser.getUsername(), "第 " + currentIndex + " 行");
502 499 respVO.getFailureUsernames().put(key, ex.getMessage());
503 500 return;
504 501 }
... ...