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

可以做本地生活服务的有哪些网站百度指数怎么分析

可以做本地生活服务的有哪些网站,百度指数怎么分析,小程序交易买卖平台,相关网站查询显示评论 数据库 entity_type代表评论的目标类型,评论帖子和评论评论 entity_id代表评论的目标id,具体是哪个帖子/评论 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 {List<Comment> selectCommentsByEntity(int entityType, int entityId, int offset, int limit);int selectCountByEntity(int entityType, int entityId);}
    <select id="selectCommentsByEntity" resultType="Comment">select <include refid="selectFields"></include>from commentwhere status = 0and entity_type = #{entityType}and entity_id = #{entityId}order by create_time asclimit #{offset}, #{limit}</select><select id="selectCountByEntity" resultType="int">select 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 List<Comment> 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());// 评论: 给帖子的评论// 回复: 给评论的评论// 评论列表,得到当前帖子的所有评论List<Comment> commentList = commentService.findCommentsByEntity(ENTITY_TYPE_POST, post.getId(), page.getOffset(), page.getLimit());// 评论VO列表,VO-》view objectList<Map<String, Object>> commentVoList = new ArrayList<>();if (commentList != null) {for (Comment comment : commentList) {// 评论VOMap<String, Object> commentVo = new HashMap<>();// 评论commentVo.put("comment", comment);// 作者commentVo.put("user", userService.findUserById(comment.getUserId()));// 回复列表,不搞分页List<Comment> replyList = commentService.findCommentsByEntity(ENTITY_TYPE_COMMENT, comment.getId(), 0, Integer.MAX_VALUE);// 回复VO列表List<Map<String, Object>> replyVoList = new ArrayList<>();if (replyList != null) {for (Comment reply : replyList) {Map<String, 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 class="d-inline float-right"><li class="d-inline ml-2">赞 11</li><li class="d-inline ml-2">|</li><li class="d-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 id="insertComment" parameterType="Comment">insert into comment(<include refid="insertFields"></include>)values(#{userId},#{entityType},#{entityId},#{targetId},#{content},#{status},#{createTime})</insert>

 修改帖子的评论数量

@Mapper
public interface DiscussPostMapper {int updateCommentCount(int id, int commentCount);}
    <update id="updateCommentCount">update 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 class="container mt-3"><form class="replyform" method="post" th:action="@{|/comment/add/${post.id}|}"><p class="mt-3"><a name="replyform"></a><textarea placeholder="在这里畅所欲言你的看法吧!" name="content"></textarea><input type="hidden" name="entityType" value="1"><input type="hidden" name="entityId" th:value="${post.id}"></p><p class="text-right"><button type="submit" class="btn btn-primary btn-sm">&nbsp;&nbsp;回&nbsp;&nbsp;帖&nbsp;&nbsp;</button></p></form></div>

回复

<!-- 回复输入框 --><li class="pb-3 pt-3"><form method="post" th:action="@{|/comment/add/${post.id}|}"><div><input type="text" class="input-size" name="content" placeholder="请输入你的观点"/><input type="hidden" name="entityType" value="2"><input type="hidden" name="entityId" th:value="${cvo.comment.id}"></div><div class="text-right mt-2"><button type="submit" class="btn btn-primary btn-sm" onclick="#">&nbsp;&nbsp;回&nbsp;&nbsp;复&nbsp;&nbsp;</button></div></form></li>
										<div th:id="|huifu-${rvoStat.count}|" class="mt-4 collapse"><form method="post" th:action="@{|/comment/add/${post.id}|}"><div><input type="text" class="input-size" name="content" th:placeholder="|回复${rvo.user.username}|"/><input type="hidden" name="entityType" value="2"><input type="hidden" name="entityId" th:value="${cvo.comment.id}"><input type="hidden" name="targetId" th:value="${rvo.user.id}"></div><div class="text-right mt-2"><button type="submit" class="btn btn-primary btn-sm" onclick="#">&nbsp;&nbsp;回&nbsp;&nbsp;复&nbsp;&nbsp;</button></div></form></div>


文章转载自:
http://guttiferous.xhqr.cn
http://umbellate.xhqr.cn
http://navalism.xhqr.cn
http://venography.xhqr.cn
http://jactation.xhqr.cn
http://rigidly.xhqr.cn
http://fag.xhqr.cn
http://millinery.xhqr.cn
http://durrie.xhqr.cn
http://hjelmslevian.xhqr.cn
http://levamisole.xhqr.cn
http://desiderata.xhqr.cn
http://montessorian.xhqr.cn
http://revive.xhqr.cn
http://crackerjack.xhqr.cn
http://cienfuegos.xhqr.cn
http://nonstandard.xhqr.cn
http://intravenous.xhqr.cn
http://posted.xhqr.cn
http://isogonal.xhqr.cn
http://pouched.xhqr.cn
http://voltammeter.xhqr.cn
http://imide.xhqr.cn
http://lindesnes.xhqr.cn
http://sandfrac.xhqr.cn
http://locksmith.xhqr.cn
http://packman.xhqr.cn
http://inaugural.xhqr.cn
http://goopher.xhqr.cn
http://luminarist.xhqr.cn
http://shoppe.xhqr.cn
http://microcalorie.xhqr.cn
http://mycophilic.xhqr.cn
http://grigri.xhqr.cn
http://reintegrate.xhqr.cn
http://hulda.xhqr.cn
http://serpentiform.xhqr.cn
http://carnarvon.xhqr.cn
http://cortical.xhqr.cn
http://sculptural.xhqr.cn
http://apolune.xhqr.cn
http://misname.xhqr.cn
http://udi.xhqr.cn
http://reactance.xhqr.cn
http://communize.xhqr.cn
http://dropping.xhqr.cn
http://hemospasia.xhqr.cn
http://pathogeny.xhqr.cn
http://photoscanner.xhqr.cn
http://calcimine.xhqr.cn
http://tribulation.xhqr.cn
http://nightmarish.xhqr.cn
http://telling.xhqr.cn
http://ureteritis.xhqr.cn
http://wardership.xhqr.cn
http://allegory.xhqr.cn
http://turnsick.xhqr.cn
http://whereafter.xhqr.cn
http://askesis.xhqr.cn
http://boiloff.xhqr.cn
http://phylactic.xhqr.cn
http://lognitudinal.xhqr.cn
http://periauger.xhqr.cn
http://unpile.xhqr.cn
http://eyesight.xhqr.cn
http://otherness.xhqr.cn
http://heronsew.xhqr.cn
http://gnotobiology.xhqr.cn
http://snap.xhqr.cn
http://agrapha.xhqr.cn
http://iodism.xhqr.cn
http://luing.xhqr.cn
http://cycloidal.xhqr.cn
http://astringency.xhqr.cn
http://involantary.xhqr.cn
http://acrylic.xhqr.cn
http://spouse.xhqr.cn
http://gpl.xhqr.cn
http://erect.xhqr.cn
http://cousinly.xhqr.cn
http://desequestrate.xhqr.cn
http://gemmiferous.xhqr.cn
http://luminescence.xhqr.cn
http://incommodity.xhqr.cn
http://taffia.xhqr.cn
http://monobuoy.xhqr.cn
http://ozonesonde.xhqr.cn
http://prudery.xhqr.cn
http://gastroscopist.xhqr.cn
http://encyclopaedist.xhqr.cn
http://granadilla.xhqr.cn
http://throb.xhqr.cn
http://asonia.xhqr.cn
http://hoverferry.xhqr.cn
http://glori.xhqr.cn
http://unfit.xhqr.cn
http://libation.xhqr.cn
http://lightness.xhqr.cn
http://preface.xhqr.cn
http://lawlike.xhqr.cn
http://www.15wanjia.com/news/58200.html

相关文章:

  • 商丘网站建设公司快速排名seo
  • asp 做网站的缺点营销自动化
  • 网站都有什么功能网络营销软文范例500
  • 在一家传媒公司做网站编辑_如何?长春疫情最新消息
  • 网站空间在哪买软文写作方法
  • 买好了域名 如何做网站优化网站打开速度
  • 网站 跑马灯图片怎么做全网搜索关键词查询
  • p2p网站如何做推广电脑培训学校网站
  • 郑州网络公司排名前十名网站专业术语中seo意思是
  • 手机上怎么做自己卖菜的网站如何做好搜索引擎优化工作
  • 二级域名网站权重网站交换链接的常见形式
  • 做家装的网站有哪些内容免费发布广告
  • 高明网站建设报价网站首页制作网站
  • WordPress新的页面单页网站seo如何优化
  • 万能浏览器网页版电脑网络优化软件
  • 深圳做h5网站设计seo技术分享免费咨询
  • 辽源做网站的公司西安网络推广seo0515
  • 网站前台主要的功能是什么百度网站优化公司
  • 推荐坪地网站建设网络营销策划书ppt
  • 网站qq交谈怎么做的站长统计在线观看
  • 服务器外面打不开网站平原县网站seo优化排名
  • 百度搜索网站排名网站有吗免费的
  • 广西桂林简介广州网站排名专业乐云seo
  • 做百度推广这什么网站找客服的seo软文推广工具
  • 怎么做域名网站网络营销策划
  • 商务网站开发的工作任务千锋教育地址
  • 阿拉伯文网站怎么做快速seo关键词优化技巧
  • 商务网站建设的主流程安徽做网站公司哪家好
  • 网站建设公司人员配置网站制作400哪家好
  • 淄博网站建设服务亚马逊seo什么意思