refactor(系统设置): 优化无组织的系统管理员登录的逻辑

This commit is contained in:
wxg0103 2024-04-01 14:09:05 +08:00 committed by 刘瑞斌
parent 3d01581ce7
commit 81eff15c8b
5 changed files with 13 additions and 3 deletions

View File

@ -42,6 +42,11 @@ public class ApiScenarioUpdateRequest {
@Size(max = 50, message = "{api_scenario.module_id.length_range}")
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 = "描述信息")
@Size(max = 1000, message = "{api_definition.description.length_range}")
private String description;

View File

@ -1199,7 +1199,8 @@ public class ApiScenarioService extends MoveNodeService {
// 统一模块下名称不能重复
example.createCriteria()
.andNameEqualTo(apiScenario.getName())
.andModuleIdEqualTo(apiScenario.getModuleId());
.andModuleIdEqualTo(apiScenario.getModuleId())
.andProjectIdEqualTo(apiScenario.getProjectId());
if (apiScenarioMapper.countByExample(example) > 0) {
throw new MSException(API_SCENARIO_EXIST);
}
@ -1214,7 +1215,8 @@ public class ApiScenarioService extends MoveNodeService {
example.createCriteria()
.andIdNotEqualTo(request.getId())
.andModuleIdEqualTo(request.getModuleId())
.andNameEqualTo(request.getName());
.andNameEqualTo(request.getName())
.andProjectIdEqualTo(request.getProjectId());
if (apiScenarioMapper.countByExample(example) > 0) {
throw new MSException(API_SCENARIO_EXIST);
}

View File

@ -582,6 +582,7 @@ public class ApiScenarioControllerTests extends BaseTest {
// @@请求成功
ApiScenarioUpdateRequest request = new ApiScenarioUpdateRequest();
request.setId(addApiScenario.getId());
request.setProjectId(DEFAULT_PROJECT_ID);
request.setDescription("desc update");
request.setName("test name update");
request.setModuleId("default");

View File

@ -364,7 +364,8 @@ public class UserLoginService {
// 变更前
User userFromDB = userMapper.selectByPrimaryKey(user.getId());
// 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());
if (!projects.isEmpty()) {
// 如果传入的 last_project_id last_organization_id 下面的

View File

@ -430,6 +430,7 @@ export interface ApiScenarioUpdateDTO extends Partial<Scenario> {
name?: string;
status?: ApiScenarioStatus;
moduleId?: string | number;
projectId?: string;
description?: string;
tags?: string[];
grouped?: boolean;