|
|
@@ -0,0 +1,216 @@
|
|
|
+<?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.kede.common.dao.ChatMsgMapper">
|
|
|
+
|
|
|
+ <resultMap type="com.kede.common.model.ChatMsg" id="ChatMsgMap">
|
|
|
+ <result property="id" column="id" jdbcType="INTEGER"/>
|
|
|
+ <result property="msgid" column="msgid" jdbcType="VARCHAR"/>
|
|
|
+ <result property="action" column="action" jdbcType="VARCHAR"/>
|
|
|
+ <result property="from" column="from" jdbcType="VARCHAR"/>
|
|
|
+ <result property="fromName" column="from_name" jdbcType="VARCHAR"/>
|
|
|
+ <result property="tolist" column="tolist" jdbcType="VARCHAR"/>
|
|
|
+ <result property="tolistName" column="tolist_name" jdbcType="VARCHAR"/>
|
|
|
+ <result property="roomid" column="roomid" jdbcType="VARCHAR"/>
|
|
|
+ <result property="msgtime" column="msgtime" jdbcType="TIMESTAMP"/>
|
|
|
+ <result property="msgtype" column="msgtype" jdbcType="VARCHAR"/>
|
|
|
+ <result property="content" column="content" jdbcType="VARCHAR"/>
|
|
|
+ <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
|
|
|
+ </resultMap>
|
|
|
+
|
|
|
+ <sql id="ChatMsgAllSql">
|
|
|
+ id, msgid, action, from, from_name, tolist, tolist_name, roomid, msgtime, msgtype, content, create_time
|
|
|
+ </sql>
|
|
|
+
|
|
|
+ <!--查询单个-->
|
|
|
+ <select id="selectById" resultMap="ChatMsgMap">
|
|
|
+ select
|
|
|
+ <include refid="ChatMsgAllSql"/>
|
|
|
+ from chat_msg
|
|
|
+ where id = #{id}
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!--新增所有列-->
|
|
|
+ <insert id="insert" keyProperty="id" useGeneratedKeys="true">
|
|
|
+ insert into chat_msg(msgid, action, from, from_name, tolist, tolist_name, roomid, msgtime, msgtype, content,
|
|
|
+ create_time)
|
|
|
+ values (#{msgid}, #{action}, #{from}, #{fromName}, #{tolist}, #{tolistName}, #{roomid}, #{msgtime}, #{msgtype},
|
|
|
+ #{content}, #{createTime})
|
|
|
+ </insert>
|
|
|
+
|
|
|
+ <insert id="insertBatch">
|
|
|
+ insert into chat_msg(msgid, action, from, from_name, tolist, tolist_name, roomid, msgtime, msgtype, content,
|
|
|
+ create_time)
|
|
|
+ values
|
|
|
+ <foreach collection="entities" item="entity" separator=",">
|
|
|
+ (#{entity.msgid}, #{entity.action}, #{entity.from}, #{entity.fromName}, #{entity.tolist},
|
|
|
+ #{entity.tolistName}, #{entity.roomid}, #{entity.msgtime}, #{entity.msgtype}, #{entity.content},
|
|
|
+ #{entity.createTime})
|
|
|
+ </foreach>
|
|
|
+ </insert>
|
|
|
+
|
|
|
+ <insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
|
|
|
+ insert into chat_msg(msgid, action, from, from_name, tolist, tolist_name, roomid, msgtime, msgtype, content,
|
|
|
+ create_time)
|
|
|
+ values
|
|
|
+ <foreach collection="entities" item="entity" separator=",">
|
|
|
+ (#{entity.msgid}, #{entity.action}, #{entity.from}, #{entity.fromName}, #{entity.tolist},
|
|
|
+ #{entity.tolistName}, #{entity.roomid}, #{entity.msgtime}, #{entity.msgtype}, #{entity.content},
|
|
|
+ #{entity.createTime})
|
|
|
+ </foreach>
|
|
|
+ on duplicate key update
|
|
|
+ msgid = values(msgid),
|
|
|
+ action = values(action),
|
|
|
+ from = values(from),
|
|
|
+ from_name = values(from_name),
|
|
|
+ tolist = values(tolist),
|
|
|
+ tolist_name = values(tolist_name),
|
|
|
+ roomid = values(roomid),
|
|
|
+ msgtime = values(msgtime),
|
|
|
+ msgtype = values(msgtype),
|
|
|
+ content = values(content),
|
|
|
+ create_time = values(create_time)
|
|
|
+ </insert>
|
|
|
+
|
|
|
+ <!--通过主键修改数据-->
|
|
|
+ <update id="update">
|
|
|
+ update chat_msg
|
|
|
+ <set>
|
|
|
+ <if test="msgid != null and msgid != ''">
|
|
|
+ msgid = #{msgid},
|
|
|
+ </if>
|
|
|
+ <if test="action != null and action != ''">
|
|
|
+ action = #{action},
|
|
|
+ </if>
|
|
|
+ <if test="from != null and from != ''">
|
|
|
+ from = #{from},
|
|
|
+ </if>
|
|
|
+ <if test="fromName != null and fromName != ''">
|
|
|
+ from_name = #{fromName},
|
|
|
+ </if>
|
|
|
+ <if test="tolist != null and tolist != ''">
|
|
|
+ tolist = #{tolist},
|
|
|
+ </if>
|
|
|
+ <if test="tolistName != null and tolistName != ''">
|
|
|
+ tolist_name = #{tolistName},
|
|
|
+ </if>
|
|
|
+ <if test="roomid != null and roomid != ''">
|
|
|
+ roomid = #{roomid},
|
|
|
+ </if>
|
|
|
+ <if test="msgtime != null">
|
|
|
+ msgtime = #{msgtime},
|
|
|
+ </if>
|
|
|
+ <if test="msgtype != null and msgtype != ''">
|
|
|
+ msgtype = #{msgtype},
|
|
|
+ </if>
|
|
|
+ <if test="content != null and content != ''">
|
|
|
+ content = #{content},
|
|
|
+ </if>
|
|
|
+ <if test="createTime != null">
|
|
|
+ create_time = #{createTime},
|
|
|
+ </if>
|
|
|
+ </set>
|
|
|
+ where id = #{id}
|
|
|
+ </update>
|
|
|
+
|
|
|
+ <!--查询指定行数据-->
|
|
|
+ <select id="findChatMsgList" resultMap="ChatMsgMap">
|
|
|
+ select
|
|
|
+ <include refid="ChatMsgAllSql"/>
|
|
|
+
|
|
|
+ from chat_msg
|
|
|
+ <where>
|
|
|
+ <if test="id != null">
|
|
|
+ and id = #{id}
|
|
|
+ </if>
|
|
|
+ <if test="msgid != null and msgid != ''">
|
|
|
+ and msgid = #{msgid}
|
|
|
+ </if>
|
|
|
+ <if test="action != null and action != ''">
|
|
|
+ and action = #{action}
|
|
|
+ </if>
|
|
|
+ <if test="from != null and from != ''">
|
|
|
+ and from = #{from}
|
|
|
+ </if>
|
|
|
+ <if test="fromName != null and fromName != ''">
|
|
|
+ and from_name = #{fromName}
|
|
|
+ </if>
|
|
|
+ <if test="tolist != null and tolist != ''">
|
|
|
+ and tolist = #{tolist}
|
|
|
+ </if>
|
|
|
+ <if test="tolistName != null and tolistName != ''">
|
|
|
+ and tolist_name = #{tolistName}
|
|
|
+ </if>
|
|
|
+ <if test="roomid != null and roomid != ''">
|
|
|
+ and roomid = #{roomid}
|
|
|
+ </if>
|
|
|
+ <if test="msgtime != null">
|
|
|
+ and msgtime = #{msgtime}
|
|
|
+ </if>
|
|
|
+ <if test="msgtype != null and msgtype != ''">
|
|
|
+ and msgtype = #{msgtype}
|
|
|
+ </if>
|
|
|
+ <if test="content != null and content != ''">
|
|
|
+ and content = #{content}
|
|
|
+ </if>
|
|
|
+ <if test="createTime != null">
|
|
|
+ and create_time = #{createTime}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ <if test="page_sql != null">
|
|
|
+ ${page_sql}
|
|
|
+ </if>
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!--统计总行数-->
|
|
|
+ <select id="findChatMsgCount" resultType="java.lang.Integer">
|
|
|
+ select count(1)
|
|
|
+ from chat_msg
|
|
|
+ <where>
|
|
|
+ <if test="id != null">
|
|
|
+ and id = #{id}
|
|
|
+ </if>
|
|
|
+ <if test="msgid != null and msgid != ''">
|
|
|
+ and msgid = #{msgid}
|
|
|
+ </if>
|
|
|
+ <if test="action != null and action != ''">
|
|
|
+ and action = #{action}
|
|
|
+ </if>
|
|
|
+ <if test="from != null and from != ''">
|
|
|
+ and from = #{from}
|
|
|
+ </if>
|
|
|
+ <if test="fromName != null and fromName != ''">
|
|
|
+ and from_name = #{fromName}
|
|
|
+ </if>
|
|
|
+ <if test="tolist != null and tolist != ''">
|
|
|
+ and tolist = #{tolist}
|
|
|
+ </if>
|
|
|
+ <if test="tolistName != null and tolistName != ''">
|
|
|
+ and tolist_name = #{tolistName}
|
|
|
+ </if>
|
|
|
+ <if test="roomid != null and roomid != ''">
|
|
|
+ and roomid = #{roomid}
|
|
|
+ </if>
|
|
|
+ <if test="msgtime != null">
|
|
|
+ and msgtime = #{msgtime}
|
|
|
+ </if>
|
|
|
+ <if test="msgtype != null and msgtype != ''">
|
|
|
+ and msgtype = #{msgtype}
|
|
|
+ </if>
|
|
|
+ <if test="content != null and content != ''">
|
|
|
+ and content = #{content}
|
|
|
+ </if>
|
|
|
+ <if test="createTime != null">
|
|
|
+ and create_time = #{createTime}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!--通过主键删除-->
|
|
|
+ <delete id="deleteById">
|
|
|
+ delete
|
|
|
+ from chat_msg
|
|
|
+ where id = #{id}
|
|
|
+ </delete>
|
|
|
+
|
|
|
+</mapper>
|
|
|
+
|