fix(缺陷管理): 第三方平台缺陷生成日志名称有误

--bug=1044337 --user=宋昌昌 【缺陷管理】项目集成jira-查看缺陷-基本信息-快捷编辑-生成系统日志-名称为空 https://www.tapd.cn/55049933/s/1552745
This commit is contained in:
song-cc-rock 2024-07-23 15:08:39 +08:00 committed by Craftsman
parent 719a13786e
commit 1342a56ff5
2 changed files with 20 additions and 5 deletions

View File

@ -3,6 +3,7 @@ package io.metersphere.bug.service;
import io.metersphere.bug.domain.Bug;
import io.metersphere.bug.domain.BugContent;
import io.metersphere.bug.dto.request.BugEditRequest;
import io.metersphere.bug.dto.response.BugCustomFieldDTO;
import io.metersphere.bug.dto.response.BugDTO;
import io.metersphere.bug.mapper.BugContentMapper;
import io.metersphere.bug.mapper.BugMapper;
@ -13,6 +14,7 @@ import io.metersphere.system.log.constants.OperationLogModule;
import io.metersphere.system.log.constants.OperationLogType;
import io.metersphere.system.log.dto.LogDTO;
import jakarta.annotation.Resource;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
@ -39,7 +41,7 @@ public class BugLogService {
* @return 日志
*/
public LogDTO addLog(BugEditRequest request, List<MultipartFile> files) {
LogDTO dto = new LogDTO(request.getProjectId(), null, null, null, OperationLogType.ADD.name(), OperationLogModule.BUG_MANAGEMENT_INDEX, request.getTitle());
LogDTO dto = new LogDTO(request.getProjectId(), null, null, null, OperationLogType.ADD.name(), OperationLogModule.BUG_MANAGEMENT_INDEX, getPlatformTitle(request));
dto.setHistory(true);
dto.setPath("/bug/add");
dto.setMethod(HttpMethodConstants.POST.name());
@ -56,7 +58,7 @@ public class BugLogService {
*/
public LogDTO updateLog(BugEditRequest request, List<MultipartFile> files) {
BugDTO history = getOriginalValue(request.getId());
LogDTO dto = new LogDTO(request.getProjectId(), null, request.getId(), null, OperationLogType.UPDATE.name(), OperationLogModule.BUG_MANAGEMENT_INDEX, request.getTitle());
LogDTO dto = new LogDTO(request.getProjectId(), null, request.getId(), null, OperationLogType.UPDATE.name(), OperationLogModule.BUG_MANAGEMENT_INDEX, getPlatformTitle(request));
dto.setHistory(true);
dto.setPath("/bug/update");
dto.setMethod(HttpMethodConstants.POST.name());
@ -123,4 +125,14 @@ public class BugLogService {
// 缺陷自定义字段
return bugService.handleCustomField(List.of(originalBug), originalBug.getProjectId()).getFirst();
}
/**
* 获取缺陷的标题
* @param request 请求参数
* @return 缺陷标题
*/
private String getPlatformTitle(BugEditRequest request) {
BugCustomFieldDTO platformTitle = request.getCustomFields().stream().filter(field -> StringUtils.equalsAny(field.getId(), "summary")).findFirst().get();
return StringUtils.isNotBlank(request.getTitle()) ? request.getTitle() : platformTitle.getValue();
}
}

View File

@ -350,9 +350,12 @@
} else if (item.type === 'INT' || item.type === 'FLOAT') {
tmpObj[item.id] = Number(item.value);
} else if (item.type === 'CASCADER') {
const arr = JSON.parse(item.value);
if (arr && arr instanceof Array && arr.length > 0) {
tmpObj[item.id] = arr[arr.length - 1];
console.log(item.value === '');
if (item.value !== '') {
const arr = JSON.parse(item.value);
if (arr && arr instanceof Array && arr.length > 0) {
tmpObj[item.id] = arr[arr.length - 1];
}
}
} else if (SINGLE_TYPE.includes(item.type)) {
const multipleOptions = getOptionFromTemplate(