<?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.ruoyi.system.mapper.WaitRemindMapper">
    
    <resultMap type="WaitRemind" id="WaitRemindResult">
        <result property="remindId"    column="remind_id"    />
        <result property="loanApplicationId"    column="loan_application_id"    />
        <result property="loanApplicationNumber"    column="loan_application_number"    />
        <result property="remindTitle"    column="remind_title"    />
        <result property="remindType"    column="remind_type"    />
        <result property="remindContent"    column="remind_content"    />
        <result property="remindTime"    column="remind_time"    />
        <result property="readUserId"    column="read_user_id"    />
        <result property="isRead"    column="is_read"    />
        <result property="status"    column="status"    />
        <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="selectWaitRemindVo">
        select remind_id, loan_application_id, loan_application_number, remind_title, remind_type, remind_content, remind_time, read_user_id, is_read, status, create_by, create_time, update_by, update_time, remark from wait_remind
    </sql>

    <select id="selectWaitRemindList" parameterType="WaitRemind" resultMap="WaitRemindResult">
        <include refid="selectWaitRemindVo"/>
        <where>  
            <if test="loanApplicationId != null "> and loan_application_id = #{loanApplicationId}</if>
            <if test="loanApplicationNumber != null  and loanApplicationNumber != ''"> and loan_application_number = #{loanApplicationNumber}</if>
            <if test="remindTitle != null  and remindTitle != ''"> and remind_title = #{remindTitle}</if>
            <if test="remindType != null  and remindType != ''"> and remind_type = #{remindType}</if>
            <if test="remindContent != null  and remindContent != ''"> and remind_content = #{remindContent}</if>
            <if test="remindTime != null "> and remind_time = #{remindTime}</if>
            <if test="readUserId != null  and readUserId != ''"> and read_user_id = #{readUserId}</if>
            <if test="isRead != null  and isRead != ''"> and is_read = #{isRead}</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
        </where>
        order by remind_time
    </select>
    
    <select id="selectWaitRemindByRemindId" parameterType="Integer" resultMap="WaitRemindResult">
        <include refid="selectWaitRemindVo"/>
        where remind_id = #{remindId}
    </select>
        
    <insert id="insertWaitRemind" parameterType="WaitRemind" useGeneratedKeys="true" keyProperty="remindId">
        insert into wait_remind
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="loanApplicationId != null">loan_application_id,</if>
            <if test="loanApplicationNumber != null and loanApplicationNumber != ''">loan_application_number,</if>
            <if test="remindTitle != null and remindTitle != ''">remind_title,</if>
            <if test="remindType != null and remindType != ''">remind_type,</if>
            <if test="remindContent != null">remind_content,</if>
            <if test="remindTime != null">remind_time,</if>
            <if test="readUserId != null and readUserId != ''">read_user_id,</if>
            <if test="isRead != null">is_read,</if>
            <if test="status != null">status,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="loanApplicationId != null">#{loanApplicationId},</if>
            <if test="loanApplicationNumber != null and loanApplicationNumber != ''">#{loanApplicationNumber},</if>
            <if test="remindTitle != null and remindTitle != ''">#{remindTitle},</if>
            <if test="remindType != null and remindType != ''">#{remindType},</if>
            <if test="remindContent != null">#{remindContent},</if>
            <if test="remindTime != null">#{remindTime},</if>
            <if test="readUserId != null and readUserId != ''">#{readUserId},</if>
            <if test="isRead != null">#{isRead},</if>
            <if test="status != null">#{status},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateWaitRemind" parameterType="WaitRemind">
        update wait_remind
        <trim prefix="SET" suffixOverrides=",">
            <if test="loanApplicationId != null">loan_application_id = #{loanApplicationId},</if>
            <if test="loanApplicationNumber != null and loanApplicationNumber != ''">loan_application_number = #{loanApplicationNumber},</if>
            <if test="remindTitle != null and remindTitle != ''">remind_title = #{remindTitle},</if>
            <if test="remindType != null and remindType != ''">remind_type = #{remindType},</if>
            <if test="remindContent != null">remind_content = #{remindContent},</if>
            <if test="remindTime != null">remind_time = #{remindTime},</if>
            <if test="readUserId != null and readUserId != ''">read_user_id = #{readUserId},</if>
            <if test="isRead != null">is_read = #{isRead},</if>
            <if test="status != null">status = #{status},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where remind_id = #{remindId}
    </update>

    <delete id="deleteWaitRemindByRemindId" parameterType="Integer">
        delete from wait_remind where remind_id = #{remindId}
    </delete>

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