调整评语结构

develop
zhouj1203@hotmail.com 4 months ago
parent e5b87627cf
commit 1fdc914ed6

@ -112,15 +112,15 @@ public class CommonServiceImpl implements CommonService {
@Override
public Comment saveOrUpdateComment(Comment comment) {
List<Comment> comments = commentRepository.findById(comment.getId(),comment.getSchool());
List<Comment> 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<Comment> getCommentById(Comment comment) {
return commentRepository.findById(comment.getId(),comment.getSchool());
return commentRepository.findById(comment.getId(),comment.getSchool(),comment.getActivityType());
}
}

@ -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<Exam> exams = examRepository.findExamByClassId("Exam-"+overViewDto.getSchool(),overViewDto.getClassId(),overViewDto.getPeriodId());

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

@ -13,7 +13,7 @@ import java.util.List;
@Repository
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 ")
List<Comment> 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<Comment> findById(@Param("id") String id, @Param("school") String school,@Param("activityType") String activityType);
}

Loading…
Cancel
Save