163 lines
6.0 KiB
XML
163 lines
6.0 KiB
XML
<?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="com.jacklei.poetry.mapper.CommentsDao">
|
|
|
|
<resultMap id="CommentsDynastyResultMap" type="com.jacklei.poetry.entities.CommentsDynasty">
|
|
<id property="commentsId" column="comments_id"/>
|
|
<result property="dynastyId" column="dynasty_id"/>
|
|
<result property="userId" column="user_id"/>
|
|
<result property="commentsInformation" column="comments_information"/>
|
|
<result property="time" column="time"/>
|
|
<!-- <collection property="replyDynastyCommentsIdResultMap" javaType="list" ofType="com.jacklei.poetry.entities.CommentsDynasty">-->
|
|
<!-- <id property="commentsId" column="comments_id"/>-->
|
|
<!-- <result property="dynastyId" column="dynasty_id"/>-->
|
|
<!-- <result property="userId" column="user_id"/>-->
|
|
<!-- <result property="commentsInformation" column="comments_information"/>-->
|
|
<!-- <result property="time" column="time"/>-->
|
|
<!-- </collection>-->
|
|
|
|
</resultMap>
|
|
|
|
<resultMap id="CommentsPoemResultMap" type="com.jacklei.poetry.entities.CommentsPoem">
|
|
<id property="commentsId" column="comments_id"/>
|
|
<result property="poemId" column="poem_id"/>
|
|
<result property="userId" column="user_id"/>
|
|
<result property="commentsInformation" column="comments_information"/>
|
|
<result property="time" column="time"/>
|
|
<!-- <collection property="replyPoemCommentsIdResultMap" javaType="list" ofType="com.jacklei.poetry.entities.CommentsPoem">-->
|
|
<!-- <id property="commentsId" column="comments_id"/>-->
|
|
<!-- <result property="poemId" column="poem_id"/>-->
|
|
<!-- <result property="userId" column="user_id"/>-->
|
|
<!-- <result property="commentsInformation" column="comments_information"/>-->
|
|
<!-- <result property="time" column="time"/>-->
|
|
<!-- </collection>-->
|
|
</resultMap>
|
|
|
|
<insert id="UserCommentsPoem">
|
|
insert into t_comments_poem (comments_id,poem_id,user_id,comments_information,`time`) values (#{commentsId},#{poemId},#{userId},#{commentsInformation},#{time});
|
|
</insert>
|
|
|
|
<insert id="UserCommentsDynasty">
|
|
insert into t_comments_dynasty (comments_id,dynasty_id,user_id,comments_information,`time`) values (#{commentsId},#{dynastyId},#{userId},#{commentsInformation},#{time});
|
|
</insert>
|
|
<insert id="UserReplyCommentsPoem">
|
|
insert into t_reply_poem (comments_id,replyer_id) values (#{replyerId},#{commentsId});
|
|
</insert>
|
|
<insert id="UserReplyCommentsDynasty">
|
|
insert into t_reply_dynasty (comments_id,replyer_id) values (#{replyerId},#{commentsId});
|
|
</insert>
|
|
|
|
<select id="SeePoemComments" useCache="true" resultMap="CommentsPoemResultMap">
|
|
select
|
|
a.comments_id,
|
|
a.poem_id,
|
|
d.username as user_id,
|
|
a.comments_information,
|
|
a.time
|
|
from
|
|
t_comments_poem a,
|
|
#t_reply_poem c ,
|
|
t_user d
|
|
where
|
|
d.user_id= a.user_id
|
|
and a.poem_id=#{poemId}
|
|
and
|
|
a.comments_id
|
|
not IN (
|
|
|
|
SELECT `replyer_id` FROM `t_reply_poem`
|
|
)
|
|
</select>
|
|
<select id="SeePoemCommentsReply" useCache="true" resultMap="CommentsPoemResultMap">
|
|
select
|
|
a.comments_id,
|
|
a.poem_id,
|
|
d.username as user_id,
|
|
a.comments_information,
|
|
a.time
|
|
from
|
|
t_comments_poem a,
|
|
t_reply_poem c ,
|
|
t_user d
|
|
where
|
|
a.comments_id=c.replyer_id and
|
|
d.user_id = a.user_id and
|
|
c.comments_id=#{commentsId}
|
|
|
|
</select>
|
|
<select id="SeeDynastyCommentsReply" useCache="true" resultMap="CommentsDynastyResultMap">
|
|
select
|
|
a.comments_id,
|
|
a.dynasty_id,
|
|
d.username as user_id,
|
|
a.comments_information,
|
|
a.time
|
|
from
|
|
t_comments_dynasty a,
|
|
t_reply_dynasty c ,
|
|
t_user d
|
|
where
|
|
a.comments_id=c.replyer_id and
|
|
d.user_id = a.user_id and
|
|
c.comments_id=#{commentsId}
|
|
</select>
|
|
<select id="SeeDynastyComments" useCache="true" resultMap="CommentsDynastyResultMap">
|
|
select
|
|
a.comments_id,
|
|
a.dynasty_id,
|
|
d.username as user_id,
|
|
a.comments_information,
|
|
a.time
|
|
from
|
|
t_comments_dynasty a,
|
|
#t_reply_dynasty c ,
|
|
t_user d
|
|
where
|
|
d.user_id= a.user_id
|
|
and a.dynasty_id=#{dynastyId}
|
|
and
|
|
a.comments_id
|
|
not IN (
|
|
|
|
SELECT `replyer_id` FROM `t_reply_dynasty`
|
|
)
|
|
</select>
|
|
|
|
<delete id="UserDeleteCommentsPoem">
|
|
delete from t_comments_poem where comments_id=#{commentsId} ;
|
|
</delete>
|
|
<delete id="UserDeleteCommentsDynasty">
|
|
delete from t_comments_dynasty where comments_id=#{commentsId};
|
|
</delete>
|
|
<delete id="UserDeleteCommentsDynastyRelation">
|
|
delete from t_reply_dynasty where comments_id=#{commentsId} or replyer_id=#{commentsId};
|
|
</delete>
|
|
<delete id="UserDeleteCommentsPoemRelation">
|
|
delete from t_reply_poem where comments_id=#{commentsId} or replyer_id=#{commentsId};
|
|
</delete>
|
|
<delete id="UserDoDeleteCommentsPoemReply">
|
|
delete from t_reply_poem
|
|
where comments_id
|
|
in (
|
|
select comments_id from t_comments_poem
|
|
where poem_id=#{poemId}
|
|
)
|
|
</delete>
|
|
<delete id="UserDoDeleteCommentsDynastyReply">
|
|
delete from t_reply_dynasty
|
|
where comments_id
|
|
in (
|
|
select comments_id from t_comments_dynasty
|
|
where dynasty_id=#{dynastyId}
|
|
)
|
|
</delete>
|
|
<delete id="UserDoDeleteCommentsPoem">
|
|
delete from t_comments_poem where poem_id=#{poemId}
|
|
</delete>
|
|
<delete id="UserDoDeleteCommentsDynasty">
|
|
delete from t_comments_dynasty where dynasty_id=#{dynastyId}
|
|
</delete>
|
|
|
|
</mapper> |