fix(通用功能): 修复跨项目禁用模块显示问题
--bug=1039836 --user=郭雨琦 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001039836
This commit is contained in:
parent
dd9199be50
commit
a2da01b4d1
|
@ -528,6 +528,8 @@ file.name.cannot.be.empty=文件名称不能为空
|
||||||
file.size.is.too.large=文件不能超过50M
|
file.size.is.too.large=文件不能超过50M
|
||||||
file.is.empty=文件为空
|
file.is.empty=文件为空
|
||||||
file.name.error=文件名不合法
|
file.name.error=文件名不合法
|
||||||
|
module.name.is.empty=模块参数为空
|
||||||
|
module.name.is.error=模块参数不正确
|
||||||
#file management over
|
#file management over
|
||||||
|
|
||||||
# template
|
# template
|
||||||
|
|
|
@ -133,6 +133,8 @@ robot_is_null=The current robot does not exist
|
||||||
ding_type_is_null= DingTalk robot type is required
|
ding_type_is_null= DingTalk robot type is required
|
||||||
ding_app_key_is_null=DingTalk AppKey is required
|
ding_app_key_is_null=DingTalk AppKey is required
|
||||||
ding_app_secret_is_null=DingTalk AppSecret is required
|
ding_app_secret_is_null=DingTalk AppSecret is required
|
||||||
|
module.name.is.empty=Module parameter is empty
|
||||||
|
module.name.is.error=Module parameter is error
|
||||||
# permission
|
# permission
|
||||||
permission.project_user.name=User
|
permission.project_user.name=User
|
||||||
permission.project_group.name=User group
|
permission.project_group.name=User group
|
||||||
|
|
|
@ -122,6 +122,8 @@ functional_case_template_extend.step_model.length_range=步骤模型长度必须
|
||||||
functional_case_template_extend.step_model.not_blank=步骤模型不能为空
|
functional_case_template_extend.step_model.not_blank=步骤模型不能为空
|
||||||
project_not_exist=项目不存在
|
project_not_exist=项目不存在
|
||||||
fake_error_name_exist=误报名称已存在
|
fake_error_name_exist=误报名称已存在
|
||||||
|
module.name.is.empty=模块参数为空
|
||||||
|
module.name.is.error=模块参数不正确
|
||||||
#消息管理
|
#消息管理
|
||||||
save_message_task_user_no_exist=所选用户部分不存在
|
save_message_task_user_no_exist=所选用户部分不存在
|
||||||
# robot
|
# robot
|
||||||
|
|
|
@ -122,6 +122,8 @@ functional_case_template_extend.step_model.length_range=步驟模型長度必須
|
||||||
functional_case_template_extend.step_model.not_blank=步驟模型不能為空
|
functional_case_template_extend.step_model.not_blank=步驟模型不能為空
|
||||||
project_is_null=項目不存在
|
project_is_null=項目不存在
|
||||||
fake_error_name_exist=誤報名稱已存在
|
fake_error_name_exist=誤報名稱已存在
|
||||||
|
module.name.is.empty=模組參數為空
|
||||||
|
module.name.is.error=模組參數不正確
|
||||||
#消息管理
|
#消息管理
|
||||||
save_message_task_user_no_exist=所選用戶部分不存在
|
save_message_task_user_no_exist=所選用戶部分不存在
|
||||||
# robot
|
# robot
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package io.metersphere.project.service;
|
package io.metersphere.project.service;
|
||||||
|
|
||||||
|
import io.metersphere.project.constants.ProjectMenuConstants;
|
||||||
import io.metersphere.project.domain.*;
|
import io.metersphere.project.domain.*;
|
||||||
import io.metersphere.project.dto.ProjectRequest;
|
import io.metersphere.project.dto.ProjectRequest;
|
||||||
import io.metersphere.project.mapper.ExtProjectMapper;
|
import io.metersphere.project.mapper.ExtProjectMapper;
|
||||||
|
@ -251,6 +252,31 @@ public class ProjectService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Project> getUserProjectWidthModule(String organizationId, String module, String userId) {
|
public List<Project> getUserProjectWidthModule(String organizationId, String module, String userId) {
|
||||||
|
if (StringUtils.isBlank(module)) {
|
||||||
|
throw new MSException(Translator.get("module.name.is.empty"));
|
||||||
|
}
|
||||||
|
String moduleName = null;
|
||||||
|
if (StringUtils.equalsIgnoreCase(module, "API") || StringUtils.equalsIgnoreCase(module, "SCENARIO")) {
|
||||||
|
moduleName = ProjectMenuConstants.MODULE_MENU_API_TEST;
|
||||||
|
}
|
||||||
|
if (StringUtils.equalsIgnoreCase(module, "FUNCTIONAL")) {
|
||||||
|
moduleName = ProjectMenuConstants.MODULE_MENU_FUNCTIONAL_CASE;
|
||||||
|
}
|
||||||
|
if (StringUtils.equalsIgnoreCase(module, "BUG")) {
|
||||||
|
moduleName = ProjectMenuConstants.MODULE_MENU_BUG;
|
||||||
|
}
|
||||||
|
if (StringUtils.equalsIgnoreCase(module, "PERFORMANCE")) {
|
||||||
|
moduleName = ProjectMenuConstants.MODULE_MENU_LOAD_TEST;
|
||||||
|
}
|
||||||
|
if (StringUtils.equalsIgnoreCase(module, "UI")) {
|
||||||
|
moduleName = ProjectMenuConstants.MODULE_MENU_UI;
|
||||||
|
}
|
||||||
|
if (StringUtils.equalsIgnoreCase(module, "TEST_PLAN")) {
|
||||||
|
moduleName = ProjectMenuConstants.MODULE_MENU_TEST_PLAN;
|
||||||
|
}
|
||||||
|
if (StringUtils.isBlank(moduleName)) {
|
||||||
|
throw new MSException(Translator.get("module.name.is.error"));
|
||||||
|
}
|
||||||
checkOrg(organizationId);
|
checkOrg(organizationId);
|
||||||
//查询用户当前的项目 如果存在默认排在第一个
|
//查询用户当前的项目 如果存在默认排在第一个
|
||||||
User user = baseUserMapper.selectById(userId);
|
User user = baseUserMapper.selectById(userId);
|
||||||
|
@ -265,9 +291,9 @@ public class ProjectService {
|
||||||
UserRoleRelationExample userRoleRelationExample = new UserRoleRelationExample();
|
UserRoleRelationExample userRoleRelationExample = new UserRoleRelationExample();
|
||||||
userRoleRelationExample.createCriteria().andUserIdEqualTo(userId).andRoleIdEqualTo(InternalUserRole.ADMIN.name());
|
userRoleRelationExample.createCriteria().andUserIdEqualTo(userId).andRoleIdEqualTo(InternalUserRole.ADMIN.name());
|
||||||
if (userRoleRelationMapper.countByExample(userRoleRelationExample) > 0) {
|
if (userRoleRelationMapper.countByExample(userRoleRelationExample) > 0) {
|
||||||
allProject = extProjectMapper.getAllProjectWidthModule(organizationId, module);
|
allProject = extProjectMapper.getAllProjectWidthModule(organizationId, moduleName);
|
||||||
} else {
|
} else {
|
||||||
allProject = extProjectMapper.getUserProjectWidthModule(organizationId, userId, module);
|
allProject = extProjectMapper.getUserProjectWidthModule(organizationId, userId, moduleName);
|
||||||
}
|
}
|
||||||
List<Project> temp = allProject;
|
List<Project> temp = allProject;
|
||||||
return allProject.stream()
|
return allProject.stream()
|
||||||
|
|
|
@ -214,8 +214,9 @@ public class ProjectControllerTests extends BaseTest {
|
||||||
ProjectExample example = new ProjectExample();
|
ProjectExample example = new ProjectExample();
|
||||||
example.createCriteria().andOrganizationIdEqualTo(DEFAULT_ORGANIZATION_ID).andEnableEqualTo(true);
|
example.createCriteria().andOrganizationIdEqualTo(DEFAULT_ORGANIZATION_ID).andEnableEqualTo(true);
|
||||||
Assertions.assertEquals(projectMapper.countByExample(example), list.size());
|
Assertions.assertEquals(projectMapper.countByExample(example), list.size());
|
||||||
|
requestGet(getOptionsWidthModule + DEFAULT_ORGANIZATION_ID +"/apiTest", status().is5xxServerError());
|
||||||
MvcResult mvcResultModule = this.responseGet(getOptionsWidthModule + DEFAULT_ORGANIZATION_ID +"/apiTest");
|
requestGet(getOptionsWidthModule + DEFAULT_ORGANIZATION_ID +"/''", status().is5xxServerError());
|
||||||
|
MvcResult mvcResultModule = this.responseGet(getOptionsWidthModule + DEFAULT_ORGANIZATION_ID +"/API");
|
||||||
List<Project> listModule = parseObjectFromMvcResult(mvcResultModule, List.class);
|
List<Project> listModule = parseObjectFromMvcResult(mvcResultModule, List.class);
|
||||||
Assertions.assertNotNull(listModule);
|
Assertions.assertNotNull(listModule);
|
||||||
ProjectExample exampleWidthModule = new ProjectExample();
|
ProjectExample exampleWidthModule = new ProjectExample();
|
||||||
|
@ -259,7 +260,7 @@ public class ProjectControllerTests extends BaseTest {
|
||||||
list = parseObjectFromMvcResult(mvcResult, List.class);
|
list = parseObjectFromMvcResult(mvcResult, List.class);
|
||||||
Assertions.assertNotNull(list);
|
Assertions.assertNotNull(list);
|
||||||
|
|
||||||
mvcResult = mockMvc.perform(MockMvcRequestBuilders.get(getOptions + DEFAULT_ORGANIZATION_ID+"/apiTest")
|
mvcResult = mockMvc.perform(MockMvcRequestBuilders.get(getOptions + DEFAULT_ORGANIZATION_ID+"/API")
|
||||||
.header(SessionConstants.HEADER_TOKEN, sessionId)
|
.header(SessionConstants.HEADER_TOKEN, sessionId)
|
||||||
.header(SessionConstants.CSRF_TOKEN, csrfToken)
|
.header(SessionConstants.CSRF_TOKEN, csrfToken)
|
||||||
.contentType(MediaType.APPLICATION_JSON))
|
.contentType(MediaType.APPLICATION_JSON))
|
||||||
|
@ -287,7 +288,7 @@ public class ProjectControllerTests extends BaseTest {
|
||||||
//断言list是空的
|
//断言list是空的
|
||||||
Assertions.assertEquals(0, list.size());
|
Assertions.assertEquals(0, list.size());
|
||||||
|
|
||||||
mvcResult = mockMvc.perform(MockMvcRequestBuilders.get(getOptions + DEFAULT_ORGANIZATION_ID+"/apiTest")
|
mvcResult = mockMvc.perform(MockMvcRequestBuilders.get(getOptions + DEFAULT_ORGANIZATION_ID+"/API")
|
||||||
.header(SessionConstants.HEADER_TOKEN, sessionId)
|
.header(SessionConstants.HEADER_TOKEN, sessionId)
|
||||||
.header(SessionConstants.CSRF_TOKEN, csrfToken)
|
.header(SessionConstants.CSRF_TOKEN, csrfToken)
|
||||||
.contentType(MediaType.APPLICATION_JSON))
|
.contentType(MediaType.APPLICATION_JSON))
|
||||||
|
|
|
@ -57,7 +57,7 @@ export default {
|
||||||
'apiTestManagement.batchUpdate': '批量更新为',
|
'apiTestManagement.batchUpdate': '批量更新为',
|
||||||
'apiTestManagement.valueRequired': '属性值不能为空',
|
'apiTestManagement.valueRequired': '属性值不能为空',
|
||||||
'apiTestManagement.envRequired': '环境值不能为空',
|
'apiTestManagement.envRequired': '环境值不能为空',
|
||||||
'apiTestManagement.reportNameRequired': '报告名不能为空',
|
'apiTestManagement.reportNameRequired': '报告名称不能为空',
|
||||||
'apiTestManagement.poolRequired': '资源池不能为空',
|
'apiTestManagement.poolRequired': '资源池不能为空',
|
||||||
'apiTestManagement.batchMoveConfirm': '移动至所选模块',
|
'apiTestManagement.batchMoveConfirm': '移动至所选模块',
|
||||||
'apiTestManagement.belongModule': '所属模块',
|
'apiTestManagement.belongModule': '所属模块',
|
||||||
|
|
Loading…
Reference in New Issue