<?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.tmerclub.cloud.user.mapper.PopupRelateMapper">
  <resultMap id="popupRelateMap" type="com.tmerclub.cloud.user.model.PopupRelate">
    <id column="relate_id" property="relateId" />
    <result column="popup_id" property="popupId"/>
    <result column="spu_id" property="spuId"/>
    <result column="user_level_id" property="userLevelId"/>
    <result column="create_time" property="createTime"/>
    <result column="update_time" property="updateTime"/>
  </resultMap>
  <sql id="Vo_Column_List">
    `relate_id`,`popup_id`,`spu_id`,`user_level_id`,`create_time`,`update_time`
  </sql>
  <select id="getByPopupId" resultMap="popupRelateMap">
    select <include refid="Vo_Column_List"/>
    from popup_relate where popup_id = #{popupId}
  </select>
  <insert id="saveBatch">
    insert into popup_relate (`popup_id`,`spu_id`,`user_level_id`)
    values
    <foreach collection="popupRelates" item="popupRelate" separator=",">
      (#{popupRelate.popupId},#{popupRelate.spuId},#{popupRelate.userLevelId})
    </foreach>
  </insert>
  <delete id="deleteById">
    delete from popup_relate where popup_id = #{popupId}
  </delete>
  <delete id="deleteByRelateIds">
    delete from popup_relate
    where relate_id IN
    <foreach collection="relateIds" item="relateId" open="(" close=")" separator=",">
      #{relateId}
    </foreach>
  </delete>
</mapper>
