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

    <resultMap type="cn.iocoder.yudao.module.jx.domain.DriveSchoolFacility" id="DriveSchoolFacilityResult">
        <result property="id"    column="id"    />
        <result property="deptId"    column="dept_id"    />
        <result property="facilityName"    column="facility_name"    />
        <result property="facilityNumber"    column="facility_number"    />
        <result property="facilityDes"    column="facility_des"    />
        <result property="createTime"    column="create_time"    />
        <result property="creator"    column="creator"    />
        <result property="updateTime"    column="update_time"    />
        <result property="updater"    column="updater"    />
        <result property="location"    column="location"    />
        <result property="price"    column="price"    />
        <result property="byinTime"    column="byinTime"    />
        <result property="yearcheckTime"    column="yearcheckTime"    />
        <result property="phone"    column="phone"    />
        <result property="landLeasingCompany"    column="land_leasing_company"    />
        <result property="equipmentListCover"    column="equipment_list_cover"    />
        <result property="custodian"    column="custodian"    />
    </resultMap>

    <sql id="selectDriveSchoolFacilityVo">
        select phone,price,byinTime,yearcheckTime,id, dept_id, facility_name, facility_number, facility_des, create_time, creator, update_time, updater, location, land_leasing_company, equipment_list_cover, custodian from drive_school_facility
    </sql>

    <select id="selectDriveSchoolFacilityList" parameterType="cn.iocoder.yudao.module.jx.domain.DriveSchoolFacility" resultMap="DriveSchoolFacilityResult">
        <include refid="selectDriveSchoolFacilityVo"/>
        <where>
            deleted = 0
            <if test="entity.deptId != null "> and dept_id = #{entity.deptId}</if>
            <if test="entity.facilityName != null  and entity.facilityName != ''"> and facility_name like concat('%', #{entity.facilityName}, '%')</if>
            <if test="entity.facilityNumber != null "> and facility_number = #{entity.facilityNumber}</if>
            <if test="entity.facilityDes != null  and entity.facilityDes != ''"> and facility_des like concat('%', #{entity.facilityDes}, '%')</if>
            <if test="entity.location != null  and entity.location != ''"> and location like concat('%', #{entity.location}, '%')</if>
            <if test="entity.landLeasingCompany != null  and entity.landLeasingCompany != ''"> and land_leasing_company like concat('%', #{entity.landLeasingCompany}, '%')</if>
            <if test="entity.equipmentListCover != null  and entity.equipmentListCover != ''"> and equipment_list_cover = #{entity.equipmentListCover}</if>
            <if test="entity.custodian != null  and entity.custodian != ''"> and custodian like concat('%', #{entity.custodian}, '%')</if>
        </where>
    </select>

    <select id="selectDriveSchoolFacilityById" parameterType="Long" resultMap="DriveSchoolFacilityResult">
        <include refid="selectDriveSchoolFacilityVo"/>
        where id = #{id}
    </select>

    <insert id="insertDriveSchoolFacility" parameterType="cn.iocoder.yudao.module.jx.domain.DriveSchoolFacility" useGeneratedKeys="true" keyProperty="id">
        insert into drive_school_facility
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="deptId != null">dept_id,</if>
            <if test="facilityName != null">facility_name,</if>
            <if test="facilityNumber != null">facility_number,</if>
            <if test="facilityDes != null">facility_des,</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>
            <if test="location != null">location,</if>
            <if test="price != null">price,</if>
            <if test="byinTime != null">byinTime,</if>
            <if test="yearcheckTime != null">yearcheckTime,</if>
            <if test="phone != null">phone,</if>
            <if test="landLeasingCompany != null">land_leasing_company,</if>
            <if test="equipmentListCover != null">equipment_list_cover,</if>
            <if test="custodian != null">custodian,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="deptId != null">#{deptId},</if>
            <if test="facilityName != null">#{facilityName},</if>
            <if test="facilityNumber != null">#{facilityNumber},</if>
            <if test="facilityDes != null">#{facilityDes},</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>
            <if test="location != null">#{location},</if>
            <if test="price != null">#{price},</if>
            <if test="byinTime != null">#{byinTime},</if>
            <if test="yearcheckTime != null">#{yearcheckTime},</if>
            <if test="phone != null">#{phone},</if>
            <if test="landLeasingCompany != null">#{landLeasingCompany},</if>
            <if test="equipmentListCover != null">#{equipmentListCover},</if>
            <if test="custodian != null">#{custodian},</if>
         </trim>
    </insert>

    <update id="updateDriveSchoolFacility" parameterType="cn.iocoder.yudao.module.jx.domain.DriveSchoolFacility">
        update drive_school_facility
        <trim prefix="SET" suffixOverrides=",">
            <if test="deptId != null">dept_id = #{deptId},</if>
            <if test="facilityName != null">facility_name = #{facilityName},</if>
            <if test="facilityNumber != null">facility_number = #{facilityNumber},</if>
            <if test="facilityDes != null">facility_des = #{facilityDes},</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>
            <if test="location != null">location = #{location},</if>
            <if test="price != null">price = #{price},</if>
            <if test="byinTime != null">byinTime = #{byinTime},</if>
            <if test="yearcheckTime != null">yearcheckTime = #{yearcheckTime},</if>
            <if test="phone != null">phone = #{phone},</if>
            <if test="landLeasingCompany != null">land_leasing_company = #{landLeasingCompany},</if>
            <if test="equipmentListCover != null">equipment_list_cover = #{equipmentListCover},</if>
            <if test="custodian != null">custodian = #{custodian},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteDriveSchoolFacilityById" parameterType="Long">
        delete from drive_school_facility where id = #{id}
    </delete>

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