fix(测试跟踪): 更新缺陷模板字段操作日志有误

--bug=1018579 --user=宋昌昌 【系统设置】操纵日志-更新缺陷模版的操作日志详情错误 https://www.tapd.cn/55049933/s/1282001
This commit is contained in:
song-cc-rock 2022-10-28 14:19:37 +08:00 committed by 刘瑞斌
parent 8a61ad3e02
commit 6eea8535a6
2 changed files with 11 additions and 16 deletions

View File

@ -212,7 +212,7 @@ public class ReflexObjectUtil {
column.setDiffValue(ApiTestEnvironmentDiffUtil.diff(newValue, oldValue)); column.setDiffValue(ApiTestEnvironmentDiffUtil.diff(newValue, oldValue));
} }
} else { } else {
String newValue = Objects.toString(column.getNewValue().toString(), ""); String newValue = Objects.toString(column.getNewValue(), "");
if (StringUtils.isNotEmpty(newValue)) { if (StringUtils.isNotEmpty(newValue)) {
column.setNewValue(newValue.replaceAll("\\n", StringUtils.SPACE)); column.setNewValue(newValue.replaceAll("\\n", StringUtils.SPACE));
} }

View File

@ -448,7 +448,7 @@ public class IssueTemplateService extends TemplateBaseService {
return issueTemplateRecords; return issueTemplateRecords;
} }
public String getLogDetails(String id, List<CustomFieldTemplate> newCustomFieldTemplates) { public String getLogDetails(String id, List<CustomFieldTemplate> newFields) {
List<DetailColumn> columns = new LinkedList<>(); List<DetailColumn> columns = new LinkedList<>();
IssueTemplate templateWithBLOBs = issueTemplateMapper.selectByPrimaryKey(id); IssueTemplate templateWithBLOBs = issueTemplateMapper.selectByPrimaryKey(id);
if (templateWithBLOBs == null) { if (templateWithBLOBs == null) {
@ -457,16 +457,16 @@ public class IssueTemplateService extends TemplateBaseService {
CustomFieldTemplateExample example = new CustomFieldTemplateExample(); CustomFieldTemplateExample example = new CustomFieldTemplateExample();
example.createCriteria().andTemplateIdEqualTo(templateWithBLOBs.getId()); example.createCriteria().andTemplateIdEqualTo(templateWithBLOBs.getId());
example.createCriteria().andSceneEqualTo("ISSUE"); example.createCriteria().andSceneEqualTo("ISSUE");
List<CustomFieldTemplate> customFieldTemplates = customFieldTemplateMapper.selectByExample(example); List<CustomFieldTemplate> oldFields = customFieldTemplateMapper.selectByExample(example);
if (newCustomFieldTemplates.size() > customFieldTemplates.size()) { Collections.sort(oldFields, (f1, f2) -> f1.getKey().compareTo(f2.getKey()));
for (int i = 0; i < newCustomFieldTemplates.size() - customFieldTemplates.size(); i++) { if (newFields.size() > oldFields.size()) {
int size = newFields.size() - oldFields.size();
for (int i = 0; i < size; i++) {
CustomFieldTemplate customFieldTemplate = new CustomFieldTemplate(); CustomFieldTemplate customFieldTemplate = new CustomFieldTemplate();
customFieldTemplates.add(customFieldTemplate); oldFields.add(oldFields.size(), customFieldTemplate);
} }
} }
return getCustomFieldColums(columns, templateWithBLOBs, oldFields);
return getCustomFieldColums(columns, templateWithBLOBs, customFieldTemplates);
} }
public String getLogDetails(UpdateIssueTemplateRequest request) { public String getLogDetails(UpdateIssueTemplateRequest request) {
@ -480,13 +480,8 @@ public class IssueTemplateService extends TemplateBaseService {
example.createCriteria().andTemplateIdEqualTo(templateWithBLOBs.getId()); example.createCriteria().andTemplateIdEqualTo(templateWithBLOBs.getId());
example.createCriteria().andSceneEqualTo("ISSUE"); example.createCriteria().andSceneEqualTo("ISSUE");
List<CustomFieldTemplate> customFieldTemplates = customFieldTemplateMapper.selectByExample(example); List<CustomFieldTemplate> customFieldTemplates = customFieldTemplateMapper.selectByExample(example);
if (newCustomFieldTemplates.size() < customFieldTemplates.size()) { Collections.sort(customFieldTemplates, (f1, f2) -> f1.getKey().compareTo(f2.getKey()));
for (int i = 0; i < customFieldTemplates.size() - newCustomFieldTemplates.size(); i++) { return getCustomFieldColums(columns, templateWithBLOBs, customFieldTemplates);
CustomFieldTemplate customFieldTemplate = new CustomFieldTemplate();
newCustomFieldTemplates.add(customFieldTemplate);
}
}
return getCustomFieldColums(columns, templateWithBLOBs, newCustomFieldTemplates);
} }
private String getCustomFieldColums(List<DetailColumn> columns, IssueTemplate templateWithBLOBs, List<CustomFieldTemplate> customFields) { private String getCustomFieldColums(List<DetailColumn> columns, IssueTemplate templateWithBLOBs, List<CustomFieldTemplate> customFields) {