<?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.SzxcButieMapper">
    
    <resultMap type="SzxcButie" id="SzxcButieResult">
        <result property="id"    column="id"    />
        <result property="type"    column="type"    />
        <result property="xmTitle"    column="xm_title"    />
        <result property="xmId"    column="xm_id"    />
        <result property="year"    column="year"    />
        <result property="money"    column="money"    />
        <result property="jmId"    column="jm_id"    />
        <result property="name"    column="name"    />
        <result property="content"    column="content"    />
        <result property="zfStatus"    column="zf_status"    />
        <result property="shRemark"    column="sh_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"    />
        <result property="deptId"    column="dept_id"    />
        <result property="deptName"    column="dept_name"    />
        <result property="userId"    column="user_id"    />
    </resultMap>

    <sql id="selectSzxcButieVo">
        select id, type, xm_title, xm_id, year, money, jm_id, name, content, zf_status, sh_remark, create_by, create_time, update_by, update_time, dept_id, dept_name, user_id from szxc_butie
    </sql>

    <select id="selectSzxcButieList" parameterType="SzxcButie" resultMap="SzxcButieResult">
        <include refid="selectSzxcButieVo"/>
        <where>  
            <if test="type != null  and type != ''"> and type = #{type}</if>
            <if test="xmTitle != null  and xmTitle != ''"> and xm_title = #{xmTitle}</if>
            <if test="xmId != null "> and xm_id = #{xmId}</if>
            <if test="year != null  and year != ''"> and year = #{year}</if>
            <if test="money != null  and money != ''"> and money = #{money}</if>
            <if test="jmId != null "> and jm_id = #{jmId}</if>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="content != null  and content != ''"> and content = #{content}</if>
            <if test="zfStatus != null  and zfStatus != ''"> and zf_status = #{zfStatus}</if>
            <if test="shRemark != null  and shRemark != ''"> and sh_remark = #{shRemark}</if>
            <if test="deptId != null "> and dept_id = #{deptId}</if>
            <if test="deptName != null  and deptName != ''"> and dept_name like concat('%', #{deptName}, '%')</if>
            <if test="userId != null "> and user_id = #{userId}</if>
        </where>
    </select>
    
    <select id="selectSzxcButieById" parameterType="Long" resultMap="SzxcButieResult">
        <include refid="selectSzxcButieVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertSzxcButie" parameterType="SzxcButie" useGeneratedKeys="true" keyProperty="id">
        insert into szxc_butie
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="type != null">type,</if>
            <if test="xmTitle != null">xm_title,</if>
            <if test="xmId != null">xm_id,</if>
            <if test="year != null">year,</if>
            <if test="money != null">money,</if>
            <if test="jmId != null">jm_id,</if>
            <if test="name != null">name,</if>
            <if test="content != null">content,</if>
            <if test="zfStatus != null">zf_status,</if>
            <if test="shRemark != null">sh_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>
            <if test="deptId != null">dept_id,</if>
            <if test="deptName != null">dept_name,</if>
            <if test="userId != null">user_id,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="type != null">#{type},</if>
            <if test="xmTitle != null">#{xmTitle},</if>
            <if test="xmId != null">#{xmId},</if>
            <if test="year != null">#{year},</if>
            <if test="money != null">#{money},</if>
            <if test="jmId != null">#{jmId},</if>
            <if test="name != null">#{name},</if>
            <if test="content != null">#{content},</if>
            <if test="zfStatus != null">#{zfStatus},</if>
            <if test="shRemark != null">#{shRemark},</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="deptId != null">#{deptId},</if>
            <if test="deptName != null">#{deptName},</if>
            <if test="userId != null">#{userId},</if>
         </trim>
    </insert>

    <update id="updateSzxcButie" parameterType="SzxcButie">
        update szxc_butie
        <trim prefix="SET" suffixOverrides=",">
            <if test="type != null">type = #{type},</if>
            <if test="xmTitle != null">xm_title = #{xmTitle},</if>
            <if test="xmId != null">xm_id = #{xmId},</if>
            <if test="year != null">year = #{year},</if>
            <if test="money != null">money = #{money},</if>
            <if test="jmId != null">jm_id = #{jmId},</if>
            <if test="name != null">name = #{name},</if>
            <if test="content != null">content = #{content},</if>
            <if test="zfStatus != null">zf_status = #{zfStatus},</if>
            <if test="shRemark != null">sh_remark = #{shRemark},</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="deptId != null">dept_id = #{deptId},</if>
            <if test="deptName != null">dept_name = #{deptName},</if>
            <if test="userId != null">user_id = #{userId},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSzxcButieById" parameterType="Long">
        delete from szxc_butie where id = #{id}
    </delete>

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