<?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.DriveSchoolDeductMapper">

    <resultMap type="cn.iocoder.yudao.module.jx.domain.DriveSchoolDeduct" id="DriveSchoolDeductResult">
        <result property="id"    column="id"    />
        <result property="deduct"    column="deduct"    />
        <result property="courseSubject"    column="course_subject"    />
        <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="selectDriveSchoolDeductVo">
        select id, deduct, course_subject, create_time, creator, update_time, updater from drive_school_deduct
    </sql>

    <select id="selectDriveSchoolDeductList" parameterType="cn.iocoder.yudao.module.jx.domain.DriveSchoolDeduct" resultMap="DriveSchoolDeductResult">
        <include refid="selectDriveSchoolDeductVo"/>
        <where>
            deleted = 0
            <if test="entity.deduct != null "> and deduct = #{entity.deduct}</if>
            <if test="entity.courseSubject != null  and entity.courseSubject != ''"> and course_subject = #{entity.courseSubject}</if>
        </where>
        order by create_time desc
    </select>

    <select id="selectDriveSchoolDeductListAll" parameterType="cn.iocoder.yudao.module.jx.domain.DriveSchoolDeduct" resultMap="DriveSchoolDeductResult">
        <include refid="selectDriveSchoolDeductVo"/>
        <where>
            deleted = 0
            <if test="entity.deduct != null "> and deduct = #{entity.deduct}</if>
            <if test="entity.courseSubject != null  and entity.courseSubject != ''"> and course_subject = #{entity.courseSubject}</if>
        </where>
        order by create_time desc
    </select>

    <select id="selectDriveSchoolDeductById" parameterType="Long" resultMap="DriveSchoolDeductResult">
        <include refid="selectDriveSchoolDeductVo"/>
        where id = #{id}
    </select>

    <insert id="insertDriveSchoolDeduct" parameterType="cn.iocoder.yudao.module.jx.domain.DriveSchoolDeduct" useGeneratedKeys="true" keyProperty="id">
        insert into drive_school_deduct
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="deduct != null">deduct,</if>
            <if test="courseSubject != null">course_subject,</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="deduct != null">#{deduct},</if>
            <if test="courseSubject != null">#{courseSubject},</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="updateDriveSchoolDeduct" parameterType="cn.iocoder.yudao.module.jx.domain.DriveSchoolDeduct">
        update drive_school_deduct
        <trim prefix="SET" suffixOverrides=",">
            <if test="deduct != null">deduct = #{deduct},</if>
            <if test="courseSubject != null">course_subject = #{courseSubject},</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="deleteDriveSchoolDeductById" parameterType="Long">
        delete from drive_school_deduct where id = #{id}
    </delete>

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

    <select id="selectByCondition" resultMap="DriveSchoolDeductResult">
        select * from drive_school_deduct
        <where>
            deleted = 0
            <if test="courseSubject != null  and courseSubject != ''"> and course_subject = #{courseSubject}</if>
        </where>
        limit 1
    </select>
</mapper>
