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); }