中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當前位置: 首頁 > news >正文

可以做本地生活服務的有哪些網(wǎng)站營銷型網(wǎng)站建設服務

可以做本地生活服務的有哪些網(wǎng)站,營銷型網(wǎng)站建設服務,做設備租賃的網(wǎng)站,株洲做網(wǎng)站定制顯示評論 數(shù)據(jù)庫 entity_type代表評論的目標類型,評論帖子和評論評論 entity_id代表評論的目標id,具體是哪個帖子/評論 targer_id代表評論指向哪個人 entity public class Comment {private int id;private int userId;private int entityType;priv…

顯示評論

數(shù)據(jù)庫

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

根據(jù)實體查詢一頁評論數(shù)據(jù)

根據(jù)實體查詢評論的數(shù)量(為了分頁)

@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

處理查詢評論的業(yè)務

處理查詢評論數(shù)量的業(yè)務

@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

查詢回復,查詢回復數(shù)量是在查看帖子的時候進行的,所以修改discussPostController里面的getDiscussPost函數(shù)就可以

顯示帖子詳細數(shù)據(jù)時,同時顯示該帖子所有的評論數(shù)據(jù)

    @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);// 回復數(shù)量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

增加評論數(shù)據(jù)

@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>

?修改帖子的評論數(shù)量

@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

處理添加評論的業(yè)務

CommentService

    @Transactional(isolation = Isolation.READ_COMMITTED, propagation = Propagation.REQUIRED)public int addComment(Comment comment) {if (comment == null) {throw new IllegalArgumentException("參數(shù)不能為空!");}// 添加評論comment.setContent(HtmlUtils.htmlEscape(comment.getContent()));comment.setContent(sensitiveFilter.filter(comment.getContent()));int rows = commentMapper.insertComment(comment);// 更新帖子評論數(shù)量if (comment.getEntityType() == ENTITY_TYPE_POST) {int count = commentMapper.selectCountByEntity(comment.getEntityType(), comment.getEntityId());discussPostService.updateCommentCount(comment.getEntityId(), count);}return rows;}

先增加評論,再更新帖子的評論數(shù)量

DiscussPostService

    public int updateCommentCount(int id, int commentCount) {return discussPostMapper.updateCommentCount(id, commentCount);}

controller

處理添加評論數(shù)據(jù)的請求

設置添加評論的表單

@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://www.risenshineclean.com/news/29201.html

相關文章:

  • 怎么登陸建設工程網(wǎng)站成都網(wǎng)站快速排名優(yōu)化
  • 零遁nas做網(wǎng)站百度開放平臺登錄
  • 網(wǎng)絡咨詢網(wǎng)站如何做網(wǎng)絡營銷?
  • WordPress如何設置站點名稱免費b站推廣網(wǎng)站2023
  • 中山網(wǎng)站代運營百度域名注冊
  • 濟寧網(wǎng)站建設案例展示產(chǎn)品營銷方案策劃
  • 企業(yè)宣傳片拍攝思路網(wǎng)站如何做seo排名
  • 做視頻網(wǎng)站如何賺錢品牌推廣的渠道有哪些
  • 基于PHP的家教網(wǎng)站開發(fā)環(huán)境谷歌seo服務商
  • 用六類網(wǎng)站做電話可以嗎長尾關鍵詞搜索網(wǎng)站
  • seo網(wǎng)站優(yōu)化推廣怎么做東莞seo優(yōu)化案例
  • 最新新聞熱點事件2024摘抄優(yōu)化大師好用嗎
  • 簡單的網(wǎng)頁設計代碼記事本專業(yè)的網(wǎng)站優(yōu)化公司排名
  • 做網(wǎng)站口碑比較好的大公司百度聯(lián)系電話多少
  • 知果果網(wǎng)站誰做的軟文編輯
  • 淘外網(wǎng)站怎么做網(wǎng)站怎么申請怎么注冊
  • 個人做購物網(wǎng)站犯法嗎交換鏈接平臺
  • 做網(wǎng)站用小公司還是大公司2022最火營銷方案
  • 2_網(wǎng)站建設的一般步驟包含哪些刷seo快速排名
  • 有沒有專門做av字幕的網(wǎng)站百度法務部聯(lián)系方式
  • 做網(wǎng)站具體指什么百度招商客服電話
  • 隨州網(wǎng)站seo常州百度推廣代理
  • 網(wǎng)站模板jsp設計公司排名前十強
  • 廠家批發(fā)網(wǎng)站平臺傳播易廣告投放平臺
  • 企業(yè)建設網(wǎng)站的好處有哪些常用的營銷方法和手段
  • 自己制作視頻的app泉州seo培訓
  • 提供微網(wǎng)站建設購物網(wǎng)站推廣方案
  • 物聯(lián)網(wǎng)手機app開發(fā)軟件天津seo方案
  • 星際網(wǎng)絡泰安網(wǎng)絡公司網(wǎng)站頁面優(yōu)化方法
  • 臺州網(wǎng)站搜索優(yōu)化友情鏈接工具