<?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.reptileclient.jlifeapp.dao.jz.JzShopMapper">
    <resultMap id="BaseResultMap" type="com.reptileclient.jlifeapp.entity.jz.JzShop">
        <id column="id" property="id" jdbcType="INTEGER"/>
        <result column="shop_no" property="shopNo" jdbcType="VARCHAR"/>
        <result column="shop_name" property="shopName" jdbcType="VARCHAR"/>
        <result column="shop_channel" property="shopChannel" jdbcType="INTEGER"/>
        <result column="shop_city" property="shopCity" jdbcType="INTEGER"/>
        <result column="shop_city_name" property="shopCityName" jdbcType="VARCHAR"/>
        <result column="deleted" property="deleted" jdbcType="BIT"/>
        <result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
        <result column="create_user" property="createUser" jdbcType="INTEGER"/>
        <result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
        <result column="update_user" property="updateUser" jdbcType="INTEGER"/>
    </resultMap>
    <sql id="Base_Column_List">
        id
        , shop_no, shop_name, shop_channel, shop_city, shop_city_name, deleted, create_time,
    create_user, update_time, update_user
    </sql>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer">
        select
        <include refid="Base_Column_List"/>
        from jz_shop
        where id = #{id,jdbcType=INTEGER}
    </select>
    <select id="selectByShopName" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from jz_shop
        where shop_name = #{shopName}
        order by id desc limit 1
    </select>
    <select id="selectByShopNo" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from jz_shop
        where shop_no = #{shopNo} limit 1
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
        delete
        from jz_shop
        where id = #{id,jdbcType=INTEGER}
    </delete>
    <insert id="insert" parameterType="com.reptileclient.jlifeapp.entity.jz.JzShop">
        insert into jz_shop (id, shop_no, shop_name,
                             shop_channel, shop_city, shop_city_name,
                             deleted, create_time, create_user,
                             update_time, update_user)
        values (#{id,jdbcType=INTEGER}, #{shopNo,jdbcType=VARCHAR}, #{shopName,jdbcType=VARCHAR},
                #{shopChannel,jdbcType=INTEGER}, #{shopCity,jdbcType=INTEGER}, #{shopCityName,jdbcType=VARCHAR},
                #{deleted,jdbcType=BIT}, #{createTime,jdbcType=TIMESTAMP}, #{createUser,jdbcType=INTEGER},
                #{updateTime,jdbcType=TIMESTAMP}, #{updateUser,jdbcType=INTEGER})
    </insert>
    <insert id="insertSelective" parameterType="com.reptileclient.jlifeapp.entity.jz.JzShop">
        insert into jz_shop
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                id,
            </if>
            <if test="shopNo != null">
                shop_no,
            </if>
            <if test="shopName != null">
                shop_name,
            </if>
            <if test="shopChannel != null">
                shop_channel,
            </if>
            <if test="shopCity != null">
                shop_city,
            </if>
            <if test="shopCityName != null">
                shop_city_name,
            </if>
            <if test="deleted != null">
                deleted,
            </if>
            <if test="createTime != null">
                create_time,
            </if>
            <if test="createUser != null">
                create_user,
            </if>
            <if test="updateTime != null">
                update_time,
            </if>
            <if test="updateUser != null">
                update_user,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">
                #{id,jdbcType=INTEGER},
            </if>
            <if test="shopNo != null">
                #{shopNo,jdbcType=VARCHAR},
            </if>
            <if test="shopName != null">
                #{shopName,jdbcType=VARCHAR},
            </if>
            <if test="shopChannel != null">
                #{shopChannel,jdbcType=INTEGER},
            </if>
            <if test="shopCity != null">
                #{shopCity,jdbcType=INTEGER},
            </if>
            <if test="shopCityName != null">
                #{shopCityName,jdbcType=VARCHAR},
            </if>
            <if test="deleted != null">
                #{deleted,jdbcType=BIT},
            </if>
            <if test="createTime != null">
                #{createTime,jdbcType=TIMESTAMP},
            </if>
            <if test="createUser != null">
                #{createUser,jdbcType=INTEGER},
            </if>
            <if test="updateTime != null">
                #{updateTime,jdbcType=TIMESTAMP},
            </if>
            <if test="updateUser != null">
                #{updateUser,jdbcType=INTEGER},
            </if>
        </trim>
    </insert>
    <update id="updateByPrimaryKeySelective" parameterType="com.reptileclient.jlifeapp.entity.jz.JzShop">
        update jz_shop
        <set>
            <if test="shopNo != null">
                shop_no = #{shopNo,jdbcType=VARCHAR},
            </if>
            <if test="shopName != null">
                shop_name = #{shopName,jdbcType=VARCHAR},
            </if>
            <if test="shopChannel != null">
                shop_channel = #{shopChannel,jdbcType=INTEGER},
            </if>
            <if test="shopCity != null">
                shop_city = #{shopCity,jdbcType=INTEGER},
            </if>
            <if test="shopCityName != null">
                shop_city_name = #{shopCityName,jdbcType=VARCHAR},
            </if>
            <if test="deleted != null">
                deleted = #{deleted,jdbcType=BIT},
            </if>
            <if test="createTime != null">
                create_time = #{createTime,jdbcType=TIMESTAMP},
            </if>
            <if test="createUser != null">
                create_user = #{createUser,jdbcType=INTEGER},
            </if>
            <if test="updateTime != null">
                update_time = #{updateTime,jdbcType=TIMESTAMP},
            </if>
            <if test="updateUser != null">
                update_user = #{updateUser,jdbcType=INTEGER},
            </if>
        </set>
        where id = #{id,jdbcType=INTEGER}
    </update>
    <update id="updateByPrimaryKey" parameterType="com.reptileclient.jlifeapp.entity.jz.JzShop">
        update jz_shop
        set shop_no        = #{shopNo,jdbcType=VARCHAR},
            shop_name      = #{shopName,jdbcType=VARCHAR},
            shop_channel   = #{shopChannel,jdbcType=INTEGER},
            shop_city      = #{shopCity,jdbcType=INTEGER},
            shop_city_name = #{shopCityName,jdbcType=VARCHAR},
            deleted        = #{deleted,jdbcType=BIT},
            create_time    = #{createTime,jdbcType=TIMESTAMP},
            create_user    = #{createUser,jdbcType=INTEGER},
            update_time    = #{updateTime,jdbcType=TIMESTAMP},
            update_user    = #{updateUser,jdbcType=INTEGER}
        where id = #{id,jdbcType=INTEGER}
    </update>

    <insert id="beatchInsert">
        <foreach collection="list" item="item" index="index" separator=";">
            INSERT INTO jz_shop ( shop_no, shop_name, shop_channel,shop_city )
            SELECT #{item.shopNo,jdbcType=VARCHAR}, #{item.shopName,jdbcType=VARCHAR},
            #{item.shopChannel,jdbcType=INTEGER}, #{item.shopCity,jdbcType=INTEGER}
            FROM dual
            WHERE NOT EXISTS ( SELECT shop_no FROM jz_shop WHERE shop_no = '123' )
        </foreach>
    </insert>

    <update id="updateCloseShop">
        update jz_shop
        set deleted=1
        where (shop_name like '废弃%' or shop_name like '关闭%')
    </update>

</mapper>