fix: 项目模板显示id问题

This commit is contained in:
chenjianxing 2021-05-25 21:29:50 +08:00 committed by jianxing
parent 151fe95722
commit 8771f82029
4 changed files with 29 additions and 5 deletions

View File

@ -47,7 +47,7 @@ public class IssueTemplateService extends TemplateBaseService {
@Resource @Resource
ProjectService projectService; ProjectService projectService;
public void add(UpdateIssueTemplateRequest request) { public String add(UpdateIssueTemplateRequest request) {
checkExist(request); checkExist(request);
IssueTemplate template = new IssueTemplate(); IssueTemplate template = new IssueTemplate();
BeanUtils.copyBean(template, request); BeanUtils.copyBean(template, request);
@ -63,6 +63,7 @@ public class IssueTemplateService extends TemplateBaseService {
issueTemplateMapper.insert(template); issueTemplateMapper.insert(template);
customFieldTemplateService.create(request.getCustomFields(), template.getId(), customFieldTemplateService.create(request.getCustomFields(), template.getId(),
TemplateConstants.FieldTemplateScene.ISSUE.name()); TemplateConstants.FieldTemplateScene.ISSUE.name());
return template.getId();
} }
public List<IssueTemplate> list(BaseQueryRequest request) { public List<IssueTemplate> list(BaseQueryRequest request) {
@ -78,8 +79,10 @@ public class IssueTemplateService extends TemplateBaseService {
public void update(UpdateIssueTemplateRequest request) { public void update(UpdateIssueTemplateRequest request) {
if (request.getGlobal() != null && request.getGlobal()) { if (request.getGlobal() != null && request.getGlobal()) {
String originId = request.getId();
// 如果是全局字段则创建对应工作空间字段 // 如果是全局字段则创建对应工作空间字段
add(request); String id = add(request);
projectService.updateIssueTemplate(originId, id);
} else { } else {
checkExist(request); checkExist(request);
customFieldTemplateService.deleteByTemplateId(request.getId()); customFieldTemplateService.deleteByTemplateId(request.getId());

View File

@ -151,6 +151,24 @@ public class ProjectService {
userGroupMapper.deleteByExample(userGroupExample); userGroupMapper.deleteByExample(userGroupExample);
} }
public void updateIssueTemplate(String originId, String templateId) {
Project project = new Project();
project.setIssueTemplateId(templateId);
ProjectExample example = new ProjectExample();
example.createCriteria()
.andIssueTemplateIdEqualTo(originId);
projectMapper.updateByExampleSelective(project, example);
}
public void updateCaseTemplate(String originId, String templateId) {
Project project = new Project();
project.setCaseTemplateId(templateId);
ProjectExample example = new ProjectExample();
example.createCriteria()
.andCaseTemplateIdEqualTo(originId);
projectMapper.updateByExampleSelective(project, example);
}
private void deleteLoadTestResourcesByProjectId(String projectId) { private void deleteLoadTestResourcesByProjectId(String projectId) {
LoadTestExample loadTestExample = new LoadTestExample(); LoadTestExample loadTestExample = new LoadTestExample();
loadTestExample.createCriteria().andProjectIdEqualTo(projectId); loadTestExample.createCriteria().andProjectIdEqualTo(projectId);

View File

@ -46,7 +46,7 @@ public class TestCaseTemplateService extends TemplateBaseService {
@Resource @Resource
ProjectService projectService; ProjectService projectService;
public void add(UpdateCaseFieldTemplateRequest request) { public String add(UpdateCaseFieldTemplateRequest request) {
checkExist(request); checkExist(request);
TestCaseTemplateWithBLOBs testCaseTemplate = new TestCaseTemplateWithBLOBs(); TestCaseTemplateWithBLOBs testCaseTemplate = new TestCaseTemplateWithBLOBs();
BeanUtils.copyBean(testCaseTemplate, request); BeanUtils.copyBean(testCaseTemplate, request);
@ -62,6 +62,7 @@ public class TestCaseTemplateService extends TemplateBaseService {
testCaseTemplateMapper.insert(testCaseTemplate); testCaseTemplateMapper.insert(testCaseTemplate);
customFieldTemplateService.create(request.getCustomFields(), testCaseTemplate.getId(), customFieldTemplateService.create(request.getCustomFields(), testCaseTemplate.getId(),
TemplateConstants.FieldTemplateScene.TEST_CASE.name()); TemplateConstants.FieldTemplateScene.TEST_CASE.name());
return testCaseTemplate.getId();
} }
public List<TestCaseTemplateWithBLOBs> list(BaseQueryRequest request) { public List<TestCaseTemplateWithBLOBs> list(BaseQueryRequest request) {
@ -77,8 +78,10 @@ public class TestCaseTemplateService extends TemplateBaseService {
public void update(UpdateCaseFieldTemplateRequest request) { public void update(UpdateCaseFieldTemplateRequest request) {
if (request.getGlobal() != null && request.getGlobal()) { if (request.getGlobal() != null && request.getGlobal()) {
String originId = request.getId();
// 如果是全局字段则创建对应工作空间字段 // 如果是全局字段则创建对应工作空间字段
add(request); String id = add(request);
projectService.updateCaseTemplate(originId, id);
} else { } else {
checkExist(request); checkExist(request);
customFieldTemplateService.deleteByTemplateId(request.getId()); customFieldTemplateService.deleteByTemplateId(request.getId());

View File

@ -175,7 +175,7 @@ public abstract class AbstractIssuePlatform implements IssuesPlatform {
protected int getNextNum(String projectId) { protected int getNextNum(String projectId) {
Issues issue = extIssuesMapper.getNextNum(projectId); Issues issue = extIssuesMapper.getNextNum(projectId);
if (issue == null) { if (issue == null || issue.getNum() == null) {
return 100001; return 100001;
} else { } else {
return Optional.of(issue.getNum() + 1).orElse(100001); return Optional.of(issue.getNum() + 1).orElse(100001);