一、dao层
1、编写接口 ProductCategoryDao
public interface ProductCategoryDao {
/**
* 批量新增商品类别
* @param productCategoryList
* @return
*/
int batchInsertProductCategory(List<ProductCategory> productCategoryList);
}
2、编写mapper实现
批量插入用<foreach>标签
传入的因为是list所以collection是list,
item是迭代的属性名,
index指定一个名字,用于表示在迭代过程中,每次迭代到的位置,
separator表示在每次进行迭代之间以什么符号作为分隔符
<!-- 批量插入 -->
<insert id="batchInsertProductCategory" parameterType="java.util.List">
INSERT INTO
tb_product_category(product_category_name,priority,create_time,shop_id)
VALUES
<foreach collection="list" item="productCategory" index="index" separator=",">
(
#{productCategory.productCategoryName},
#{productCategory.p