parent
2a661ac7b3
commit
ccbb0da54c
|
@ -1,9 +1,8 @@
|
||||||
package io.metersphere.service;
|
package io.metersphere.service;
|
||||||
|
|
||||||
import io.metersphere.base.domain.*;
|
import io.metersphere.base.domain.CustomField;
|
||||||
|
import io.metersphere.base.domain.CustomFieldExample;
|
||||||
import io.metersphere.base.mapper.CustomFieldMapper;
|
import io.metersphere.base.mapper.CustomFieldMapper;
|
||||||
import io.metersphere.base.mapper.CustomFieldTemplateMapper;
|
|
||||||
import io.metersphere.base.mapper.ProjectMapper;
|
|
||||||
import io.metersphere.base.mapper.ext.BaseCustomFieldMapper;
|
import io.metersphere.base.mapper.ext.BaseCustomFieldMapper;
|
||||||
import io.metersphere.commons.constants.CustomFieldType;
|
import io.metersphere.commons.constants.CustomFieldType;
|
||||||
import io.metersphere.commons.utils.JSON;
|
import io.metersphere.commons.utils.JSON;
|
||||||
|
@ -30,11 +29,6 @@ public class BaseCustomFieldService {
|
||||||
@Resource
|
@Resource
|
||||||
CustomFieldMapper customFieldMapper;
|
CustomFieldMapper customFieldMapper;
|
||||||
|
|
||||||
@Resource
|
|
||||||
private ProjectMapper projectMapper;
|
|
||||||
@Resource
|
|
||||||
private CustomFieldTemplateMapper customFieldTemplateMapper;
|
|
||||||
|
|
||||||
public CustomField get(String id) {
|
public CustomField get(String id) {
|
||||||
return customFieldMapper.selectByPrimaryKey(id);
|
return customFieldMapper.selectByPrimaryKey(id);
|
||||||
}
|
}
|
||||||
|
@ -108,41 +102,13 @@ public class BaseCustomFieldService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public CustomField getCustomFieldByName(String projectId, String fieldName) {
|
public CustomField getCustomFieldByName(String projectId, String fieldName) {
|
||||||
Project project = projectMapper.selectByPrimaryKey(projectId);
|
|
||||||
if (project == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
String issueTemplateId = project.getIssueTemplateId();
|
|
||||||
if (StringUtils.isBlank(issueTemplateId)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
CustomFieldTemplateExample customFieldTemplateExample = new CustomFieldTemplateExample();
|
|
||||||
customFieldTemplateExample.createCriteria().andTemplateIdEqualTo(issueTemplateId);
|
|
||||||
List<CustomFieldTemplate> customFieldTemplates = customFieldTemplateMapper.selectByExample(customFieldTemplateExample);
|
|
||||||
if (CollectionUtils.isEmpty(customFieldTemplates)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<String> templateFieldIds = customFieldTemplates
|
|
||||||
.stream()
|
|
||||||
.map(CustomFieldTemplate::getFieldId)
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
|
|
||||||
CustomFieldExample example = new CustomFieldExample();
|
CustomFieldExample example = new CustomFieldExample();
|
||||||
example.createCriteria()
|
example.createCriteria()
|
||||||
.andProjectIdEqualTo(projectId)
|
.andProjectIdEqualTo(projectId)
|
||||||
.andNameEqualTo(fieldName);
|
.andNameEqualTo(fieldName);
|
||||||
|
|
||||||
List<CustomField> customFields = customFieldMapper.selectByExample(example);
|
List<CustomField> customFields = customFieldMapper.selectByExample(example);
|
||||||
if (CollectionUtils.isNotEmpty(customFields)) {
|
if (CollectionUtils.isNotEmpty(customFields)) {
|
||||||
for (CustomField customField : customFields) {
|
return customFields.get(0);
|
||||||
if (templateFieldIds.contains(customField.getId())) {
|
|
||||||
return customField;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
} else {
|
} else {
|
||||||
example.clear();
|
example.clear();
|
||||||
example.createCriteria()
|
example.createCriteria()
|
||||||
|
|
Loading…
Reference in New Issue