<?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.voluntary.mapper.BusiSchoolsMapper">

    <resultMap type="BusiSchools" id="BusiSchoolsResult">
        <result property="id"    column="id"    />
        <result property="name"    column="name"    />
        <result property="agentId"    column="agent_id"    />
        <result property="location"    column="location"    />
        <result property="pro"    column="pro"    />
        <result property="city"    column="city"    />
        <result property="area"    column="area"    />
        <result property="status"    column="status"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectBusiSchoolsVo">
        select id, name, agent_id, location, pro, city, area, status, create_time, update_time from b_busi_schools
    </sql>

    <select id="selectBusiSchoolsList" parameterType="BusiSchools" resultMap="BusiSchoolsResult">
        <include refid="selectBusiSchoolsVo"/>
        <where>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="agentId != null "> and agent_id = #{agentId}</if>
            <if test="location != null  and location != ''"> and location = #{location}</if>
            <if test="pro != null "> and pro = #{pro}</if>
            <if test="city != null "> and city = #{city}</if>
            <if test="area != null "> and area = #{area}</if>
            <if test="status != null "> and status = #{status}</if>
        </where>
        order by id desc
    </select>

    <select id="selectBusiSchoolsById" parameterType="Long" resultMap="BusiSchoolsResult">
        <include refid="selectBusiSchoolsVo"/>
        where id = #{id}
    </select>

    <select id="selectBusiSchoolsByIds" resultMap="BusiSchoolsResult">
        <include refid="selectBusiSchoolsVo"/>
        where 1=1 and id in
        <foreach collection="list"  item="id"  open="(" separator="," close=")">
            #{id}
        </foreach>
    </select>

    <insert id="insertBusiSchools" parameterType="BusiSchools" useGeneratedKeys="true" keyProperty="id">
        insert into b_busi_schools
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="name != null and name != ''">name,</if>
            <if test="agentId != null">agent_id,</if>
            <if test="location != null">location,</if>
            <if test="pro != null">pro,</if>
            <if test="city != null">city,</if>
            <if test="area != null">area,</if>
            <if test="status != null">status,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="name != null and name != ''">#{name},</if>
            <if test="agentId != null">#{agentId},</if>
            <if test="location != null">#{location},</if>
            <if test="pro != null">#{pro},</if>
            <if test="city != null">#{city},</if>
            <if test="area != null">#{area},</if>
            <if test="status != null">#{status},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>

    <update id="updateBusiSchools" parameterType="BusiSchools">
        update b_busi_schools
        <trim prefix="SET" suffixOverrides=",">
            <if test="name != null and name != ''">name = #{name},</if>
            <if test="agentId != null">agent_id = #{agentId},</if>
            <if test="location != null">location = #{location},</if>
            <if test="pro != null">pro = #{pro},</if>
            <if test="city != null">city = #{city},</if>
            <if test="area != null">area = #{area},</if>
            <if test="status != null">status = #{status},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteBusiSchoolsById" parameterType="Long">
        delete from b_busi_schools where id = #{id}
    </delete>

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