<?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.izouma.awesomeadmin.dao.BusinessCircleMapper">
    <resultMap id="BaseResultMap" type="com.izouma.awesomeadmin.model.BusinessCircle">
        <id column="id" property="id" jdbcType="INTEGER"/>
        <result column="del_flag" property="delFlag" jdbcType="CHAR"/>
        <result column="short_name" property="shortName" jdbcType="VARCHAR"/>
        <result column="code" property="code" jdbcType="VARCHAR"/>
        <result column="lat" property="lat" jdbcType="VARCHAR"/>
        <result column="lng" property="lng" jdbcType="VARCHAR"/>
        <result column="remark" property="remark" jdbcType="VARCHAR"/>
        <result column="city_code" property="cityCode" jdbcType="VARCHAR"/>
        <result column="rank" property="rank" jdbcType="INTEGER"/>
        <result column="hot" property="hot" jdbcType="INTEGER"/>
        <result column="district_code" property="districtCode" jdbcType="VARCHAR"/>
        <result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
        <result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
        <result column="full_name" property="fullName" jdbcType="VARCHAR"/>
    </resultMap>
    <sql id="Base_Column_List">
            id,            del_flag,            short_name,            code,            lat,            lng,            remark,            city_code,            rank,            hot,            district_code,            create_time,            update_time,            full_name        </sql>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer">
        select
        <include refid="Base_Column_List"/>
        from business_circle
        where id = #{id,jdbcType=INTEGER}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
        delete from business_circle
        where id = #{id,jdbcType=INTEGER}
    </delete>
    <insert id="insertSelective" parameterType="com.izouma.awesomeadmin.model.BusinessCircle" useGeneratedKeys="true"
            keyProperty="id">
        insert into business_circle
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id!= null">
                id,
            </if>
            <if test="delFlag!= null">
                del_flag,
            </if>
            <if test="shortName!= null">
                short_name,
            </if>
            <if test="code!= null">
                code,
            </if>
            <if test="lat!= null">
                lat,
            </if>
            <if test="lng!= null">
                lng,
            </if>
            <if test="remark!= null">
                remark,
            </if>
            <if test="cityCode!= null">
                city_code,
            </if>
            <if test="rank!= null">
                rank,
            </if>
            <if test="hot!= null">
                hot,
            </if>
            <if test="districtCode!= null">
                district_code,
            </if>
            <if test="createTime!= null">
                create_time,
            </if>
            <if test="updateTime!= null">
                update_time,
            </if>
            <if test="fullName!= null">
                full_name,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">
                #{id,jdbcType=INTEGER},
            </if>
            <if test="delFlag != null">
                #{delFlag,jdbcType=CHAR},
            </if>
            <if test="shortName != null">
                #{shortName,jdbcType=VARCHAR},
            </if>
            <if test="code != null">
                #{code,jdbcType=VARCHAR},
            </if>
            <if test="lat != null">
                #{lat,jdbcType=VARCHAR},
            </if>
            <if test="lng != null">
                #{lng,jdbcType=VARCHAR},
            </if>
            <if test="remark != null">
                #{remark,jdbcType=VARCHAR},
            </if>
            <if test="cityCode != null">
                #{cityCode,jdbcType=VARCHAR},
            </if>
            <if test="rank != null">
                #{rank,jdbcType=INTEGER},
            </if>
            <if test="hot != null">
                #{hot,jdbcType=INTEGER},
            </if>
            <if test="districtCode != null">
                #{districtCode,jdbcType=VARCHAR},
            </if>
            <if test="createTime != null">
                #{createTime,jdbcType=TIMESTAMP},
            </if>
            <if test="updateTime != null">
                #{updateTime,jdbcType=TIMESTAMP},
            </if>
            <if test="fullName != null">
                #{fullName,jdbcType=VARCHAR},
            </if>
        </trim>
    </insert>
    <update id="updateByPrimaryKeySelective" parameterType="com.izouma.awesomeadmin.model.BusinessCircle">
        update business_circle
        <set>
            <if test="id != null">
                id= #{id,jdbcType=INTEGER},
            </if>
            <if test="delFlag != null">
                del_flag= #{delFlag,jdbcType=CHAR},
            </if>
            <if test="shortName != null">
                short_name= #{shortName,jdbcType=VARCHAR},
            </if>
            <if test="code != null">
                code= #{code,jdbcType=VARCHAR},
            </if>
            <if test="lat != null">
                lat= #{lat,jdbcType=VARCHAR},
            </if>
            <if test="lng != null">
                lng= #{lng,jdbcType=VARCHAR},
            </if>
            <if test="remark != null">
                remark= #{remark,jdbcType=VARCHAR},
            </if>
            <if test="cityCode != null">
                city_code= #{cityCode,jdbcType=VARCHAR},
            </if>
            <if test="rank != null">
                rank= #{rank,jdbcType=INTEGER},
            </if>
            <if test="hot != null">
                hot= #{hot,jdbcType=INTEGER},
            </if>
            <if test="districtCode != null">
                district_code= #{districtCode,jdbcType=VARCHAR},
            </if>
            <if test="createTime != null">
                create_time= #{createTime,jdbcType=TIMESTAMP},
            </if>
            <if test="updateTime != null">
                update_time= #{updateTime,jdbcType=TIMESTAMP},
            </if>
            <if test="fullName != null">
                full_name= #{fullName,jdbcType=VARCHAR},
            </if>
        </set>
        where id = #{id,jdbcType=INTEGER}
    </update>
    <select id="queryBusinessCircleByPage" parameterType="java.util.Map"
            resultType="com.izouma.awesomeadmin.model.BusinessCircle">
        select
        <include refid="Base_Column_List"/>
        from business_circle
        <where>
            and del_flag = 'N'
            <if test="record.id != null and !&quot;&quot;.equals(record.id)">
                and id = #{record.id}
            </if>
            <if test="record.delFlag != null and !&quot;&quot;.equals(record.delFlag)">
                and del_flag = #{record.delFlag}
            </if>
            <if test="record.shortName != null and !&quot;&quot;.equals(record.shortName)">
                and short_name = #{record.shortName}
            </if>
            <if test="record.code != null and !&quot;&quot;.equals(record.code)">
                and code = #{record.code}
            </if>
            <if test="record.lat != null and !&quot;&quot;.equals(record.lat)">
                and lat = #{record.lat}
            </if>
            <if test="record.lng != null and !&quot;&quot;.equals(record.lng)">
                and lng = #{record.lng}
            </if>
            <if test="record.remark != null and !&quot;&quot;.equals(record.remark)">
                and remark = #{record.remark}
            </if>
            <if test="record.cityCode != null and !&quot;&quot;.equals(record.cityCode)">
                and city_code = #{record.cityCode}
            </if>
            <if test="record.rank != null and !&quot;&quot;.equals(record.rank)">
                and rank = #{record.rank}
            </if>
            <if test="record.hot != null and !&quot;&quot;.equals(record.hot)">
                and hot = #{record.hot}
            </if>
            <if test="record.districtCode != null and !&quot;&quot;.equals(record.districtCode)">
                and district_code = #{record.districtCode}
            </if>
            <if test="record.createTime != null and !&quot;&quot;.equals(record.createTime)">
                and create_time = #{record.createTime}
            </if>
            <if test="record.updateTime != null and !&quot;&quot;.equals(record.updateTime)">
                and update_time = #{record.updateTime}
            </if>
            <if test="record.fullName != null and !&quot;&quot;.equals(record.fullName)">
                and full_name = #{record.fullName}
            </if>

            <if test="record.searchKey != null and !&quot;&quot;.equals(record.searchKey)">
                <trim prefix="and (" suffix=")" prefixOverrides="OR">
                    OR short_name LIKE concat('%',#{record.searchKey},'%')
                    OR full_name LIKE concat('%',#{record.searchKey},'%')
                    OR code LIKE concat('%',#{record.searchKey},'%')
                    OR city_code LIKE concat('%',#{record.searchKey},'%')
                    OR remark LIKE concat('%',#{record.searchKey},'%')
                    OR district_code LIKE concat('%',#{record.searchKey},'%')
                </trim>
            </if>

        </where>
        order by id desc
    </select>
    <select id="queryAllBusinessCircle" parameterType="java.util.Map"
            resultType="com.izouma.awesomeadmin.model.BusinessCircle">
        select
        <include refid="Base_Column_List"/>
        from business_circle
        <where>
            and del_flag = 'N'
            <if test="id != null and !&quot;&quot;.equals(id)">
                and id = #{id}
            </if>
            <if test="delFlag != null and !&quot;&quot;.equals(delFlag)">
                and del_flag = #{delFlag}
            </if>
            <if test="shortName != null and !&quot;&quot;.equals(shortName)">
                and short_name = #{shortName}
            </if>
            <if test="code != null and !&quot;&quot;.equals(code)">
                and code = #{code}
            </if>
            <if test="lat != null and !&quot;&quot;.equals(lat)">
                and lat = #{lat}
            </if>
            <if test="lng != null and !&quot;&quot;.equals(lng)">
                and lng = #{lng}
            </if>
            <if test="remark != null and !&quot;&quot;.equals(remark)">
                and remark = #{remark}
            </if>
            <if test="cityCode != null and !&quot;&quot;.equals(cityCode)">
                and city_code = #{cityCode}
            </if>
            <if test="rank != null and !&quot;&quot;.equals(rank)">
                and rank = #{rank}
            </if>
            <if test="hot != null and !&quot;&quot;.equals(hot)">
                and hot = #{hot}
            </if>
            <if test="districtCode != null and !&quot;&quot;.equals(districtCode)">
                and district_code = #{districtCode}
            </if>
            <if test="createTime != null and !&quot;&quot;.equals(createTime)">
                and create_time = #{createTime}
            </if>
            <if test="updateTime != null and !&quot;&quot;.equals(updateTime)">
                and update_time = #{updateTime}
            </if>
            <if test="fullName != null and !&quot;&quot;.equals(fullName)">
                and full_name = #{fullName}
            </if>
        </where>
        order by id desc
    </select>
    <select id="queryBusinessCircle" parameterType="java.util.Map"
            resultType="com.izouma.awesomeadmin.model.BusinessCircle">
        select
        <include refid="Base_Column_List"/>
        from business_circle
        <where>
            and del_flag = 'N'
            <if test="id != null and !&quot;&quot;.equals(id)">
                and id = #{id}
            </if>
            <if test="delFlag != null and !&quot;&quot;.equals(delFlag)">
                and del_flag = #{delFlag}
            </if>
            <if test="shortName != null and !&quot;&quot;.equals(shortName)">
                and short_name = #{shortName}
            </if>
            <if test="code != null and !&quot;&quot;.equals(code)">
                and code = #{code}
            </if>
            <if test="lat != null and !&quot;&quot;.equals(lat)">
                and lat = #{lat}
            </if>
            <if test="lng != null and !&quot;&quot;.equals(lng)">
                and lng = #{lng}
            </if>
            <if test="remark != null and !&quot;&quot;.equals(remark)">
                and remark = #{remark}
            </if>
            <if test="cityCode != null and !&quot;&quot;.equals(cityCode)">
                and city_code = #{cityCode}
            </if>
            <if test="rank != null and !&quot;&quot;.equals(rank)">
                and rank = #{rank}
            </if>
            <if test="hot != null and !&quot;&quot;.equals(hot)">
                and hot = #{hot}
            </if>
            <if test="districtCode != null and !&quot;&quot;.equals(districtCode)">
                and district_code = #{districtCode}
            </if>
            <if test="createTime != null and !&quot;&quot;.equals(createTime)">
                and create_time = #{createTime}
            </if>
            <if test="updateTime != null and !&quot;&quot;.equals(updateTime)">
                and update_time = #{updateTime}
            </if>
            <if test="fullName != null and !&quot;&quot;.equals(fullName)">
                and full_name = #{fullName}
            </if>

        </where>
        LIMIT 1
    </select>
    <update id="delete">
        UPDATE business_circle SET del_flag = 'Y'
        <where>
            AND id = #{id}
        </where>
    </update>
    <select id="query" parameterType="java.util.Map" resultType="com.izouma.awesomeadmin.model.BusinessCircle">
        select
        <include refid="Base_Column_List"/>
        from business_circle
        <where>
            and del_flag = 'N'
        </where>
        order by id desc
    </select>
</mapper>

