<?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="cn.iocoder.yudao.module.jx.mapper.DriveSchoolReimbursementMapper">

    <resultMap type="cn.iocoder.yudao.module.jx.domain.DriveSchoolReimbursement" id="DriveSchoolReimbursementResult">
        <result property="id"    column="id"    />
        <result property="deptId"    column="dept_id"    />
        <result property="userId"    column="user_id"    />
        <result property="userName"    column="user_name"    />
        <result property="content"    column="content"    />
        <result property="state"    column="state"    />
        <result property="createTime"    column="create_time"    />
        <result property="creator"    column="creator"    />
        <result property="updateTime"    column="update_time"    />
        <result property="updater"    column="updater"    />
    </resultMap>

    <sql id="selectDriveSchoolReimbursementVo">
        select id, dept_id, user_id, user_name, content, state, create_time, creator, update_time, updater from drive_school_reimbursement
    </sql>

    <select id="selectDriveSchoolReimbursementList" parameterType="cn.iocoder.yudao.module.jx.domain.DriveSchoolReimbursement" resultMap="DriveSchoolReimbursementResult">
        <include refid="selectDriveSchoolReimbursementVo"/>
        <where>
            deleted = 0
            <if test="entity.deptId != null "> and dept_id = #{entity.deptId}</if>
            <if test="entity.userId != null "> and user_id = #{entity.userId}</if>
            <if test="entity.userName != null  and entity.userName != ''"> and user_name like concat('%', #{entity.userName}, '%')</if>
            <if test="entity.content != null  and entity.content != ''"> and content = #{entity.content}</if>
            <if test="entity.state != null  and entity.state != ''"> and state = #{entity.state}</if>
        </where>
        order by create_time desc
    </select>

    <select id="selectDriveSchoolReimbursementById" parameterType="Long" resultMap="DriveSchoolReimbursementResult">
        <include refid="selectDriveSchoolReimbursementVo"/>
        where id = #{id}
    </select>

    <insert id="insertDriveSchoolReimbursement" parameterType="cn.iocoder.yudao.module.jx.domain.DriveSchoolReimbursement">
        insert into drive_school_reimbursement
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="deptId != null">dept_id,</if>
            <if test="userId != null">user_id,</if>
            <if test="userName != null">user_name,</if>
            <if test="content != null">content,</if>
            <if test="state != null">state,</if>
            <if test="createTime != null">create_time,</if>
            <if test="creator != null">creator,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="updater != null">updater,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="deptId != null">#{deptId},</if>
            <if test="userId != null">#{userId},</if>
            <if test="userName != null">#{userName},</if>
            <if test="content != null">#{content},</if>
            <if test="state != null">#{state},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="creator != null">#{creator},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="updater != null">#{updater},</if>
         </trim>
    </insert>

    <update id="updateDriveSchoolReimbursement" parameterType="cn.iocoder.yudao.module.jx.domain.DriveSchoolReimbursement">
        update drive_school_reimbursement
        <trim prefix="SET" suffixOverrides=",">
            <if test="deptId != null">dept_id = #{deptId},</if>
            <if test="userId != null">user_id = #{userId},</if>
            <if test="userName != null">user_name = #{userName},</if>
            <if test="content != null">content = #{content},</if>
            <if test="state != null">state = #{state},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="creator != null">creator = #{creator},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="updater != null">updater = #{updater},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteDriveSchoolReimbursementById" parameterType="Long">
        delete from drive_school_reimbursement where id = #{id}
    </delete>

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