|
|
|
|
<?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.ResiTopicDao">
|
|
|
|
|
|
|
|
|
|
<!-- 新增话题 -->
|
|
|
|
|
<insert id="insertOne" useGeneratedKeys="true" keyColumn="id" keyProperty="id" parameterType="com.epmet.modules.topic.entity.ResiTopicEntity">
|
|
|
|
|
|
|
|
|
|
<selectKey keyProperty="id" resultType="java.lang.String" order="BEFORE">
|
|
|
|
|
select replace(uuid(),'-','') AS ID
|
|
|
|
|
</selectKey>
|
|
|
|
|
|
|
|
|
|
INSERT INTO resi_topic
|
|
|
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
|
|
|
id,
|
|
|
|
|
<if test ='null != groupId'>
|
|
|
|
|
group_id,
|
|
|
|
|
</if>
|
|
|
|
|
<if test ='null != topicContent'>
|
|
|
|
|
topic_content,
|
|
|
|
|
</if>
|
|
|
|
|
<if test ='null != status'>
|
|
|
|
|
status,
|
|
|
|
|
</if>
|
|
|
|
|
<if test ='null != province'>
|
|
|
|
|
province,
|
|
|
|
|
</if>
|
|
|
|
|
<if test ='null != city'>
|
|
|
|
|
city,
|
|
|
|
|
</if>
|
|
|
|
|
<if test ='null != area'>
|
|
|
|
|
area,
|
|
|
|
|
</if>
|
|
|
|
|
<if test ='null != address'>
|
|
|
|
|
address,
|
|
|
|
|
</if>
|
|
|
|
|
<if test ='null != longitude'>
|
|
|
|
|
longitude,
|
|
|
|
|
</if>
|
|
|
|
|
<if test ='null != dimension'>
|
|
|
|
|
dimension,
|
|
|
|
|
</if>
|
|
|
|
|
<if test ='null != createdBy'>
|
|
|
|
|
created_by,
|
|
|
|
|
</if>
|
|
|
|
|
updated_by,
|
|
|
|
|
del_flag,
|
|
|
|
|
revision,
|
|
|
|
|
created_time,
|
|
|
|
|
updated_time
|
|
|
|
|
|
|
|
|
|
</trim>
|
|
|
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
|
|
|
#{id},
|
|
|
|
|
<if test ='null != groupId'>
|
|
|
|
|
#{groupId},
|
|
|
|
|
</if>
|
|
|
|
|
<if test ='null != topicContent'>
|
|
|
|
|
#{topicContent},
|
|
|
|
|
</if>
|
|
|
|
|
<if test ='null != status'>
|
|
|
|
|
#{status},
|
|
|
|
|
</if>
|
|
|
|
|
<if test ='null != province'>
|
|
|
|
|
#{province},
|
|
|
|
|
</if>
|
|
|
|
|
<if test ='null != city'>
|
|
|
|
|
#{city},
|
|
|
|
|
</if>
|
|
|
|
|
<if test ='null != area'>
|
|
|
|
|
#{area},
|
|
|
|
|
</if>
|
|
|
|
|
<if test ='null != address'>
|
|
|
|
|
#{address},
|
|
|
|
|
</if>
|
|
|
|
|
<if test ='null != longitude'>
|
|
|
|
|
#{longitude},
|
|
|
|
|
</if>
|
|
|
|
|
<if test ='null != dimension'>
|
|
|
|
|
#{dimension},
|
|
|
|
|
</if>
|
|
|
|
|
<if test ='null != createdBy'>
|
|
|
|
|
#{createdBy},
|
|
|
|
|
</if>
|
|
|
|
|
'APP_USER',
|
|
|
|
|
'0',
|
|
|
|
|
'0',
|
|
|
|
|
now(),
|
|
|
|
|
now()
|
|
|
|
|
</trim>
|
|
|
|
|
</insert>
|
|
|
|
|
|
|
|
|
|
<!-- 查询最近十条话题 -->
|
|
|
|
|
<select id="getLatestTenTopics" parameterType="string" resultType="com.epmet.resi.group.dto.topic.result.ResiTopicInfoResultDTO">
|
|
|
|
|
SELECT
|
|
|
|
|
topic.ID AS topicId,
|
|
|
|
|
topic.GROUP_ID,
|
|
|
|
|
topic.TOPIC_CONTENT,
|
|
|
|
|
topic.STATUS,
|
|
|
|
|
topic.CREATED_TIME AS releaseTime,
|
|
|
|
|
topic.CREATED_BY AS userId,
|
|
|
|
|
attachement2.firstPhoto,
|
|
|
|
|
CASE
|
|
|
|
|
WHEN topic.CREATED_BY = #{userId} THEN 'me'
|
|
|
|
|
ELSE 'other'
|
|
|
|
|
END AS releaseUserFlag
|
|
|
|
|
|
|
|
|
|
FROM
|
|
|
|
|
RESI_TOPIC topic
|
|
|
|
|
LEFT JOIN
|
|
|
|
|
(
|
|
|
|
|
SELECT
|
|
|
|
|
attachment.TOPIC_ID AS attachmentTopicId,
|
|
|
|
|
attachment.ATTACHMENT_URL as firstPhoto,
|
|
|
|
|
MIN(attachment.SORD)
|
|
|
|
|
FROM
|
|
|
|
|
RESI_TOPIC_ATTACHMENT attachment
|
|
|
|
|
WHERE
|
|
|
|
|
attachment.DEL_FLAG = '0'
|
|
|
|
|
GROUP BY attachment.TOPIC_ID
|
|
|
|
|
) attachement2
|
|
|
|
|
ON
|
|
|
|
|
topic.ID = attachement2.attachmentTopicId
|
|
|
|
|
WHERE
|
|
|
|
|
topic.DEL_FLAG = '0'
|
|
|
|
|
AND <![CDATA[ topic.STATUS <> 'hidden' ]]>
|
|
|
|
|
AND topic.GROUP_ID = #{groupId}
|
|
|
|
|
ORDER BY
|
|
|
|
|
topic.CREATED_TIME DESC
|
|
|
|
|
LIMIT 10
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<!-- 查询历史话题,分页,参数查询 -->
|
|
|
|
|
<select id="getPastTopics" parameterType="com.epmet.resi.group.dto.topic.form.ResiTopicPageFormDTO" resultType="com.epmet.resi.group.dto.topic.result.ResiTopicInfoResultDTO">
|
|
|
|
|
SELECT
|
|
|
|
|
topic.ID AS topicId,
|
|
|
|
|
topic.GROUP_ID,
|
|
|
|
|
topic.TOPIC_CONTENT,
|
|
|
|
|
topic.STATUS,
|
|
|
|
|
topic.CREATED_TIME AS releaseTime,
|
|
|
|
|
topic.CREATED_BY AS userId,
|
|
|
|
|
attachement2.firstPhoto,
|
|
|
|
|
CASE
|
|
|
|
|
WHEN topic.CREATED_BY = #{userId} THEN 'me'
|
|
|
|
|
ELSE 'other'
|
|
|
|
|
END AS releaseUserFlag
|
|
|
|
|
FROM
|
|
|
|
|
RESI_TOPIC topic
|
|
|
|
|
LEFT JOIN
|
|
|
|
|
(
|
|
|
|
|
SELECT
|
|
|
|
|
attachment.TOPIC_ID AS attachmentTopicId,
|
|
|
|
|
attachment.ATTACHMENT_URL as firstPhoto,
|
|
|
|
|
MIN(attachment.SORT)
|
|
|
|
|
FROM
|
|
|
|
|
RESI_TOPIC_ATTACHMENT attachment
|
|
|
|
|
WHERE
|
|
|
|
|
attachment.DEL_FLAG = '0'
|
|
|
|
|
GROUP BY attachment.TOPIC_ID
|
|
|
|
|
) attachement2
|
|
|
|
|
ON
|
|
|
|
|
topic.ID = attachement2.attachmentTopicId
|
|
|
|
|
<where>
|
|
|
|
|
topic.DEL_FLAG = '0'
|
|
|
|
|
AND topic.GROUP_ID = #{groupId}
|
|
|
|
|
<if test='"hidden" != status'>
|
|
|
|
|
AND <![CDATA[ topic.STATUS <> 'hidden' ]]>
|
|
|
|
|
</if>
|
|
|
|
|
<if test='null != status and "" != status'>
|
|
|
|
|
AND topic.STATUS = #{status}
|
|
|
|
|
</if>
|
|
|
|
|
|
|
|
|
|
</where>
|
|
|
|
|
ORDER BY
|
|
|
|
|
topic.CREATED_TIME DESC
|
|
|
|
|
LIMIT #{pageNo},#{pageSize}
|
|
|
|
|
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<!-- 单条更新 -->
|
|
|
|
|
<update id="update" parameterType="com.epmet.modules.topic.entity.ResiTopicEntity">
|
|
|
|
|
|
|
|
|
|
UPDATE
|
|
|
|
|
RESI_TOPIC
|
|
|
|
|
<set>
|
|
|
|
|
<if test='null != status and "" != status'>
|
|
|
|
|
STATUS = #{status} ,
|
|
|
|
|
</if>
|
|
|
|
|
<if test='null != delFlag and "" != delFlag'>
|
|
|
|
|
DEL_FLAG = #{delFlag} ,
|
|
|
|
|
</if>
|
|
|
|
|
<if test='null != topicContent and "" != topicContent'>
|
|
|
|
|
TOPIC_CONTENT = #{topicContent} ,
|
|
|
|
|
</if>
|
|
|
|
|
UPDATED_BY = #{updatedBy} ,
|
|
|
|
|
UPDATED_TIME = NOW()
|
|
|
|
|
</set>
|
|
|
|
|
WHERE
|
|
|
|
|
ID = #{id}
|
|
|
|
|
AND DEL_FLAG = '0'
|
|
|
|
|
</update>
|
|
|
|
|
|
|
|
|
|
<!-- 批量取消屏蔽 -->
|
|
|
|
|
<update id="cancelHiddenOrCloseBatch">
|
|
|
|
|
UPDATE
|
|
|
|
|
RESI_TOPIC
|
|
|
|
|
SET
|
|
|
|
|
STATUS = #{status},
|
|
|
|
|
UPDATED_TIME = NOW(),
|
|
|
|
|
UPDATED_BY = #{updatedBy}
|
|
|
|
|
<where>
|
|
|
|
|
ID
|
|
|
|
|
<foreach collection="list" item="item" index="index" open="in (" separator="," close=")">
|
|
|
|
|
#{item}
|
|
|
|
|
</foreach>
|
|
|
|
|
AND
|
|
|
|
|
DEL_FLAG = '0'
|
|
|
|
|
<if test='"discussing" == status'>
|
|
|
|
|
AND STATUS = 'hidden'
|
|
|
|
|
</if>
|
|
|
|
|
</where>
|
|
|
|
|
</update>
|
|
|
|
|
|
|
|
|
|
<!-- 批量更新 -->
|
|
|
|
|
<update id="updateBatch" parameterType="list">
|
|
|
|
|
update RESI_TOPIC
|
|
|
|
|
<trim prefix="set" suffixOverrides=",">
|
|
|
|
|
<trim prefix="topic_content= case" suffix="end,">
|
|
|
|
|
<foreach collection="list" item="i" index="index">
|
|
|
|
|
<if test="i.topicContent!=null">
|
|
|
|
|
when id=#{i.id} then #{i.topicContent}
|
|
|
|
|
</if>
|
|
|
|
|
</foreach>
|
|
|
|
|
</trim>
|
|
|
|
|
<trim prefix=" status =case" suffix="end,">
|
|
|
|
|
<foreach collection="list" item="i" index="index">
|
|
|
|
|
<if test="i.status!=null">
|
|
|
|
|
when id=#{i.id} then #{i.status}
|
|
|
|
|
</if>
|
|
|
|
|
</foreach>
|
|
|
|
|
</trim>
|
|
|
|
|
|
|
|
|
|
<trim prefix="updated_by =case" suffix="end," >
|
|
|
|
|
<foreach collection="list" item="i" index="index">
|
|
|
|
|
<if test="i.updatedBy!=null">
|
|
|
|
|
when id=#{i.id} then #{i.updatedBy}
|
|
|
|
|
</if>
|
|
|
|
|
</foreach>
|
|
|
|
|
</trim>
|
|
|
|
|
</trim>
|
|
|
|
|
updated_time = now()
|
|
|
|
|
where
|
|
|
|
|
<foreach collection="list" separator="or" item="i" index="index" >
|
|
|
|
|
id=#{i.id}
|
|
|
|
|
</foreach>
|
|
|
|
|
</update>
|
|
|
|
|
|
|
|
|
|
</mapper>
|