TdCPushMsgSMapper.xml 5.82 KB
<?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.zteits.pay.mapper.smapper.TdCPushMsgSMapper">
    <resultMap id="BaseResultMap" type="com.zteits.pay.domain.TdCPushMsg">
        <id column="id" jdbcType="BIGINT" property="id"/>
        <result column="cust_id" jdbcType="VARCHAR" property="custId"/>
        <result column="msg_title" jdbcType="VARCHAR" property="msgTitle"/>
        <result column="msg_content" jdbcType="VARCHAR" property="msgContent"/>
        <result column="msg_type" jdbcType="INTEGER" property="msgType"/>
        <result column="templete_id" jdbcType="VARCHAR" property="templeteId"/>
        <result column="push_type" jdbcType="INTEGER" property="pushType"/>
        <result column="return_type" jdbcType="INTEGER" property="returnType"/>
        <result column="read_type" jdbcType="INTEGER" property="readType"/>
        <result column="data_state" jdbcType="INTEGER" property="dataState"/>
        <result column="create_empid" jdbcType="VARCHAR" property="createEmpid"/>
        <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
        <result column="modfiy_empid" jdbcType="VARCHAR" property="modfiyEmpid"/>
        <result column="modfiy_date" jdbcType="TIMESTAMP" property="modfiyDate"/>
        <result column="out_msg_no" jdbcType="VARCHAR" property="outMsgNo"/>
    </resultMap>
    <sql id="Base_Column_List">
        id, cust_id, msg_title, msg_content, msg_type, templete_id, push_type, return_type,
        read_type, data_state, create_empid, create_date, modfiy_empid, modfiy_date, out_msg_no
    </sql>
    <!-- 推送消息中心首页,查询各消息类型的最新一条 -->
    <select id="getLatestPushedMessages" parameterType="com.zteits.clouds.api.dto.pay.param.JPushMessageRequest"
            resultType="com.zteits.pay.domain.JPushMessageDO">
        SELECT B.msg_title                                      title,
               B.msg_content                                    msgContent,
               date_format(B.create_date, '%Y-%m-%d %H:%i:%s') msgTime,
               B.msg_type                                       msgType
        FROM (select max(id) id
              from td_c_push_msg b
              where b.return_type = 1
                and b.data_state = 1
                and b.cust_id = #{custId}
              group by b.msg_type) A
               left join td_c_push_msg B on A.id =B.id
        order by B.create_date desc
    </select>

    <!-- 推送消息中心-消息详情,查询某一消息的详情 -->
    <select id="getPushedMessageDetails" parameterType="com.zteits.clouds.api.dto.pay.param.JPushMessageRequest"
            resultType="com.zteits.pay.domain.JPushMessageDO">
        select
        msg_title title,
        msg_content msgContent,
        date_format(create_date, '%Y-%m-%d %H:%i:%s') msgTime,
        msg_type msgType
        from td_c_push_msg
        where
        msg_type=#{msgType}
        <if test="custId != null and custId !=''">
            and cust_id=#{custId}
        </if>
        and return_type=1
        and data_state=1
        order by create_date Desc
    </select>

    <!-- 消息中心-删除消息,删除出某一种消息的详情 -->
    <delete id="deletePushedMessageDetails" parameterType="com.zteits.clouds.api.dto.pay.param.JPushMessageRequest">
        delete
        from td_c_push_msg
        where
                msg_type=#{msgType}
                and cust_id=#{custId};
    </delete>


    <select id="queryParkOrderByCondition" parameterType="com.zteits.clouds.api.dto.pay.JPushMsgQueryRequest"
            resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from td_c_push_msg
        where cust_id=#{custId}
        and msg_type=#{msgType}
        and create_date = date(#{queryDate})
        and data_state = 1
        <if test="templeteIds != null and templeteIds.size > 0">
            and templete_id in
            <foreach collection="templeteIds" open="(" close=")" item="templeteId" separator=",">
                #{templeteId}
            </foreach>
        </if>

    </select>

    <!-- 新版消息中心首页-查询未读消息条数 -->
    <select id="countUnreadMessage" resultType="com.zteits.clouds.api.dto.pay.NewMessagePushDTO"
            parameterType="com.zteits.clouds.api.dto.owner.param.QueryMessageRequest">
        select
        count(case when ap.msg_type=1 then 1 ELSE NULL
        END) accountUnreads,
        count(case when ap.msg_type=6 then 1 ELSE NULL
        END) activityUnreads,
        count(case when ap.msg_type in(2,3,4,5,7) then 1 ELSE NULL
        END) systemUnreads,
        count(case when ap.msg_type=9 then 1 ELSE NULL
        END) questionUnreads
        from td_c_push_msg ap
        where data_state=1
        and read_type = 0
        and cust_id = #{custId,jdbcType=VARCHAR}
    </select>

    <!-- 新版消息中心-更新消息未读状态 -->
    <update id="updateUnreadMessage" parameterType="com.zteits.clouds.api.dto.owner.param.QueryMessageRequest">
        update
        td_c_push_msg
        set read_type = 1,
        <if test="modfiyEmpid != null" >
            modfiy_empid = #{modfiyEmpid,jdbcType=VARCHAR},
        </if>
        <if test="modfiyDate != null" >
            modfiy_date = #{modfiyDate,jdbcType=TIMESTAMP}
        </if>
        where data_state=1
        <if test="messageType == '1'.toString()" >
            and msg_type = 1
        </if>
        <if test="messageType == '2'.toString()" >
            and msg_type = 6
        </if>
        <if test="messageType == '4'.toString()" >
            and msg_type = 9
        </if>
        <if test="messageType == '3'.toString()" >
            and msg_type in (2,3,4,5,7)
        </if>
        and read_type = 0
        and cust_id = #{custId,jdbcType=VARCHAR}
    </update>
</mapper>