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

當(dāng)前位置: 首頁 > news >正文

用凡科做網(wǎng)站可靠嗎外國網(wǎng)站怎么進(jìn)入

用凡科做網(wǎng)站可靠嗎,外國網(wǎng)站怎么進(jìn)入,c .net網(wǎng)站開發(fā),網(wǎng)站建設(shè)?首選百川互動(dòng)顯示評(píng)論 數(shù)據(jù)庫 entity_type代表評(píng)論的目標(biāo)類型,評(píng)論帖子和評(píng)論評(píng)論 entity_id代表評(píng)論的目標(biāo)id,具體是哪個(gè)帖子/評(píng)論 targer_id代表評(píng)論指向哪個(gè)人 entity public class Comment {private int id;private int userId;private int entityType;priv…

顯示評(píng)論

數(shù)據(jù)庫

entity_type代表評(píng)論的目標(biāo)類型,評(píng)論帖子和評(píng)論評(píng)論

entity_id代表評(píng)論的目標(biāo)id,具體是哪個(gè)帖子/評(píng)論

targer_id代表評(píng)論指向哪個(gè)人

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í)體查詢一頁評(píng)論數(shù)據(jù)

根據(jù)實(shí)體查詢?cè)u(píng)論的數(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

處理查詢?cè)u(píng)論的業(yè)務(wù)

處理查詢?cè)u(píng)論數(shù)量的業(yè)務(wù)

@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

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

顯示帖子詳細(xì)數(shù)據(jù)時(shí),同時(shí)顯示該帖子所有的評(píng)論數(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);// 評(píng)論分頁信息page.setLimit(5);page.setPath("/discuss/detail/" + discussPostId);// 直接在帖子里面取了page.setRows(post.getCommentCount());// 評(píng)論: 給帖子的評(píng)論// 回復(fù): 給評(píng)論的評(píng)論// 評(píng)論列表,得到當(dāng)前帖子的所有評(píng)論List<Comment> commentList = commentService.findCommentsByEntity(ENTITY_TYPE_POST, post.getId(), page.getOffset(), page.getLimit());// 評(píng)論VO列表,VO-》view objectList<Map<String, Object>> commentVoList = new ArrayList<>();if (commentList != null) {for (Comment comment : commentList) {// 評(píng)論VOMap<String, Object> commentVo = new HashMap<>();// 評(píng)論commentVo.put("comment", comment);// 作者commentVo.put("user", userService.findUserById(comment.getUserId()));// 回復(fù)列表,不搞分頁List<Comment> replyList = commentService.findCommentsByEntity(ENTITY_TYPE_COMMENT, comment.getId(), 0, Integer.MAX_VALUE);// 回復(fù)VO列表List<Map<String, Object>> replyVoList = new ArrayList<>();if (replyList != null) {for (Comment reply : replyList) {Map<String, Object> replyVo = new HashMap<>();// 回復(fù)replyVo.put("reply", reply);// 作者replyVo.put("user", userService.findUserById(reply.getUserId()));// 回復(fù)目標(biāo)User target = reply.getTargetId() == 0 ? null : userService.findUserById(reply.getTargetId());replyVo.put("target", target);replyVoList.add(replyVo);}}commentVo.put("replys", replyVoList);// 回復(fù)數(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

這個(gè)改的有點(diǎn)多,但是估計(jì)不會(huì)問前端的東西

增加評(píng)論

mapper

增加評(píng)論數(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>

?修改帖子的評(píng)論數(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

處理添加評(píng)論的業(yè)務(wù)

CommentService

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

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

DiscussPostService

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

controller

處理添加評(píng)論數(shù)據(jù)的請(qǐng)求

設(shè)置添加評(píng)論的表單

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

前端

評(píng)論

<!-- 回帖輸入 --><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>

回復(fù)

<!-- 回復(fù)輸入框 --><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="請(qǐng)輸入你的觀點(diǎn)"/><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;復(fù)&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="|回復(fù)${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;復(fù)&nbsp;&nbsp;</button></div></form></div>

http://www.risenshineclean.com/news/46970.html

相關(guān)文章:

  • 網(wǎng)站 f型軟文營銷的案例
  • 如何做酒店網(wǎng)站設(shè)計(jì)uc瀏覽器關(guān)鍵詞排名優(yōu)化
  • 揚(yáng)州高郵網(wǎng)站建設(shè)上海網(wǎng)站建設(shè)哪家好
  • 南江縣建設(shè)局網(wǎng)站企業(yè)線上培訓(xùn)平臺(tái)有哪些
  • 網(wǎng)站關(guān)鍵詞排名全掉了seo優(yōu)化大公司排名
  • 照明網(wǎng)站建設(shè)新媒體
  • 公眾號(hào)做電影網(wǎng)站營銷伎巧第一季
  • 東莞網(wǎng)絡(luò)優(yōu)化哪家強(qiáng)seo排名點(diǎn)擊軟件運(yùn)營
  • 家居網(wǎng)站建設(shè)的需求分析今日新聞簡報(bào)
  • 安吉城鄉(xiāng)建設(shè)局網(wǎng)站百度推廣登陸網(wǎng)址
  • 聊城網(wǎng)站改版搜索引擎營銷與seo優(yōu)化
  • 成人版嗶哩嗶哩bilibili邢臺(tái)市seo服務(wù)
  • 網(wǎng)站建設(shè)專業(yè)簡介優(yōu)化營商環(huán)境心得體會(huì)個(gè)人
  • 青田網(wǎng)站做服裝找工作aso優(yōu)化貼吧
  • 六安哪家做網(wǎng)站好什么平臺(tái)打廣告比較好免費(fèi)的
  • 怎么用jsp做網(wǎng)站b站黃頁推廣
  • 中國建設(shè)行業(yè)網(wǎng)黑帽seo什么意思
  • 郴州新網(wǎng)最新招聘信息奉節(jié)縣關(guān)鍵詞seo排名優(yōu)化
  • 建設(shè)網(wǎng)站的公司要什么資質(zhì)百度官網(wǎng)認(rèn)證申請(qǐng)
  • 免費(fèi)域名網(wǎng)站建設(shè)站長之家域名解析
  • 設(shè)計(jì)網(wǎng)站推薦室內(nèi)排名優(yōu)化方案
  • 寶塔 wordpress 404蘭州seo公司
  • 女性時(shí)尚網(wǎng)站模板鄒平縣seo網(wǎng)頁優(yōu)化外包
  • 廣東工程建設(shè)監(jiān)理有限公司網(wǎng)站石家莊關(guān)鍵詞優(yōu)化報(bào)價(jià)
  • 網(wǎng)站開發(fā)的基本技術(shù)業(yè)務(wù)推廣方式有哪些
  • 網(wǎng)站開發(fā)定制多少錢南京百度搜索優(yōu)化
  • 廣州城市建設(shè)網(wǎng)站宣傳推廣渠道有哪些
  • 商業(yè)廣告創(chuàng)意設(shè)計(jì)seo關(guān)鍵詞推廣怎么做
  • 全國企業(yè)信用信息平臺(tái)武漢整站優(yōu)化
  • 提供衡水網(wǎng)站建設(shè)深圳網(wǎng)站建設(shè)方案