|
@@ -3,17 +3,21 @@ package com.hssx.pcbms.service.impl;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.hssx.pcbms.entity.Idea;
|
|
import com.hssx.pcbms.entity.Idea;
|
|
import com.hssx.pcbms.entity.IdeaComment;
|
|
import com.hssx.pcbms.entity.IdeaComment;
|
|
|
|
+import com.hssx.pcbms.entity.Score;
|
|
import com.hssx.pcbms.entity.User;
|
|
import com.hssx.pcbms.entity.User;
|
|
import com.hssx.pcbms.mapper.IdeaCommentMapper;
|
|
import com.hssx.pcbms.mapper.IdeaCommentMapper;
|
|
import com.hssx.pcbms.mapper.IdeaMapper;
|
|
import com.hssx.pcbms.mapper.IdeaMapper;
|
|
|
|
+import com.hssx.pcbms.mapper.ScoreMapper;
|
|
import com.hssx.pcbms.mapper.UserMapper;
|
|
import com.hssx.pcbms.mapper.UserMapper;
|
|
import com.hssx.pcbms.service.IdeaCommentService;
|
|
import com.hssx.pcbms.service.IdeaCommentService;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
+import com.hssx.pcbms.service.ScoreService;
|
|
import com.hssx.pcbms.util.HttpRespMsg;
|
|
import com.hssx.pcbms.util.HttpRespMsg;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
|
+import java.util.List;
|
|
|
|
|
|
/**
|
|
/**
|
|
* @author 吴涛涛
|
|
* @author 吴涛涛
|
|
@@ -28,6 +32,8 @@ public class IdeaCommentServiceImpl extends ServiceImpl<IdeaCommentMapper, IdeaC
|
|
private IdeaMapper ideaMapper;
|
|
private IdeaMapper ideaMapper;
|
|
@Resource
|
|
@Resource
|
|
private UserMapper userMapper;
|
|
private UserMapper userMapper;
|
|
|
|
+ @Resource
|
|
|
|
+ private ScoreMapper scoreMapper;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public HttpRespMsg addOrUpdate(IdeaComment ideaComment,Double score,Integer scoreId) {
|
|
public HttpRespMsg addOrUpdate(IdeaComment ideaComment,Double score,Integer scoreId) {
|
|
@@ -42,6 +48,11 @@ public class IdeaCommentServiceImpl extends ServiceImpl<IdeaCommentMapper, IdeaC
|
|
idea.setIsEvaluated(1);
|
|
idea.setIsEvaluated(1);
|
|
idea.setScoreId(scoreId);
|
|
idea.setScoreId(scoreId);
|
|
ideaMapper.update(idea,new QueryWrapper<Idea>().eq("id",ideaComment.getIdeaId()));
|
|
ideaMapper.update(idea,new QueryWrapper<Idea>().eq("id",ideaComment.getIdeaId()));
|
|
|
|
+ List<Idea> ideaList = ideaMapper.selectList(new QueryWrapper<Idea>().eq("score_id", scoreId));
|
|
|
|
+ Score scoreEntiry = new Score();
|
|
|
|
+ scoreEntiry.setScoreId(scoreId);
|
|
|
|
+ scoreEntiry.setIdeaScore(ideaList.stream().mapToDouble(Idea::getScore).sum()+0);
|
|
|
|
+ scoreMapper.update(scoreEntiry,new QueryWrapper<Score>().eq("score_id",scoreId));
|
|
} else {
|
|
} else {
|
|
//修改评论
|
|
//修改评论
|
|
Idea idea = ideaMapper.selectOne(new QueryWrapper<Idea>().eq("id", ideaComment.getIdeaId()));
|
|
Idea idea = ideaMapper.selectOne(new QueryWrapper<Idea>().eq("id", ideaComment.getIdeaId()));
|