From 840acafe6f5351227a4f2f3d856cd39a55b2fa9d Mon Sep 17 00:00:00 2001 From: wxg0103 <727495428@qq.com> Date: Mon, 6 May 2024 11:52:07 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E7=B3=BB=E7=BB=9F=E8=AE=BE=E7=BD=AE):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=B3=BB=E7=BB=9F=E7=9A=84=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E4=B8=AD=E5=BF=83=E6=B2=A1=E6=9C=89=E6=98=BE=E7=A4=BA=E5=85=A8?= =?UTF-8?q?=E9=83=A8=E9=A1=B9=E7=9B=AE=E7=9A=84=E7=BC=BA=E9=99=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1040246 --user=王孝刚 【系统设置】系统/组织-任务中心-所属项目-下拉应该显示所有组织下的所有项目 https://www.tapd.cn/55049933/s/1511602 --- .../controller/SystemProjectController.java | 8 +++++ .../mapper/ExtSystemOrgProjectMapper.xml | 2 +- .../system/mapper/ExtSystemProjectMapper.java | 3 ++ .../system/mapper/ExtSystemProjectMapper.xml | 10 ++++++ .../system/service/SystemProjectService.java | 5 +++ .../SystemProjectControllerTests.java | 16 +++++++++ frontend/src/api/modules/system.ts | 5 +++ frontend/src/api/requrls/setting/member.ts | 1 + .../business/ms-user-selector/utils.ts | 7 +++- .../member/components/addMemberModal.vue | 2 +- .../taskCenter/component/apiCase.vue | 33 +++++++++++++++---- .../taskCenter/component/scheduledTask.vue | 25 +++++++++++--- 12 files changed, 103 insertions(+), 14 deletions(-) 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 @@ -