<?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.diaoyun.zion.chinafrica.dao.TbCfStoreDao">

    <resultMap type="com.diaoyun.zion.chinafrica.entity.TbCfStoreEntity" id="tbCfStoreMap">
        <result property="storeId" column="store_id"/>
        <result property="storeCode" column="store_code"/>
        <result property="storeName" column="store_name"/>
        <result property="storeBrief" column="store_brief"/>
        <result property="storeUrl" column="store_url"/>
        <result property="storeImg" column="store_img"/>
        <result property="platformCode" column="platform_code"/>
        <result property="platformName" column="platform_name"/>
        <result property="enableFlag" column="enable_flag"/>
        <result property="createTime" column="create_time"/>
    </resultMap>

    <select id="queryObject" resultType="com.diaoyun.zion.chinafrica.entity.TbCfStoreEntity">
		select
			`store_id`,
			`store_code`,
			`store_name`,
			`store_brief`,
			`store_url`,
			`store_img`,
			`platform_code`,
			`platform_name`,
			`enable_flag`,
			`create_time`,
			`item_img_1`,
			`item_img_2`
		from tb_cf_store
		where store_id = #{id}
	</select>

    <select id="queryList" resultType="com.diaoyun.zion.chinafrica.entity.TbCfStoreEntity">
        select
			`store_id`,
			`store_code`,
			`store_name`,
			`store_brief`,
			`store_url`,
			`store_img`,
			`platform_code`,
			`platform_name`,
			`enable_flag`,
			`create_time`,
			`item_img_1`,
			`item_img_2`
        from tb_cf_store
        WHERE 1=1
        <if test="name != null and name.trim() != ''">
            AND name LIKE concat('%',#{name},'%')
        </if>
        <choose>
            <when test="sidx != null and sidx.trim() != ''">
                order by ${sidx} ${order}
            </when>
            <otherwise>
                order by store_id desc
            </otherwise>
        </choose>
        <if test="offset != null and limit != null">
            limit #{offset}, #{limit}
        </if>
    </select>

    <select id="queryTotal" resultType="int">
        select count(*) from tb_cf_store
        WHERE 1=1
        <if test="name != null and name.trim() != ''">
            AND name LIKE concat('%',#{name},'%')
        </if>
    </select>

    <insert id="save" parameterType="com.diaoyun.zion.chinafrica.entity.TbCfStoreEntity">
		insert into tb_cf_store(
			`store_id`,
			`store_code`,
			`store_name`,
			`store_brief`,
			`store_url`,
			`store_img`,
			`platform_code`,
			`platform_name`,
			`enable_flag`,
			`create_time`,
			`item_img_1`,
			`item_img_2`)
		values(
			#{storeId},
			#{storeCode},
			#{storeName},
			#{storeBrief},
			#{storeUrl},
			#{storeImg},
			#{platformCode},
			#{platformName},
			#{enableFlag},
			#{createTime},
			#{itemImg1},
			#{itemImg2})
	</insert>

    <update id="update" parameterType="com.diaoyun.zion.chinafrica.entity.TbCfStoreEntity">
        update tb_cf_store
        <set>
            <if test="storeCode != null">`store_code` = #{storeCode},</if>
            <if test="storeName != null">`store_name` = #{storeName},</if>
            <if test="storeBrief != null">`store_brief` = #{storeBrief},</if>
            <if test="storeUrl != null">`store_url` = #{storeUrl},</if>
            <if test="storeImg != null">`store_img` = #{storeImg},</if>
            <if test="platformCode != null">`platform_code` = #{platformCode},</if>
            <if test="platformName != null">`platform_name` = #{platformName},</if>
            <if test="enableFlag != null">`enable_flag` = #{enableFlag},</if>
            <if test="createTime != null">`create_time` = #{createTime}</if>
            <if test="itemImg1 != null">`item_img_1` = #{itemImg1}</if>
            <if test="itemImg2 != null">`item_img_2` = #{itemImg2}</if>
        </set>
        where store_id = #{storeId}
    </update>

    <delete id="delete">
		delete from tb_cf_store where store_id = #{value}
	</delete>

    <delete id="deleteBatch">
        delete from tb_cf_store where store_id in
        <foreach item="storeId" collection="array" open="(" separator="," close=")">
            #{storeId}
        </foreach>
    </delete>
    <!--获取店铺独立站-->
    <select id="getStoreStationList" resultType="com.diaoyun.zion.chinafrica.entity.TbCfStoreEntity">
		 select * from tb_cf_store where enable_flag!=0 order by enable_flag asc
	</select>

</mapper>