fix(缺陷管理): 评论富文本图片处理
--bug=1041226 --user=宋昌昌 【缺陷管理】缺陷评论富文本框中上传图片,查看评论图片,图片过期不显示 https://www.tapd.cn/55049933/s/1522342
This commit is contained in:
parent
718ec6c03e
commit
5bf0d63b01
|
@ -7,6 +7,7 @@ import jakarta.validation.constraints.NotBlank;
|
|||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class BugCommentEditRequest implements Serializable {
|
||||
|
@ -33,4 +34,7 @@ public class BugCommentEditRequest implements Serializable {
|
|||
@Schema(description = "任务事件(仅评论: ’COMMENT‘; 评论并@: ’AT‘; 回复评论/回复并@: ’REPLY‘;)", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "{bug_comment.event.not_blank}", groups = {Created.class})
|
||||
private String event;
|
||||
|
||||
@Schema(description = "富文本临时文件ID")
|
||||
private List<String> richTextTmpFileIds;
|
||||
}
|
||||
|
|
|
@ -9,5 +9,9 @@ public enum BugAttachmentSourceType {
|
|||
/**
|
||||
* 富文本
|
||||
*/
|
||||
RICH_TEXT
|
||||
RICH_TEXT,
|
||||
/**
|
||||
* 评论
|
||||
*/
|
||||
COMMENT
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import io.metersphere.bug.domain.BugCommentExample;
|
|||
import io.metersphere.bug.dto.request.BugCommentEditRequest;
|
||||
import io.metersphere.bug.dto.response.BugCommentDTO;
|
||||
import io.metersphere.bug.dto.response.BugCommentNoticeDTO;
|
||||
import io.metersphere.bug.enums.BugAttachmentSourceType;
|
||||
import io.metersphere.bug.mapper.BugCommentMapper;
|
||||
import io.metersphere.bug.mapper.BugMapper;
|
||||
import io.metersphere.sdk.exception.MSException;
|
||||
|
@ -37,6 +38,8 @@ public class BugCommentService {
|
|||
private BugCommentMapper bugCommentMapper;
|
||||
@Resource
|
||||
private BugCommentNoticeService bugCommentNoticeService;
|
||||
@Resource
|
||||
private BugAttachmentService bugAttachmentService;
|
||||
|
||||
/**
|
||||
* 获取缺陷评论
|
||||
|
@ -112,8 +115,10 @@ public class BugCommentService {
|
|||
* @return 缺陷评论
|
||||
*/
|
||||
public BugComment addComment(BugCommentEditRequest request, String currentUser) {
|
||||
checkBug(request.getBugId());
|
||||
Bug bug = checkBug(request.getBugId());
|
||||
BugComment bugComment = getBugComment(request, currentUser, false);
|
||||
// 评论富文本附件处理
|
||||
bugAttachmentService.transferTmpFile(bug.getId(), bug.getProjectId(), request.getRichTextTmpFileIds(), currentUser, BugAttachmentSourceType.COMMENT.name());
|
||||
if (StringUtils.equals(request.getEvent(), NoticeConstants.Event.REPLY)) {
|
||||
return addBugCommentAndReplyNotice(request, bugComment, currentUser);
|
||||
} else {
|
||||
|
@ -128,8 +133,11 @@ public class BugCommentService {
|
|||
* @return 缺陷评论
|
||||
*/
|
||||
public BugComment updateComment(BugCommentEditRequest request, String currentUser) {
|
||||
Bug bug = checkBug(request.getBugId());
|
||||
checkComment(request.getId(), currentUser);
|
||||
BugComment bugComment = getBugComment(request, currentUser, true);
|
||||
// 评论富文本附件处理
|
||||
bugAttachmentService.transferTmpFile(bug.getId(), bug.getProjectId(), request.getRichTextTmpFileIds(), currentUser, BugAttachmentSourceType.COMMENT.name());
|
||||
return updateBugCommentAndNotice(request, bugComment, currentUser);
|
||||
}
|
||||
|
||||
|
@ -262,11 +270,12 @@ public class BugCommentService {
|
|||
* 校验缺陷是否存在
|
||||
* @param bugId 缺陷ID
|
||||
*/
|
||||
private void checkBug(String bugId) {
|
||||
private Bug checkBug(String bugId) {
|
||||
Bug bug = bugMapper.selectByPrimaryKey(bugId);
|
||||
if (bug == null) {
|
||||
throw new IllegalArgumentException(Translator.get("bug_not_exist"));
|
||||
}
|
||||
return bug;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue