Merge remote-tracking branch 'origin/develop' into develop

develop
PL 4 months ago
commit 8eba7eb8dc

@ -112,15 +112,15 @@ 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()); List<Comment> comments = commentRepository.findById(comment.getId(),comment.getSchool(),comment.getActivityType());
Comment existingComment = comments.stream().findFirst().orElse(null); Comment existingComment = comments.stream().findFirst().orElse(null);
if (existingComment != null) { if (existingComment != null) {
// 如果评论对象存在,则进行更新操作 // 如果评论对象存在,则进行更新操作
// 这里你可以根据需要更新评论对象的属性 // 这里你可以根据需要更新评论对象的属性
existingComment.setContent(comment.getContent()); existingComment.setContentInfo(comment.getContentInfo());
existingComment.setUpdateTime(Instant.now().toEpochMilli()); 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); return commentRepository.save(existingComment);
} else { } else {
@ -141,6 +141,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()); 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.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.JSON;
import com.alibaba.fastjson.TypeReference; import com.alibaba.fastjson.TypeReference;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -35,6 +36,8 @@ public class ExamServiceImpl implements ExamService {
try { try {
overView = GroupUtil.getGroupId(overViewDto,new GroupUtil(env), request,url); overView = GroupUtil.getGroupId(overViewDto,new GroupUtil(env), request,url);
examRate = GroupUtil.getGroupId(overViewDto,new GroupUtil(env), request,url_exam); examRate = GroupUtil.getGroupId(overViewDto,new GroupUtil(env), request,url_exam);
//SnowflakeIdGenerator generator = new SnowflakeIdGenerator(1);
//overView.put("reportId",generator.nextId());
overView.putAll(examRate); overView.putAll(examRate);
//获取所有考试数据 //获取所有考试数据
//List<Exam> exams = examRepository.findExamByClassId("Exam-"+overViewDto.getSchool(),overViewDto.getClassId(),overViewDto.getPeriodId()); //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.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import java.util.List;
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@Container(containerName = "Common") @Container(containerName = "Common")
@Data @Data
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_NULL)
public class Comment extends BaseItem { public class Comment extends BaseItem {
@ApiModelProperty("活动内容")
private String content;
private String creatorId; private String creatorId;
private String creatorName; private String creatorName;
@ApiModelProperty("学校编码") @ApiModelProperty("学校编码")
@ -23,11 +23,17 @@ public class Comment extends BaseItem {
private String activityId; private String activityId;
@ApiModelProperty("活动类型") @ApiModelProperty("活动类型")
private String activityType; private String activityType;
@ApiModelProperty("评论类型") private List<ContentInfo> contentInfo;
private String contentType;
private String pk = "Comment"; private String pk = "Comment";
private int ttl = -1; private int ttl = -1;
private Long createTime; private Long createTime;
private Long updateTime; 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 @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 ") @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); List<Comment> findById(@Param("id") String id, @Param("school") String school,@Param("activityType") String activityType);
} }

Loading…
Cancel
Save