From 1fdc914ed6de95e7603ea6d9a2fdd21c3bc089cb Mon Sep 17 00:00:00 2001 From: "zhouj1203@hotmail.com" Date: Fri, 30 Aug 2024 12:11:02 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E8=AF=84=E8=AF=AD=E7=BB=93?= =?UTF-8?q?=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/service/impl/CommonServiceImpl.java | 8 ++++---- .../admin/service/impl/ExamServiceImpl.java | 3 +++ .../cn/teammodel/model/entity/common/Comment.java | 14 ++++++++++---- .../cn/teammodel/repository/CommentRepository.java | 4 ++-- 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/main/java/cn/teammodel/controller/admin/service/impl/CommonServiceImpl.java b/src/main/java/cn/teammodel/controller/admin/service/impl/CommonServiceImpl.java index 71eef44..7a8451b 100644 --- a/src/main/java/cn/teammodel/controller/admin/service/impl/CommonServiceImpl.java +++ b/src/main/java/cn/teammodel/controller/admin/service/impl/CommonServiceImpl.java @@ -112,15 +112,15 @@ public class CommonServiceImpl implements CommonService { @Override public Comment saveOrUpdateComment(Comment comment) { - List comments = commentRepository.findById(comment.getId(),comment.getSchool()); + List comments = commentRepository.findById(comment.getId(),comment.getSchool(),comment.getActivityType()); Comment existingComment = comments.stream().findFirst().orElse(null); if (existingComment != null) { // 如果评论对象存在,则进行更新操作 // 这里你可以根据需要更新评论对象的属性 - existingComment.setContent(comment.getContent()); + existingComment.setContentInfo(comment.getContentInfo()); existingComment.setUpdateTime(Instant.now().toEpochMilli()); - commentRepository.deleteById(existingComment.getId(),new PartitionKey(existingComment.getSchool())); + //commentRepository.deleteById(existingComment.getId(),new PartitionKey(existingComment.getSchool())); // 最后保存更新后的评论对象 return commentRepository.save(existingComment); } else { @@ -141,6 +141,6 @@ public class CommonServiceImpl implements CommonService { @Override public List getCommentById(Comment comment) { - return commentRepository.findById(comment.getId(),comment.getSchool()); + return commentRepository.findById(comment.getId(),comment.getSchool(),comment.getActivityType()); } } diff --git a/src/main/java/cn/teammodel/controller/admin/service/impl/ExamServiceImpl.java b/src/main/java/cn/teammodel/controller/admin/service/impl/ExamServiceImpl.java index fb2b4aa..8bad3eb 100644 --- a/src/main/java/cn/teammodel/controller/admin/service/impl/ExamServiceImpl.java +++ b/src/main/java/cn/teammodel/controller/admin/service/impl/ExamServiceImpl.java @@ -8,6 +8,7 @@ import cn.teammodel.model.dto.admin.exam.OverViewDto; import cn.teammodel.model.entity.common.Exam; import cn.teammodel.repository.ExamRepository; import cn.teammodel.utils.GroupUtil; +import cn.teammodel.utils.SnowflakeIdGenerator; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.TypeReference; import org.springframework.beans.factory.annotation.Autowired; @@ -35,6 +36,8 @@ public class ExamServiceImpl implements ExamService { try { overView = GroupUtil.getGroupId(overViewDto,new GroupUtil(env), request,url); examRate = GroupUtil.getGroupId(overViewDto,new GroupUtil(env), request,url_exam); + //SnowflakeIdGenerator generator = new SnowflakeIdGenerator(1); + //overView.put("reportId",generator.nextId()); overView.putAll(examRate); //获取所有考试数据 //List exams = examRepository.findExamByClassId("Exam-"+overViewDto.getSchool(),overViewDto.getClassId(),overViewDto.getPeriodId()); diff --git a/src/main/java/cn/teammodel/model/entity/common/Comment.java b/src/main/java/cn/teammodel/model/entity/common/Comment.java index 20e76e8..d0acbc5 100644 --- a/src/main/java/cn/teammodel/model/entity/common/Comment.java +++ b/src/main/java/cn/teammodel/model/entity/common/Comment.java @@ -7,13 +7,13 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; +import java.util.List; + @EqualsAndHashCode(callSuper = true) @Container(containerName = "Common") @Data @JsonInclude(JsonInclude.Include.NON_NULL) public class Comment extends BaseItem { - @ApiModelProperty("活动内容") - private String content; private String creatorId; private String creatorName; @ApiModelProperty("学校编码") @@ -23,11 +23,17 @@ public class Comment extends BaseItem { private String activityId; @ApiModelProperty("活动类型") private String activityType; - @ApiModelProperty("评论类型") - private String contentType; + private List contentInfo; private String pk = "Comment"; private int ttl = -1; private Long createTime; private Long updateTime; + @Data + public static class ContentInfo { + @ApiModelProperty("评论内容") + private String content; + @ApiModelProperty("评论类型") + private String contentType; + } } diff --git a/src/main/java/cn/teammodel/repository/CommentRepository.java b/src/main/java/cn/teammodel/repository/CommentRepository.java index 5f345a4..cddfcf4 100644 --- a/src/main/java/cn/teammodel/repository/CommentRepository.java +++ b/src/main/java/cn/teammodel/repository/CommentRepository.java @@ -13,7 +13,7 @@ import java.util.List; @Repository public interface CommentRepository extends CosmosRepository { - @Query("select * from Comment as s where s.id = @id and s.pk = 'Comment' and s.school = @school ") - List findById(@Param("id") String id, @Param("school") String school); + @Query("select * from Comment as s where s.id = @id and s.pk = 'Comment' and s.school = @school and s.activityType = @activityType ") + List findById(@Param("id") String id, @Param("school") String school,@Param("activityType") String activityType); }