From 3becbcb33d2b785d43197e72f20c3c20518aece4 Mon Sep 17 00:00:00 2001 From: shiziyuan9527 Date: Tue, 25 May 2021 14:36:07 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E6=9D=83=E9=99=90=E7=AE=A1=E7=90=86):?= =?UTF-8?q?=20=E6=9D=83=E9=99=90=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../base/mapper/ext/ExtProjectMapper.java | 3 + .../base/mapper/ext/ExtProjectMapper.xml | 11 + .../controller/ProjectController.java | 12 + .../controller/request/ProjectRequest.java | 1 + .../metersphere/service/ProjectService.java | 18 + .../components/common/head/SearchList.vue | 58 ++-- .../settings/project/EditMember.vue | 3 +- .../settings/workspace/MsProject.vue | 308 +++++++++++++++++- 8 files changed, 380 insertions(+), 34 deletions(-) diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtProjectMapper.java b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtProjectMapper.java index baafe6c422..8a85ffb334 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtProjectMapper.java +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtProjectMapper.java @@ -1,5 +1,6 @@ package io.metersphere.base.mapper.ext; +import io.metersphere.base.domain.Project; import io.metersphere.controller.request.ProjectRequest; import io.metersphere.dto.ProjectDTO; import org.apache.ibatis.annotations.Param; @@ -13,4 +14,6 @@ public interface ExtProjectMapper { List getProjectIdByWorkspaceId(String workspaceId); int removeIssuePlatform(@Param("platform") String platform, @Param("orgId") String orgId); + + List getSwitchProject(@Param("proRequest") ProjectRequest request); } diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtProjectMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtProjectMapper.xml index 106506f0ed..2d85b3dd57 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtProjectMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtProjectMapper.xml @@ -82,6 +82,17 @@ from project where workspace_id = #{workspaceId} + update project diff --git a/backend/src/main/java/io/metersphere/controller/ProjectController.java b/backend/src/main/java/io/metersphere/controller/ProjectController.java index 57f10827dd..5321e287aa 100644 --- a/backend/src/main/java/io/metersphere/controller/ProjectController.java +++ b/backend/src/main/java/io/metersphere/controller/ProjectController.java @@ -90,6 +90,18 @@ public class ProjectController { return PageUtils.setPageInfo(page, projectService.getProjectList(request)); } + /** + * 切换项目 + * @param request + * @return + */ + @PostMapping("/list/related") + public List getSwitchProject(@RequestBody ProjectRequest request) { + request.setWorkspaceId(SessionUtils.getCurrentWorkspaceId()); + return projectService.getSwitchProject(request); + } + + @GetMapping("/delete/{projectId}") @MsAuditLog(module = "project_project_manager", type = OperLogConstants.DELETE, beforeEvent = "#msClass.getLogDetails(#projectId)", msClass = ProjectService.class) public void deleteProject(@PathVariable(value = "projectId") String projectId) { diff --git a/backend/src/main/java/io/metersphere/controller/request/ProjectRequest.java b/backend/src/main/java/io/metersphere/controller/request/ProjectRequest.java index 74acf0bb27..c635fedda7 100644 --- a/backend/src/main/java/io/metersphere/controller/request/ProjectRequest.java +++ b/backend/src/main/java/io/metersphere/controller/request/ProjectRequest.java @@ -11,6 +11,7 @@ import java.util.Map; public class ProjectRequest { private String workspaceId; private String projectId; + private String userId; private String name; private List orders; private Map> filters; diff --git a/backend/src/main/java/io/metersphere/service/ProjectService.java b/backend/src/main/java/io/metersphere/service/ProjectService.java index 6f0e832b61..5f503aa452 100644 --- a/backend/src/main/java/io/metersphere/service/ProjectService.java +++ b/backend/src/main/java/io/metersphere/service/ProjectService.java @@ -110,6 +110,14 @@ public class ProjectService { return extProjectMapper.getProjectWithWorkspace(request); } + public List getSwitchProject(ProjectRequest request) { + if (StringUtils.isNotBlank(request.getName())) { + request.setName(StringUtils.wrapIfMissing(request.getName(), "%")); + } + request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders())); + return extProjectMapper.getSwitchProject(request); + } + public List getProjectByIds(List ids) { if (!CollectionUtils.isEmpty(ids)) { ProjectExample example = new ProjectExample(); @@ -128,10 +136,20 @@ public class ProjectService { // 删除项目下 接口测试 相关 deleteAPIResourceByProjectId(projectId); + + // User Group + deleteProjectUserGroup(projectId); + // delete project projectMapper.deleteByPrimaryKey(projectId); } + private void deleteProjectUserGroup(String projectId) { + UserGroupExample userGroupExample = new UserGroupExample(); + userGroupExample.createCriteria().andSourceIdEqualTo(projectId); + userGroupMapper.deleteByExample(userGroupExample); + } + private void deleteLoadTestResourcesByProjectId(String projectId) { LoadTestExample loadTestExample = new LoadTestExample(); loadTestExample.createCriteria().andProjectIdEqualTo(projectId); diff --git a/frontend/src/business/components/common/head/SearchList.vue b/frontend/src/business/components/common/head/SearchList.vue index d8e05c4109..4a82973428 100644 --- a/frontend/src/business/components/common/head/SearchList.vue +++ b/frontend/src/business/components/common/head/SearchList.vue @@ -26,7 +26,7 @@ @@ -375,4 +663,18 @@ pre { margin: 0 0; font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB", Arial, sans-serif; } + +.dialog-css >>> .el-dialog__header { + padding: 0px; +} + +.workspace-member-name { + float: left; +} + +.workspace-member-email { + float: right; + color: #8492a6; + font-size: 13px; +}