feat:(REQ-2227) 修改角色移位时查询角色的接口,原接口有bug

This commit is contained in:
lilong 2024-04-16 10:22:27 +08:00
parent 346dab8247
commit db3c2bd4c6
2 changed files with 19 additions and 10 deletions

View File

@ -239,7 +239,7 @@ public class SaasRoleController implements TyrSaasRoleApi {
}
List<SaasRoleGroupRelation> saasRoleGroupRelations = saasRoleGroupRelationService.list(SaasRoleGroupRelationService.ListSaasRoleGroupRelationParam.builder()
.roleId(Lists.newArrayList(saasRole.getId()))
.roleIds(Lists.newArrayList(saasRole.getId()))
.build());
if (CollectionUtils.isEmpty(saasRoleGroupRelations)) {
throw new ServiceException("角色分组信息不存在");
@ -249,14 +249,19 @@ public class SaasRoleController implements TyrSaasRoleApi {
throw new ServiceException("角色分组信息不唯一,请检查异常");
}
List<SaasRoleVO> saasRoles = roleService.query(QuerySaasRoleReq.builder()
.sassRoleGroupIds(Lists.transform(saasRoleGroupRelations, SaasRoleGroupRelation::getSaasRoleGroupId))
List<SaasRoleGroupRelation> saasRoleGroupRelationAll = saasRoleGroupRelationService.list(SaasRoleGroupRelationService.ListSaasRoleGroupRelationParam.builder()
.saasRoleGroupIds(Lists.transform(saasRoleGroupRelations, SaasRoleGroupRelation::getSaasRoleGroupId))
.build());
List<SaasRoleRes> saasRoles = roleService.list(RoleService.ListSaasRoleParam.builder()
.roleIds(Lists.transform(saasRoleGroupRelationAll, SaasRoleGroupRelation::getRoleId))
.build())
.stream()
.sorted(Comparator.comparing(SaasRoleVO::getSort))
.sorted(Comparator.comparing(SaasRoleRes::getSort))
.collect(Collectors.toList());
SaasRoleVO exchangeRole = findExchangeRole(request, saasRoles);
SaasRoleRes exchangeRole = findExchangeRole(request, saasRoles);
if (exchangeRole == null) {
throw new ServiceException("未找到可以移动的位置");
}
@ -286,10 +291,10 @@ public class SaasRoleController implements TyrSaasRoleApi {
* @param roles
* @return
*/
private SaasRoleVO findExchangeRole(UpdateRoleOffsetReq request,
List<SaasRoleVO> roles) {
private SaasRoleRes findExchangeRole(UpdateRoleOffsetReq request,
List<SaasRoleRes> roles) {
List<Long> ids = roles.stream()
.map(SaasRoleVO::getId)
.map(SaasRoleRes::getId)
.collect(Collectors.toList());
int currentIndex = ids.indexOf(request.getId());
// 下移一位

View File

@ -27,7 +27,11 @@ public interface SaasRoleGroupRelationService extends IService<SaasRoleGroupRela
class ListSaasRoleGroupRelationParam {
@CriteriaField(field = "roleId", operator = Operator.IN)
private List<Long> roleId;
private List<Long> roleIds;
@CriteriaField(field = "saasRoleGroupId", operator = Operator.IN)
private List<Long> saasRoleGroupIds;
}
@SuperBuilder