在这里插入代码片
service:调用mapper里的方法
List<ClubGoodsCommonClass> mapList = classMapper.selectCommonClassByGcIds(list);
mapper:
List<ClubGoodsCommonClass> selectCommonClassByGcIds(@Param("goodsIds") List<String> goodsIds);
mapper.xml里的方法:
<select id="selectCommonClassByGcIds" resultMap="BaseResultMap">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select gc_id, gc_name, gc_parent_id, full_name, full_id, gc_sort, gc_img, is_delete,gc_type, `level`,
create_time
from club_goods_common_class
where 1>1
<if test="goodsIds!=null ">
<foreach item="goodsId" index="index" collection="goodsIds">
or gc_id = #{goodsId}
</foreach>
</if>
</select>
mybatis 传入集合新增:
service调mapper里的接口:
clubGoodsClassMapper.createGoodsClassList(arrayList);
mapper里的方法:
int createGoodsClassList(@Param(“list”) List bean);
mapper.xml里的方法:
在这里插入代码片
<!--批量创建-->
<insert id="createGoodsClassList" parameterType="com.shop.core.beans.ClubGoodsClass">
INSERT INTO club_goods_class
(class_id,gc_id, gc_name, gc_parent_id,
full_name, full_id, gc_sort,
gc_img, gc_type, shop_id, `level`, create_time
)
VALUES
<foreach collection="list" item="item" index="index" separator="," >
(#{item.classId},
#{item.gcId},
#{item.gcName},
#{item.gcParentId},
#{item.fullName},
#{item.fullId},
#{item.gcSort},
#{item.gcImg},
#{item.gcType},
#{item.shopId},
#{item.level},
#{item.createTime})
</foreach>
</insert>