refactor(系统设置): 优化无组织的系统管理员登录的逻辑
This commit is contained in:
parent
3d01581ce7
commit
81eff15c8b
|
@ -42,6 +42,11 @@ public class ApiScenarioUpdateRequest {
|
||||||
@Size(max = 50, message = "{api_scenario.module_id.length_range}")
|
@Size(max = 50, message = "{api_scenario.module_id.length_range}")
|
||||||
private String moduleId;
|
private String moduleId;
|
||||||
|
|
||||||
|
@Schema(description = "项目fk", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@NotBlank(message = "{api_scenario.project_id.not_blank}")
|
||||||
|
@Size(min = 1, max = 50, message = "{api_scenario.project_id.length_range}")
|
||||||
|
private String projectId;
|
||||||
|
|
||||||
@Schema(description = "描述信息")
|
@Schema(description = "描述信息")
|
||||||
@Size(max = 1000, message = "{api_definition.description.length_range}")
|
@Size(max = 1000, message = "{api_definition.description.length_range}")
|
||||||
private String description;
|
private String description;
|
||||||
|
|
|
@ -1199,7 +1199,8 @@ public class ApiScenarioService extends MoveNodeService {
|
||||||
// 统一模块下名称不能重复
|
// 统一模块下名称不能重复
|
||||||
example.createCriteria()
|
example.createCriteria()
|
||||||
.andNameEqualTo(apiScenario.getName())
|
.andNameEqualTo(apiScenario.getName())
|
||||||
.andModuleIdEqualTo(apiScenario.getModuleId());
|
.andModuleIdEqualTo(apiScenario.getModuleId())
|
||||||
|
.andProjectIdEqualTo(apiScenario.getProjectId());
|
||||||
if (apiScenarioMapper.countByExample(example) > 0) {
|
if (apiScenarioMapper.countByExample(example) > 0) {
|
||||||
throw new MSException(API_SCENARIO_EXIST);
|
throw new MSException(API_SCENARIO_EXIST);
|
||||||
}
|
}
|
||||||
|
@ -1214,7 +1215,8 @@ public class ApiScenarioService extends MoveNodeService {
|
||||||
example.createCriteria()
|
example.createCriteria()
|
||||||
.andIdNotEqualTo(request.getId())
|
.andIdNotEqualTo(request.getId())
|
||||||
.andModuleIdEqualTo(request.getModuleId())
|
.andModuleIdEqualTo(request.getModuleId())
|
||||||
.andNameEqualTo(request.getName());
|
.andNameEqualTo(request.getName())
|
||||||
|
.andProjectIdEqualTo(request.getProjectId());
|
||||||
if (apiScenarioMapper.countByExample(example) > 0) {
|
if (apiScenarioMapper.countByExample(example) > 0) {
|
||||||
throw new MSException(API_SCENARIO_EXIST);
|
throw new MSException(API_SCENARIO_EXIST);
|
||||||
}
|
}
|
||||||
|
|
|
@ -582,6 +582,7 @@ public class ApiScenarioControllerTests extends BaseTest {
|
||||||
// @@请求成功
|
// @@请求成功
|
||||||
ApiScenarioUpdateRequest request = new ApiScenarioUpdateRequest();
|
ApiScenarioUpdateRequest request = new ApiScenarioUpdateRequest();
|
||||||
request.setId(addApiScenario.getId());
|
request.setId(addApiScenario.getId());
|
||||||
|
request.setProjectId(DEFAULT_PROJECT_ID);
|
||||||
request.setDescription("desc update");
|
request.setDescription("desc update");
|
||||||
request.setName("test name update");
|
request.setName("test name update");
|
||||||
request.setModuleId("default");
|
request.setModuleId("default");
|
||||||
|
|
|
@ -364,7 +364,8 @@ public class UserLoginService {
|
||||||
// 变更前
|
// 变更前
|
||||||
User userFromDB = userMapper.selectByPrimaryKey(user.getId());
|
User userFromDB = userMapper.selectByPrimaryKey(user.getId());
|
||||||
// last organization id 变了
|
// last organization id 变了
|
||||||
if (user.getLastOrganizationId() != null && !StringUtils.equals(user.getLastOrganizationId(), userFromDB.getLastOrganizationId())) {
|
if (user.getLastOrganizationId() != null && !StringUtils.equals(user.getLastOrganizationId(), userFromDB.getLastOrganizationId())
|
||||||
|
&& !baseUserMapper.isSuperUser(user.getId())) {
|
||||||
List<Project> projects = getProjectListByWsAndUserId(user.getId(), user.getLastOrganizationId());
|
List<Project> projects = getProjectListByWsAndUserId(user.getId(), user.getLastOrganizationId());
|
||||||
if (!projects.isEmpty()) {
|
if (!projects.isEmpty()) {
|
||||||
// 如果传入的 last_project_id 是 last_organization_id 下面的
|
// 如果传入的 last_project_id 是 last_organization_id 下面的
|
||||||
|
|
|
@ -430,6 +430,7 @@ export interface ApiScenarioUpdateDTO extends Partial<Scenario> {
|
||||||
name?: string;
|
name?: string;
|
||||||
status?: ApiScenarioStatus;
|
status?: ApiScenarioStatus;
|
||||||
moduleId?: string | number;
|
moduleId?: string | number;
|
||||||
|
projectId?: string;
|
||||||
description?: string;
|
description?: string;
|
||||||
tags?: string[];
|
tags?: string[];
|
||||||
grouped?: boolean;
|
grouped?: boolean;
|
||||||
|
|
Loading…
Reference in New Issue