<?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.BusiAgentsLocationMapper">
    
    <resultMap type="BusiAgentsLocation" id="BusiAgentsLocationResult">
        <result property="id"    column="id"    />
        <result property="agentId"    column="agent_id"    />
        <result property="pro"    column="pro"    />
        <result property="city"    column="city"    />
        <result property="area"    column="area"    />
        <result property="level"    column="level"    />
        <result property="status"    column="status"    />
        <result property="createTime"    column="create_time"    />
    </resultMap>

    <sql id="selectBusiAgentsLocationVo">
        select id, agent_id, pro, city, area, level, status, create_time from b_busi_agents_location
    </sql>

    <select id="selectBusiAgentsLocationList" parameterType="BusiAgentsLocation" resultMap="BusiAgentsLocationResult">
        <include refid="selectBusiAgentsLocationVo"/>
        <where>  
            <if test="agentId != null "> and agent_id = #{agentId}</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="level != null "> and level = #{level}</if>
            <if test="status != null "> and status = #{status}</if>
        </where>
        order by id desc
    </select>
    
    <select id="selectBusiAgentsLocationById" parameterType="Long" resultMap="BusiAgentsLocationResult">
        <include refid="selectBusiAgentsLocationVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertBusiAgentsLocation" parameterType="BusiAgentsLocation" useGeneratedKeys="true" keyProperty="id">
        insert into b_busi_agents_location
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="agentId != null">agent_id,</if>
            <if test="pro != null">pro,</if>
            <if test="city != null">city,</if>
            <if test="area != null">area,</if>
            <if test="level != null">level,</if>
            <if test="status != null">status,</if>
            <if test="createTime != null">create_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="agentId != null">#{agentId},</if>
            <if test="pro != null">#{pro},</if>
            <if test="city != null">#{city},</if>
            <if test="area != null">#{area},</if>
            <if test="level != null">#{level},</if>
            <if test="status != null">#{status},</if>
            <if test="createTime != null">#{createTime},</if>
         </trim>
    </insert>

    <update id="updateBusiAgentsLocation" parameterType="BusiAgentsLocation">
        update b_busi_agents_location
        <trim prefix="SET" suffixOverrides=",">
            <if test="agentId != null">agent_id = #{agentId},</if>
            <if test="pro != null">pro = #{pro},</if>
            <if test="city != null">city = #{city},</if>
            <if test="area != null">area = #{area},</if>
            <if test="level != null">level = #{level},</if>
            <if test="status != null">status = #{status},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteBusiAgentsLocationById" parameterType="Long">
        delete from b_busi_agents_location where id = #{id}
    </delete>

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