develop
CrazyIter_Bin 4 months ago
parent 1fdc914ed6
commit f8b29d0b2f

@ -118,17 +118,17 @@
</dependency> </dependency>
<!-- 修改后的jjwt --> <!-- 修改后的jjwt -->
<dependency> <!-- <dependency>
<groupId>jsonwebtoken</groupId> <groupId>jsonwebtoken</groupId>
<artifactId>habook-jjwt</artifactId> <artifactId>habook-jjwt</artifactId>
<version>0.0.1</version> <version>0.0.1</version>
</dependency> </dependency>-->
<!--<dependency> <dependency>
<groupId>io.jsonwebtoken</groupId> <groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId> <artifactId>jjwt</artifactId>
<version>0.9.1</version> <version>0.9.1</version>
</dependency>--> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>

@ -112,7 +112,7 @@ public class CommonServiceImpl implements CommonService {
@Override @Override
public Comment saveOrUpdateComment(Comment comment) { public Comment saveOrUpdateComment(Comment comment) {
List<Comment> comments = commentRepository.findById(comment.getId(),comment.getSchool(),comment.getActivityType()); List<Comment> comments = commentRepository.findById(comment.getId(),comment.getSchool(),comment.getActivityType(),comment.getCode());
Comment existingComment = comments.stream().findFirst().orElse(null); Comment existingComment = comments.stream().findFirst().orElse(null);
if (existingComment != null) { if (existingComment != null) {
// 如果评论对象存在,则进行更新操作 // 如果评论对象存在,则进行更新操作
@ -125,7 +125,11 @@ public class CommonServiceImpl implements CommonService {
return commentRepository.save(existingComment); return commentRepository.save(existingComment);
} else { } 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()); comment.setCreateTime(Instant.now().toEpochMilli());
return commentRepository.save(comment); return commentRepository.save(comment);
} }
@ -141,6 +145,6 @@ public class CommonServiceImpl implements CommonService {
@Override @Override
public List<Comment> getCommentById(Comment comment) { public List<Comment> getCommentById(Comment comment) {
return commentRepository.findById(comment.getId(),comment.getSchool(),comment.getActivityType()); return commentRepository.findById(comment.getId(),comment.getSchool(),comment.getActivityType(),comment.getCode());
} }
} }

@ -3,14 +3,9 @@ package cn.teammodel.controller.admin.service.impl;
import cn.teammodel.common.ErrorCode; import cn.teammodel.common.ErrorCode;
import cn.teammodel.config.exception.ServiceException; import cn.teammodel.config.exception.ServiceException;
import cn.teammodel.controller.admin.service.ExamService; 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.dto.admin.exam.OverViewDto;
import cn.teammodel.model.entity.common.Exam;
import cn.teammodel.repository.ExamRepository; import cn.teammodel.repository.ExamRepository;
import cn.teammodel.utils.GroupUtil; 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.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment; import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;

@ -28,6 +28,10 @@ public class Comment extends BaseItem {
private int ttl = -1; private int ttl = -1;
private Long createTime; private Long createTime;
private Long updateTime; private Long updateTime;
@ApiModelProperty("学年")
private int year;
@ApiModelProperty("当前学年所处第几学期")
private int semester;
@Data @Data
public static class ContentInfo { public static class ContentInfo {
@ApiModelProperty("评论内容") @ApiModelProperty("评论内容")

@ -13,7 +13,7 @@ import java.util.List;
@Repository @Repository
public interface CommentRepository extends CosmosRepository<Comment, String> { public interface CommentRepository extends CosmosRepository<Comment, String> {
@Query("select * from Comment as s where s.id = @id and s.pk = 'Comment' and s.school = @school and s.activityType = @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<Comment> findById(@Param("id") String id, @Param("school") String school,@Param("activityType") String activityType); List<Comment> findById(@Param("id") String id, @Param("school") String school,@Param("activityType") String activityType,@Param("code") String code);
} }

@ -97,9 +97,10 @@ public class ChatMessageServiceImpl implements ChatMessageService {
} }
return sseEmitter; return sseEmitter;
} catch (Exception e) { } catch (Exception e) {
log.info(e.getStackTrace().toString()); log.error(e.getMessage()+ e.getStackTrace().toString());
throw new ServiceException(ErrorCode.OPERATION_ERROR.getCode(), e.getStackTrace().toString()); throw new ServiceException(ErrorCode.OPERATION_ERROR.getCode(), e.getMessage()+ e.getStackTrace().toString());
} }
} }
/** /**

Loading…
Cancel
Save