<?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.willalp.msg.mapper.HsAppUserMsgMapper">

    <resultMap type="com.willalp.msg.domain.HsAppUserMsg" id="HsAppUserMsgResult">
        <result property="id" column="id"/>
        <result property="userCode" column="user_code"/>
        <result property="msgTitle" column="msg_title"/>
        <result property="msgType" column="msg_type"/>
        <result property="msgContent" column="msg_content"/>
        <result property="msgIsRead" column="msg_is_read"/>
        <result property="isPush" column="is_push"/>
        <result property="isDelete" column="is_delete"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateTime" column="update_time"/>
        <result property="remark" column="remark"/>
    </resultMap>

    <sql id="selectHsAppUserMsgVo">
        select id,
               user_code,
               msg_title,
               msg_type,
               msg_content,
               msg_is_read,
               is_push,
               is_delete,
               create_by,
               create_time,
               update_by,
               update_time,
               remark
        from hs_app_user_msg
    </sql>
    <select id="selectHsAppUserMsgList" parameterType="HsAppUserMsg" resultMap="HsAppUserMsgResult">
        <include refid="selectHsAppUserMsgVo"/>
        <where>
            is_delete = 0
            <if test="userCode != null  and userCode != ''">
                and user_code like concat('%', #{userCode}, '%')
            </if>
            <if test="msgTitle != null  and msgTitle != ''">
                and msg_title like concat('%', #{msgTitle}, '%')
            </if>
            <if test="msgType != null  and msgType != ''">
                and msg_type = #{msgType}
            </if>
            <if test="msgContent != null  and msgContent != ''">
                and msg_content like concat('%', #{msgContent}, '%')
            </if>
            <if test="isDelete != null ">
                and is_delete = #{isDelete}
            </if>
        </where>
    </select>

</mapper>
