WechatMessageMapper.xml 5.4 KB
Newer Older
张新旗 committed
1 2 3 4
<?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">
5
<mapper namespace="com.soss.system.mapper.WechatMessageMapper">
张新旗 committed
6 7 8 9 10 11
    
    <resultMap type="WechatMessage" id="WechatMessageResult">
        <result property="id"    column="id"    />
        <result property="userId"    column="user_id"    />
        <result property="msgId"    column="msg_id"    />
        <result property="message"    column="message"    />
caiyt committed
12
        <result property="targetId" column="target_id"/>
张新旗 committed
13 14 15 16 17 18 19 20 21 22
        <result property="targetUrl"    column="target_url"    />
        <result property="state"    column="state"    />
        <result property="type"    column="type"    />
        <result property="isRead"    column="is_read"    />
        <result property="isDeleted"    column="is_deleted"    />
        <result property="createdAt"    column="created_at"    />
        <result property="updatedAt"    column="updated_at"    />
    </resultMap>

    <sql id="selectWechatMessageVo">
caiyt committed
23
        select * from wechat_message
张新旗 committed
24 25 26 27 28 29 30 31
    </sql>

    <select id="selectWechatMessageList" parameterType="WechatMessage" resultMap="WechatMessageResult">
        <include refid="selectWechatMessageVo"/>
        <where>  
            <if test="userId != null "> and user_id = #{userId}</if>
            <if test="msgId != null  and msgId != ''"> and msg_id = #{msgId}</if>
            <if test="message != null  and message != ''"> and message = #{message}</if>
caiyt committed
32
            <if test="targetId != null">and target_id = #{targetId}</if>
张新旗 committed
33 34
            <if test="targetUrl != null  and targetUrl != ''"> and target_url = #{targetUrl}</if>
            <if test="state != null  and state != ''"> and state = #{state}</if>
caiyt committed
35
            <if test="type != null"> and type = #{type}</if>
张新旗 committed
36 37 38 39
            <if test="isRead != null  and isRead != ''"> and is_read = #{isRead}</if>
            <if test="isDeleted != null  and isDeleted != ''"> and is_deleted = #{isDeleted}</if>
            <if test="createdAt != null "> and created_at = #{createdAt}</if>
            <if test="updatedAt != null "> and updated_at = #{updatedAt}</if>
40
            order by created_at desc
张新旗 committed
41 42 43 44 45 46 47 48 49 50 51 52 53 54
        </where>
    </select>
    
    <select id="selectWechatMessageById" parameterType="String" resultMap="WechatMessageResult">
        <include refid="selectWechatMessageVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertWechatMessage" parameterType="WechatMessage" useGeneratedKeys="true" keyProperty="id">
        insert into wechat_message
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="userId != null">user_id,</if>
            <if test="msgId != null and msgId != ''">msg_id,</if>
            <if test="message != null and message != ''">message,</if>
caiyt committed
55
            <if test="targetId != null">target_id,</if>
张新旗 committed
56 57
            <if test="targetUrl != null and targetUrl != ''">target_url,</if>
            <if test="state != null and state != ''">state,</if>
caiyt committed
58
            <if test="type != null">type,</if>
张新旗 committed
59 60 61 62 63 64 65 66 67
            <if test="isRead != null and isRead != ''">is_read,</if>
            <if test="isDeleted != null and isDeleted != ''">is_deleted,</if>
            <if test="createdAt != null">created_at,</if>
            <if test="updatedAt != null">updated_at,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="userId != null">#{userId},</if>
            <if test="msgId != null and msgId != ''">#{msgId},</if>
            <if test="message != null and message != ''">#{message},</if>
caiyt committed
68
            <if test="targetId != null">#{targetId},</if>
张新旗 committed
69 70
            <if test="targetUrl != null and targetUrl != ''">#{targetUrl},</if>
            <if test="state != null and state != ''">#{state},</if>
caiyt committed
71
            <if test="type != null">#{type},</if>
张新旗 committed
72 73 74 75 76 77 78 79 80 81 82 83 84
            <if test="isRead != null and isRead != ''">#{isRead},</if>
            <if test="isDeleted != null and isDeleted != ''">#{isDeleted},</if>
            <if test="createdAt != null">#{createdAt},</if>
            <if test="updatedAt != null">#{updatedAt},</if>
         </trim>
    </insert>

    <update id="updateWechatMessage" parameterType="WechatMessage">
        update wechat_message
        <trim prefix="SET" suffixOverrides=",">
            <if test="userId != null">user_id = #{userId},</if>
            <if test="msgId != null and msgId != ''">msg_id = #{msgId},</if>
            <if test="message != null and message != ''">message = #{message},</if>
caiyt committed
85
            <if test="targetId != null">target_id = #{targetId},</if>
张新旗 committed
86 87
            <if test="targetUrl != null and targetUrl != ''">target_url = #{targetUrl},</if>
            <if test="state != null and state != ''">state = #{state},</if>
caiyt committed
88
            <if test="type != null">type = #{type},</if>
张新旗 committed
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
            <if test="isRead != null and isRead != ''">is_read = #{isRead},</if>
            <if test="isDeleted != null and isDeleted != ''">is_deleted = #{isDeleted},</if>
            <if test="updatedAt != null">updated_at = #{updatedAt},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteWechatMessageById" parameterType="String">
        delete from wechat_message where id = #{id}
    </delete>

    <delete id="deleteWechatMessageByIds" parameterType="String">
        delete from wechat_message where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>