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

    <resultMap type="cn.iocoder.yudao.module.jx.domain.DriveSchoolInfo" id="DriveSchoolInfoResult">
        <result property="id"    column="id"    />
        <result property="deptId"    column="dept_id"    />
        <result property="schoolName"    column="school_name"    />
        <result property="leaderName"    column="leader_name"    />
        <result property="phone"    column="phone"    />
        <result property="region"    column="region"    />
        <result property="photo"    column="photo"    />
        <result property="address"    column="address"    />
        <result property="lat"    column="lat"    />
        <result property="lgt"    column="lgt"    />
        <result property="businessStartTime"    column="business_start_time"    />
        <result property="businessEndTime"    column="business_end_time"    />
        <result property="createTime"    column="create_time"    />
        <result property="creator"    column="creator"    />
        <result property="updateTime"    column="update_time"    />
        <result property="updater"    column="updater"    />
    </resultMap>

    <resultMap type="cn.iocoder.yudao.module.jx.vo.DriveSchoolInfoVO" id="DriveSchoolInfoVOResult">
        <result property="id"    column="id"    />
        <result property="deptId"    column="dept_id"    />
        <result property="schoolName"    column="school_name"    />
        <result property="leaderName"    column="leader_name"    />
        <result property="phone"    column="phone"    />
        <result property="region"    column="region"    />
        <result property="photo"    column="photo"    />
        <result property="address"    column="address"    />
        <result property="lat"    column="lat"    />
        <result property="lgt"    column="lgt"    />
        <result property="businessStartTime"    column="business_start_time"    />
        <result property="businessEndTime"    column="business_end_time"    />
        <result property="createTime"    column="create_time"    />
        <result property="creator"    column="creator"    />
        <result property="updateTime"    column="update_time"    />
        <result property="updater"    column="updater"    />
        <result property="announcement"    column="announcement"    />
    </resultMap>

    <sql id="selectDriveSchoolInfoVo">
        select id, dept_id, school_name,leader_name, region, phone, photo, announcement, address, lat, lgt, business_start_time, business_end_time,sort, create_time, creator, update_time, updater from drive_school_info
    </sql>

    <select id="selectDriveSchoolInfoList" parameterType="cn.iocoder.yudao.module.jx.domain.DriveSchoolInfo" resultMap="DriveSchoolInfoResult">
        <include refid="selectDriveSchoolInfoVo"/>
        <where>
            deleted = 0
            <if test="id != null "> and id = #{id}</if>
            <if test="entity.deptId != null "> and dept_id = #{entity.deptId}</if>
            <if test="entity.schoolName != null  and entity.schoolName != ''"> and school_name like concat('%', #{entity.schoolName}, '%')</if>
            <if test="entity.leaderName != null  and entity.leaderName != ''"> and leader_name like concat('%', #{entity.leaderName}, '%')</if>
            <if test="entity.phone != null  and entity.phone != ''"> and phone = #{entity.phone}</if>
            <if test="entity.region != null  and entity.region != ''"> and region = #{entity.region}</if>
            <if test="entity.photo != null  and entity.photo != ''"> and photo = #{entity.photo}</if>
            <if test="entity.address != null  and entity.address != ''"> and address = #{entity.address}</if>
            <if test="entity.businessStartTime != null "> and business_start_time = #{entity.businessStartTime}</if>
            <if test="entity.businessEndTime != null "> and business_end_time = #{entity.businessEndTime}</if>
            <if test="entity.announcement != null "> and announcement = #{entity.announcement}</if>
        </where>
        order by sort asc
    </select>

    <select id="selectDriveSchoolInfoById" parameterType="Long" resultMap="DriveSchoolInfoResult">
        <include refid="selectDriveSchoolInfoVo"/>
        where id = #{id}
    </select>

    <insert id="insertDriveSchoolInfo" parameterType="cn.iocoder.yudao.module.jx.domain.DriveSchoolInfo">
        insert into drive_school_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="deptId != null">dept_id,</if>
            <if test="schoolName != null and schoolName != ''">school_name,</if>
            <if test="leaderName != null and leaderName != ''">leader_name,</if>
            <if test="phone != null and phone != ''">phone,</if>
            <if test="announcement != null and announcement != ''">announcement,</if>
            <if test="photo != null and photo != ''">photo,</if>
            <if test="region != null and region != ''">region,</if>
            <if test="address != null">address,</if>
            <if test="lat != null">lat,</if>
            <if test="lgt != null">lgt,</if>
            <if test="businessStartTime != null">business_start_time,</if>
            <if test="businessEndTime != null">business_end_time,</if>
            <if test="sort != null">sort,</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="schoolName != null and schoolName != ''">#{schoolName},</if>
            <if test="leaderName != null and leaderName != ''">#{leaderName},</if>
            <if test="phone != null and phone != ''">#{phone},</if>
            <if test="announcement != null and announcement != ''">#{announcement},</if>
            <if test="region != null and region != ''">#{region},</if>
            <if test="photo != null and photo != ''">#{photo},</if>
            <if test="address != null">#{address},</if>
            <if test="lat != null">#{lat},</if>
            <if test="lgt != null">#{lgt},</if>
            <if test="businessStartTime != null">#{businessStartTime},</if>
            <if test="businessEndTime != null">#{businessEndTime},</if>
            <if test="sort != null">#{sort},</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="updateDriveSchoolInfo" parameterType="cn.iocoder.yudao.module.jx.domain.DriveSchoolInfo">
        update drive_school_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="deptId != null">dept_id = #{deptId},</if>
            <if test="schoolName != null and schoolName != ''">school_name = #{schoolName},</if>
            <if test="leaderName != null and leaderName != ''">leader_name = #{leaderName},</if>
            <if test="phone != null and phone != ''">phone = #{phone},</if>
            <if test="announcement != null and announcement != ''">announcement = #{announcement},</if>
            <if test="region != null and region != ''">region = #{region},</if>
            <if test="photo != null and photo != ''">photo = #{photo},</if>
            <if test="address != null">address = #{address},</if>
            <if test="lat != null">lat = #{lat},</if>
            <if test="lgt != null">lgt = #{lgt},</if>
            <if test="businessStartTime != null">business_start_time = #{businessStartTime},</if>
            <if test="businessEndTime != null">business_end_time = #{businessEndTime},</if>
            <if test="sort != null">sort = #{sort},</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="deleteDriveSchoolInfoById" parameterType="Long">
        delete from drive_school_info where id = #{id}
    </delete>

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

    <select id="getSchoolInfoByDeptId" parameterType="Long" resultMap="DriveSchoolInfoVOResult">
        <include refid="selectDriveSchoolInfoVo"/>
        where deleted = 0 and dept_id = #{deptId}
    </select>

    <select id="findInfoByJxId" parameterType="Long" resultMap="DriveSchoolInfoVOResult">
        <include refid="selectDriveSchoolInfoVo"/>
         where id = #{jxId};
    </select>


</mapper>