feat:(REQ-2227) 修改角色移位时查询角色的接口,原接口有bug
This commit is contained in:
parent
346dab8247
commit
db3c2bd4c6
@ -239,7 +239,7 @@ public class SaasRoleController implements TyrSaasRoleApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<SaasRoleGroupRelation> saasRoleGroupRelations = saasRoleGroupRelationService.list(SaasRoleGroupRelationService.ListSaasRoleGroupRelationParam.builder()
|
List<SaasRoleGroupRelation> saasRoleGroupRelations = saasRoleGroupRelationService.list(SaasRoleGroupRelationService.ListSaasRoleGroupRelationParam.builder()
|
||||||
.roleId(Lists.newArrayList(saasRole.getId()))
|
.roleIds(Lists.newArrayList(saasRole.getId()))
|
||||||
.build());
|
.build());
|
||||||
if (CollectionUtils.isEmpty(saasRoleGroupRelations)) {
|
if (CollectionUtils.isEmpty(saasRoleGroupRelations)) {
|
||||||
throw new ServiceException("角色分组信息不存在");
|
throw new ServiceException("角色分组信息不存在");
|
||||||
@ -249,14 +249,19 @@ public class SaasRoleController implements TyrSaasRoleApi {
|
|||||||
throw new ServiceException("角色分组信息不唯一,请检查异常");
|
throw new ServiceException("角色分组信息不唯一,请检查异常");
|
||||||
}
|
}
|
||||||
|
|
||||||
List<SaasRoleVO> saasRoles = roleService.query(QuerySaasRoleReq.builder()
|
List<SaasRoleGroupRelation> saasRoleGroupRelationAll = saasRoleGroupRelationService.list(SaasRoleGroupRelationService.ListSaasRoleGroupRelationParam.builder()
|
||||||
.sassRoleGroupIds(Lists.transform(saasRoleGroupRelations, SaasRoleGroupRelation::getSaasRoleGroupId))
|
.saasRoleGroupIds(Lists.transform(saasRoleGroupRelations, SaasRoleGroupRelation::getSaasRoleGroupId))
|
||||||
.build())
|
.build());
|
||||||
|
|
||||||
|
List<SaasRoleRes> saasRoles = roleService.list(RoleService.ListSaasRoleParam.builder()
|
||||||
|
.roleIds(Lists.transform(saasRoleGroupRelationAll, SaasRoleGroupRelation::getRoleId))
|
||||||
|
.build())
|
||||||
.stream()
|
.stream()
|
||||||
.sorted(Comparator.comparing(SaasRoleVO::getSort))
|
.sorted(Comparator.comparing(SaasRoleRes::getSort))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
SaasRoleVO exchangeRole = findExchangeRole(request, saasRoles);
|
|
||||||
|
SaasRoleRes exchangeRole = findExchangeRole(request, saasRoles);
|
||||||
if (exchangeRole == null) {
|
if (exchangeRole == null) {
|
||||||
throw new ServiceException("未找到可以移动的位置");
|
throw new ServiceException("未找到可以移动的位置");
|
||||||
}
|
}
|
||||||
@ -286,10 +291,10 @@ public class SaasRoleController implements TyrSaasRoleApi {
|
|||||||
* @param roles
|
* @param roles
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private SaasRoleVO findExchangeRole(UpdateRoleOffsetReq request,
|
private SaasRoleRes findExchangeRole(UpdateRoleOffsetReq request,
|
||||||
List<SaasRoleVO> roles) {
|
List<SaasRoleRes> roles) {
|
||||||
List<Long> ids = roles.stream()
|
List<Long> ids = roles.stream()
|
||||||
.map(SaasRoleVO::getId)
|
.map(SaasRoleRes::getId)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
int currentIndex = ids.indexOf(request.getId());
|
int currentIndex = ids.indexOf(request.getId());
|
||||||
// 下移一位
|
// 下移一位
|
||||||
|
|||||||
@ -27,7 +27,11 @@ public interface SaasRoleGroupRelationService extends IService<SaasRoleGroupRela
|
|||||||
class ListSaasRoleGroupRelationParam {
|
class ListSaasRoleGroupRelationParam {
|
||||||
|
|
||||||
@CriteriaField(field = "roleId", operator = Operator.IN)
|
@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
|
@SuperBuilder
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user