refactor(系统设置): 添加用户组成员默认排序
This commit is contained in:
parent
de3d90f420
commit
6d80e68e1a
|
@ -14,7 +14,7 @@
|
||||||
</if>
|
</if>
|
||||||
<include refid="filter"/>
|
<include refid="filter"/>
|
||||||
</where>
|
</where>
|
||||||
order by u.name
|
order by urr.create_time desc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getMemberByOrg" resultType="io.metersphere.system.dto.user.UserExtendDTO">
|
<select id="getMemberByOrg" resultType="io.metersphere.system.dto.user.UserExtendDTO">
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
or u.phone like concat('%', #{request.keyword}, '%')
|
or u.phone like concat('%', #{request.keyword}, '%')
|
||||||
)
|
)
|
||||||
</if>
|
</if>
|
||||||
|
order by urr.create_time desc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getProjectUserList" resultType="io.metersphere.system.domain.User">
|
<select id="getProjectUserList" resultType="io.metersphere.system.domain.User">
|
||||||
|
|
|
@ -71,6 +71,7 @@ public class ProjectMemberService {
|
||||||
UserRoleRelationExample relationExample = new UserRoleRelationExample();
|
UserRoleRelationExample relationExample = new UserRoleRelationExample();
|
||||||
relationExample.createCriteria().andSourceIdEqualTo(request.getProjectId()).andUserIdIn(members);
|
relationExample.createCriteria().andSourceIdEqualTo(request.getProjectId()).andUserIdIn(members);
|
||||||
List<UserRoleRelation> userRoleRelates = userRoleRelationMapper.selectByExample(relationExample);
|
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,
|
Map<String, List<String>> userRoleRelateMap = userRoleRelates.stream().collect(Collectors.groupingBy(UserRoleRelation::getUserId,
|
||||||
Collectors.mapping(UserRoleRelation::getRoleId, Collectors.toList())));
|
Collectors.mapping(UserRoleRelation::getRoleId, Collectors.toList())));
|
||||||
// 查询所有项目类型用户组
|
// 查询所有项目类型用户组
|
||||||
|
@ -100,7 +101,6 @@ public class ProjectMemberService {
|
||||||
User user = userMap.get(projectUser.getId());
|
User user = userMap.get(projectUser.getId());
|
||||||
BeanUtils.copyBean(projectUser, user);
|
BeanUtils.copyBean(projectUser, user);
|
||||||
});
|
});
|
||||||
projectUsers.sort(Comparator.comparing(ProjectUserDTO::getName));
|
|
||||||
return projectUsers;
|
return projectUsers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -121,8 +121,7 @@ public class OrganizationProjectController {
|
||||||
@RequiresPermissions(PermissionConstants.ORGANIZATION_PROJECT_READ)
|
@RequiresPermissions(PermissionConstants.ORGANIZATION_PROJECT_READ)
|
||||||
@Operation(summary = "系统设置-组织-项目-成员列表")
|
@Operation(summary = "系统设置-组织-项目-成员列表")
|
||||||
public Pager<List<UserExtendDTO>> getProjectMember(@Validated @RequestBody ProjectMemberRequest request) {
|
public Pager<List<UserExtendDTO>> getProjectMember(@Validated @RequestBody ProjectMemberRequest request) {
|
||||||
Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize(),
|
Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize());
|
||||||
StringUtils.isNotBlank(request.getSortString()) ? request.getSortString() : "create_time desc");
|
|
||||||
return PageUtils.setPageInfo(page, organizationProjectService.getProjectMember(request));
|
return PageUtils.setPageInfo(page, organizationProjectService.getProjectMember(request));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -126,8 +126,7 @@ public class SystemProjectController {
|
||||||
@Operation(summary = "系统设置-系统-组织与项目-项目-成员列表")
|
@Operation(summary = "系统设置-系统-组织与项目-项目-成员列表")
|
||||||
@CheckOwner(resourceId = "#request.projectId", resourceType = "project")
|
@CheckOwner(resourceId = "#request.projectId", resourceType = "project")
|
||||||
public Pager<List<UserExtendDTO>> getProjectMember(@Validated @RequestBody ProjectMemberRequest request) {
|
public Pager<List<UserExtendDTO>> getProjectMember(@Validated @RequestBody ProjectMemberRequest request) {
|
||||||
Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize(),
|
Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize());
|
||||||
StringUtils.isNotBlank(request.getSortString()) ? request.getSortString() : "create_time desc");
|
|
||||||
return PageUtils.setPageInfo(page, systemProjectService.getProjectMember(request));
|
return PageUtils.setPageInfo(page, systemProjectService.getProjectMember(request));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,9 +57,9 @@
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
<select id="listMember" resultType="io.metersphere.system.dto.user.UserExtendDTO">
|
<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 (
|
from (
|
||||||
select u.*, urr.role_id
|
select u.*, urr.role_id, urr.create_time as memberTime
|
||||||
from user_role_relation urr
|
from user_role_relation urr
|
||||||
join `user` u on urr.user_id = u.id
|
join `user` u on urr.user_id = u.id
|
||||||
<where>
|
<where>
|
||||||
|
@ -71,10 +71,10 @@
|
||||||
and u.name like concat('%', #{request.keyword},'%')
|
and u.name like concat('%', #{request.keyword},'%')
|
||||||
</if>
|
</if>
|
||||||
</where>
|
</where>
|
||||||
order by u.update_time desc
|
order by urr.create_time desc
|
||||||
) temp
|
) temp
|
||||||
group by temp.id
|
group by temp.id
|
||||||
order by adminFlag desc
|
order by adminFlag desc, groupTime desc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="listMemberByOrg" resultType="io.metersphere.system.dto.OrgUserExtend">
|
<select id="listMemberByOrg" resultType="io.metersphere.system.dto.OrgUserExtend">
|
||||||
|
|
|
@ -4,9 +4,9 @@
|
||||||
|
|
||||||
|
|
||||||
<select id="getProjectMemberList" resultType="io.metersphere.system.dto.user.UserExtendDTO">
|
<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 (
|
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
|
FROM user_role_relation
|
||||||
LEFT JOIN `user` ON user_role_relation.user_id = `user`.id
|
LEFT JOIN `user` ON user_role_relation.user_id = `user`.id
|
||||||
<where>
|
<where>
|
||||||
|
@ -20,7 +20,7 @@
|
||||||
or user.phone like CONCAT('%', #{request.keyword},'%'))
|
or user.phone like CONCAT('%', #{request.keyword},'%'))
|
||||||
</if>
|
</if>
|
||||||
</where>
|
</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>
|
||||||
<select id="getProjectList" resultType="io.metersphere.system.dto.ProjectDTO">
|
<select id="getProjectList" resultType="io.metersphere.system.dto.ProjectDTO">
|
||||||
select p.id,
|
select p.id,
|
||||||
|
|
|
@ -25,5 +25,6 @@
|
||||||
or u.phone like concat('%', #{request.keyword}, '%')
|
or u.phone like concat('%', #{request.keyword}, '%')
|
||||||
)
|
)
|
||||||
</if>
|
</if>
|
||||||
|
order by urr.create_time desc
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
|
@ -35,5 +35,6 @@
|
||||||
or u.email like concat('%', #{request.keyword},'%')
|
or u.email like concat('%', #{request.keyword},'%')
|
||||||
)
|
)
|
||||||
</if>
|
</if>
|
||||||
|
order by urr.create_time desc
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
Loading…
Reference in New Issue