You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

129 lines
4.1 KiB

<?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.epmet.modules.topic.dao.ResiTopicCommentDao">
<!-- 新增一条数据 : 一条评论-->
<insert id="insertOne" parameterType="com.epmet.modules.comment.entity.ResiTopicCommentEntity">
<selectKey keyProperty="id" resultType="java.lang.String" order="BEFORE">
select replace(uuid(),'-','') AS ID
</selectKey>
INSERT INTO resi_topic_comment
<trim prefix="(" suffix=")" suffixOverrides=",">
id,
<if test ='null != topicId'>
topic_id,
</if>
<if test ='null != commentContent'>
comment_content,
</if>
<if test='null != status'>
status,
</if>
<if test ='null != createdBy'>
created_by,
</if>
del_flag,
revision,
created_time,
updated_by,
updated_time
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
#{id},
<if test ='null != topicId'>
#{topicId},
</if>
<if test ='null != commentContent'>
#{commentContent},
</if>
<if test='null != status'>
#{status},
</if>
<if test ='null != createdBy'>
#{createdBy},
</if>
'0',
'0',
now(),
'APP_USER',
now()
</trim>
</insert>
<!-- 分页查询某个话题下的评论列表 -->
<select id="getCommentList" parameterType="com.epmet.resi.group.dto.comment.form.ResiQueryCommentFormDTO" resultType="com.epmet.resi.group.dto.comment.result.ResiCommentResultDTO">
SELECT
ID AS commentId,
COMMENT_CONTENT,
STATUS AS commentStatus,
CREATED_TIME AS commentTime,
CREATED_BY AS userId
FROM
RESI_TOPIC_COMMENT
WHERE
DEL_FLAG = '0'
and `STATUS`='discussing'
AND TOPIC_ID = #{topicId}
ORDER BY
CREATED_TIME DESC
LIMIT #{pageNo},#{pageSize}
</select>
<select id="selectTopicList" resultType="java.lang.String">
SELECT
DISTINCT(topic_id)
FROM
resi_topic_comment
WHERE
del_flag = '0'
AND created_by = #{userId}
AND topic_id NOT IN (
SELECT
id
FROM
resi_topic
WHERE
created_by = #{userId}
)
</select>
<!-- 根据userId查询此人今日评论次数 -->
<select id="selectCommentCountByUserId" resultType="java.lang.Integer">
SELECT COUNT(ID) FROM resi_topic_comment
WHERE DEL_FLAG = 0
AND DATE_FORMAT(CREATED_TIME,'%Y%m%d') = DATE_FORMAT(NOW(),'%Y%m%d')
AND CHAR_LENGTH(COMMENT_CONTENT) > 15
AND CREATED_BY = #{userId}
</select>
<select id="selectTopicIds" resultType="java.lang.String">
SELECT DISTINCT
re.topic_id
FROM
resi_topic_comment re
INNER JOIN resi_topic rt ON re.topic_id = rt.id
WHERE
rt.del_flag = '0'
AND re.del_flag = '0'
<!-- 本小组内不是当前被删除人创建的话题 但是当前人评论过的话题 -->
AND rt.group_id = #{groupId}
AND rt.created_by != #{userId}
AND re.created_by = #{userId}
</select>
<!-- 屏蔽当前人员对某些话题的评论 -->
<update id="upTopicCommentList">
UPDATE resi_topic_comment
SET `status` = 'hidden',
updated_by = #{operateUserId},
updated_time = NOW()
WHERE
del_flag = '0'
AND created_by = #{userId}
<foreach collection="delIdList" item="topicId" open="AND (" close=")" separator=" OR ">
topic_id = #{topicId}
</foreach>
</update>
</mapper>