diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/controller/SystemProjectController.java b/backend/services/system-setting/src/main/java/io/metersphere/system/controller/SystemProjectController.java index 094edd7d49..8f398e74a8 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/controller/SystemProjectController.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/controller/SystemProjectController.java @@ -175,4 +175,12 @@ public class SystemProjectController { systemProjectService.rename(request, SessionUtils.getUserId()); } + @GetMapping("/list") + @Operation(summary = "系统设置-系统-组织与项目-项目-获取所有项目") + @RequiresPermissions(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_READ) + public List getProjectList(@Schema(description = "查询关键字,根据项目名查询", requiredMode = Schema.RequiredMode.REQUIRED) @RequestParam(value = "keyword", required = false) String keyword) { + return systemProjectService.list(keyword); + } + + } diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtSystemOrgProjectMapper.xml b/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtSystemOrgProjectMapper.xml index ed54914943..36fbc19c1c 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtSystemOrgProjectMapper.xml +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtSystemOrgProjectMapper.xml @@ -5,7 +5,7 @@ + \ No newline at end of file diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/service/SystemProjectService.java b/backend/services/system-setting/src/main/java/io/metersphere/system/service/SystemProjectService.java index 307150f1d0..90e678de3c 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/service/SystemProjectService.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/service/SystemProjectService.java @@ -105,4 +105,9 @@ public class SystemProjectService { public void rename(UpdateProjectNameRequest project, String userId) { commonProjectService.rename(project, userId); } + + public List list(String keyword) { + return extSystemProjectMapper.getSystemProject(keyword); + + } } diff --git a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/SystemProjectControllerTests.java b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/SystemProjectControllerTests.java index 06deccc038..843409ec70 100644 --- a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/SystemProjectControllerTests.java +++ b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/SystemProjectControllerTests.java @@ -16,6 +16,7 @@ import io.metersphere.system.controller.handler.ResultHolder; import io.metersphere.system.domain.*; import io.metersphere.system.dto.*; import io.metersphere.system.dto.request.*; +import io.metersphere.system.dto.sdk.OptionDTO; import io.metersphere.system.dto.sdk.request.CustomFieldOptionRequest; import io.metersphere.system.dto.sdk.request.PosRequest; import io.metersphere.system.dto.sdk.request.TemplateCustomFieldRequest; @@ -1217,4 +1218,19 @@ public class SystemProjectControllerTests extends BaseTest { apiTestCaseMapper.deleteByPrimaryKey(anotherCase.getId()); } + + @Test + @Order(17) + public void getProjectListByOrgSuccess() throws Exception { + MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.get(prefix + "/list") + .header(SessionConstants.HEADER_TOKEN, sessionId) + .header(SessionConstants.CSRF_TOKEN, csrfToken) + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON)).andReturn(); + String contentAsString = mvcResult.getResponse().getContentAsString(); + ResultHolder resultHolder = JSON.parseObject(contentAsString, ResultHolder.class); + List projectList = JSON.parseArray(JSON.toJSONString(resultHolder.getData()), OptionDTO.class); + Assertions.assertTrue(CollectionUtils.isNotEmpty(projectList)); + } } diff --git a/frontend/src/api/modules/system.ts b/frontend/src/api/modules/system.ts index d0d0338920..d25da8e5c2 100644 --- a/frontend/src/api/modules/system.ts +++ b/frontend/src/api/modules/system.ts @@ -1,5 +1,6 @@ // 系统全局类的接口 import MSR from '@/api/http/index'; +import { getSystemProjectListUrl } from '@/api/requrls/setting/member'; import { GetVersionUrl, OrgOptionsUrl, @@ -32,3 +33,7 @@ export function getPackageType() { export function getUserHasProjectPermission(userId: string) { return MSR.get({ url: `${userHasProjectPermissionUrl}/${userId}` }); } + +export function getSystemProjectList(keyword: string) { + return MSR.get({ url: getSystemProjectListUrl, params: { keyword } }); +} diff --git a/frontend/src/api/requrls/setting/member.ts b/frontend/src/api/requrls/setting/member.ts index d2458c4751..b8784eb22e 100644 --- a/frontend/src/api/requrls/setting/member.ts +++ b/frontend/src/api/requrls/setting/member.ts @@ -12,3 +12,4 @@ export const getUserGroupList = '/organization/user/role/list'; export const getUserList = '/organization/not-exist/user/list'; // 获取弹窗里边的穿梭项目列表 export const getProjectListUrl = '/organization/project/list'; +export const getSystemProjectListUrl = '/system/project/list'; // 获取系统项目列表 diff --git a/frontend/src/components/business/ms-user-selector/utils.ts b/frontend/src/components/business/ms-user-selector/utils.ts index ba478e7b5d..5bb79a3d44 100644 --- a/frontend/src/components/business/ms-user-selector/utils.ts +++ b/frontend/src/components/business/ms-user-selector/utils.ts @@ -8,7 +8,7 @@ import { getUserByProjectByOrg, } from '@/api/modules/setting/organizationAndProject'; import { getOrgUserGroupOption, getSystemUserGroupOption } from '@/api/modules/setting/usergroup'; -import { getOrgOptions } from '@/api/modules/system'; +import { getOrgOptions, getSystemProjectList } from '@/api/modules/system'; // eslint-disable-next-line no-shadow export enum UserRequestTypeEnum { SYSTEM_USER_GROUP = 'SYSTEM_USER_GROUP', @@ -25,6 +25,7 @@ export enum UserRequestTypeEnum { PROJECT_PERMISSION_MEMBER = 'PROJECT_PERMISSION_MEMBER', PROJECT_USER_GROUP = 'PROJECT_USER_GROUP', SYSTEM_ORGANIZATION_LIST = 'SYSTEM_ORGANIZATION_LIST', + SYSTEM_PROJECT_LIST = 'SYSTEM_PROJECT_LIST', } export default function initOptionsFunc(type: string, params: Record) { if (type === UserRequestTypeEnum.SYSTEM_USER_GROUP) { @@ -71,4 +72,8 @@ export default function initOptionsFunc(type: string, params: Record { try { - if (lastProjectId) { + if (lastProjectId.value) { const result = await getProjectMemberOptions(lastProjectId.value); memberList.value = result; } diff --git a/frontend/src/views/project-management/taskCenter/component/apiCase.vue b/frontend/src/views/project-management/taskCenter/component/apiCase.vue index 71e4b6b310..c7cb2e92bb 100644 --- a/frontend/src/views/project-management/taskCenter/component/apiCase.vue +++ b/frontend/src/views/project-management/taskCenter/component/apiCase.vue @@ -102,7 +102,7 @@ -