refactor(功能用例): 优化功能用例返回的评论结构
This commit is contained in:
parent
26e48a6319
commit
edc4bcc010
|
@ -1,6 +1,7 @@
|
||||||
package io.metersphere.functional.dto;
|
package io.metersphere.functional.dto;
|
||||||
|
|
||||||
import io.metersphere.functional.domain.FunctionalCaseComment;
|
import io.metersphere.functional.domain.FunctionalCaseComment;
|
||||||
|
import io.metersphere.system.dto.CommentUserInfo;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
@ -9,17 +10,8 @@ import java.util.List;
|
||||||
@Data
|
@Data
|
||||||
public class FunctionalCaseCommentDTO extends FunctionalCaseComment {
|
public class FunctionalCaseCommentDTO extends FunctionalCaseComment {
|
||||||
|
|
||||||
@Schema(description = "评论的人名")
|
@Schema(description = "评论相关用户信息")
|
||||||
private String userName;
|
private List<CommentUserInfo> commentUserInfos;
|
||||||
|
|
||||||
@Schema(description = "被回复的人名")
|
|
||||||
private String replyUserName;
|
|
||||||
|
|
||||||
@Schema(description = "被回复的人头像")
|
|
||||||
private String replyUserLogo;
|
|
||||||
|
|
||||||
@Schema(description = "评论的人头像")
|
|
||||||
private String userLogo;
|
|
||||||
|
|
||||||
@Schema(description = "该条评论下的所有回复数据")
|
@Schema(description = "该条评论下的所有回复数据")
|
||||||
private List<FunctionalCaseCommentDTO> childComments;
|
private List<FunctionalCaseCommentDTO> childComments;
|
||||||
|
|
|
@ -242,13 +242,19 @@ public class FunctionalCaseCommentService {
|
||||||
List<FunctionalCaseCommentDTO>list = new ArrayList<>();
|
List<FunctionalCaseCommentDTO>list = new ArrayList<>();
|
||||||
for (FunctionalCaseComment functionalCaseComment : functionalCaseComments) {
|
for (FunctionalCaseComment functionalCaseComment : functionalCaseComments) {
|
||||||
FunctionalCaseCommentDTO functionalCaseCommentDTO = new FunctionalCaseCommentDTO();
|
FunctionalCaseCommentDTO functionalCaseCommentDTO = new FunctionalCaseCommentDTO();
|
||||||
|
List<CommentUserInfo>commentUserInfos = new ArrayList<>();
|
||||||
BeanUtils.copyBean(functionalCaseCommentDTO,functionalCaseComment);
|
BeanUtils.copyBean(functionalCaseCommentDTO,functionalCaseComment);
|
||||||
functionalCaseCommentDTO.setUserName(userMap.get(functionalCaseComment.getCreateUser()).getName());
|
CommentUserInfo createUserInfo = userMap.get(functionalCaseComment.getCreateUser());
|
||||||
functionalCaseCommentDTO.setUserLogo(userMap.get(functionalCaseComment.getCreateUser()).getAvatar());
|
commentUserInfos.add(createUserInfo);
|
||||||
if (StringUtils.isNotBlank(functionalCaseComment.getReplyUser())) {
|
if (StringUtils.isNotBlank(functionalCaseComment.getReplyUser())) {
|
||||||
functionalCaseCommentDTO.setReplyUserName(userMap.get(functionalCaseComment.getReplyUser()).getName());
|
CommentUserInfo replyUserInfo = userMap.get(functionalCaseComment.getReplyUser());
|
||||||
functionalCaseCommentDTO.setReplyUserLogo(userMap.get(functionalCaseComment.getReplyUser()).getAvatar());
|
commentUserInfos.add(replyUserInfo);
|
||||||
}
|
}
|
||||||
|
if (StringUtils.isNotBlank(functionalCaseComment.getNotifier())) {
|
||||||
|
List<String> notifiers = Arrays.asList(functionalCaseComment.getNotifier().split(";"));
|
||||||
|
notifiers.forEach(t-> commentUserInfos.add(userMap.get(functionalCaseComment.getReplyUser())));
|
||||||
|
}
|
||||||
|
functionalCaseCommentDTO.setCommentUserInfos(commentUserInfos);
|
||||||
list.add(functionalCaseCommentDTO);
|
list.add(functionalCaseCommentDTO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,14 @@ package io.metersphere.system.dto;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class CommentUserInfo{
|
public class CommentUserInfo implements Serializable {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@Schema(description = "用户ID")
|
@Schema(description = "用户ID")
|
||||||
private String id;
|
private String id;
|
||||||
|
|
Loading…
Reference in New Issue