refactor(系统设置): 添加用户组成员默认排序

This commit is contained in:
song-cc-rock 2024-01-31 18:03:01 +08:00 committed by Craftsman
parent de3d90f420
commit 6d80e68e1a
9 changed files with 14 additions and 13 deletions

View File

@ -14,7 +14,7 @@
</if>
<include refid="filter"/>
</where>
order by u.name
order by urr.create_time desc
</select>
<select id="getMemberByOrg" resultType="io.metersphere.system.dto.user.UserExtendDTO">

View File

@ -35,6 +35,7 @@
or u.phone like concat('%', #{request.keyword}, '%')
)
</if>
order by urr.create_time desc
</select>
<select id="getProjectUserList" resultType="io.metersphere.system.domain.User">

View File

@ -71,6 +71,7 @@ public class ProjectMemberService {
UserRoleRelationExample relationExample = new UserRoleRelationExample();
relationExample.createCriteria().andSourceIdEqualTo(request.getProjectId()).andUserIdIn(members);
List<UserRoleRelation> userRoleRelates = userRoleRelationMapper.selectByExample(relationExample);
userRoleRelates.sort(Comparator.comparing(UserRoleRelation::getCreateTime).reversed());
Map<String, List<String>> userRoleRelateMap = userRoleRelates.stream().collect(Collectors.groupingBy(UserRoleRelation::getUserId,
Collectors.mapping(UserRoleRelation::getRoleId, Collectors.toList())));
// 查询所有项目类型用户组
@ -100,7 +101,6 @@ public class ProjectMemberService {
User user = userMap.get(projectUser.getId());
BeanUtils.copyBean(projectUser, user);
});
projectUsers.sort(Comparator.comparing(ProjectUserDTO::getName));
return projectUsers;
}

View File

@ -121,8 +121,7 @@ public class OrganizationProjectController {
@RequiresPermissions(PermissionConstants.ORGANIZATION_PROJECT_READ)
@Operation(summary = "系统设置-组织-项目-成员列表")
public Pager<List<UserExtendDTO>> getProjectMember(@Validated @RequestBody ProjectMemberRequest request) {
Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize(),
StringUtils.isNotBlank(request.getSortString()) ? request.getSortString() : "create_time desc");
Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize());
return PageUtils.setPageInfo(page, organizationProjectService.getProjectMember(request));
}

View File

@ -126,8 +126,7 @@ public class SystemProjectController {
@Operation(summary = "系统设置-系统-组织与项目-项目-成员列表")
@CheckOwner(resourceId = "#request.projectId", resourceType = "project")
public Pager<List<UserExtendDTO>> getProjectMember(@Validated @RequestBody ProjectMemberRequest request) {
Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize(),
StringUtils.isNotBlank(request.getSortString()) ? request.getSortString() : "create_time desc");
Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize());
return PageUtils.setPageInfo(page, systemProjectService.getProjectMember(request));
}

View File

@ -57,9 +57,9 @@
</update>
<select id="listMember" resultType="io.metersphere.system.dto.user.UserExtendDTO">
select temp.*, max(if(temp.role_id = 'org_admin', true, false)) as adminFlag
select temp.*, max(if(temp.role_id = 'org_admin', true, false)) as adminFlag, min(temp.memberTime) as groupTime
from (
select u.*, urr.role_id
select u.*, urr.role_id, urr.create_time as memberTime
from user_role_relation urr
join `user` u on urr.user_id = u.id
<where>
@ -71,10 +71,10 @@
and u.name like concat('%', #{request.keyword},'%')
</if>
</where>
order by u.update_time desc
order by urr.create_time desc
) temp
group by temp.id
order by adminFlag desc
order by adminFlag desc, groupTime desc
</select>
<select id="listMemberByOrg" resultType="io.metersphere.system.dto.OrgUserExtend">

View File

@ -4,9 +4,9 @@
<select id="getProjectMemberList" resultType="io.metersphere.system.dto.user.UserExtendDTO">
SELECT temp.* , MAX( if (temp.role_id = 'project_admin', true, false)) as adminFlag
SELECT temp.* , MAX( if (temp.role_id = 'project_admin', true, false)) as adminFlag, MIN(temp.memberTime) as groupTime
FROM (
SELECT `user`.* , user_role_relation.role_id
SELECT `user`.* , user_role_relation.role_id, user_role_relation.create_time as memberTime
FROM user_role_relation
LEFT JOIN `user` ON user_role_relation.user_id = `user`.id
<where>
@ -20,7 +20,7 @@
or user.phone like CONCAT('%', #{request.keyword},'%'))
</if>
</where>
ORDER BY `user`.update_time DESC) temp GROUP BY temp.id ORDER BY adminFlag DESC
ORDER BY `user_role_relation`.create_time DESC) temp GROUP BY temp.id ORDER BY adminFlag DESC, groupTime DESC
</select>
<select id="getProjectList" resultType="io.metersphere.system.dto.ProjectDTO">
select p.id,

View File

@ -25,5 +25,6 @@
or u.phone like concat('%', #{request.keyword}, '%')
)
</if>
order by urr.create_time desc
</select>
</mapper>

View File

@ -35,5 +35,6 @@
or u.email like concat('%', #{request.keyword},'%')
)
</if>
order by urr.create_time desc
</select>
</mapper>