增加接口
This commit is contained in:
parent
6e22899397
commit
9e571ca41d
@ -47,6 +47,10 @@ public interface IRoleUserRemoteService {
|
||||
@RemoteGetMethod("/list-role-id/user-id/{userId}")
|
||||
List<String> listRoleIdByUserId(@RemoteServerParams String userCenter, @RemotePathParams("userId") String userId, @RemoteQueryParams("access_token") String accessToken);
|
||||
|
||||
@RemotePostMethod("/list-role-po/user-ids")
|
||||
List<RolePO> listRolePOByUserIds(String userCenter, String accessToken, IdsVO idsVO);
|
||||
|
||||
|
||||
@RemoteGetMethod("/list-user/role-id/{roleId}")
|
||||
List<UserDTO> listUserByRoleId(@RemoteServerParams String userCenter, @RemotePathParams("roleId") String roleId, @RemoteQueryParams("access_token") String accessToken);
|
||||
|
||||
@ -60,4 +64,5 @@ public interface IRoleUserRemoteService {
|
||||
SuccessResultList<List<UserDTO>> listPageUserNoDepartmentAndNoRole(@RemoteServerParams String userCenter, @RemoteQueryParams("access_token") String accessToken, @RemoteQueryParams("page") int page, @RemoteQueryParams("rows") int rows, @RemoteQueryParamsMap Map<String, Object> params);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -57,6 +57,13 @@ public class RoleUserServiceImpl extends DefaultBaseService implements IRoleUser
|
||||
return roleUserRemoteService.listRolePOByUserId(apiPathProperties.getUserCenter(), userId, OAuth2ClientTokenManager.getInstance().getToken().getAccessToken());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RolePO> listRolePOByUserIds(List<String> userIds) {
|
||||
IdsVO idsVO = new IdsVO();
|
||||
idsVO.setIds(userIds);
|
||||
return roleUserRemoteService.listRolePOByUserIds(apiPathProperties.getUserCenter(), OAuth2ClientTokenManager.getInstance().getToken().getAccessToken(), idsVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RolePO> listRolePOByRoleIds(List<String> roleIds) {
|
||||
if (roleIds.isEmpty()) {
|
||||
|
@ -154,4 +154,14 @@ public class RoleUserResourceController extends DefaultBaseController {
|
||||
return roleUserService.listPageUserNoDepartmentAndNoRole(page);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "角色列表", notes = "通过用户ID列表获取角色列表")
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@PostMapping("list-role-po/user-ids")
|
||||
public List<RolePO> listRoleIdByUserId(@RequestBody IdsVO idsVO) {
|
||||
if(idsVO.getIds().isEmpty()) {
|
||||
throw new ParamsException("id列表不能为空");
|
||||
}
|
||||
return roleUserService.listRolePOByUserIds(idsVO.getIds());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
@ -206,17 +207,13 @@ public class RoleUserServiceImpl extends DefaultBaseService implements IRoleUser
|
||||
public SuccessResultList<List<RoleUserDTO>> listPage(String roleId, ListPage page) {
|
||||
SuccessResultList<List<UserDTO>> successResultList;
|
||||
if (StringUtils.equals(roleId, ISystemConstant.TREE_BASE_ROOT_ID_VALUE)) {
|
||||
successResultList = listPageUserDTOByExcludeRole(page);
|
||||
} else {
|
||||
successResultList = listPageUser(roleId, page);
|
||||
page.getParams().put("noRole", true);
|
||||
}
|
||||
List<UserDTO> userDTOs = successResultList.getRows();
|
||||
List<RoleUserDTO> roleUserDTOs = new ArrayList<>();
|
||||
for (UserDTO userDTO : userDTOs) {
|
||||
successResultList = listPageUserByRoleId(roleId, page);
|
||||
return new SuccessResultList<>(successResultList.getRows().stream().map(userDTO -> {
|
||||
RoleUserDTO roleUserDTO = new RoleUserDTO(userDTO);
|
||||
roleUserDTOs.add(roleUserDTO);
|
||||
}
|
||||
return new SuccessResultList<>(roleUserDTOs, successResultList.getPage(), successResultList.getTotal());
|
||||
return roleUserDTO;
|
||||
}).collect(Collectors.toList()), successResultList.getPage(), successResultList.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -373,19 +370,4 @@ public class RoleUserServiceImpl extends DefaultBaseService implements IRoleUser
|
||||
return userBaseService.listPageByExcludeIds(hasRoleUserIds, page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户组的用户分页列表
|
||||
*
|
||||
* @param roleId 用户组ID
|
||||
* @param page
|
||||
* @return
|
||||
*/
|
||||
private SuccessResultList<List<UserDTO>> listPageUser(String roleId, ListPage page) {
|
||||
List<String> userIds = listUserId(roleId);
|
||||
if (userIds.isEmpty()) {
|
||||
return new SuccessResultList<>(new ArrayList<>(), 1, 0L);
|
||||
}
|
||||
return userBaseService.listPageByIds(userIds, page);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user