| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 |
- <?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.ChatMsgUserMapper">
- <resultMap type="com.kede.common.model.ChatMsgUser" id="ChatMsgUserMap">
- <result property="id" column="id" jdbcType="INTEGER"/>
- <result property="userId" column="user_id" jdbcType="VARCHAR"/>
- <result property="name" column="name" jdbcType="VARCHAR"/>
- <result property="type" column="type" jdbcType="INTEGER"/>
- <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
- <result property="provinceType" column="province_type" jdbcType="INTEGER"/>
- </resultMap>
- <sql id="ChatMsgUserAllSql">
- id, user_id, name, type, create_time, province_type
- </sql>
- <!--查询单个-->
- <select id="selectById" resultMap="ChatMsgUserMap">
- select
- <include refid="ChatMsgUserAllSql"/>
- from chat_msg_user
- where id = #{id}
- </select>
- <!--新增所有列-->
- <insert id="insert" keyProperty="id" useGeneratedKeys="true">
- insert into chat_msg_user(user_id, name, type, create_time, province_type)
- values (#{userId}, #{name}, #{type}, #{createTime}, #{provinceType})
- </insert>
- <insert id="insertBatch">
- insert into chat_msg_user(user_id, name, type, create_time, province_type)
- values
- <foreach collection="entities" item="entity" separator=",">
- (#{entity.userId}, #{entity.name}, #{entity.type}, #{entity.createTime}, #{entity.provinceType})
- </foreach>
- </insert>
- <insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
- insert into chat_msg_user(user_id, name, type, create_time, province_type)
- values
- <foreach collection="entities" item="entity" separator=",">
- (#{entity.userId}, #{entity.name}, #{entity.type}, #{entity.createTime}, #{entity.provinceType})
- </foreach>
- on duplicate key update
- user_id = values(user_id),
- name = values(name),
- type = values(type),
- create_time = values(create_time),
- province_type = values(province_type)
- </insert>
- <!--通过主键修改数据-->
- <update id="update">
- update chat_msg_user
- <set>
- <if test="userId != null and userId != ''">
- user_id = #{userId},
- </if>
- <if test="name != null and name != ''">
- name = #{name},
- </if>
- <if test="type != null">
- type = #{type},
- </if>
- <if test="createTime != null">
- create_time = #{createTime},
- </if>
- <if test="provinceType != null">
- province_type = #{provinceType},
- </if>
- </set>
- where id = #{id}
- </update>
- <!--查询指定行数据-->
- <select id="findChatMsgUserList" resultMap="ChatMsgUserMap">
- select
- <include refid="ChatMsgUserAllSql"/>
- from chat_msg_user
- <where>
- <if test="id != null">
- and id = #{id}
- </if>
- <if test="userId != null and userId != ''">
- and user_id = #{userId}
- </if>
- <if test="name != null and name != ''">
- and name = #{name}
- </if>
- <if test="type != null">
- and type = #{type}
- </if>
- <if test="createTime != null">
- and create_time = #{createTime}
- </if>
- <if test="provinceType != null">
- and province_type = #{provinceType}
- </if>
- </where>
- <if test="page_sql != null">
- ${page_sql}
- </if>
- </select>
- <!--统计总行数-->
- <select id="findChatMsgUserCount" resultType="java.lang.Integer">
- select count(1)
- from chat_msg_user
- <where>
- <if test="id != null">
- and id = #{id}
- </if>
- <if test="userId != null and userId != ''">
- and user_id = #{userId}
- </if>
- <if test="name != null and name != ''">
- and name = #{name}
- </if>
- <if test="type != null">
- and type = #{type}
- </if>
- <if test="createTime != null">
- and create_time = #{createTime}
- </if>
- <if test="provinceType != null">
- and province_type = #{provinceType}
- </if>
- </where>
- </select>
- <!--通过主键删除-->
- <delete id="deleteById">
- delete
- from chat_msg_user
- where id = #{id}
- </delete>
- <delete id="deleteByUserId">
- delete
- from chat_msg_user
- where chat_msg_user.user_id = #{id}
- </delete>
- <select id="selectByUserId" resultMap="ChatMsgUserMap">
- select
- <include refid="ChatMsgUserAllSql"/>
- from chat_msg_user
- where user_id = #{id}
- <if test="provinceType != null">
- and province_type = #{provinceType}
- </if>
- </select>
- <select id="getUserList" resultMap="ChatMsgUserMap">
- select
- <include refid="ChatMsgUserAllSql"/>
- from chat_msg_user
- <where>
- <if test="type != null">
- and type = #{type}
- </if>
- <if test="provinceType != null">
- and province_type = #{provinceType}
- </if>
- </where>
- </select>
- <select id="selectMyIdByUser" resultMap="ChatMsgUserMap">
- select x.user_id,b.name
- from (select tolist user_id
- from chat_msg
- where from_id = #{userId} and type=0
- <if test="startTime != null and startTime != ''">
- and msgtime between #{startTime} and #{endTime}
- </if>
- union
- select from_id user_id
- from chat_msg
- where find_in_set(#{userId},tolist) and type=0
- <if test="startTime != null and startTime != ''">
- and msgtime between #{startTime} and #{endTime}
- </if>
- )x left join chat_msg_user b on x.user_id=b.user_id
- </select>
- <select id="selectMyIdByRoom" resultType="com.kede.common.model.ChatMsgUser">
- select x.roomid userId,b.name
- from (select roomid
- from chat_msg
- where from_id = #{userId} and type=1
- <if test="startTime != null and startTime != ''">
- and msgtime between #{startTime} and #{endTime}
- </if>
- union
- select roomid
- from chat_msg
- where find_in_set(#{userId},tolist) and type=1
- <if test="startTime != null and startTime != ''">
- and msgtime between #{startTime} and #{endTime}
- </if>
- )x left join chat_msg_user b on x.roomid=b.user_id
- </select>
- </mapper>
|