<?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.yami.shop.user.comment.dao.UserLevelCategoryMapper">

  <resultMap id="userLevelCategoryMap" type="com.yami.shop.user.comment.model.UserLevelCategory">
    <id column="user_level_category_id" property="userLevelCategoryId" />
    <result column="level_id" property="levelId"/>
    <result column="category_id" property="categoryId"/>
  </resultMap>
  <select id="getCategoryIdByLevelId" resultType="java.lang.Long">
    SELECT category_id FROM tz_user_level_category WHERE level_id = #{id}
  </select>
  <insert id="insertBatch">
    insert into tz_user_level_category (level_id,category_id) values
    <foreach collection="categorys" item="categoryId" separator=",">
      (#{id},#{categoryId})
    </foreach>
  </insert>
  <delete id="delBatch">
    delete from tz_user_level_category where level_id = #{id} and category_id in
    <foreach item="categoryId" collection="categorys" open="(" separator="," close=")">
      #{categoryId}
    </foreach>
  </delete>
</mapper>
