From 73957bbab905d527de230b3e5a67454019cefe19 Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Wed, 3 Nov 2021 11:51:13 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20--bug=3D1007573=20--user=3D=E9=99=88?= =?UTF-8?q?=E5=BB=BA=E6=98=9F=20=E3=80=90=E7=B3=BB=E7=BB=9F=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E3=80=91=E5=9C=A8=E5=85=B6=E4=BB=96=E7=A9=BA=E9=97=B4?= =?UTF-8?q?=E4=B8=AD=E8=87=AA=E5=AE=9A=E4=B9=89=E7=9A=84=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E4=BC=9A=E5=9C=A8=E5=85=B6=E4=BB=96=E7=A9=BA=E9=97=B4=E7=9A=84?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B=E6=A8=A1=E7=89=88=E4=B8=AD?= =?UTF-8?q?=E5=B1=95=E7=8E=B0=20https://www.tapd.cn/55049933/s/1063447?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ProjectController.java | 4 ---- .../service/IssueTemplateService.java | 2 +- .../io/metersphere/service/ProjectService.java | 17 +++++++++++++---- .../service/TestCaseTemplateService.java | 2 +- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/backend/src/main/java/io/metersphere/controller/ProjectController.java b/backend/src/main/java/io/metersphere/controller/ProjectController.java index 3235f6e876..88955a7987 100644 --- a/backend/src/main/java/io/metersphere/controller/ProjectController.java +++ b/backend/src/main/java/io/metersphere/controller/ProjectController.java @@ -5,7 +5,6 @@ import com.github.pagehelper.PageHelper; import io.metersphere.api.service.ApiTestEnvironmentService; import io.metersphere.base.domain.FileMetadata; import io.metersphere.base.domain.Project; -import io.metersphere.base.domain.UserGroup; import io.metersphere.commons.constants.OperLogConstants; import io.metersphere.commons.utils.PageUtils; import io.metersphere.commons.utils.Pager; @@ -17,16 +16,13 @@ import io.metersphere.dto.WorkspaceMemberDTO; import io.metersphere.log.annotation.MsAuditLog; import io.metersphere.service.CheckPermissionService; import io.metersphere.service.ProjectService; -import org.apache.commons.lang3.StringUtils; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import java.util.Collection; -import java.util.HashMap; import java.util.List; -import java.util.stream.Collectors; @RestController @RequestMapping(value = "/project") diff --git a/backend/src/main/java/io/metersphere/service/IssueTemplateService.java b/backend/src/main/java/io/metersphere/service/IssueTemplateService.java index 84c0a66447..5a5bdbef26 100644 --- a/backend/src/main/java/io/metersphere/service/IssueTemplateService.java +++ b/backend/src/main/java/io/metersphere/service/IssueTemplateService.java @@ -82,7 +82,7 @@ public class IssueTemplateService extends TemplateBaseService { String originId = request.getId(); // 如果是全局字段,则创建对应工作空间字段 String id = add(request); - projectService.updateIssueTemplate(originId, id); + projectService.updateIssueTemplate(originId, id, request.getWorkspaceId()); } else { checkExist(request); customFieldTemplateService.deleteByTemplateId(request.getId()); diff --git a/backend/src/main/java/io/metersphere/service/ProjectService.java b/backend/src/main/java/io/metersphere/service/ProjectService.java index f7a42b8468..89c946a264 100644 --- a/backend/src/main/java/io/metersphere/service/ProjectService.java +++ b/backend/src/main/java/io/metersphere/service/ProjectService.java @@ -214,21 +214,30 @@ public class ProjectService { userGroupMapper.deleteByExample(userGroupExample); } - public void updateIssueTemplate(String originId, String templateId) { + public void updateIssueTemplate(String originId, String templateId, String workspaceId) { Project project = new Project(); project.setIssueTemplateId(templateId); ProjectExample example = new ProjectExample(); example.createCriteria() - .andIssueTemplateIdEqualTo(originId); + .andIssueTemplateIdEqualTo(originId) + .andWorkspaceIdEqualTo(workspaceId); projectMapper.updateByExampleSelective(project, example); } - public void updateCaseTemplate(String originId, String templateId) { + /** + * 把原来为系统模板的项目模板设置成新的模板 + * 只设置改工作空间下的 + * @param originId + * @param templateId + * @param workspaceId + */ + public void updateCaseTemplate(String originId, String templateId, String workspaceId) { Project project = new Project(); project.setCaseTemplateId(templateId); ProjectExample example = new ProjectExample(); example.createCriteria() - .andCaseTemplateIdEqualTo(originId); + .andCaseTemplateIdEqualTo(originId) + .andWorkspaceIdEqualTo(workspaceId); projectMapper.updateByExampleSelective(project, example); } diff --git a/backend/src/main/java/io/metersphere/service/TestCaseTemplateService.java b/backend/src/main/java/io/metersphere/service/TestCaseTemplateService.java index 688c4673e4..497fdfdaaa 100644 --- a/backend/src/main/java/io/metersphere/service/TestCaseTemplateService.java +++ b/backend/src/main/java/io/metersphere/service/TestCaseTemplateService.java @@ -82,7 +82,7 @@ public class TestCaseTemplateService extends TemplateBaseService { String originId = request.getId(); // 如果是全局字段,则创建对应工作空间字段 String id = add(request); - projectService.updateCaseTemplate(originId, id); + projectService.updateCaseTemplate(originId, id, request.getWorkspaceId()); } else { checkExist(request); customFieldTemplateService.deleteByTemplateId(request.getId());