159 lines
4.3 KiB
XML
159 lines
4.3 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.suisung.mall.im.mapper.ChatHistoryMapper">
|
|
|
|
<sql id="chatHistoryColumns">
|
|
a.id,
|
|
a.sender,
|
|
a.receiver,
|
|
a.msg,
|
|
a.status,
|
|
a.create_date,
|
|
a.type
|
|
</sql>
|
|
|
|
<sql id="chatHistoryJoins">
|
|
</sql>
|
|
|
|
<select id="get" resultType="com.suisung.mall.im.pojo.entity.ChatHistory">
|
|
SELECT
|
|
<include refid="chatHistoryColumns"/>
|
|
FROM iim_chat_history a
|
|
<include refid="chatHistoryJoins"/>
|
|
WHERE a.id = #{id}
|
|
</select>
|
|
|
|
<select id="findList" resultType="com.suisung.mall.im.pojo.entity.ChatHistory">
|
|
SELECT
|
|
<include refid="chatHistoryColumns"/>
|
|
FROM iim_chat_history a
|
|
<include refid="chatHistoryJoins"/>
|
|
<where>
|
|
|
|
<if test="sender != null and sender != ''">
|
|
AND a.sender = #{sender}
|
|
</if>
|
|
<if test="receiver != null and receiver != ''">
|
|
AND a.receiver LIKE concat('%',#{receiver},'%')
|
|
</if>
|
|
<if test="msg != null and msg != ''">
|
|
AND a.msg LIKE concat('%',#{msg},'%')
|
|
</if>
|
|
<if test="status != null and status != ''">
|
|
AND a.status = #{status}
|
|
</if>
|
|
<if test="create_date != null and create_date != ''">
|
|
AND a.create_date = #{create_date}
|
|
</if>
|
|
</where>
|
|
ORDER BY a.create_date asc
|
|
</select>
|
|
|
|
<select id="findLogList" resultType="com.suisung.mall.im.pojo.entity.ChatHistory">
|
|
SELECT
|
|
<include refid="chatHistoryColumns"/>
|
|
FROM iim_chat_history a
|
|
<include refid="chatHistoryJoins"/>
|
|
<where>
|
|
|
|
<if test="chatHistory.sender != null and chatHistory.sender != '' and chatHistory.receiver != null and chatHistory.receiver != ''">
|
|
AND ((a.sender = #{chatHistory.sender} AND a.receiver = #{chatHistory.receiver}) or (a.sender = #{chatHistory.receiver} AND a.receiver = #{chatHistory.sender}))
|
|
</if>
|
|
<if test="chatHistory.msg != null and chatHistory.msg != ''">
|
|
AND a.msg LIKE concat('%',#{chatHistory.msg},'%')
|
|
</if>
|
|
<if test="chatHistory.status != null and chatHistory.status != ''">
|
|
AND a.status = #{chatHistory.status}
|
|
</if>
|
|
<if test="chatHistory.create_date != null and chatHistory.create_date != ''">
|
|
AND a.create_date = #{chatHistory.create_date}
|
|
</if>
|
|
</where>
|
|
ORDER BY a.create_date desc
|
|
</select>
|
|
|
|
<select id="findGroupLogList" resultType="com.suisung.mall.im.pojo.entity.ChatHistory">
|
|
SELECT
|
|
<include refid="chatHistoryColumns"/>
|
|
FROM iim_chat_history a
|
|
<include refid="chatHistoryJoins"/>
|
|
<where>
|
|
|
|
<if test="chatHistory.sender != null and chatHistory.sender != '' and chatHistory.receiver != null and chatHistory.receiver != ''">
|
|
AND
|
|
((a.sender = concat(#{chatHistory.receiver},'_msg_',#{chatHistory.sender})
|
|
AND a.receiver = #{chatHistory.sender})
|
|
|
|
OR (a.sender like concat(#{chatHistory.receiver},'_msg_','%')
|
|
and a.receiver = #{chatHistory.sender}))
|
|
|
|
</if>
|
|
<if test="chatHistory.msg != null and chatHistory.msg != ''">
|
|
AND a.msg LIKE concat('%',#{chatHistory.msg},'%')
|
|
</if>
|
|
<if test="chatHistory.status != null and chatHistory.status != ''">
|
|
AND a.status = #{chatHistory.status}
|
|
</if>
|
|
<if test="chatHistory.create_date != null and chatHistory.create_date != ''">
|
|
AND a.create_date = #{chatHistory.create_date}
|
|
</if>
|
|
</where>
|
|
ORDER BY a.create_date desc
|
|
</select>
|
|
<select id="findAllList" resultType="com.suisung.mall.im.pojo.entity.ChatHistory">
|
|
SELECT
|
|
<include refid="chatHistoryColumns"/>
|
|
FROM iim_chat_history a
|
|
<include refid="chatHistoryJoins"/>
|
|
<where>
|
|
|
|
</where>
|
|
ORDER BY a.create_date asc
|
|
</select>
|
|
|
|
<insert id="insert">
|
|
INSERT INTO iim_chat_history(
|
|
id,
|
|
sender,
|
|
receiver,
|
|
msg,
|
|
status,
|
|
create_date,
|
|
type
|
|
) VALUES (
|
|
#{id},
|
|
#{sender},
|
|
#{receiver},
|
|
#{msg},
|
|
#{status},
|
|
NOW(),
|
|
#{type}
|
|
)
|
|
</insert>
|
|
|
|
<update id="update">
|
|
UPDATE iim_chat_history SET
|
|
sender = #{sender},
|
|
receiver = #{receiver},
|
|
msg = #{msg},
|
|
status = #{status},
|
|
create_date = NOW(),
|
|
type = #{type}
|
|
WHERE id = #{id}
|
|
</update>
|
|
|
|
<update id="delete">
|
|
DELETE FROM iim_chat_history
|
|
WHERE id = #{id}
|
|
</update>
|
|
|
|
<!-- 查询全部用户数目 -->
|
|
<select id="findUnReadCount" resultType="int">
|
|
SELECT
|
|
COUNT(1)
|
|
FROM iim_chat_history a WHERE
|
|
a.sender = #{receiver} AND a.receiver = #{sender}
|
|
AND a.status = '0'
|
|
</select>
|
|
|
|
</mapper> |