|
|
@@ -15,7 +15,6 @@ import com.hz.pm.api.sys.model.entity.UserRole; |
|
|
|
import com.hz.pm.api.sys.service.IRoleService; |
|
|
|
import com.hz.pm.api.sys.service.IUserRoleService; |
|
|
|
import com.hz.pm.api.user.helper.MhUnitCache; |
|
|
|
import com.hz.pm.api.user.model.dto.UnitDTO; |
|
|
|
import com.hz.pm.api.user.model.entity.UserInfo; |
|
|
|
import com.hz.pm.api.user.model.enumeration.UserAvailableEnum; |
|
|
|
import com.hz.pm.api.user.model.po.ReqUserDetailEditPO; |
|
|
@@ -75,6 +74,8 @@ public class UserInfoManage { |
|
|
|
if (page.getTotal() == 0) { |
|
|
|
return PageVo.empty(); |
|
|
|
} |
|
|
|
List<Long> userIds = CollUtils.fieldList(page.getRecords(), UserInfo::getId); |
|
|
|
Map<Long, List<UserRoleVO>> userRoleMap = getUserRoleMap(userIds); |
|
|
|
List<UserInfoListVO> result = new ArrayList<>(); |
|
|
|
page.getRecords().forEach(r -> { |
|
|
|
UserInfoListVO item = new UserInfoListVO(); |
|
|
@@ -82,7 +83,7 @@ public class UserInfoManage { |
|
|
|
userStatusBuilder(item, r); |
|
|
|
item.setUpdateTime(r.getUpdateOn()); |
|
|
|
item.setEmployeeCode(r.getEmployeeCode()); |
|
|
|
item.setUserRoleList(getUserRole(item.getUserId())); |
|
|
|
item.setUserRoleList(userRoleMap.get(r.getId())); |
|
|
|
item.setUserId(r.getId()); |
|
|
|
item.setPhoneNo(r.getMobile()); |
|
|
|
item.setMhUnitId(r.getMhUnitId()); |
|
|
@@ -154,6 +155,36 @@ public class UserInfoManage { |
|
|
|
return userRoleInfoList; |
|
|
|
} |
|
|
|
|
|
|
|
private Map<Long, List<UserRoleVO>> getUserRoleMap(Collection<Long> userIds) { |
|
|
|
if (CollUtil.isEmpty(userIds)) { |
|
|
|
return Collections.emptyMap(); |
|
|
|
} |
|
|
|
List<UserRole> userRoleList = userRoleService.list(Wrappers.lambdaQuery(UserRole.class) |
|
|
|
.in(UserRole::getUserId, userIds) |
|
|
|
.orderByAsc(UserRole::getCreateOn)); |
|
|
|
if (CollUtil.isNotEmpty(userRoleList)) { |
|
|
|
List<Long> roleIds = CollUtils.fieldList(userRoleList, UserRole::getRoleId); |
|
|
|
List<Role> roleList = roleService.listByIds(roleIds); |
|
|
|
Map<Long, Role> roleMap = CollUtils.listToMap(roleList, Role::getId); |
|
|
|
Map<Long, List<UserRoleVO>> userRoleMap = userRoleList.stream() |
|
|
|
.filter(r -> roleMap.containsKey(r.getRoleId())) |
|
|
|
.collect(Collectors.groupingBy(UserRole::getUserId, |
|
|
|
Collectors.mapping(w -> { |
|
|
|
Role role = roleMap.get(w.getRoleId()); |
|
|
|
UserRoleVO userRoleVO = new UserRoleVO(); |
|
|
|
userRoleVO.setId(role.getId()); |
|
|
|
userRoleVO.setName(role.getName()); |
|
|
|
userRoleVO.setCreateOn(role.getCreateOn()); |
|
|
|
return userRoleVO; |
|
|
|
}, Collectors.toList()))); |
|
|
|
for (List<UserRoleVO> value : userRoleMap.values()) { |
|
|
|
value.sort(Comparator.comparing(UserRoleVO::getCreateOn)); |
|
|
|
} |
|
|
|
return userRoleMap; |
|
|
|
} |
|
|
|
return Collections.emptyMap(); |
|
|
|
} |
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void disableOrEnable(ReqUserDisableOrEnablePO req) { |
|
|
|
Long userId; |
|
|
|