当前位置: 首页 > news >正文

哪里有网站开发服务器网页工具栏

哪里有网站开发服务器,网页工具栏,做谱的网站,免费crm下载显示评论 数据库 entity_type代表评论的目标类型#xff0c;评论帖子和评论评论 entity_id代表评论的目标id#xff0c;具体是哪个帖子/评论 targer_id代表评论指向哪个人 entity public class Comment {private int id;private int userId;private int entityType;priv…显示评论 数据库 entity_type代表评论的目标类型评论帖子和评论评论 entity_id代表评论的目标id具体是哪个帖子/评论 targer_id代表评论指向哪个人 entity public class Comment {private int id;private int userId;private int entityType;private int entityId;private int targetId;private String content;private int status;private Date createTime;} mapper 根据实体查询一页评论数据 根据实体查询评论的数量为了分页 Mapper public interface CommentMapper {ListComment selectCommentsByEntity(int entityType, int entityId, int offset, int limit);int selectCountByEntity(int entityType, int entityId);} select idselectCommentsByEntity resultTypeCommentselect include refidselectFields/includefrom commentwhere status 0and entity_type #{entityType}and entity_id #{entityId}order by create_time asclimit #{offset}, #{limit}/selectselect idselectCountByEntity resultTypeintselect count(id)from commentwhere status 0and entity_type #{entityType}and entity_id #{entityId}/select service 处理查询评论的业务 处理查询评论数量的业务 Service public class CommentService implements CommunityConstant {Autowiredprivate CommentMapper commentMapper;public ListComment findCommentsByEntity(int entityType, int entityId, int offset, int limit) {return commentMapper.selectCommentsByEntity(entityType, entityId, offset, limit);}public int findCommentCount(int entityType, int entityId) {return commentMapper.selectCountByEntity(entityType, entityId);}} controller 查询回复查询回复数量是在查看帖子的时候进行的所以修改discussPostController里面的getDiscussPost函数就可以 显示帖子详细数据时同时显示该帖子所有的评论数据 RequestMapping(path /detail/{discussPostId}, method RequestMethod.GET)public String getDiscussPost(PathVariable(discussPostId) int discussPostId, Model model, Page page) {// 帖子DiscussPost post discussPostService.findDiscussPostById(discussPostId);model.addAttribute(post, post);// 作者User user userService.findUserById(post.getUserId());model.addAttribute(user, user);// 评论分页信息page.setLimit(5);page.setPath(/discuss/detail/ discussPostId);// 直接在帖子里面取了page.setRows(post.getCommentCount());// 评论: 给帖子的评论// 回复: 给评论的评论// 评论列表得到当前帖子的所有评论ListComment commentList commentService.findCommentsByEntity(ENTITY_TYPE_POST, post.getId(), page.getOffset(), page.getLimit());// 评论VO列表VO-》view objectListMapString, Object commentVoList new ArrayList();if (commentList ! null) {for (Comment comment : commentList) {// 评论VOMapString, Object commentVo new HashMap();// 评论commentVo.put(comment, comment);// 作者commentVo.put(user, userService.findUserById(comment.getUserId()));// 回复列表不搞分页ListComment replyList commentService.findCommentsByEntity(ENTITY_TYPE_COMMENT, comment.getId(), 0, Integer.MAX_VALUE);// 回复VO列表ListMapString, Object replyVoList new ArrayList();if (replyList ! null) {for (Comment reply : replyList) {MapString, Object replyVo new HashMap();// 回复replyVo.put(reply, reply);// 作者replyVo.put(user, userService.findUserById(reply.getUserId()));// 回复目标User target reply.getTargetId() 0 ? null : userService.findUserById(reply.getTargetId());replyVo.put(target, target);replyVoList.add(replyVo);}}commentVo.put(replys, replyVoList);// 回复数量int replyCount commentService.findCommentCount(ENTITY_TYPE_COMMENT, comment.getId());commentVo.put(replyCount, replyCount);commentVoList.add(commentVo);}}model.addAttribute(comments, commentVoList);return /site/discuss-detail;} 前端 index ul classd-inline float-rightli classd-inline ml-2赞 11/lili classd-inline ml-2|/lili classd-inline ml-2回帖 span th:text${map.post.commentCount}7/span/li /ul discuss-detail 这个改的有点多但是估计不会问前端的东西 增加评论 mapper 增加评论数据 Mapper public interface CommentMapper {int insertComment(Comment comment);} insert idinsertComment parameterTypeCommentinsert into comment(include refidinsertFields/include)values(#{userId},#{entityType},#{entityId},#{targetId},#{content},#{status},#{createTime})/insert 修改帖子的评论数量 Mapper public interface DiscussPostMapper {int updateCommentCount(int id, int commentCount);} update idupdateCommentCountupdate discuss_post set comment_count #{commentCount} where id #{id}/update service 处理添加评论的业务 CommentService Transactional(isolation Isolation.READ_COMMITTED, propagation Propagation.REQUIRED)public int addComment(Comment comment) {if (comment null) {throw new IllegalArgumentException(参数不能为空!);}// 添加评论comment.setContent(HtmlUtils.htmlEscape(comment.getContent()));comment.setContent(sensitiveFilter.filter(comment.getContent()));int rows commentMapper.insertComment(comment);// 更新帖子评论数量if (comment.getEntityType() ENTITY_TYPE_POST) {int count commentMapper.selectCountByEntity(comment.getEntityType(), comment.getEntityId());discussPostService.updateCommentCount(comment.getEntityId(), count);}return rows;} 先增加评论再更新帖子的评论数量 DiscussPostService public int updateCommentCount(int id, int commentCount) {return discussPostMapper.updateCommentCount(id, commentCount);} controller 处理添加评论数据的请求 设置添加评论的表单 Controller RequestMapping(/comment) public class CommentController {Autowiredprivate CommentService commentService;Autowiredprivate HostHolder hostHolder;RequestMapping(path /add/{discussPostId}, method RequestMethod.POST)public String addComment(PathVariable(discussPostId) int discussPostId, Comment comment) {comment.setUserId(hostHolder.getUser().getId());comment.setStatus(0);comment.setCreateTime(new Date());commentService.addComment(comment);return redirect:/discuss/detail/ discussPostId;}} 前端 评论 !-- 回帖输入 --div classcontainer mt-3form classreplyform methodpost th:action{|/comment/add/${post.id}|}p classmt-3a namereplyform/atextarea placeholder在这里畅所欲言你的看法吧! namecontent/textareainput typehidden nameentityType value1input typehidden nameentityId th:value${post.id}/pp classtext-rightbutton typesubmit classbtn btn-primary btn-smnbsp;nbsp;回nbsp;nbsp;帖nbsp;nbsp;/button/p/form/div 回复 !-- 回复输入框 --li classpb-3 pt-3form methodpost th:action{|/comment/add/${post.id}|}divinput typetext classinput-size namecontent placeholder请输入你的观点/input typehidden nameentityType value2input typehidden nameentityId th:value${cvo.comment.id}/divdiv classtext-right mt-2button typesubmit classbtn btn-primary btn-sm onclick#nbsp;nbsp;回nbsp;nbsp;复nbsp;nbsp;/button/div/form/li div th:id|huifu-${rvoStat.count}| classmt-4 collapseform methodpost th:action{|/comment/add/${post.id}|}divinput typetext classinput-size namecontent th:placeholder|回复${rvo.user.username}|/input typehidden nameentityType value2input typehidden nameentityId th:value${cvo.comment.id}input typehidden nametargetId th:value${rvo.user.id}/divdiv classtext-right mt-2button typesubmit classbtn btn-primary btn-sm onclick#nbsp;nbsp;回nbsp;nbsp;复nbsp;nbsp;/button/div/form/div
http://www.sczhlp.com/news/173271/

相关文章:

  • 深圳网站建设迈兰州企业网站优化
  • 先建设网站后付款网站开发所以浏览器兼容模式
  • 伊春网站建设久久建筑网 围栏工程专项施工方案
  • Exp2-后门原理与实践
  • 【Hexo】4.Hexo 博客文章进行加密 - 实践
  • 思考的动力
  • 加拿大加密货币牌照:合规化加速数字资产成功
  • 网站开发建设方案哈尔滨seo优化公司多少钱
  • 广告公司的网站建设价格小程序云开发收费
  • 郑州网站制作郑州网站制作html5播放器
  • 上海 专业网站设计 母婴类贵阳手机网站开发
  • 安徽网站优化多少钱手机制作网站教程
  • 简述营销网站建设包括哪些内容响应式网站是什么软件做的
  • 为网站做电影花絮语音网站怎么做
  • 类似站酷的设计网站加强网站的建设
  • 教师招聘网站长城建设集团网站 源码 下载
  • 佛山定制建站公司推荐做交易平台网站
  • 东莞网站建设开发价格广州建设网站专家
  • hyip系统网站开发网站开发方向和移动开发方向那个好
  • 太仓市住房和城乡建设局官方网站门户网站制度建设
  • 网站建设设备预算wordpress po文件
  • 网站前端做报名框代码php网站建设入门教程
  • 开发公司办公电脑申请怎么写seo任务大厅
  • 宜春网站建设公司点餐网站模板 手机端
  • 2023年7月最新新闻摘抄大连seo网站管理
  • 数学之美感悟。
  • 基于DeploySharp 的深度学习模型部署测试平台:支持YOLO全系列模型
  • 复制别人的vmware虚拟机无法联网ubuntu2204
  • xampp做网站在网站开发中如何设置登录
  • 电子商务网站硬件需求购物网站er图