<?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.usoft.fin.grpc.dal.mapper.MessagesMapper">
    <select id="countByMsReceiverenuu" parameterType="java.lang.Integer" resultType="java.lang.Integer">
        select count(1) from t_messages
        where ms_receiverenuu = #{ms_receiverenuu,jdbcType=INTEGER}
    </select>

    <select id="findListByEnuu" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from t_messages
        where ms_receiverenuu = #{arg2} limit #{arg0}, #{arg1}
    </select>

    <select id="findListByEnuuAndIsread" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from t_messages
        where ms_receiverenuu = #{arg2}
        <if test="arg3 != 2">
            and ms_isread = #{arg3,jdbcType=INTEGER}
        </if>
        limit #{arg0}, #{arg1}
    </select>

    <select id="countByEnuuAndIsread" parameterType="int" resultType="int">
        select count(1) from t_messages where ms_receiverenuu = #{arg0,jdbcType=INTEGER}
        <if test="arg1 != 2">
            and ms_isread = #{arg1,jdbcType=INTEGER}
        </if>
    </select>

    <update id="updateIsReadByMsCode" parameterType="java.lang.String">
        update t_messages
        set  ms_isread = 1
        where ms_code = #{msCode,jdbcType=VARCHAR}
    </update>
</mapper>