From 20ed80bf3f56423331edf6cdbc61686405dffbc3 Mon Sep 17 00:00:00 2001 From: shiziyuan9527 Date: Wed, 4 Mar 2020 18:10:43 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E7=BC=96=E8=BE=91=E6=97=B6?= =?UTF-8?q?=E5=8F=AF=E9=80=89=E6=8B=A9=E6=89=80=E5=B1=9E=E5=B7=A5=E4=BD=9C?= =?UTF-8?q?=E7=A9=BA=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../base/mapper/ext/ExtProjectMapper.java | 12 ++++ .../base/mapper/ext/ExtProjectMapper.xml | 15 ++++ .../controller/ProjectController.java | 5 +- .../java/io/metersphere/dto/ProjectDTO.java | 68 +++++++++++++++++++ .../metersphere/service/ProjectService.java | 14 ++-- frontend/src/i18n/en-US.js | 2 + frontend/src/i18n/zh-CN.js | 4 +- .../components/project/MsProject.vue | 22 ++++++ 8 files changed, 132 insertions(+), 10 deletions(-) create mode 100644 backend/src/main/java/io/metersphere/base/mapper/ext/ExtProjectMapper.java create mode 100644 backend/src/main/java/io/metersphere/base/mapper/ext/ExtProjectMapper.xml create mode 100644 backend/src/main/java/io/metersphere/dto/ProjectDTO.java 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 new file mode 100644 index 0000000000..2dd083346c --- /dev/null +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtProjectMapper.java @@ -0,0 +1,12 @@ +package io.metersphere.base.mapper.ext; + +import io.metersphere.controller.request.ProjectRequest; +import io.metersphere.dto.ProjectDTO; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +public interface ExtProjectMapper { + + List getProjectWithWorkspace(@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 new file mode 100644 index 0000000000..5f7d030259 --- /dev/null +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtProjectMapper.xml @@ -0,0 +1,15 @@ + + + + + + + \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/controller/ProjectController.java b/backend/src/main/java/io/metersphere/controller/ProjectController.java index fa67a7de67..32ec2477d7 100644 --- a/backend/src/main/java/io/metersphere/controller/ProjectController.java +++ b/backend/src/main/java/io/metersphere/controller/ProjectController.java @@ -7,6 +7,7 @@ import io.metersphere.commons.constants.RoleConstants; import io.metersphere.commons.utils.PageUtils; import io.metersphere.commons.utils.Pager; import io.metersphere.controller.request.ProjectRequest; +import io.metersphere.dto.ProjectDTO; import io.metersphere.service.ProjectService; import io.metersphere.user.SessionUtils; import org.apache.shiro.authz.annotation.Logical; @@ -23,7 +24,7 @@ public class ProjectController { private ProjectService projectService; @GetMapping("/listAll") - public List listAll() { + public List listAll() { String currentWorkspaceId = SessionUtils.getCurrentWorkspaceId(); ProjectRequest request = new ProjectRequest(); request.setWorkspaceId(currentWorkspaceId); @@ -49,7 +50,7 @@ public class ProjectController { @PostMapping("/list/{goPage}/{pageSize}") @RequiresRoles(RoleConstants.TEST_MANAGER) - public Pager> getProjectList(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody ProjectRequest request) { + public Pager> getProjectList(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody ProjectRequest request) { request.setWorkspaceId(SessionUtils.getCurrentWorkspaceId()); Page page = PageHelper.startPage(goPage, pageSize, true); return PageUtils.setPageInfo(page, projectService.getProjectList(request)); diff --git a/backend/src/main/java/io/metersphere/dto/ProjectDTO.java b/backend/src/main/java/io/metersphere/dto/ProjectDTO.java new file mode 100644 index 0000000000..bf4482668c --- /dev/null +++ b/backend/src/main/java/io/metersphere/dto/ProjectDTO.java @@ -0,0 +1,68 @@ +package io.metersphere.dto; + +public class ProjectDTO { + + private String id; + private String name; + private String workspaceId; + private String workspaceName; + private String description; + private Long createTime; + private Long updateTime; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getWorkspaceId() { + return workspaceId; + } + + public void setWorkspaceId(String workspaceId) { + this.workspaceId = workspaceId; + } + + public String getWorkspaceName() { + return workspaceName; + } + + public void setWorkspaceName(String workspaceName) { + this.workspaceName = workspaceName; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Long getCreateTime() { + return createTime; + } + + public void setCreateTime(Long createTime) { + this.createTime = createTime; + } + + public Long getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Long updateTime) { + this.updateTime = updateTime; + } +} diff --git a/backend/src/main/java/io/metersphere/service/ProjectService.java b/backend/src/main/java/io/metersphere/service/ProjectService.java index 4cfe911cec..39b07b1ce0 100644 --- a/backend/src/main/java/io/metersphere/service/ProjectService.java +++ b/backend/src/main/java/io/metersphere/service/ProjectService.java @@ -3,10 +3,13 @@ package io.metersphere.service; import io.metersphere.base.domain.Project; import io.metersphere.base.domain.ProjectExample; import io.metersphere.base.mapper.ProjectMapper; +import io.metersphere.base.mapper.ext.ExtProjectMapper; import io.metersphere.commons.exception.MSException; import io.metersphere.controller.request.ProjectRequest; +import io.metersphere.dto.ProjectDTO; import io.metersphere.user.SessionUtils; import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -19,6 +22,8 @@ import java.util.UUID; public class ProjectService { @Resource private ProjectMapper projectMapper; + @Resource + private ExtProjectMapper extProjectMapper; public Project addProject(Project project) { if (StringUtils.isBlank(project.getName())) { @@ -41,13 +46,8 @@ public class ProjectService { return project; } - public List getProjectList(ProjectRequest request) { - ProjectExample example = new ProjectExample(); - ProjectExample.Criteria criteria = example.createCriteria(); - if (StringUtils.isNotBlank(request.getWorkspaceId())) { - criteria.andWorkspaceIdEqualTo(request.getWorkspaceId()); - } - return projectMapper.selectByExample(example); + public List getProjectList(ProjectRequest request) { + return extProjectMapper.getProjectWithWorkspace(request); } public void deleteProject(String projectId) { diff --git a/frontend/src/i18n/en-US.js b/frontend/src/i18n/en-US.js index e2a08a4630..f5ddc24327 100644 --- a/frontend/src/i18n/en-US.js +++ b/frontend/src/i18n/en-US.js @@ -58,6 +58,8 @@ export default { 'delete_confirm': 'Are you sure you want to delete this project?', 'search_by_name': 'Search by name', 'input_name': 'Please enter a workspace name', + 'owning_workspace': 'Owning Workspace', + 'please_choose_workspace': 'Please select Workspace', }, member: { 'create': 'Create', diff --git a/frontend/src/i18n/zh-CN.js b/frontend/src/i18n/zh-CN.js index f33f5a6ba3..f312b2092e 100644 --- a/frontend/src/i18n/zh-CN.js +++ b/frontend/src/i18n/zh-CN.js @@ -35,7 +35,7 @@ export default { workspace: { 'create': '创建工作空间', 'update': '修改工作空间', - 'delete_confirm': '这个工作空间确定要删除吗?', + 'delete_confirm': '删除工作空间会级联删除该工作空间下的资源,确定要删除吗?', 'add': '添加工作空间', 'input_name': '请输入工作空间名称', 'search_by_name': '根据名称搜索', @@ -58,6 +58,8 @@ export default { 'delete_confirm': '这个项目确定要删除吗?', 'search_by_name': '根据名称搜索', 'input_name': '请输入项目名称', + 'owning_workspace': '所属工作空间', + 'please_choose_workspace': '选择工作空间', }, member: { 'create': '添加成员', diff --git a/frontend/src/performance/components/project/MsProject.vue b/frontend/src/performance/components/project/MsProject.vue index 4b292c96a8..a8995bc0f5 100644 --- a/frontend/src/performance/components/project/MsProject.vue +++ b/frontend/src/performance/components/project/MsProject.vue @@ -18,6 +18,7 @@ +