|
@@ -0,0 +1,247 @@
|
|
|
+<?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.ruoyi.system.mapper.CommentIndexMapper">
|
|
|
+
|
|
|
+ <resultMap type="CommentIndex" id="CommentIndexResult">
|
|
|
+ <result property="commentId" column="comment_id"/>
|
|
|
+ <result property="communityId" column="community_id"/>
|
|
|
+ <result property="communityType" column="community_type"/>
|
|
|
+ <result property="isRoot" column="is_root"/>
|
|
|
+ <result property="parentId" column="parent_id"/>
|
|
|
+ <result property="userId" column="user_id"/>
|
|
|
+ <result property="nickName" column="nick_name"/>
|
|
|
+ <result property="avatar" column="avatar"/>
|
|
|
+ <result property="toUserId" column="to_user_id"/>
|
|
|
+ <result property="toNickName" column="to_nick_name"/>
|
|
|
+ <result property="toAvatar" column="to_avatar"/>
|
|
|
+ <result property="contentId" column="content_id"/>
|
|
|
+ <result property="commentContent" column="comment_content"/>
|
|
|
+ <result property="delFlag" column="del_flag"/>
|
|
|
+ <result property="createBy" column="create_by"/>
|
|
|
+ <result property="createTime" column="create_time"/>
|
|
|
+ <result property="updateBy" column="update_by"/>
|
|
|
+ <result property="updateTime" column="update_time"/>
|
|
|
+ <result property="remark" column="remark"/>
|
|
|
+ </resultMap>
|
|
|
+ <!--回复列表返回给前端的格式-->
|
|
|
+ <resultMap type="com.ruoyi.system.domain.communityNews.vo.CommentIndexVo" id="CommentIndexVoResult">
|
|
|
+ <id property="id" column="ci_id"/>
|
|
|
+ <result property="content" column="ci_content"/>
|
|
|
+ <result property="likeCount" column="ci_likeCount"/>
|
|
|
+ <result property="isLike" column="ci_isLike"/>
|
|
|
+ <result property="createTime" column="ci_create_time"/>
|
|
|
+ <association property="commentUserVo" javaType="com.ruoyi.system.domain.communityNews.vo.CommentUserVo"
|
|
|
+ resultMap="CommentUserVoResult"/>
|
|
|
+ <collection property="childrenList" javaType="java.util.List" resultMap="ChildrenListResult"/>
|
|
|
+ </resultMap>
|
|
|
+ <resultMap id="ChildrenListResult" type="com.ruoyi.system.domain.communityNews.vo.CommentChildrenVo">
|
|
|
+ <result property="content" column="cl_content"/>
|
|
|
+ <result property="likeCount" column="cl_likeCount"/>
|
|
|
+ <result property="isLike" column="cl_isLike"/>
|
|
|
+ <result property="createTime" column="cl_create_time"/>
|
|
|
+ <association property="commentUserVo" javaType="com.ruoyi.system.domain.communityNews.vo.CommentUserVo"
|
|
|
+ resultMap="CommentUserVoResult"/>
|
|
|
+ <association property="targetUserVo" javaType="com.ruoyi.system.domain.communityNews.vo.TargetUserVo"
|
|
|
+ resultMap="TargetUserVoResult"/>
|
|
|
+ </resultMap>
|
|
|
+ <resultMap id="CommentUserVoResult" type="com.ruoyi.system.domain.communityNews.vo.CommentUserVo">
|
|
|
+ <id property="id" column="cu_id"/>
|
|
|
+ <result property="nickName" column="cu_nickName"/>
|
|
|
+ <result property="avatar" column="cu_avatar"/>
|
|
|
+ <result property="createTime" column="cl_create_time"/>
|
|
|
+ </resultMap>
|
|
|
+ <resultMap id="TargetUserVoResult" type="com.ruoyi.system.domain.communityNews.vo.TargetUserVo">
|
|
|
+ <id property="id" column="tu_id"/>
|
|
|
+ <result property="nickName" column="tu_nickName"/>
|
|
|
+ <result property="avatar" column="tu_avatar"/>
|
|
|
+ <result property="createTime" column="tu_create_time"/>
|
|
|
+ </resultMap>
|
|
|
+
|
|
|
+
|
|
|
+ <sql id="selectCommentIndexVo">
|
|
|
+ select comment_id,
|
|
|
+ community_id,
|
|
|
+ community_type,
|
|
|
+ is_root,
|
|
|
+ parent_id,
|
|
|
+ user_id,
|
|
|
+ nick_name,
|
|
|
+ avatar,
|
|
|
+ to_user_id,
|
|
|
+ to_nick_name,
|
|
|
+ to_avatar,
|
|
|
+ content_id,
|
|
|
+ comment_content,
|
|
|
+ del_flag,
|
|
|
+ create_by,
|
|
|
+ create_time,
|
|
|
+ update_by,
|
|
|
+ update_time,
|
|
|
+ remark
|
|
|
+ from comment_index
|
|
|
+ </sql>
|
|
|
+
|
|
|
+ <select id="selectCommentIndexList" parameterType="CommentIndex" resultMap="CommentIndexResult">
|
|
|
+ <include refid="selectCommentIndexVo"/>
|
|
|
+ <where>
|
|
|
+ <if test="communityId != null ">and community_id = #{communityId}</if>
|
|
|
+ <if test="communityType != null and communityType != ''">and community_type = #{communityType}</if>
|
|
|
+ <if test="isRoot != null ">and is_root = #{isRoot}</if>
|
|
|
+ <if test="parentId != null ">and parent_id = #{parentId}</if>
|
|
|
+ <if test="userId != null ">and user_id = #{userId}</if>
|
|
|
+ <if test="nickName != null and nickName != ''">and nick_name like concat('%', #{nickName}, '%')</if>
|
|
|
+ <if test="avatar != null and avatar != ''">and avatar = #{avatar}</if>
|
|
|
+ <if test="toUserId != null ">and to_user_id = #{toUserId}</if>
|
|
|
+ <if test="toNickName != null and toNickName != ''">and to_nick_name like concat('%', #{toNickName}, '%')
|
|
|
+ </if>
|
|
|
+ <if test="toAvatar != null and toAvatar != ''">and to_avatar = #{toAvatar}</if>
|
|
|
+ <if test="contentId != null ">and content_id = #{contentId}</if>
|
|
|
+ <if test="commentContent != null and commentContent != ''">and comment_content = #{commentContent}</if>
|
|
|
+ </where>
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="selectCommentIndexByCommentId" parameterType="Long" resultMap="CommentIndexResult">
|
|
|
+ <include refid="selectCommentIndexVo"/>
|
|
|
+ where comment_id = #{commentId}
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="getAllComment" parameterType="CommentIndex" resultMap="CommentIndexVoResult">
|
|
|
+ SELECT
|
|
|
+ i.comment_id AS ci_id,
|
|
|
+ i.create_time AS ci_create_time,
|
|
|
+ c.comment_content AS ci_content,
|
|
|
+ children.cu_id AS cu_id,
|
|
|
+ children.cu_nick_name AS cu_nickName,
|
|
|
+ children.cu_avatar AS cu_avatar,
|
|
|
+ children.cl_create_time AS cl_create_time,
|
|
|
+ children.ta_id AS tu_id,
|
|
|
+ children.ta_nick_name AS tu_nickName,
|
|
|
+ children.ta_avatar AS tu_avatar,
|
|
|
+ children.tu_create_time AS tu_create_time,
|
|
|
+ children.c_content AS cl_content
|
|
|
+ FROM
|
|
|
+ comment_index i
|
|
|
+ LEFT JOIN comment_content c ON i.content_id = c.content_id
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ i.community_id AS ci_id,
|
|
|
+ i.parent_id AS ci_parent_id,
|
|
|
+ i.user_id AS cu_id,
|
|
|
+ i.nick_name AS cu_nick_name,
|
|
|
+ i.avatar AS cu_avatar,
|
|
|
+ i.to_user_id AS ta_id,
|
|
|
+ i.to_nick_name AS ta_nick_name,
|
|
|
+ i.to_avatar AS ta_avatar,
|
|
|
+ i.create_time AS cl_create_time,
|
|
|
+ i.create_time AS tu_create_time,
|
|
|
+ c.comment_content AS c_content
|
|
|
+ FROM
|
|
|
+ comment_index i
|
|
|
+ LEFT JOIN comment_content c ON i.content_id = c.content_id
|
|
|
+ WHERE
|
|
|
+ c.STATUS = '2'
|
|
|
+ AND i.is_root = 2
|
|
|
+ AND c.del_flag = 'N'
|
|
|
+ AND i.del_flag = 'N'
|
|
|
+ ) AS children ON children.ci_parent_id = i.comment_id
|
|
|
+ WHERE
|
|
|
+ c.STATUS = '2'
|
|
|
+ AND i.is_root = 1
|
|
|
+ AND c.del_flag = 'N'
|
|
|
+ AND i.del_flag = 'N'
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <insert id="insertCommentIndex" parameterType="CommentIndex" useGeneratedKeys="true" keyProperty="commentId">
|
|
|
+ insert into comment_index
|
|
|
+ <trim prefix="(" suffix=")" suffixOverrides=",">
|
|
|
+ <if test="communityId != null">community_id,</if>
|
|
|
+ <if test="communityType != null and communityType != ''">community_type,</if>
|
|
|
+ <if test="isRoot != null">is_root,</if>
|
|
|
+ <if test="parentId != null">parent_id,</if>
|
|
|
+ <if test="userId != null">user_id,</if>
|
|
|
+ <if test="nickName != null">nick_name,</if>
|
|
|
+ <if test="avatar != null">avatar,</if>
|
|
|
+ <if test="toUserId != null">to_user_id,</if>
|
|
|
+ <if test="toNickName != null">to_nick_name,</if>
|
|
|
+ <if test="toAvatar != null">to_avatar,</if>
|
|
|
+ <if test="contentId != null">content_id,</if>
|
|
|
+ <if test="commentContent != null">comment_content,</if>
|
|
|
+ <if test="delFlag != null">del_flag,</if>
|
|
|
+ <if test="createBy != null">create_by,</if>
|
|
|
+ <if test="createTime != null">create_time,</if>
|
|
|
+ <if test="updateBy != null">update_by,</if>
|
|
|
+ <if test="updateTime != null">update_time,</if>
|
|
|
+ <if test="remark != null">remark,</if>
|
|
|
+ </trim>
|
|
|
+ <trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
|
+ <if test="communityId != null">#{communityId},</if>
|
|
|
+ <if test="communityType != null and communityType != ''">#{communityType},</if>
|
|
|
+ <if test="isRoot != null">#{isRoot},</if>
|
|
|
+ <if test="parentId != null">#{parentId},</if>
|
|
|
+ <if test="userId != null">#{userId},</if>
|
|
|
+ <if test="nickName != null">#{nickName},</if>
|
|
|
+ <if test="avatar != null">#{avatar},</if>
|
|
|
+ <if test="toUserId != null">#{toUserId},</if>
|
|
|
+ <if test="toNickName != null">#{toNickName},</if>
|
|
|
+ <if test="toAvatar != null">#{toAvatar},</if>
|
|
|
+ <if test="contentId != null">#{contentId},</if>
|
|
|
+ <if test="commentContent != null">#{commentContent},</if>
|
|
|
+ <if test="delFlag != null">#{delFlag},</if>
|
|
|
+ <if test="createBy != null">#{createBy},</if>
|
|
|
+ <if test="createTime != null">#{createTime},</if>
|
|
|
+ <if test="updateBy != null">#{updateBy},</if>
|
|
|
+ <if test="updateTime != null">#{updateTime},</if>
|
|
|
+ <if test="remark != null">#{remark},</if>
|
|
|
+ </trim>
|
|
|
+ </insert>
|
|
|
+
|
|
|
+ <update id="updateCommentIndex" parameterType="CommentIndex">
|
|
|
+ update comment_index
|
|
|
+ <trim prefix="SET" suffixOverrides=",">
|
|
|
+ <if test="communityId != null">community_id = #{communityId},</if>
|
|
|
+ <if test="communityType != null and communityType != ''">community_type = #{communityType},</if>
|
|
|
+ <if test="isRoot != null">is_root = #{isRoot},</if>
|
|
|
+ <if test="parentId != null">parent_id = #{parentId},</if>
|
|
|
+ <if test="userId != null">user_id = #{userId},</if>
|
|
|
+ <if test="nickName != null">nick_name = #{nickName},</if>
|
|
|
+ <if test="avatar != null">avatar = #{avatar},</if>
|
|
|
+ <if test="toUserId != null">to_user_id = #{toUserId},</if>
|
|
|
+ <if test="toNickName != null">to_nick_name = #{toNickName},</if>
|
|
|
+ <if test="toAvatar != null">to_avatar = #{toAvatar},</if>
|
|
|
+ <if test="contentId != null">content_id = #{contentId},</if>
|
|
|
+ <if test="commentContent != null">comment_content = #{commentContent},</if>
|
|
|
+ <if test="delFlag != null">del_flag = #{delFlag},</if>
|
|
|
+ <if test="createBy != null">create_by = #{createBy},</if>
|
|
|
+ <if test="createTime != null">create_time = #{createTime},</if>
|
|
|
+ <if test="updateBy != null">update_by = #{updateBy},</if>
|
|
|
+ <if test="updateTime != null">update_time = #{updateTime},</if>
|
|
|
+ <if test="remark != null">remark = #{remark},</if>
|
|
|
+ </trim>
|
|
|
+ where comment_id = #{commentId}
|
|
|
+ </update>
|
|
|
+
|
|
|
+ <delete id="deleteCommentIndexByCommentId" parameterType="Long">
|
|
|
+ delete
|
|
|
+ from comment_index
|
|
|
+ where comment_id = #{commentId}
|
|
|
+ </delete>
|
|
|
+ <update id="updateCommentIndexByCommentId" parameterType="CommentIndex">
|
|
|
+ update set delFlag = 'Y'
|
|
|
+ from comment_index
|
|
|
+ where comment_id = #{commentId}
|
|
|
+ </update>
|
|
|
+ <update id="updateCommentIndexByParentId" parameterType="CommentIndex">
|
|
|
+ update set delFlag = 'Y'
|
|
|
+ from comment_index
|
|
|
+ where parent_id = #{commentId}
|
|
|
+ </update>
|
|
|
+
|
|
|
+ <delete id="deleteCommentIndexByCommentIds" parameterType="String">
|
|
|
+ delete from comment_index where comment_id in
|
|
|
+ <foreach item="commentId" collection="array" open="(" separator="," close=")">
|
|
|
+ #{commentId}
|
|
|
+ </foreach>
|
|
|
+ </delete>
|
|
|
+</mapper>
|