<?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.szxc.mapper.SzxcXyAuditRecardMapper">

    <resultMap type="SzxcXyAuditRecard" id="SzxcXyAuditRecardResult">
        <result property="id"    column="id"    />
        <result property="shRecardType"    column="sh_recard_type"    />
        <result property="jlId"    column="jl_id"    />
        <result property="auditDept"    column="audit_dept"    />
        <result property="auditName"    column="audit_name"    />
        <result property="auditResult"    column="audit_result"    />
        <result property="auditReason"    column="audit_reason"    />
        <result property="remark"    column="remark"    />
        <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="selectSzxcXyAuditRecardVo">
        select id, sh_recard_type, jl_id, audit_dept, audit_name, audit_result, audit_reason, remark, create_by, create_time, update_by, update_time from szxc_xy_audit_recard
    </sql>

    <select id="selectSzxcXyAuditRecardList" parameterType="SzxcXyAuditRecard" resultMap="SzxcXyAuditRecardResult">
        <include refid="selectSzxcXyAuditRecardVo"/>
        <where>
            <if test="shRecardType != null  and shRecardType != ''"> and sh_recard_type = #{shRecardType}</if>
            <if test="jlId != null "> and jl_id = #{jlId}</if>
            <if test="auditDept != null  and auditDept != ''"> and audit_dept = #{auditDept}</if>
            <if test="auditName != null  and auditName != ''"> and audit_name like concat('%', #{auditName}, '%')</if>
            <if test="auditResult != null  and auditResult != ''"> and audit_result = #{auditResult}</if>
            <if test="auditReason != null  and auditReason != ''"> and audit_reason = #{auditReason}</if>
        </where>
    </select>

    <select id="selectSzxcXyAuditRecardById" parameterType="Long" resultMap="SzxcXyAuditRecardResult">
        <include refid="selectSzxcXyAuditRecardVo"/>
        where id = #{id}
    </select>

    <insert id="insertSzxcXyAuditRecard" parameterType="SzxcXyAuditRecard" useGeneratedKeys="true" keyProperty="id">
        insert into szxc_xy_audit_recard
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="shRecardType != null">sh_recard_type,</if>
            <if test="jlId != null">jl_id,</if>
            <if test="auditDept != null">audit_dept,</if>
            <if test="auditName != null">audit_name,</if>
            <if test="auditResult != null">audit_result,</if>
            <if test="auditReason != null">audit_reason,</if>
            <if test="remark != null">remark,</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="shRecardType != null">#{shRecardType},</if>
            <if test="jlId != null">#{jlId},</if>
            <if test="auditDept != null">#{auditDept},</if>
            <if test="auditName != null">#{auditName},</if>
            <if test="auditResult != null">#{auditResult},</if>
            <if test="auditReason != null">#{auditReason},</if>
            <if test="remark != null">#{remark},</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="updateSzxcXyAuditRecard" parameterType="SzxcXyAuditRecard">
        update szxc_xy_audit_recard
        <trim prefix="SET" suffixOverrides=",">
            <if test="shRecardType != null">sh_recard_type = #{shRecardType},</if>
            <if test="jlId != null">jl_id = #{jlId},</if>
            <if test="auditDept != null">audit_dept = #{auditDept},</if>
            <if test="auditName != null">audit_name = #{auditName},</if>
            <if test="auditResult != null">audit_result = #{auditResult},</if>
            <if test="auditReason != null">audit_reason = #{auditReason},</if>
            <if test="remark != null">remark = #{remark},</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="deleteSzxcXyAuditRecardById" parameterType="Long">
        delete from szxc_xy_audit_recard where id = #{id}
    </delete>

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