|
@@ -3,12 +3,15 @@ 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.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.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.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 javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
@@ -23,18 +26,24 @@ public class IdeaCommentServiceImpl extends ServiceImpl<IdeaCommentMapper, IdeaC
|
|
private IdeaCommentMapper ideaCommentMapper;
|
|
private IdeaCommentMapper ideaCommentMapper;
|
|
@Resource
|
|
@Resource
|
|
private IdeaMapper ideaMapper;
|
|
private IdeaMapper ideaMapper;
|
|
|
|
+ @Resource
|
|
|
|
+ private UserMapper userMapper;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public HttpRespMsg addOrUpdate(IdeaComment ideaComment,Double score) {
|
|
|
|
|
|
+ public HttpRespMsg addOrUpdate(IdeaComment ideaComment,Double score,Integer scoreId) {
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
if (null == ideaComment.getId()) {
|
|
if (null == ideaComment.getId()) {
|
|
|
|
+ //添加评论
|
|
|
|
+ User user = userMapper.selectById(ideaComment.getResponderId());
|
|
|
|
+ ideaComment.setResponder(user.getName());
|
|
ideaCommentMapper.insert(ideaComment);
|
|
ideaCommentMapper.insert(ideaComment);
|
|
Idea idea = new Idea();
|
|
Idea idea = new Idea();
|
|
- idea.setId(ideaComment.getId());
|
|
|
|
idea.setScore(score);
|
|
idea.setScore(score);
|
|
idea.setIsEvaluated(1);
|
|
idea.setIsEvaluated(1);
|
|
|
|
+ idea.setScoreId(scoreId);
|
|
ideaMapper.update(idea,new QueryWrapper<Idea>().eq("id",ideaComment.getIdeaId()));
|
|
ideaMapper.update(idea,new QueryWrapper<Idea>().eq("id",ideaComment.getIdeaId()));
|
|
} else {
|
|
} else {
|
|
|
|
+ //修改评论
|
|
Idea idea = ideaMapper.selectOne(new QueryWrapper<Idea>().eq("id", ideaComment.getIdeaId()));
|
|
Idea idea = ideaMapper.selectOne(new QueryWrapper<Idea>().eq("id", ideaComment.getIdeaId()));
|
|
if (idea != null) {
|
|
if (idea != null) {
|
|
ideaCommentMapper.updateById(ideaComment);
|
|
ideaCommentMapper.updateById(ideaComment);
|