<?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.CphGoodCancelLogMapper">
    
    <resultMap type="CphGoodCancelLog" id="CphGoodCancelLogResult">
        <result property="id"    column="id"    />
        <result property="stuNo"    column="stu_no"    />
        <result property="typeCode"    column="type_code"    />
        <result property="reason"    column="reason"    />
        <result property="ip"    column="ip"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectCphGoodCancelLogVo">
        select id, stu_no, type_code, reason, ip, create_by, create_time, update_by, update_time from cph_good_cancel_log
    </sql>

    <select id="selectCphGoodCancelLogList" parameterType="CphGoodCancelLog" resultMap="CphGoodCancelLogResult">
        <include refid="selectCphGoodCancelLogVo"/>
        <where>  
            <if test="stuNo != null  and stuNo != ''"> and stu_no = #{stuNo}</if>
            <if test="typeCode != null  and typeCode != ''"> and type_code = #{typeCode}</if>
            <if test="reason != null  and reason != ''"> and reason = #{reason}</if>
            <if test="ip != null  and ip != ''"> and ip = #{ip}</if>
        </where>
    </select>
    
    <select id="selectCphGoodCancelLogById" parameterType="Long" resultMap="CphGoodCancelLogResult">
        <include refid="selectCphGoodCancelLogVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertCphGoodCancelLog" parameterType="CphGoodCancelLog">
        insert into cph_good_cancel_log
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="stuNo != null">stu_no,</if>
            <if test="typeCode != null">type_code,</if>
            <if test="reason != null">reason,</if>
            <if test="ip != null">ip,</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>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="stuNo != null">#{stuNo},</if>
            <if test="typeCode != null">#{typeCode},</if>
            <if test="reason != null">#{reason},</if>
            <if test="ip != null">#{ip},</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>
         </trim>
    </insert>

    <update id="updateCphGoodCancelLog" parameterType="CphGoodCancelLog">
        update cph_good_cancel_log
        <trim prefix="SET" suffixOverrides=",">
            <if test="stuNo != null">stu_no = #{stuNo},</if>
            <if test="typeCode != null">type_code = #{typeCode},</if>
            <if test="reason != null">reason = #{reason},</if>
            <if test="ip != null">ip = #{ip},</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>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteCphGoodCancelLogById" parameterType="Long">
        delete from cph_good_cancel_log where id = #{id}
    </delete>

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