|
|
@ -112,7 +112,11 @@ 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(),comment.getCode());
|
|
|
|
String formattedString = String.format("Comment-%s-%s-%s",
|
|
|
|
|
|
|
|
comment.getSchool(),
|
|
|
|
|
|
|
|
comment.getYear(),
|
|
|
|
|
|
|
|
comment.getSemester());
|
|
|
|
|
|
|
|
List<Comment> comments = commentRepository.findById(comment.getId(),comment.getSchool(),comment.getActivityType(),formattedString);
|
|
|
|
Comment existingComment = comments.stream().findFirst().orElse(null);
|
|
|
|
Comment existingComment = comments.stream().findFirst().orElse(null);
|
|
|
|
if (existingComment != null) {
|
|
|
|
if (existingComment != null) {
|
|
|
|
// 如果评论对象存在,则进行更新操作
|
|
|
|
// 如果评论对象存在,则进行更新操作
|
|
|
@ -125,10 +129,7 @@ public class CommonServiceImpl implements CommonService {
|
|
|
|
return commentRepository.save(existingComment);
|
|
|
|
return commentRepository.save(existingComment);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
// 如果评论对象不存在,则创建新的记录
|
|
|
|
// 如果评论对象不存在,则创建新的记录
|
|
|
|
String formattedString = String.format("Comment-%s-%s-%s",
|
|
|
|
|
|
|
|
comment.getSchool(),
|
|
|
|
|
|
|
|
comment.getYear(),
|
|
|
|
|
|
|
|
comment.getSemester());
|
|
|
|
|
|
|
|
comment.setCode(formattedString);
|
|
|
|
comment.setCode(formattedString);
|
|
|
|
comment.setCreateTime(Instant.now().toEpochMilli());
|
|
|
|
comment.setCreateTime(Instant.now().toEpochMilli());
|
|
|
|
return commentRepository.save(comment);
|
|
|
|
return commentRepository.save(comment);
|
|
|
@ -145,6 +146,10 @@ 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(),comment.getCode());
|
|
|
|
String formattedString = String.format("Comment-%s-%s-%s",
|
|
|
|
|
|
|
|
comment.getSchool(),
|
|
|
|
|
|
|
|
comment.getYear(),
|
|
|
|
|
|
|
|
comment.getSemester());
|
|
|
|
|
|
|
|
return commentRepository.findById(comment.getId(),comment.getSchool(),comment.getActivityType(),formattedString);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|