<?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.gic.haoban.manage.service.dao.mapper.hm.HmLinkStoreMapper">
	<resultMap type="com.gic.haoban.manage.service.entity.hm.TabHmLinkStore"
		id="result-map-tabHaobanHmLinkStore">
		<result column="id" property="id" />
		<result column="wx_enterprise_id" property="wxEnterpriseId" />
		<result column="enterprise_id" property="enterpriseId" />
		<result column="store_id" property="storeId" />
		<result column="store_code" property="storeCode" />
		<result column="store_name" property="storeName" />
		<result column="status_flag" property="statusFlag" />
		<result column="link_id" property="linkId" />
		<result column="settting_type" property="setttingType" />
		
	</resultMap>
	<sql id="Base_Column_List">
		id,
		wx_enterprise_id,
		enterprise_id,
		store_id,
		store_code,
		store_name,
		status_flag,
		link_id,
		settting_type , create_time , update_time
	</sql>
	<insert id="insertBatch">
		INSERT INTO tab_haoban_hm_link_store(
		id,
		wx_enterprise_id,
		enterprise_id,
		store_id,
		store_code,
		store_name,
		status_flag,
		link_id,
		settting_type ,  create_time , update_time 
		)VALUES
		<foreach collection="list" item="item" separator=","  >
			( #{item.id} , #{item.wxEnterpriseId},
			#{item.enterpriseId},
			#{item.storeId},
			#{item.storeCode},
			#{item.storeName},
			#{item.statusFlag},
			#{item.linkId},
			#{item.setttingType} , now() , now())
		</foreach>
	</insert>

	<update id="deleteByLinkId" parameterType="long">
		UPDATE
		tab_haoban_hm_link_store SET status_flag = 0 , update_time=now() WHERE
		link_id = #{linkId} and status_flag = 1
	</update>
	
	
	<update id="deleteById">
		UPDATE
		tab_haoban_hm_link_store SET status_flag = 0 , update_time=now() WHERE
		id in <foreach collection="list" item="item" separator="," open="(" close=")"  >
			#{item}
		</foreach>
		 and status_flag = 1
	</update>


	<select id="listByLinkId"
		parameterType="com.gic.haoban.manage.service.entity.hm.TabHmLinkStore"
		resultMap="result-map-tabHaobanHmLinkStore">
		select <include refid="Base_Column_List" /> from tab_haoban_hm_link_store where link_id=#{linkId} and status_flag = 1
	</select>
</mapper> 