提交 170f4f3c authored 作者: chaoyanjun's avatar chaoyanjun

--no commit message

上级 56726ee9
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry including="**/*.java" kind="src" output="target/classes" path="src/main/java">
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
......@@ -15,11 +15,13 @@
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
......
......@@ -26,6 +26,11 @@
</arguments>
</buildCommand>
<buildCommand>
<name>org.springframework.ide.eclipse.boot.validation.springbootbuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
......
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8
boot.validation.initialized=true
eclipse.preferences.version=1
package com.zrqx.sysuser.ydcc.controller.topic;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zrqx.core.constant.sysuser.SysUserRequestPath;
import com.zrqx.core.form.member.wap.member.UpdateFabulousForm;
import com.zrqx.core.form.resource.wap.LoadByIdForm;
import com.zrqx.core.model.sysuser.topic.Topic;
import com.zrqx.core.model.sysuser.topic.TopicComment;
import com.zrqx.core.util.ip.CusAccessObjectUtil;
import com.zrqx.core.util.page.PageInfo;
import com.zrqx.core.util.page.PageParam;
import com.zrqx.core.util.response.CallBack;
import com.zrqx.core.vo.sysuser.bg.comment.CommentDetailsVo;
import com.zrqx.core.vo.sysuser.bg.topic.TopicVo;
import com.zrqx.core.vo.topic.TopicCommentVo;
import com.zrqx.sysuser.wap.service.WapCommentAgreeService;
import com.zrqx.sysuser.ydcc.service.topic.YdccTopicService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping(SysUserRequestPath.YDCC + SysUserRequestPath.TOPIC)
@Api(description = "医道传承-话题管理")
@Api(description = "医道传承-前台-话题/评论")
public class YdccTopicController {
@Autowired
@Autowired
private WapCommentAgreeService wapService;
@Autowired
private YdccTopicService ydccTopicService;
@ApiOperation(value = "话题互动分页列表")
......@@ -41,4 +59,41 @@ public class YdccTopicController {
public CallBack<List<TopicVo>> getTopicList(LoadByIdForm form) {
return CallBack.success(ydccTopicService.queryTopicsByMemberId(form.getId()));
}
@ApiOperation(value = "查看话题详情", notes = "查看话题详情")
@PostMapping(SysUserRequestPath.OID)
public CallBack<Topic> getTopic(@PathVariable Integer oid) {
return CallBack.success(ydccTopicService.selectByPrimaryKey(oid));
}
@ApiOperation(value = "添加评论", notes = "添加评论,状态默认为未审核")
@PostMapping(SysUserRequestPath.ADD)
public CallBack<Boolean> saveTopicComment(@RequestBody TopicComment form) {
return ydccTopicService.saveTopicComment(form) ? CallBack.success() : CallBack.fail();
}
@ApiOperation(value = "查所有评论", notes = "查询评论,状态默认为已审核")
@PostMapping(SysUserRequestPath.ALL)
public CallBack<List<TopicCommentVo>> getList(Integer id) {
// 查询所有已审核的评论list不分页
return CallBack.success(ydccTopicService.getList(id));
}
@ApiOperation(value = "查评论详情", notes = "查评论详情,状态默认为已审核")
@PostMapping(SysUserRequestPath.LIST)
public CallBack<CommentDetailsVo> getListInfo(Integer id) {
// 查询所有已审核的评论的评论list不分页
return CallBack.success(ydccTopicService.getListInfo(id));
}
@PostMapping("/thumbs-up")
@ApiOperation(value = "评论点赞 ", notes = "评论点赞/取消点赞")
public CallBack<Boolean> thumbsUp(UpdateFabulousForm form, HttpServletRequest request) {
//IP
form.setUserAddress(CusAccessObjectUtil.getIpAddress(request));
return wapService.updateFabulousNum(form) ? CallBack.success() : CallBack.fail();
}
}
package com.zrqx.sysuser.ydcc.mapper.topic;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import com.zrqx.core.mapper.BaseMapper;
import com.zrqx.core.model.sysuser.topic.TopicComment;
import com.zrqx.core.vo.sysuser.bg.comment.ReplyVo;
import com.zrqx.core.vo.topic.TopicCommentVo;
@Mapper
public interface YdccTopicCommentMapper extends BaseMapper<TopicComment> {
@Select("<script>"
+ " select id,userName,userImg,content,score,fabulousNum,releaseTime from sys_ydcc_topic_comment "
+ " where 1=1 and status = '1' and resourceId = #{id} ORDER BY releaseTime DESC "
+ "</script>")
List<TopicCommentVo> selectForVoById(@Param("id") Integer id);
@Select("<script>"
+ " SELECT * "
+ " FROM sys_ydcc_topic_comment "
+ " WHERE 1=1 and status = '1' and mainId = #{id} and ORDER BY releaseTime DESC "
+ "</script>")
List<ReplyVo> selectForListById(@Param("id") Integer id);
@Select("<script>"
+ " select count(*) from sys_ydcc_topic_comment "
+ " where 1=1 and status = '1' and mainId = #{id} "
+ "</script>")
int selectCountById(@Param("id") Integer id);
}
package com.zrqx.sysuser.ydcc.service.topic;
import com.zrqx.core.model.sysuser.topic.Topic;
import com.zrqx.core.model.sysuser.topic.TopicComment;
import com.zrqx.core.service.BaseService;
import com.zrqx.core.util.page.PageInfo;
import com.zrqx.core.util.page.PageParam;
import com.zrqx.core.vo.sysuser.bg.comment.CommentDetailsVo;
import com.zrqx.core.vo.sysuser.bg.topic.TopicVo;
import com.zrqx.core.vo.topic.TopicCommentVo;
import java.util.List;
......@@ -35,4 +38,9 @@ public interface YdccTopicService extends BaseService<Topic,Integer>{
*/
List<TopicVo> queryTopicsByMemberId(Integer id);
boolean saveTopicComment(TopicComment form);
List<TopicCommentVo> getList(Integer id);
CommentDetailsVo getListInfo(Integer id);
}
package com.zrqx.sysuser.ydcc.service.topic;
import java.util.Date;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zrqx.core.enums.sysuser.comment.UserTypeEnum;
import com.zrqx.core.mapper.BaseMapper;
import com.zrqx.core.model.sysuser.topic.Topic;
import com.zrqx.core.model.sysuser.topic.TopicComment;
import com.zrqx.core.service.BaseServiceImpl;
import com.zrqx.core.util.datatype.DateUtils;
import com.zrqx.core.util.page.PageInfo;
import com.zrqx.core.util.page.PageParam;
import com.zrqx.core.vo.sysuser.bg.comment.CommentDetailsVo;
import com.zrqx.core.vo.sysuser.bg.comment.ReplyVo;
import com.zrqx.core.vo.sysuser.bg.topic.TopicVo;
import com.zrqx.core.vo.topic.TopicCommentVo;
import com.zrqx.sysuser.commons.redis.Redis;
import com.zrqx.sysuser.ydcc.mapper.topic.YdccTopicCommentMapper;
import com.zrqx.sysuser.ydcc.mapper.topic.YdccTopicMapper;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
@Service
public class YdccTopicServiceImpl extends BaseServiceImpl<Topic,Integer> implements YdccTopicService{
@Autowired
private YdccTopicMapper ydccTopicMapper;
@Autowired
private YdccTopicCommentMapper tocMapper;
@Autowired
private Redis redis;
......@@ -55,4 +66,39 @@ public class YdccTopicServiceImpl extends BaseServiceImpl<Topic,Integer> impleme
@Override
public boolean saveTopicComment(TopicComment form) {
form.setReleaseTime(new Date());
form.setUserId(redis.getMember().getId()+"");
form.setUserName(redis.getMember().getNickName());
form.setUserImg(redis.getMember().getImg());
form.setName(redis.getMember().getName());
form.setUserClass(UserTypeEnum.STATUS_0.getCode());
form.setAccessMedium(1);// 访问媒介 1:PC端,2:Wap端
return tocMapper.insert(form) > 0;
}
@Override
public List<TopicCommentVo> getList(Integer id) {
List<TopicCommentVo> list = tocMapper.selectForVoById(id);
list.forEach(vo ->{
long fromNow = DateUtils.secondsFromNow(vo.getReleaseTime());
vo.setSeconds(fromNow);
// 根据评论id 查回复个数
int score = tocMapper.selectCountById(vo.getId());
vo.setScore(score);
});
return list;
}
@Override
public CommentDetailsVo getListInfo(Integer id) {
TopicComment top = tocMapper.selectByPrimaryKey(id);
CommentDetailsVo vo = new CommentDetailsVo();
BeanUtils.copyProperties(top, vo);
List<ReplyVo> list = tocMapper.selectForListById(id);
vo.setReplyVoList(list);
return vo;
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论