<?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.srs.comprehensive.mapper.SrsPaymentMapper">
    
    <resultMap type="SrsPayment" id="SrsPaymentResult">
        <result property="id"    column="id"    />
        <result property="paymentName"    column="payment_name"    />
        <result property="amount"    column="amount"    />
        <result property="paymentCode"    column="payment_code"    />
        <result property="status"    column="status"    />
        <result property="createTime"    column="create_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="delFlag"    column="del_flag"    />
    </resultMap>

    <sql id="selectSrsPaymentVo">
        select id, payment_name, amount, payment_code, status, create_time, create_by, update_time, update_by, del_flag from srs_payment
    </sql>

    <select id="selectSrsPaymentList" parameterType="SrsPayment" resultMap="SrsPaymentResult">
        <include refid="selectSrsPaymentVo"/>
        <where>  
            <if test="paymentName != null  and paymentName != ''"> and payment_name like concat('%', #{paymentName}, '%')</if>
            <if test="amount != null "> and amount = #{amount}</if>
            <if test="paymentCode != null  and paymentCode != ''"> and payment_code = #{paymentCode}</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
        </where>
    </select>
    
    <select id="selectSrsPaymentById" parameterType="Long" resultMap="SrsPaymentResult">
        <include refid="selectSrsPaymentVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertSrsPayment" parameterType="SrsPayment">
        insert into srs_payment
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="paymentName != null">payment_name,</if>
            <if test="amount != null">amount,</if>
            <if test="paymentCode != null">payment_code,</if>
            <if test="status != null and status != ''">status,</if>
            <if test="createTime != null">create_time,</if>
            <if test="createBy != null">create_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="delFlag != null">del_flag,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="paymentName != null">#{paymentName},</if>
            <if test="amount != null">#{amount},</if>
            <if test="paymentCode != null">#{paymentCode},</if>
            <if test="status != null and status != ''">#{status},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="delFlag != null">#{delFlag},</if>
         </trim>
    </insert>

    <update id="updateSrsPayment" parameterType="SrsPayment">
        update srs_payment
        <trim prefix="SET" suffixOverrides=",">
            <if test="paymentName != null">payment_name = #{paymentName},</if>
            <if test="amount != null">amount = #{amount},</if>
            <if test="paymentCode != null">payment_code = #{paymentCode},</if>
            <if test="status != null and status != ''">status = #{status},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSrsPaymentById" parameterType="Long">
        delete from srs_payment where id = #{id}
    </delete>

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