usrntfmapper.xml 4.17 KB
Newer Older
hulei committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
<?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.brilliance.isc.mda.dao.UsrntfMapper">

    <resultMap id="BaseResultMap" type="com.brilliance.isc.bo.Usrntf">
        <result property="inr" column="inr" jdbcType="VARCHAR"/>
        <result property="sndusr" column="sndusr" jdbcType="VARCHAR"/>
        <result property="sndtim" column="sndtim" jdbcType="DATE"/>
        <result property="rcvusr" column="rcvusr" jdbcType="VARCHAR"/>
        <result property="rcvtim" column="rcvtim" jdbcType="DATE"/>
        <result property="readtim" column="readtim" jdbcType="DATE"/>
        <result property="ntfsta" column="ntfsta" jdbcType="VARCHAR"/>
        <result property="ntftxt" column="ntftxt" jdbcType="VARCHAR"/>
        <result property="qfsta" column="qfsta" jdbcType="VARCHAR"/>
        <result property="mac" column="mac" jdbcType="VARCHAR"/>
    </resultMap>

    <sql id="Base_Column_List">
        inr,sndusr,sndtim,rcvusr,ntfsta,ntftxt,qfsta,mac
    </sql>

    <select id="queryByPage" resultMap="BaseResultMap">
        select inr,sndusr,sndtim,rcvusr,rcvtim,readtim,ntfsta,ntftxt from usrntf
        <where>
            (((sndusr = #{sndusr} and ((qfsta = 'A' and rcvusr = 'ALL USER') or (qfsta = 'O' and rcvusr = 'ONLINE USER')))
            or (sndusr = #{sndusr} and qfsta = 'S')) or rcvusr = #{sndusr})
            <if test="rcvusr != null and rcvusr != ''">
                and rcvusr like concat(concat ('%',#{rcvusr}),'%')
            </if>
            <if test="sndbegdat != null">
                and date_format(sndtim,'%Y-%m-%d') <![CDATA[>=]]> #{sndbegdat, jdbcType=DATE}
            </if>
            <if test="sndenddat != null">
                and date_format(sndtim,'%Y-%m-%d') <![CDATA[<=]]> #{sndenddat, jdbcType=DATE}
            </if>
        </where>
    </select>

    <insert id="insert">
        insert into usrntf (<include refid="Base_Column_List"/>)
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            #{inr,jdbcType=VARCHAR},
            #{sndusr,jdbcType=VARCHAR},
            now(),
            #{rcvusr,jdbcType=VARCHAR},
            '1',
            #{ntftxt,jdbcType=VARCHAR},
            #{qfsta, jdbcType=VARCHAR},
            #{mac, jdbcType=VARCHAR},
        </trim>
    </insert>

    <insert id="batchInsert">
        insert into usrntf
        (<include refid="Base_Column_List"/>) values
        <foreach collection="list" separator="," item="item">
            (
            #{item.inr,jdbcType=VARCHAR},
            #{item.sndusr,jdbcType=VARCHAR},
            now(),
            #{item.rcvusr,jdbcType=VARCHAR},
            '1',
            #{item.ntftxt,jdbcType=VARCHAR},
            #{item.qfsta, jdbcType=VARCHAR},
            #{item.mac, jdbcType=VARCHAR}
            )
        </foreach>
    </insert>

    <delete id="delete">
        delete from usrntf where inr = #{inr}
    </delete>

    <select id="queryUnRcvMsg" resultType="int">
        select count(1) from usrntf
        where rcvusr = #{rcvusr} and ISNULL(readtim) = 1
    </select>

    <select id="queryReadMsg" resultMap="BaseResultMap">
        select inr,sndusr,sndtim,rcvusr,rcvtim,readtim,ntfsta,ntftxt from usrntf where rcvusr = #{rcvusr} and ISNULL(readtim) = 1
    </select>

    <update id="updateRcvTim">
        update usrntf
        <set>
            rcvtim = now(),
            ntfsta = '2',
        </set>
        where inr = #{inr,jdbcType=VARCHAR}
    </update>

    <update id="updateReadTim">
        update usrntf
        <set>
            readtim = now(),
            ntfsta = '3',
        </set>
        where inr = #{inr,jdbcType=VARCHAR}
    </update>

    <select id="getMsgInfo" resultMap="BaseResultMap">
        select inr,sndusr,sndtim,rcvusr,rcvtim,readtim,ntfsta,ntftxt from usrntf
        where inr = #{inr,jdbcType=VARCHAR}
    </select>

    <update id="batchUpdateReadTim">
        update usrntf
        <set>
            readtim = now(),
            ntfsta = '3',
        </set>
        where inr in
        <foreach collection="usrntflist" index="index" item="item" separator="," open="(" close=")">
            #{item.inr}
        </foreach>
    </update>
</mapper>