From f8b29d0b2fd7e8d0bcfda2c6f4aa0bd82be98d97 Mon Sep 17 00:00:00 2001 From: CrazyIter_Bin Date: Fri, 30 Aug 2024 14:59:34 +0800 Subject: [PATCH] updaye --- pom.xml | 8 ++++---- .../admin/service/impl/CommonServiceImpl.java | 10 +++++++--- .../controller/admin/service/impl/ExamServiceImpl.java | 5 ----- .../java/cn/teammodel/model/entity/common/Comment.java | 4 ++++ .../cn/teammodel/repository/CommentRepository.java | 4 ++-- .../teammodel/service/impl/ChatMessageServiceImpl.java | 5 +++-- 6 files changed, 20 insertions(+), 16 deletions(-) diff --git a/pom.xml b/pom.xml index c99e6b2..f004316 100644 --- a/pom.xml +++ b/pom.xml @@ -118,17 +118,17 @@ - + - + org.springframework.boot 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 7a8451b..210f737 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,7 +112,7 @@ public class CommonServiceImpl implements CommonService { @Override public Comment saveOrUpdateComment(Comment comment) { - List comments = commentRepository.findById(comment.getId(),comment.getSchool(),comment.getActivityType()); + List comments = commentRepository.findById(comment.getId(),comment.getSchool(),comment.getActivityType(),comment.getCode()); Comment existingComment = comments.stream().findFirst().orElse(null); if (existingComment != null) { // 如果评论对象存在,则进行更新操作 @@ -125,7 +125,11 @@ public class CommonServiceImpl implements CommonService { return commentRepository.save(existingComment); } else { // 如果评论对象不存在,则创建新的记录 - comment.setCode("Comment-"+ comment.getSchool()); + String formattedString = String.format("Comment-%s-%s-%s", + comment.getSchool(), + comment.getYear(), + comment.getSemester()); + comment.setCode(formattedString); comment.setCreateTime(Instant.now().toEpochMilli()); return commentRepository.save(comment); } @@ -141,6 +145,6 @@ public class CommonServiceImpl implements CommonService { @Override public List getCommentById(Comment comment) { - return commentRepository.findById(comment.getId(),comment.getSchool(),comment.getActivityType()); + return commentRepository.findById(comment.getId(),comment.getSchool(),comment.getActivityType(),comment.getCode()); } } 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 8bad3eb..f7b80d8 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 @@ -3,14 +3,9 @@ package cn.teammodel.controller.admin.service.impl; import cn.teammodel.common.ErrorCode; import cn.teammodel.config.exception.ServiceException; import cn.teammodel.controller.admin.service.ExamService; -import cn.teammodel.model.dto.admin.common.RGroupList; 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; import org.springframework.core.env.Environment; import org.springframework.stereotype.Service; 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 d0acbc5..ffc3667 100644 --- a/src/main/java/cn/teammodel/model/entity/common/Comment.java +++ b/src/main/java/cn/teammodel/model/entity/common/Comment.java @@ -28,6 +28,10 @@ public class Comment extends BaseItem { private int ttl = -1; private Long createTime; private Long updateTime; + @ApiModelProperty("学年") + private int year; + @ApiModelProperty("当前学年所处第几学期") + private int semester; @Data public static class ContentInfo { @ApiModelProperty("评论内容") diff --git a/src/main/java/cn/teammodel/repository/CommentRepository.java b/src/main/java/cn/teammodel/repository/CommentRepository.java index cddfcf4..9087efa 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 and s.activityType = @activityType ") - List findById(@Param("id") String id, @Param("school") String school,@Param("activityType") String activityType); + @Query("select * from Comment as s where s.id = @id and s.pk = 'Comment' and s.school = @school and s.activityType = @activityType and s.code = @code ") + List findById(@Param("id") String id, @Param("school") String school,@Param("activityType") String activityType,@Param("code") String code); } diff --git a/src/main/java/cn/teammodel/service/impl/ChatMessageServiceImpl.java b/src/main/java/cn/teammodel/service/impl/ChatMessageServiceImpl.java index ba721a0..66505e6 100644 --- a/src/main/java/cn/teammodel/service/impl/ChatMessageServiceImpl.java +++ b/src/main/java/cn/teammodel/service/impl/ChatMessageServiceImpl.java @@ -97,9 +97,10 @@ public class ChatMessageServiceImpl implements ChatMessageService { } return sseEmitter; } catch (Exception e) { - log.info(e.getStackTrace().toString()); - throw new ServiceException(ErrorCode.OPERATION_ERROR.getCode(), e.getStackTrace().toString()); + log.error(e.getMessage()+ e.getStackTrace().toString()); + throw new ServiceException(ErrorCode.OPERATION_ERROR.getCode(), e.getMessage()+ e.getStackTrace().toString()); } + } /**