|
|
@ -211,41 +211,29 @@ public class StaffRoleServiceImpl extends BaseServiceImpl<StaffRoleDao, StaffRol |
|
|
|
* @date 2021/6/15 3:03 下午 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public List<CustomerAgencyUserRoleDTO> getRoles(CustomerAgencyUserRoleFormDTO formDTO) { |
|
|
|
List<CustomerAgencyUserRoleDTO> result = new ArrayList<>(); |
|
|
|
List<String> disUserIds = new ArrayList<>(); |
|
|
|
if (!CollectionUtils.isEmpty(formDTO.getStaffIds())){ |
|
|
|
List<String> staffIds = formDTO.getStaffIds(); |
|
|
|
String customerId = formDTO.getCustomerId(); |
|
|
|
staffIds.forEach(userId -> { |
|
|
|
CustomerAgencyUserRoleDTO role = staffRoleRedis.getRole(customerId, userId); |
|
|
|
if (null != role){ |
|
|
|
result.add(role); |
|
|
|
}else { |
|
|
|
disUserIds.add(userId); |
|
|
|
} |
|
|
|
}); |
|
|
|
if (!CollectionUtils.isEmpty(disUserIds)){ |
|
|
|
List<RoleKeyValueResultDTO> rolesByDB = baseDao.getRolesByDB(disUserIds); |
|
|
|
if (!CollectionUtils.isEmpty(rolesByDB)){ |
|
|
|
Map<String, List<RoleKeyValueResultDTO>> groupByUserId = rolesByDB.stream().collect(Collectors.groupingBy(RoleKeyValueResultDTO::getStaffId)); |
|
|
|
groupByUserId.forEach((userId,list) -> { |
|
|
|
CustomerAgencyUserRoleDTO dto = new CustomerAgencyUserRoleDTO(); |
|
|
|
dto.setStaffId(list.get(NumConstant.ZERO).getStaffId()); |
|
|
|
dto.setCustomerId(customerId); |
|
|
|
dto.setAgencyId(list.get(NumConstant.ZERO).getOrgId()); |
|
|
|
Map map = new HashMap(16); |
|
|
|
list.forEach(l -> { |
|
|
|
map.put(l.getRoleKey(),l.getRoleName()); |
|
|
|
}); |
|
|
|
dto.setRoles(map.toString()); |
|
|
|
staffRoleRedis.setRole(customerId,userId,dto); |
|
|
|
result.add(dto); |
|
|
|
}); |
|
|
|
} |
|
|
|
public CustomerAgencyUserRoleDTO getUserRoles(CustomerAgencyUserRoleFormDTO formDTO) { |
|
|
|
String staffId = formDTO.getStaffId(); |
|
|
|
String customerId = formDTO.getCustomerId(); |
|
|
|
CustomerAgencyUserRoleDTO role = staffRoleRedis.getRole(customerId, staffId); |
|
|
|
if (null != role){ |
|
|
|
return role; |
|
|
|
}else { |
|
|
|
List<RoleKeyValueResultDTO> rolesByDB = baseDao.getRolesByDB(staffId); |
|
|
|
if (!CollectionUtils.isEmpty(rolesByDB)) { |
|
|
|
CustomerAgencyUserRoleDTO dto = new CustomerAgencyUserRoleDTO(); |
|
|
|
dto.setStaffId(rolesByDB.get(NumConstant.ZERO).getStaffId()); |
|
|
|
dto.setCustomerId(customerId); |
|
|
|
dto.setAgencyId(rolesByDB.get(NumConstant.ZERO).getOrgId()); |
|
|
|
Map map = new HashMap(16); |
|
|
|
rolesByDB.forEach(l -> { |
|
|
|
map.put(l.getRoleKey(), l.getRoleName()); |
|
|
|
}); |
|
|
|
dto.setRoles(map.toString()); |
|
|
|
staffRoleRedis.setRole(customerId, staffId, dto); |
|
|
|
return dto; |
|
|
|
} |
|
|
|
} |
|
|
|
return result; |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
} |