mirror of
https://gitee.com/fit2cloud-feizhiyun/MeterSphere.git
synced 2024-12-05 05:29:29 +08:00
refactor(系统设置): 优化查询项目列表的逻辑
This commit is contained in:
parent
d918d86edf
commit
f3e8fc208b
@ -12,7 +12,7 @@ import java.io.Serializable;
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class UserExtend extends User implements Serializable {
|
||||
public class UserExtendDTO extends User implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
@ -10,10 +10,10 @@ import io.metersphere.project.request.ProjectMemberRequest;
|
||||
import io.metersphere.project.service.ProjectMemberService;
|
||||
import io.metersphere.sdk.constants.PermissionConstants;
|
||||
import io.metersphere.sdk.dto.OptionDTO;
|
||||
import io.metersphere.sdk.dto.UserExtendDTO;
|
||||
import io.metersphere.sdk.util.PageUtils;
|
||||
import io.metersphere.sdk.util.Pager;
|
||||
import io.metersphere.system.utils.SessionUtils;
|
||||
import io.metersphere.sdk.dto.UserExtend;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
@ -48,8 +48,8 @@ public class ProjectMemberController {
|
||||
@GetMapping("/get-member/option/{projectId}")
|
||||
@Operation(summary = "项目管理-成员-获取成员下拉选项")
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_USER_READ)
|
||||
public List<UserExtend> getMemberOption(@PathVariable String projectId,
|
||||
@Schema(description = "查询关键字,根据邮箱和用户名查询")
|
||||
public List<UserExtendDTO> getMemberOption(@PathVariable String projectId,
|
||||
@Schema(description = "查询关键字,根据邮箱和用户名查询")
|
||||
@RequestParam(value = "keyword", required = false) String keyword) {
|
||||
return projectMemberService.getMemberOption(projectId, keyword);
|
||||
}
|
||||
|
@ -11,17 +11,17 @@ import io.metersphere.project.service.ProjectUserRoleLogService;
|
||||
import io.metersphere.project.service.ProjectUserRoleService;
|
||||
import io.metersphere.sdk.constants.PermissionConstants;
|
||||
import io.metersphere.sdk.dto.PermissionDefinitionItem;
|
||||
import io.metersphere.sdk.dto.UserExtend;
|
||||
import io.metersphere.sdk.dto.UserExtendDTO;
|
||||
import io.metersphere.sdk.dto.request.PermissionSettingUpdateRequest;
|
||||
import io.metersphere.system.log.annotation.Log;
|
||||
import io.metersphere.system.log.constants.OperationLogType;
|
||||
import io.metersphere.sdk.util.BeanUtils;
|
||||
import io.metersphere.sdk.util.PageUtils;
|
||||
import io.metersphere.sdk.util.Pager;
|
||||
import io.metersphere.system.utils.SessionUtils;
|
||||
import io.metersphere.system.domain.User;
|
||||
import io.metersphere.system.domain.UserRole;
|
||||
import io.metersphere.system.log.annotation.Log;
|
||||
import io.metersphere.system.log.constants.OperationLogType;
|
||||
import io.metersphere.system.service.UserRoleService;
|
||||
import io.metersphere.system.utils.SessionUtils;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
@ -106,9 +106,9 @@ public class ProjectUserRoleController {
|
||||
@Parameter(name = "projectId", description = "当前项目ID", schema = @Schema(requiredMode = Schema.RequiredMode.REQUIRED)),
|
||||
@Parameter(name = "roleId", description = "用户组ID", schema = @Schema(requiredMode = Schema.RequiredMode.REQUIRED))
|
||||
})
|
||||
public List<UserExtend> getMember(@PathVariable String projectId,
|
||||
@PathVariable String roleId,
|
||||
@Schema(description = "查询关键字,根据邮箱和用户名查询")
|
||||
public List<UserExtendDTO> getMember(@PathVariable String projectId,
|
||||
@PathVariable String roleId,
|
||||
@Schema(description = "查询关键字,根据邮箱和用户名查询")
|
||||
@RequestParam(required = false) String keyword) {
|
||||
return userRoleService.getMember(projectId, roleId, keyword);
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ public class CommonParams implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Schema(description = "链接超时时间")
|
||||
private Long requestTimeout;
|
||||
private Long requestTimeout = 600000L;
|
||||
@Schema(description = "响应超时时间")
|
||||
private Long responseTimeout;
|
||||
private Long responseTimeout = 600000L;
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ public class ScriptContent {
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class ScenarioPostScript extends ScriptContent {
|
||||
public static class ScenarioScript extends ScriptContent {
|
||||
|
||||
@Schema(description = "关联场景结果 true: 是/false: 否")
|
||||
private Boolean associateScenarioResults = false;
|
||||
@ -28,12 +28,11 @@ public class ScriptContent {
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class StepPostScript extends ScriptContent {
|
||||
|
||||
public static class StepScript extends ScriptContent {
|
||||
@Schema(description = "忽略请求")
|
||||
private List<String> filterRequestPostScript;
|
||||
private List<String> filterRequestScript;
|
||||
@Schema(description = "脚本执行顺序 true:先执行 false:后执行")
|
||||
private Boolean preScriptExecBefore = true;
|
||||
private Boolean scriptExecBefore = true;
|
||||
@Schema(description = "脚本内容")
|
||||
private ScriptContent scriptContent;
|
||||
|
||||
@ -42,10 +41,10 @@ public class ScriptContent {
|
||||
@Data
|
||||
public static class ApiScript {
|
||||
@Schema(description = "测试计划级")
|
||||
private ScriptContent envJSR223PostScript;
|
||||
private ScriptContent envJSR223Script;
|
||||
@Schema(description = "场景级")
|
||||
private ScenarioPostScript scenarioJSR223PostScript;
|
||||
@Schema(description = "步骤级")
|
||||
private StepPostScript stepJSR223PostScript;
|
||||
private ScenarioScript scenarioJSR223Script;
|
||||
@Schema(description = "步骤级 ")
|
||||
private List<StepScript> stepJSR223Script;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package io.metersphere.project.mapper;
|
||||
|
||||
import io.metersphere.project.request.ProjectMemberRequest;
|
||||
import io.metersphere.sdk.dto.UserExtend;
|
||||
import io.metersphere.sdk.dto.UserExtendDTO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
@ -25,5 +25,5 @@ public interface ExtProjectMemberMapper {
|
||||
* @param keyword 搜索关键字
|
||||
* @return 成员
|
||||
*/
|
||||
List<UserExtend> getMemberByOrg(@Param("organizationId") String organizationId, @Param("keyword") String keyword);
|
||||
List<UserExtendDTO> getMemberByOrg(@Param("organizationId") String organizationId, @Param("keyword") String keyword);
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
order by u.name
|
||||
</select>
|
||||
|
||||
<select id="getMemberByOrg" resultType="io.metersphere.sdk.dto.UserExtend">
|
||||
<select id="getMemberByOrg" resultType="io.metersphere.sdk.dto.UserExtendDTO">
|
||||
select distinct u.* from user_role_relation urr join `user` u on urr.user_id = u.id
|
||||
where
|
||||
u.deleted = 0
|
||||
|
@ -13,7 +13,7 @@ import io.metersphere.sdk.constants.UserRoleEnum;
|
||||
import io.metersphere.sdk.constants.UserRoleType;
|
||||
import io.metersphere.sdk.dto.LogDTO;
|
||||
import io.metersphere.sdk.dto.OptionDTO;
|
||||
import io.metersphere.sdk.dto.UserExtend;
|
||||
import io.metersphere.sdk.dto.UserExtendDTO;
|
||||
import io.metersphere.sdk.exception.MSException;
|
||||
import io.metersphere.sdk.util.BeanUtils;
|
||||
import io.metersphere.sdk.util.JSON;
|
||||
@ -109,18 +109,18 @@ public class ProjectMemberService {
|
||||
* @param projectId 项目ID
|
||||
* @return 项目成员下拉选项
|
||||
*/
|
||||
public List<UserExtend> getMemberOption(String projectId, String keyword) {
|
||||
public List<UserExtendDTO> getMemberOption(String projectId, String keyword) {
|
||||
Project project = projectMapper.selectByPrimaryKey(projectId);
|
||||
if (project == null) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
// 组织成员
|
||||
List<UserExtend> orgMembers = extProjectMemberMapper.getMemberByOrg(project.getOrganizationId(), keyword);
|
||||
List<UserExtendDTO> orgMembers = extProjectMemberMapper.getMemberByOrg(project.getOrganizationId(), keyword);
|
||||
if (CollectionUtils.isEmpty(orgMembers)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
// 设置是否是项目成员
|
||||
List<String> orgMemberIds = orgMembers.stream().map(UserExtend::getId).toList();
|
||||
List<String> orgMemberIds = orgMembers.stream().map(UserExtendDTO::getId).toList();
|
||||
UserRoleRelationExample example = new UserRoleRelationExample();
|
||||
example.createCriteria().andUserIdIn(orgMemberIds).andSourceIdEqualTo(projectId).andOrganizationIdEqualTo(project.getOrganizationId());
|
||||
List<UserRoleRelation> projectRelations = userRoleRelationMapper.selectByExample(example);
|
||||
|
@ -324,16 +324,16 @@ public class EnvironmentControllerTests extends BaseTest {
|
||||
ScriptContent.ApiScript apiScript = new ScriptContent.ApiScript();
|
||||
ScriptContent scriptContent = new ScriptContent();
|
||||
scriptContent.setScript("script");
|
||||
apiScript.setEnvJSR223PostScript(scriptContent);
|
||||
ScriptContent.ScenarioPostScript scenarioPostScript = new ScriptContent.ScenarioPostScript();
|
||||
scenarioPostScript.setAssociateScenarioResults(true);
|
||||
scenarioPostScript.setScript("scenarioPostScript");
|
||||
apiScript.setScenarioJSR223PostScript(scenarioPostScript);
|
||||
ScriptContent.StepPostScript stepPostScript = new ScriptContent.StepPostScript();
|
||||
stepPostScript.setPreScriptExecBefore(true);
|
||||
apiScript.setEnvJSR223Script(scriptContent);
|
||||
ScriptContent.ScenarioScript scenarioScript = new ScriptContent.ScenarioScript();
|
||||
scenarioScript.setAssociateScenarioResults(true);
|
||||
scenarioScript.setScript("scenarioPostScript");
|
||||
apiScript.setScenarioJSR223Script(scenarioScript);
|
||||
ScriptContent.StepScript stepPostScript = new ScriptContent.StepScript();
|
||||
stepPostScript.setScriptExecBefore(true);
|
||||
stepPostScript.setScriptContent(scriptContent);
|
||||
stepPostScript.setFilterRequestPostScript(new ArrayList<>());
|
||||
apiScript.setStepJSR223PostScript(stepPostScript);
|
||||
stepPostScript.setFilterRequestScript(new ArrayList<>());
|
||||
apiScript.setStepJSR223Script(List.of(stepPostScript));
|
||||
return apiScript;
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@ import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import io.metersphere.sdk.constants.PermissionConstants;
|
||||
import io.metersphere.sdk.dto.OptionDTO;
|
||||
import io.metersphere.sdk.dto.UserExtend;
|
||||
import io.metersphere.sdk.dto.UserExtendDTO;
|
||||
import io.metersphere.sdk.util.PageUtils;
|
||||
import io.metersphere.sdk.util.Pager;
|
||||
import io.metersphere.system.dto.AddProjectRequest;
|
||||
@ -116,7 +116,7 @@ public class OrganizationProjectController {
|
||||
@PostMapping("/member-list")
|
||||
@RequiresPermissions(PermissionConstants.ORGANIZATION_PROJECT_READ)
|
||||
@Operation(summary = "系统设置-组织-项目-成员列表")
|
||||
public Pager<List<UserExtend>> getProjectMember(@Validated @RequestBody ProjectMemberRequest request) {
|
||||
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");
|
||||
return PageUtils.setPageInfo(page, organizationProjectService.getProjectMember(request));
|
||||
@ -145,7 +145,7 @@ public class OrganizationProjectController {
|
||||
@GetMapping("/user-admin-list/{organizationId}")
|
||||
@Operation(summary = "系统设置-组织-项目-获取管理员列表")
|
||||
@RequiresPermissions(PermissionConstants.ORGANIZATION_PROJECT_READ)
|
||||
public List<UserExtend> getUserAdminList(@PathVariable String organizationId, @Schema(description = "查询关键字,根据邮箱和用户名查询")
|
||||
public List<UserExtendDTO> getUserAdminList(@PathVariable String organizationId, @Schema(description = "查询关键字,根据邮箱和用户名查询")
|
||||
@RequestParam(value = "keyword", required = false) String keyword) {
|
||||
return organizationProjectService.getUserAdminList(organizationId, keyword);
|
||||
}
|
||||
@ -153,8 +153,8 @@ public class OrganizationProjectController {
|
||||
@GetMapping("/user-member-list/{organizationId}/{projectId}")
|
||||
@Operation(summary = "系统设置-组织-项目-获取成员列表")
|
||||
@RequiresPermissions(PermissionConstants.ORGANIZATION_PROJECT_READ)
|
||||
public List<UserExtend> getUserMemberList(@PathVariable String organizationId, @PathVariable String projectId,
|
||||
@Schema(description = "查询关键字,根据邮箱和用户名查询")
|
||||
public List<UserExtendDTO> getUserMemberList(@PathVariable String organizationId, @PathVariable String projectId,
|
||||
@Schema(description = "查询关键字,根据邮箱和用户名查询")
|
||||
@RequestParam(value = "keyword", required = false) String keyword) {
|
||||
return organizationProjectService.getUserMemberList(organizationId, projectId, keyword);
|
||||
}
|
||||
|
@ -4,22 +4,22 @@ import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import io.metersphere.sdk.constants.PermissionConstants;
|
||||
import io.metersphere.sdk.dto.PermissionDefinitionItem;
|
||||
import io.metersphere.sdk.dto.UserExtend;
|
||||
import io.metersphere.sdk.dto.UserExtendDTO;
|
||||
import io.metersphere.sdk.dto.request.PermissionSettingUpdateRequest;
|
||||
import io.metersphere.system.log.annotation.Log;
|
||||
import io.metersphere.system.log.constants.OperationLogType;
|
||||
import io.metersphere.sdk.util.BeanUtils;
|
||||
import io.metersphere.sdk.util.PageUtils;
|
||||
import io.metersphere.sdk.util.Pager;
|
||||
import io.metersphere.system.utils.SessionUtils;
|
||||
import io.metersphere.system.domain.User;
|
||||
import io.metersphere.system.domain.UserRole;
|
||||
import io.metersphere.system.log.annotation.Log;
|
||||
import io.metersphere.system.log.constants.OperationLogType;
|
||||
import io.metersphere.system.request.OrganizationUserRoleEditRequest;
|
||||
import io.metersphere.system.request.OrganizationUserRoleMemberEditRequest;
|
||||
import io.metersphere.system.request.OrganizationUserRoleMemberRequest;
|
||||
import io.metersphere.system.service.OrganizationUserRoleLogService;
|
||||
import io.metersphere.system.service.OrganizationUserRoleService;
|
||||
import io.metersphere.system.service.UserRoleService;
|
||||
import io.metersphere.system.utils.SessionUtils;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
@ -106,9 +106,9 @@ public class OrganizationUserRoleController {
|
||||
@Parameter(name = "organizationId", description = "组织ID", schema = @Schema(requiredMode = Schema.RequiredMode.REQUIRED)),
|
||||
@Parameter(name = "roleId", description = "用户组ID", schema = @Schema(requiredMode = Schema.RequiredMode.REQUIRED))
|
||||
})
|
||||
public List<UserExtend> getMember(@PathVariable String organizationId,
|
||||
@PathVariable String roleId,
|
||||
@Schema(description = "查询关键字,根据邮箱和用户名查询")
|
||||
public List<UserExtendDTO> getMember(@PathVariable String organizationId,
|
||||
@PathVariable String roleId,
|
||||
@Schema(description = "查询关键字,根据邮箱和用户名查询")
|
||||
@RequestParam(required = false) String keyword) {
|
||||
return userRoleService.getMember(organizationId, roleId, keyword);
|
||||
}
|
||||
|
@ -4,13 +4,12 @@ import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import io.metersphere.sdk.constants.PermissionConstants;
|
||||
import io.metersphere.sdk.dto.OptionDTO;
|
||||
import io.metersphere.system.dto.ProjectDTO;
|
||||
import io.metersphere.sdk.dto.UserExtendDTO;
|
||||
import io.metersphere.sdk.util.BeanUtils;
|
||||
import io.metersphere.sdk.util.PageUtils;
|
||||
import io.metersphere.sdk.util.Pager;
|
||||
import io.metersphere.system.utils.SessionUtils;
|
||||
import io.metersphere.system.dto.OrganizationDTO;
|
||||
import io.metersphere.sdk.dto.UserExtend;
|
||||
import io.metersphere.system.dto.ProjectDTO;
|
||||
import io.metersphere.system.request.OrganizationMemberRequest;
|
||||
import io.metersphere.system.request.OrganizationProjectRequest;
|
||||
import io.metersphere.system.request.OrganizationRequest;
|
||||
@ -18,6 +17,7 @@ import io.metersphere.system.request.ProjectRequest;
|
||||
import io.metersphere.system.service.OrganizationService;
|
||||
import io.metersphere.system.service.SystemProjectService;
|
||||
import io.metersphere.system.service.UserService;
|
||||
import io.metersphere.system.utils.SessionUtils;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
@ -66,7 +66,7 @@ public class SystemOrganizationController {
|
||||
@PostMapping("/list-member")
|
||||
@Operation(summary = "系统设置-系统-组织与项目-组织-获取组织成员列表")
|
||||
@RequiresPermissions(value = {PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_READ, PermissionConstants.SYSTEM_USER_READ})
|
||||
public Pager<List<UserExtend>> listMember(@Validated @RequestBody OrganizationRequest request) {
|
||||
public Pager<List<UserExtendDTO>> listMember(@Validated @RequestBody OrganizationRequest request) {
|
||||
Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize(), true);
|
||||
return PageUtils.setPageInfo(page, organizationService.getMemberListBySystem(request));
|
||||
}
|
||||
@ -118,8 +118,8 @@ public class SystemOrganizationController {
|
||||
@Operation(summary = "系统设置-系统-组织与项目-获取成员下拉选项")
|
||||
@RequiresPermissions(value = {PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_READ})
|
||||
@Parameter(name = "sourceId", description = "组织ID或项目ID", schema = @Schema(requiredMode = Schema.RequiredMode.REQUIRED))
|
||||
public List<UserExtend> getMemberOption(@PathVariable String sourceId,
|
||||
@Schema(description = "查询关键字,根据邮箱和用户名查询")
|
||||
public List<UserExtendDTO> getMemberOption(@PathVariable String sourceId,
|
||||
@Schema(description = "查询关键字,根据邮箱和用户名查询")
|
||||
@RequestParam(value = "keyword", required = false) String keyword) {
|
||||
return userService.getMemberOption(sourceId, keyword);
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import io.metersphere.sdk.constants.PermissionConstants;
|
||||
import io.metersphere.sdk.dto.OptionDTO;
|
||||
import io.metersphere.sdk.dto.UserExtend;
|
||||
import io.metersphere.sdk.dto.UserExtendDTO;
|
||||
import io.metersphere.sdk.util.PageUtils;
|
||||
import io.metersphere.sdk.util.Pager;
|
||||
import io.metersphere.system.domain.User;
|
||||
@ -120,7 +120,7 @@ public class SystemProjectController {
|
||||
@PostMapping("/member-list")
|
||||
@RequiresPermissions(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_READ)
|
||||
@Operation(summary = "系统设置-系统-组织与项目-项目-成员列表")
|
||||
public Pager<List<UserExtend>> getProjectMember(@Validated @RequestBody ProjectMemberRequest request) {
|
||||
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");
|
||||
return PageUtils.setPageInfo(page, systemProjectService.getProjectMember(request));
|
||||
|
@ -1,7 +1,7 @@
|
||||
package io.metersphere.system.dto;
|
||||
|
||||
import io.metersphere.project.domain.Project;
|
||||
import io.metersphere.sdk.dto.UserExtend;
|
||||
import io.metersphere.sdk.dto.UserExtendDTO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
@ -17,7 +17,7 @@ public class ProjectDTO extends Project implements Serializable {
|
||||
@Schema(description = "所属组织", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
|
||||
private String organizationName;
|
||||
@Schema(description = "管理员", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
|
||||
private List<UserExtend> adminList;
|
||||
private List<UserExtendDTO> adminList;
|
||||
@Schema(description = "创建人是否是管理员", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
|
||||
private Boolean projectCreateUserIsAdmin;
|
||||
@Schema(description = "模块设置", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
|
||||
|
@ -1,7 +1,7 @@
|
||||
package io.metersphere.system.mapper;
|
||||
|
||||
import io.metersphere.sdk.dto.OptionDTO;
|
||||
import io.metersphere.sdk.dto.UserExtend;
|
||||
import io.metersphere.sdk.dto.UserExtendDTO;
|
||||
import io.metersphere.system.domain.User;
|
||||
import io.metersphere.system.dto.*;
|
||||
import io.metersphere.system.request.OrganizationDeleteRequest;
|
||||
@ -66,7 +66,7 @@ public interface ExtOrganizationMapper {
|
||||
* @param request 组织成员列表请求参数
|
||||
* @return 组织成员列表数据
|
||||
*/
|
||||
List<UserExtend> listMember(@Param("request") OrganizationRequest request);
|
||||
List<UserExtendDTO> listMember(@Param("request") OrganizationRequest request);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -56,7 +56,7 @@
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<select id="listMember" resultType="io.metersphere.sdk.dto.UserExtend">
|
||||
<select id="listMember" resultType="io.metersphere.sdk.dto.UserExtendDTO">
|
||||
select temp.*, max(if(temp.role_id = 'org_admin', true, false)) as adminFlag
|
||||
from (
|
||||
select u.*, urr.role_id
|
||||
|
@ -1,9 +1,9 @@
|
||||
package io.metersphere.system.mapper;
|
||||
|
||||
import io.metersphere.sdk.dto.UserExtendDTO;
|
||||
import io.metersphere.system.dto.OrganizationProjectOptionsDTO;
|
||||
import io.metersphere.system.dto.ProjectDTO;
|
||||
import io.metersphere.system.dto.ProjectResourcePoolDTO;
|
||||
import io.metersphere.sdk.dto.UserExtend;
|
||||
import io.metersphere.system.dto.OrganizationProjectOptionsDTO;
|
||||
import io.metersphere.system.request.ProjectMemberRequest;
|
||||
import io.metersphere.system.request.ProjectRequest;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
@ -12,17 +12,17 @@ import java.util.List;
|
||||
|
||||
public interface ExtSystemProjectMapper {
|
||||
|
||||
List<UserExtend> getProjectMemberList(@Param("request") ProjectMemberRequest request);
|
||||
List<UserExtendDTO> getProjectMemberList(@Param("request") ProjectMemberRequest request);
|
||||
|
||||
List<ProjectDTO> getProjectList(@Param("request") ProjectRequest request);
|
||||
|
||||
List<UserExtend> getProjectAdminList(@Param("projectIds") List<String> projectIds);
|
||||
List<UserExtendDTO> getProjectAdminList(@Param("projectIds") List<String> projectIds);
|
||||
|
||||
List<OrganizationProjectOptionsDTO> selectProjectOptions(@Param("organizationId") String organizationId);
|
||||
|
||||
List<UserExtend> getUserAdminList(@Param("organizationId") String organizationId, @Param("keyword") String keyword);
|
||||
List<UserExtendDTO> getUserAdminList(@Param("organizationId") String organizationId, @Param("keyword") String keyword);
|
||||
|
||||
List<UserExtend> getUserMemberList(@Param("userIds") List<String> userIds, @Param("projectId") String projectId, @Param("keyword") String keyword);
|
||||
List<UserExtendDTO> getUserMemberList(@Param("userIds") List<String> userIds, @Param("projectId") String projectId, @Param("keyword") String keyword);
|
||||
|
||||
List<ProjectDTO> getProjectExtendDTOList(@Param("projectIds") List<String> projectIds);
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
<mapper namespace="io.metersphere.system.mapper.ExtSystemProjectMapper">
|
||||
|
||||
|
||||
<select id="getProjectMemberList" resultType="io.metersphere.sdk.dto.UserExtend">
|
||||
<select id="getProjectMemberList" resultType="io.metersphere.sdk.dto.UserExtendDTO">
|
||||
SELECT temp.* , MAX( if (temp.role_id = 'project_admin', true, false)) as adminFlag
|
||||
FROM (
|
||||
SELECT `user`.* , user_role_relation.role_id
|
||||
@ -42,7 +42,7 @@
|
||||
INNER JOIN organization o on p.organization_id = o.id
|
||||
<include refid="queryWhereCondition"/>
|
||||
</select>
|
||||
<select id="getProjectAdminList" resultType="io.metersphere.sdk.dto.UserExtend">
|
||||
<select id="getProjectAdminList" resultType="io.metersphere.sdk.dto.UserExtendDTO">
|
||||
SELECT `user`.*, user_role_relation.source_id
|
||||
FROM user_role_relation
|
||||
LEFT JOIN `user` ON user_role_relation.user_id = `user`.id
|
||||
@ -114,7 +114,7 @@
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
<select id="getUserAdminList" resultType="io.metersphere.sdk.dto.UserExtend">
|
||||
<select id="getUserAdminList" resultType="io.metersphere.sdk.dto.UserExtendDTO">
|
||||
select distinct
|
||||
u.id,
|
||||
u.NAME,
|
||||
@ -129,7 +129,7 @@
|
||||
|
||||
</select>
|
||||
|
||||
<select id="getUserMemberList" resultType="io.metersphere.sdk.dto.UserExtend">
|
||||
<select id="getUserMemberList" resultType="io.metersphere.sdk.dto.UserExtendDTO">
|
||||
select distinct u.id,
|
||||
u.NAME,
|
||||
u.email, count(temp.id) > 0 as memberFlag from
|
||||
|
@ -1,6 +1,6 @@
|
||||
package io.metersphere.system.mapper;
|
||||
|
||||
import io.metersphere.sdk.dto.UserExtend;
|
||||
import io.metersphere.sdk.dto.UserExtendDTO;
|
||||
import io.metersphere.system.domain.User;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
@ -8,7 +8,7 @@ import java.util.List;
|
||||
|
||||
public interface ExtUserMapper {
|
||||
|
||||
List<UserExtend> getMemberOption(@Param("sourceId") String sourceId, @Param("keyword") String keyword);
|
||||
List<UserExtendDTO> getMemberOption(@Param("sourceId") String sourceId, @Param("keyword") String keyword);
|
||||
|
||||
List<User> getUserListByOrgId(@Param("sourceId") String sourceId, @Param("keyword") String keyword);
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="io.metersphere.system.mapper.ExtUserMapper">
|
||||
<select id="getMemberOption" resultType="io.metersphere.sdk.dto.UserExtend">
|
||||
<select id="getMemberOption" resultType="io.metersphere.sdk.dto.UserExtendDTO">
|
||||
select distinct u.*, count(urr.id) > 0 as memberFlag
|
||||
from `user` u left join user_role_relation urr on urr.user_id = u.id and urr.source_id = #{sourceId}
|
||||
where u.deleted = 0
|
||||
|
@ -12,7 +12,7 @@ import io.metersphere.sdk.constants.OperationLogConstants;
|
||||
import io.metersphere.sdk.constants.UserRoleType;
|
||||
import io.metersphere.sdk.dto.LogDTO;
|
||||
import io.metersphere.sdk.dto.OptionDTO;
|
||||
import io.metersphere.sdk.dto.UserExtend;
|
||||
import io.metersphere.sdk.dto.UserExtendDTO;
|
||||
import io.metersphere.sdk.exception.MSException;
|
||||
import io.metersphere.sdk.util.BeanUtils;
|
||||
import io.metersphere.sdk.util.JSON;
|
||||
@ -210,49 +210,51 @@ public class CommonProjectService {
|
||||
public List<ProjectDTO> buildUserInfo(List<ProjectDTO> projectList) {
|
||||
//取项目的创建人 修改人 删除人到一个list中
|
||||
List<String> userIds = new ArrayList<>();
|
||||
userIds.addAll(projectList.stream().map(ProjectDTO::getCreateUser).toList());
|
||||
userIds.addAll(projectList.stream().map(ProjectDTO::getUpdateUser).toList());
|
||||
userIds.addAll(projectList.stream().map(ProjectDTO::getDeleteUser).toList());
|
||||
Map<String, String> userMap = userLoginService.getUserNameMap(userIds.stream().filter(StringUtils::isNotBlank).distinct().toList());
|
||||
// 获取项目id
|
||||
List<String> projectIds = projectList.stream().map(ProjectDTO::getId).toList();
|
||||
List<UserExtend> users = extSystemProjectMapper.getProjectAdminList(projectIds);
|
||||
List<ProjectDTO> projectDTOList = extSystemProjectMapper.getProjectExtendDTOList(projectIds);
|
||||
Map<String, ProjectDTO> projectMap = projectDTOList.stream().collect(Collectors.toMap(ProjectDTO::getId, projectDTO -> projectDTO));
|
||||
//根据sourceId分组
|
||||
Map<String, List<UserExtend>> userMapList = users.stream().collect(Collectors.groupingBy(UserExtend::getSourceId));
|
||||
//获取资源池
|
||||
List<ProjectResourcePoolDTO> projectResourcePoolDTOList = extSystemProjectMapper.getProjectResourcePoolDTOList(projectIds);
|
||||
//根据projectId分组 key为项目id 值为资源池TestResourcePool
|
||||
Map<String, List<ProjectResourcePoolDTO>> poolMap = projectResourcePoolDTOList.stream().collect(Collectors.groupingBy(ProjectResourcePoolDTO::getProjectId));
|
||||
if (CollectionUtils.isNotEmpty(projectList)) {
|
||||
userIds.addAll(projectList.stream().map(ProjectDTO::getCreateUser).toList());
|
||||
userIds.addAll(projectList.stream().map(ProjectDTO::getUpdateUser).toList());
|
||||
userIds.addAll(projectList.stream().map(ProjectDTO::getDeleteUser).toList());
|
||||
Map<String, String> userMap = userLoginService.getUserNameMap(userIds.stream().filter(StringUtils::isNotBlank).distinct().toList());
|
||||
// 获取项目id
|
||||
List<String> projectIds = projectList.stream().map(ProjectDTO::getId).toList();
|
||||
List<UserExtendDTO> users = extSystemProjectMapper.getProjectAdminList(projectIds);
|
||||
List<ProjectDTO> projectDTOList = extSystemProjectMapper.getProjectExtendDTOList(projectIds);
|
||||
Map<String, ProjectDTO> projectMap = projectDTOList.stream().collect(Collectors.toMap(ProjectDTO::getId, projectDTO -> projectDTO));
|
||||
//根据sourceId分组
|
||||
Map<String, List<UserExtendDTO>> userMapList = users.stream().collect(Collectors.groupingBy(UserExtendDTO::getSourceId));
|
||||
//获取资源池
|
||||
List<ProjectResourcePoolDTO> projectResourcePoolDTOList = extSystemProjectMapper.getProjectResourcePoolDTOList(projectIds);
|
||||
//根据projectId分组 key为项目id 值为资源池TestResourcePool
|
||||
Map<String, List<ProjectResourcePoolDTO>> poolMap = projectResourcePoolDTOList.stream().collect(Collectors.groupingBy(ProjectResourcePoolDTO::getProjectId));
|
||||
|
||||
projectList.forEach(projectDTO -> {
|
||||
if (StringUtils.isNotBlank(projectDTO.getModuleSetting())) {
|
||||
projectDTO.setModuleIds(JSON.parseArray(projectDTO.getModuleSetting(), String.class));
|
||||
}
|
||||
projectDTO.setMemberCount(projectMap.get(projectDTO.getId()).getMemberCount());
|
||||
List<UserExtend> userExtends = userMapList.get(projectDTO.getId());
|
||||
if (CollectionUtils.isNotEmpty(userExtends)) {
|
||||
projectDTO.setAdminList(userExtends);
|
||||
List<String> userIdList = userExtends.stream().map(User::getId).collect(Collectors.toList());
|
||||
if (CollectionUtils.isNotEmpty(userIdList) && userIdList.contains(projectDTO.getCreateUser())) {
|
||||
projectDTO.setProjectCreateUserIsAdmin(true);
|
||||
} else {
|
||||
projectDTO.setProjectCreateUserIsAdmin(false);
|
||||
projectList.forEach(projectDTO -> {
|
||||
if (StringUtils.isNotBlank(projectDTO.getModuleSetting())) {
|
||||
projectDTO.setModuleIds(JSON.parseArray(projectDTO.getModuleSetting(), String.class));
|
||||
}
|
||||
} else {
|
||||
projectDTO.setAdminList(new ArrayList<>());
|
||||
}
|
||||
List<ProjectResourcePoolDTO> projectResourcePoolDTOS = poolMap.get(projectDTO.getId());
|
||||
if (CollectionUtils.isNotEmpty(projectResourcePoolDTOS)) {
|
||||
projectDTO.setResourcePoolList(projectResourcePoolDTOS);
|
||||
} else {
|
||||
projectDTO.setResourcePoolList(new ArrayList<>());
|
||||
}
|
||||
projectDTO.setCreateUser(userMap.get(projectDTO.getCreateUser()));
|
||||
projectDTO.setUpdateUser(userMap.get(projectDTO.getUpdateUser()));
|
||||
projectDTO.setDeleteUser(userMap.get(projectDTO.getDeleteUser()));
|
||||
});
|
||||
projectDTO.setMemberCount(projectMap.get(projectDTO.getId()).getMemberCount());
|
||||
List<UserExtendDTO> userExtendDTOS = userMapList.get(projectDTO.getId());
|
||||
if (CollectionUtils.isNotEmpty(userExtendDTOS)) {
|
||||
projectDTO.setAdminList(userExtendDTOS);
|
||||
List<String> userIdList = userExtendDTOS.stream().map(User::getId).collect(Collectors.toList());
|
||||
if (CollectionUtils.isNotEmpty(userIdList) && userIdList.contains(projectDTO.getCreateUser())) {
|
||||
projectDTO.setProjectCreateUserIsAdmin(true);
|
||||
} else {
|
||||
projectDTO.setProjectCreateUserIsAdmin(false);
|
||||
}
|
||||
} else {
|
||||
projectDTO.setAdminList(new ArrayList<>());
|
||||
}
|
||||
List<ProjectResourcePoolDTO> projectResourcePoolDTOS = poolMap.get(projectDTO.getId());
|
||||
if (CollectionUtils.isNotEmpty(projectResourcePoolDTOS)) {
|
||||
projectDTO.setResourcePoolList(projectResourcePoolDTOS);
|
||||
} else {
|
||||
projectDTO.setResourcePoolList(new ArrayList<>());
|
||||
}
|
||||
projectDTO.setCreateUser(userMap.get(projectDTO.getCreateUser()));
|
||||
projectDTO.setUpdateUser(userMap.get(projectDTO.getUpdateUser()));
|
||||
projectDTO.setDeleteUser(userMap.get(projectDTO.getDeleteUser()));
|
||||
});
|
||||
}
|
||||
return projectList;
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package io.metersphere.system.service;
|
||||
|
||||
import io.metersphere.sdk.dto.OptionDTO;
|
||||
import io.metersphere.sdk.dto.UserExtend;
|
||||
import io.metersphere.sdk.dto.UserExtendDTO;
|
||||
import io.metersphere.sdk.exception.MSException;
|
||||
import io.metersphere.sdk.util.BeanUtils;
|
||||
import io.metersphere.sdk.util.Translator;
|
||||
@ -76,7 +76,7 @@ public class OrganizationProjectService {
|
||||
return commonProjectService.delete(id, deleteUser);
|
||||
}
|
||||
|
||||
public List<UserExtend> getProjectMember(ProjectMemberRequest request) {
|
||||
public List<UserExtendDTO> getProjectMember(ProjectMemberRequest request) {
|
||||
return extSystemProjectMapper.getProjectMemberList(request);
|
||||
}
|
||||
|
||||
@ -106,12 +106,12 @@ public class OrganizationProjectService {
|
||||
commonProjectService.disable(id, updateUser);
|
||||
}
|
||||
|
||||
public List<UserExtend> getUserAdminList(String organizationId, String keyword) {
|
||||
public List<UserExtendDTO> getUserAdminList(String organizationId, String keyword) {
|
||||
checkOrgIsExist(organizationId);
|
||||
return extSystemProjectMapper.getUserAdminList(organizationId, keyword);
|
||||
}
|
||||
|
||||
public List<UserExtend> getUserMemberList(String organizationId, String projectId, String keyword) {
|
||||
public List<UserExtendDTO> getUserMemberList(String organizationId, String projectId, String keyword) {
|
||||
checkOrgIsExist(organizationId);
|
||||
commonProjectService.checkProjectNotExist(projectId);
|
||||
UserRoleRelationExample example = new UserRoleRelationExample();
|
||||
|
@ -6,7 +6,7 @@ import io.metersphere.project.mapper.ProjectMapper;
|
||||
import io.metersphere.sdk.constants.*;
|
||||
import io.metersphere.sdk.dto.LogDTO;
|
||||
import io.metersphere.sdk.dto.OptionDTO;
|
||||
import io.metersphere.sdk.dto.UserExtend;
|
||||
import io.metersphere.sdk.dto.UserExtendDTO;
|
||||
import io.metersphere.sdk.exception.MSException;
|
||||
import io.metersphere.sdk.util.BeanUtils;
|
||||
import io.metersphere.sdk.util.CommonBeanFactory;
|
||||
@ -108,7 +108,7 @@ public class OrganizationService {
|
||||
* @param request 请求参数
|
||||
* @return 组织成员集合
|
||||
*/
|
||||
public List<UserExtend> getMemberListBySystem(OrganizationRequest request) {
|
||||
public List<UserExtendDTO> getMemberListBySystem(OrganizationRequest request) {
|
||||
return extOrganizationMapper.listMember(request);
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@ package io.metersphere.system.service;
|
||||
|
||||
import io.metersphere.project.domain.Project;
|
||||
import io.metersphere.sdk.dto.OptionDTO;
|
||||
import io.metersphere.sdk.dto.UserExtend;
|
||||
import io.metersphere.sdk.dto.UserExtendDTO;
|
||||
import io.metersphere.sdk.util.Translator;
|
||||
import io.metersphere.system.dto.*;
|
||||
import io.metersphere.system.log.constants.OperationLogModule;
|
||||
@ -58,7 +58,7 @@ public class SystemProjectService {
|
||||
return commonProjectService.delete(id, deleteUser);
|
||||
}
|
||||
|
||||
public List<UserExtend> getProjectMember(ProjectMemberRequest request) {
|
||||
public List<UserExtendDTO> getProjectMember(ProjectMemberRequest request) {
|
||||
return extSystemProjectMapper.getProjectMemberList(request);
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package io.metersphere.system.service;
|
||||
|
||||
import io.metersphere.sdk.dto.UserExtend;
|
||||
import io.metersphere.sdk.dto.UserExtendDTO;
|
||||
import io.metersphere.sdk.util.BeanUtils;
|
||||
import io.metersphere.system.domain.*;
|
||||
import io.metersphere.system.mapper.ExtUserMapper;
|
||||
@ -39,8 +39,8 @@ public class UserRoleService {
|
||||
}
|
||||
}
|
||||
|
||||
public List<UserExtend> getMember(String sourceId, String roleId, String keyword) {
|
||||
List<UserExtend> userExtends = new ArrayList<>();
|
||||
public List<UserExtendDTO> getMember(String sourceId, String roleId, String keyword) {
|
||||
List<UserExtendDTO> userExtendDTOS = new ArrayList<>();
|
||||
// 查询组织或项目下所有用户关系
|
||||
UserRoleRelationExample example = new UserRoleRelationExample();
|
||||
example.createCriteria().andSourceIdEqualTo(sourceId);
|
||||
@ -49,22 +49,22 @@ public class UserRoleService {
|
||||
Map<String, List<String>> userRoleMap = userRoleRelations.stream().collect(Collectors.groupingBy(UserRoleRelation::getUserId,
|
||||
Collectors.mapping(UserRoleRelation::getRoleId, Collectors.toList())));
|
||||
userRoleMap.forEach((k, v) -> {
|
||||
UserExtend userExtend = new UserExtend();
|
||||
userExtend.setId(k);
|
||||
UserExtendDTO userExtendDTO = new UserExtendDTO();
|
||||
userExtendDTO.setId(k);
|
||||
v.forEach(roleItem -> {
|
||||
if (StringUtils.equals(roleItem, roleId)) {
|
||||
// 该用户已存在用户组关系, 设置为选中状态
|
||||
userExtend.setCheckRoleFlag(true);
|
||||
userExtendDTO.setCheckRoleFlag(true);
|
||||
}
|
||||
});
|
||||
userExtends.add(userExtend);
|
||||
userExtendDTOS.add(userExtendDTO);
|
||||
});
|
||||
// 设置用户信息, 用户不存在或者已删除, 则不展示
|
||||
List<String> userIds = userExtends.stream().map(UserExtend::getId).toList();
|
||||
List<String> userIds = userExtendDTOS.stream().map(UserExtendDTO::getId).toList();
|
||||
List<User> users = extUserMapper.getRoleUserByParam(userIds, keyword);
|
||||
if (CollectionUtils.isNotEmpty(users)) {
|
||||
Map<String, User> userMap = users.stream().collect(Collectors.toMap(User::getId, user -> user));
|
||||
userExtends.removeIf(userExtend -> {
|
||||
userExtendDTOS.removeIf(userExtend -> {
|
||||
if (userMap.containsKey(userExtend.getId())) {
|
||||
BeanUtils.copyBean(userExtend, userMap.get(userExtend.getId()));
|
||||
return false;
|
||||
@ -72,11 +72,11 @@ public class UserRoleService {
|
||||
return true;
|
||||
});
|
||||
} else {
|
||||
userExtends.clear();
|
||||
userExtendDTOS.clear();
|
||||
}
|
||||
}
|
||||
|
||||
userExtends.sort(Comparator.comparing(UserExtend::getName));
|
||||
return userExtends;
|
||||
userExtendDTOS.sort(Comparator.comparing(UserExtendDTO::getName));
|
||||
return userExtendDTOS;
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ package io.metersphere.system.service;
|
||||
import com.alibaba.excel.EasyExcelFactory;
|
||||
import io.metersphere.sdk.constants.ParamConstants;
|
||||
import io.metersphere.sdk.constants.UserSource;
|
||||
import io.metersphere.sdk.dto.UserExtend;
|
||||
import io.metersphere.sdk.dto.*;
|
||||
import io.metersphere.sdk.exception.MSException;
|
||||
import io.metersphere.sdk.util.*;
|
||||
@ -330,7 +329,7 @@ public class UserService {
|
||||
* @param sourceId 组织ID, 项目ID
|
||||
* @return 系统用户选项
|
||||
*/
|
||||
public List<UserExtend> getMemberOption(String sourceId, String keyword) {
|
||||
public List<UserExtendDTO> getMemberOption(String sourceId, String keyword) {
|
||||
return extUserMapper.getMemberOption(sourceId, keyword);
|
||||
}
|
||||
|
||||
|
@ -6,19 +6,20 @@ import io.metersphere.project.domain.ProjectTestResourcePool;
|
||||
import io.metersphere.project.domain.ProjectTestResourcePoolExample;
|
||||
import io.metersphere.project.mapper.ProjectMapper;
|
||||
import io.metersphere.project.mapper.ProjectTestResourcePoolMapper;
|
||||
import io.metersphere.system.base.BaseTest;
|
||||
import io.metersphere.sdk.constants.InternalUserRole;
|
||||
import io.metersphere.sdk.constants.PermissionConstants;
|
||||
import io.metersphere.sdk.constants.SessionConstants;
|
||||
import io.metersphere.system.controller.handler.ResultHolder;
|
||||
import io.metersphere.sdk.dto.*;
|
||||
import io.metersphere.system.dto.*;
|
||||
import io.metersphere.system.log.constants.OperationLogType;
|
||||
import io.metersphere.sdk.dto.UserDTO;
|
||||
import io.metersphere.sdk.dto.UserExtendDTO;
|
||||
import io.metersphere.sdk.util.JSON;
|
||||
import io.metersphere.sdk.util.Pager;
|
||||
import io.metersphere.system.base.BaseTest;
|
||||
import io.metersphere.system.controller.handler.ResultHolder;
|
||||
import io.metersphere.system.domain.User;
|
||||
import io.metersphere.system.domain.UserRoleRelation;
|
||||
import io.metersphere.system.domain.UserRoleRelationExample;
|
||||
import io.metersphere.system.dto.*;
|
||||
import io.metersphere.system.log.constants.OperationLogType;
|
||||
import io.metersphere.system.mapper.UserMapper;
|
||||
import io.metersphere.system.mapper.UserRoleRelationMapper;
|
||||
import io.metersphere.system.request.OrganizationProjectRequest;
|
||||
@ -667,7 +668,7 @@ public class OrganizationProjectControllerTests extends BaseTest {
|
||||
//返回值的页码和当前页码相同
|
||||
Assertions.assertEquals(returnPager.getCurrent(), memberRequest.getCurrent());
|
||||
//返回的数据量不超过规定要返回的数据量相同
|
||||
Assertions.assertTrue(((List<UserExtend>) returnPager.getList()).size() <= memberRequest.getPageSize());
|
||||
Assertions.assertTrue(((List<UserExtendDTO>) returnPager.getList()).size() <= memberRequest.getPageSize());
|
||||
UserRoleRelationExample userRoleRelationExample = new UserRoleRelationExample();
|
||||
userRoleRelationExample.createCriteria().andSourceIdEqualTo(projectId);
|
||||
List<UserRoleRelation> userRoleRelations = userRoleRelationMapper.selectByExample(userRoleRelationExample);
|
||||
@ -682,10 +683,10 @@ public class OrganizationProjectControllerTests extends BaseTest {
|
||||
returnPager = parseObjectFromMvcResult(mvcResult, Pager.class);
|
||||
//第一个数据的createTime是最大的
|
||||
assert returnPager != null;
|
||||
List<UserExtend> userExtends = JSON.parseArray(JSON.toJSONString(returnPager.getList()), UserExtend.class);
|
||||
long firstCreateTime = userExtends.get(0).getCreateTime();
|
||||
for (UserExtend userExtend : userExtends) {
|
||||
Assertions.assertFalse(userExtend.getCreateTime() > firstCreateTime);
|
||||
List<UserExtendDTO> userExtendDTOS = JSON.parseArray(JSON.toJSONString(returnPager.getList()), UserExtendDTO.class);
|
||||
long firstCreateTime = userExtendDTOS.get(0).getCreateTime();
|
||||
for (UserExtendDTO userExtendDTO : userExtendDTOS) {
|
||||
Assertions.assertFalse(userExtendDTO.getCreateTime() > firstCreateTime);
|
||||
}
|
||||
// @@校验权限
|
||||
requestPostPermissionTest(PermissionConstants.ORGANIZATION_PROJECT_READ, getProjectMemberList, memberRequest);
|
||||
|
@ -2,13 +2,13 @@ package io.metersphere.system.controller;
|
||||
|
||||
import io.metersphere.sdk.constants.PermissionConstants;
|
||||
import io.metersphere.sdk.constants.SessionConstants;
|
||||
import io.metersphere.system.dto.ProjectDTO;
|
||||
import io.metersphere.sdk.dto.UserExtend;
|
||||
import io.metersphere.sdk.dto.UserExtendDTO;
|
||||
import io.metersphere.sdk.util.JSON;
|
||||
import io.metersphere.sdk.util.Pager;
|
||||
import io.metersphere.system.base.BaseTest;
|
||||
import io.metersphere.system.controller.handler.ResultHolder;
|
||||
import io.metersphere.system.dto.OrganizationDTO;
|
||||
import io.metersphere.system.dto.ProjectDTO;
|
||||
import io.metersphere.system.log.constants.OperationLogType;
|
||||
import io.metersphere.system.request.OrganizationMemberRequest;
|
||||
import io.metersphere.system.request.OrganizationRequest;
|
||||
@ -171,10 +171,10 @@ public class SystemOrganizationControllerTests extends BaseTest{
|
||||
// 返回的数据量不超过规定要返回的数据量相同
|
||||
Assertions.assertTrue(JSON.parseArray(JSON.toJSONString(pageData.getList())).size() <= organizationRequest.getPageSize());
|
||||
// 返回值中取出第一条数据, 并判断是否包含关键字admin
|
||||
UserExtend userExtend = JSON.parseArray(JSON.toJSONString(pageData.getList()), UserExtend.class).get(0);
|
||||
Assertions.assertTrue(StringUtils.contains(userExtend.getName(), organizationRequest.getKeyword())
|
||||
|| StringUtils.contains(userExtend.getEmail(), organizationRequest.getKeyword())
|
||||
|| StringUtils.contains(userExtend.getPhone(), organizationRequest.getKeyword()));
|
||||
UserExtendDTO userExtendDTO = JSON.parseArray(JSON.toJSONString(pageData.getList()), UserExtendDTO.class).get(0);
|
||||
Assertions.assertTrue(StringUtils.contains(userExtendDTO.getName(), organizationRequest.getKeyword())
|
||||
|| StringUtils.contains(userExtendDTO.getEmail(), organizationRequest.getKeyword())
|
||||
|| StringUtils.contains(userExtendDTO.getPhone(), organizationRequest.getKeyword()));
|
||||
|
||||
// sort不为空
|
||||
Map<String, String> sort = new HashMap<>();
|
||||
@ -185,8 +185,8 @@ public class SystemOrganizationControllerTests extends BaseTest{
|
||||
ResultHolder sortHolder = JSON.parseObject(sortData, ResultHolder.class);
|
||||
Pager<?> sortPageData = JSON.parseObject(JSON.toJSONString(sortHolder.getData()), Pager.class);
|
||||
// 返回值中取出第一条ID最大的数据, 并判断是否是admin
|
||||
UserExtend userExtend1 = JSON.parseArray(JSON.toJSONString(sortPageData.getList()), UserExtend.class).get(0);
|
||||
Assertions.assertTrue(StringUtils.contains(userExtend1.getId(), "admin"));
|
||||
UserExtendDTO userExtendDTO1 = JSON.parseArray(JSON.toJSONString(sortPageData.getList()), UserExtendDTO.class).get(0);
|
||||
Assertions.assertTrue(StringUtils.contains(userExtendDTO1.getId(), "admin"));
|
||||
// 权限校验
|
||||
requestPostPermissionsTest(List.of(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_READ, PermissionConstants.SYSTEM_USER_READ),
|
||||
ORGANIZATION_LIST_MEMBER, organizationRequest);
|
||||
@ -241,10 +241,10 @@ public class SystemOrganizationControllerTests extends BaseTest{
|
||||
// 返回的数据量不超过规定要返回的数据量相同
|
||||
Assertions.assertTrue(JSON.parseArray(JSON.toJSONString(pageData.getList())).size() <= organizationRequest.getPageSize());
|
||||
// 返回值中取出第一条数据, 并判断是否包含关键字admin
|
||||
UserExtend userExtend = JSON.parseArray(JSON.toJSONString(pageData.getList()), UserExtend.class).get(0);
|
||||
Assertions.assertTrue(StringUtils.contains(userExtend.getName(), organizationRequest.getKeyword())
|
||||
|| StringUtils.contains(userExtend.getEmail(), organizationRequest.getKeyword())
|
||||
|| StringUtils.contains(userExtend.getPhone(), organizationRequest.getKeyword()));
|
||||
UserExtendDTO userExtendDTO = JSON.parseArray(JSON.toJSONString(pageData.getList()), UserExtendDTO.class).get(0);
|
||||
Assertions.assertTrue(StringUtils.contains(userExtendDTO.getName(), organizationRequest.getKeyword())
|
||||
|| StringUtils.contains(userExtendDTO.getEmail(), organizationRequest.getKeyword())
|
||||
|| StringUtils.contains(userExtendDTO.getPhone(), organizationRequest.getKeyword()));
|
||||
// 权限校验
|
||||
organizationMemberRequest.setUserIds(List.of("admin"));
|
||||
requestPostPermissionTest(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_MEMBER_ADD, ORGANIZATION_ADD_MEMBER, organizationMemberRequest);
|
||||
@ -277,10 +277,10 @@ public class SystemOrganizationControllerTests extends BaseTest{
|
||||
// 返回的数据量不超过规定要返回的数据量相同
|
||||
Assertions.assertTrue(JSON.parseArray(JSON.toJSONString(pageData.getList())).size() <= organizationRequest.getPageSize());
|
||||
// 返回值中取出第一条数据, 并判断是否包含关键字admin
|
||||
UserExtend userExtend = JSON.parseArray(JSON.toJSONString(pageData.getList()), UserExtend.class).get(0);
|
||||
Assertions.assertTrue(StringUtils.contains(userExtend.getName(), organizationRequest.getKeyword())
|
||||
|| StringUtils.contains(userExtend.getEmail(), organizationRequest.getKeyword())
|
||||
|| StringUtils.contains(userExtend.getPhone(), organizationRequest.getKeyword()));
|
||||
UserExtendDTO userExtendDTO = JSON.parseArray(JSON.toJSONString(pageData.getList()), UserExtendDTO.class).get(0);
|
||||
Assertions.assertTrue(StringUtils.contains(userExtendDTO.getName(), organizationRequest.getKeyword())
|
||||
|| StringUtils.contains(userExtendDTO.getEmail(), organizationRequest.getKeyword())
|
||||
|| StringUtils.contains(userExtendDTO.getPhone(), organizationRequest.getKeyword()));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -7,7 +7,7 @@ import io.metersphere.project.domain.ProjectTestResourcePoolExample;
|
||||
import io.metersphere.project.mapper.ProjectMapper;
|
||||
import io.metersphere.project.mapper.ProjectTestResourcePoolMapper;
|
||||
import io.metersphere.sdk.constants.*;
|
||||
import io.metersphere.sdk.dto.UserExtend;
|
||||
import io.metersphere.sdk.dto.UserExtendDTO;
|
||||
import io.metersphere.sdk.util.BeanUtils;
|
||||
import io.metersphere.sdk.util.JSON;
|
||||
import io.metersphere.sdk.util.Pager;
|
||||
@ -563,6 +563,13 @@ public class SystemProjectControllerTests extends BaseTest {
|
||||
Assertions.assertFalse(projectDTO.getOrganizationName().compareTo(firstOrganizationName) > 0);
|
||||
}
|
||||
|
||||
//查询不存在的组织id
|
||||
projectRequest.setOrganizationId("111111");
|
||||
mvcResult = this.responsePost(getProjectList, projectRequest);
|
||||
returnPager = parseObjectFromMvcResult(mvcResult, Pager.class);
|
||||
//返回值不为空
|
||||
Assertions.assertNotNull(returnPager);
|
||||
//返回值为
|
||||
|
||||
// @@校验权限
|
||||
requestPostPermissionTest(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_READ, getProjectList, projectRequest);
|
||||
@ -786,17 +793,17 @@ public class SystemProjectControllerTests extends BaseTest {
|
||||
//返回值的页码和当前页码相同
|
||||
Assertions.assertEquals(returnPager.getCurrent(), memberRequest.getCurrent());
|
||||
//返回的数据量不超过规定要返回的数据量相同
|
||||
Assertions.assertTrue(((List<UserExtend>) returnPager.getList()).size() <= memberRequest.getPageSize());
|
||||
Assertions.assertTrue(((List<UserExtendDTO>) returnPager.getList()).size() <= memberRequest.getPageSize());
|
||||
memberRequest.setSort(new HashMap<>() {{
|
||||
put("createTime", "desc");
|
||||
}});
|
||||
mvcResult = this.responsePost(getProjectMemberList, memberRequest);
|
||||
returnPager = parseObjectFromMvcResult(mvcResult, Pager.class);
|
||||
//第一个数据的createTime是最大的
|
||||
List<UserExtend> userExtends = JSON.parseArray(JSON.toJSONString(returnPager.getList()), UserExtend.class);
|
||||
long firstCreateTime = userExtends.get(0).getCreateTime();
|
||||
for (UserExtend userExtend : userExtends) {
|
||||
Assertions.assertFalse(userExtend.getCreateTime() > firstCreateTime);
|
||||
List<UserExtendDTO> userExtendDTOS = JSON.parseArray(JSON.toJSONString(returnPager.getList()), UserExtendDTO.class);
|
||||
long firstCreateTime = userExtendDTOS.get(0).getCreateTime();
|
||||
for (UserExtendDTO userExtendDTO : userExtendDTOS) {
|
||||
Assertions.assertFalse(userExtendDTO.getCreateTime() > firstCreateTime);
|
||||
}
|
||||
// @@校验权限
|
||||
requestPostPermissionTest(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_READ, getProjectMemberList, memberRequest);
|
||||
|
Loading…
Reference in New Issue
Block a user