基於Angularjs+mybatis實現二級評論系統(仿簡書),angularjsmybatis

來源:互聯網
上載者:User

基於Angularjs+mybatis實現二級評論系統(仿簡書),angularjsmybatis

一直想寫個評論系統,看了下多說,網易,簡書的評論,想了下自己該實現怎樣的評論系統。

評論系統關鍵是嵌套層數以及資料庫表設計。嵌套層數多,表結構複雜,呈現也麻煩,最後決定實現一個二級評論。系統由maven構建,springboot快速搭建spring環境。前台採用angularjs+bootstrap,後台使用springmvc+mybatis,資料庫採用MySQL.前台請求後台API操作評論。

目錄結構

資料庫表設計

##說說表或者文章表 create table saying (  saying_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,  sayingContent VARCHAR(500) NOT NULL,  author VARCHAR(50) NOT NULL,  sayingAvatar VARCHAR(50) NOT NULL,  likes VARCHAR(500) NOT NULL,  createTime datetime NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8;  ##一級評論表 create table firstLevelComment (  flc_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,  sayingId INT NOT NULL,  commenter VARCHAR(50) NOT NULL,  commenterAvatar VARCHAR(50) NOT NULL,  commentContent VARCHAR(500) NOT NULL,  commentTime datetime NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8;  ##二級評論表 create table secondLevelComment (  slc_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,  sayingId INT NOT NULL,  flcId INT NOT NULL,  replier VARCHAR(50) NOT NULL,  toCommenter VARCHAR(50) NOT NULL,  replyContent VARCHAR(50) NOT NULL,  replyTime datetime NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 

擷取評論的mapper(關鍵)

<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > <mapper namespace="personal.timeless.cms.mapper.SayingMapper" >   <resultMap id="SayingMap" type="saying" >  <id column="saying_id" property="id" jdbcType="INTEGER" />  <result column="sayingContent" property="sayingContent" jdbcType="INTEGER" />  <result column="author" property="author" jdbcType="VARCHAR" />  <result column="sayingAvatar" property="avatar" jdbcType="VARCHAR" />  <result column="likes" property="likes" jdbcType="VARCHAR" />  <result column="createTime" property="createTime" jdbcType="TIMESTAMP" />  <collection property="flcs" ofType="firstLevelComment" column="sayingId">  <id column="flc_id" property="id" jdbcType="INTEGER" />  <result column="sayingId" property="sayingId" jdbcType="INTEGER" />  <result column="commenter" property="commenter"/>  <result column="commenterAvatar" property="avatar"/>  <result column="commentContent" property="commentContent"/>  <result column="commentTime" property="commentTime" jdbcType="TIMESTAMP" />  <collection property="slcs" ofType="secondLevelComment" column="flcId">   <id column="slc_id" property="id" jdbcType="INTEGER" />   <result column="flcId" property="flcId" jdbcType="INTEGER" />   <result column="replier" property="replier"/>   <result column="toCommenter" property="toCommenter"/>   <result column="replyContent" property="replyContent"/>   <result column="replyTime" property="replyTime" jdbcType="TIMESTAMP" />  </collection>  </collection>  </resultMap>   <select id="selectOneById" resultMap="SayingMap" parameterType="int" >  select * from  (select * from saying s left join firstLevelComment fc on s.saying_id=fc.sayingId where s.saying_id=#{id}) tmp left join secondLevelComment sc  on tmp.flc_id = sc.flcId  </select>   <select id="updateLikesById">  update saying set likes = #{likes} where saying_id = #{id}  </select>  </mapper> 

頁面展示


以上就是本文的全部內容,希望對大家的學習有所協助,也希望大家多多支援幫客之家。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.