foreach collection 读取类中list

XML:

    select * from goods_info
    where delete_flag = 0
    <if test="query.code != null and query.code != ''">
        and code = #{query.code}
    </if>
    <if test="query.name != null and query.name != ''">
        and name = #{query.name}
    </if>
    <if test="query.kksCode != null and query.kksCode != ''">
        and kks_code = #{query.kksCode}
    </if>
    <if test="query.goodsIdList != null ">
        and id not in
        <foreach collection="query.goodsIdList" item="item" index="index" open="(" separator="," close=")">
              #{item}
        </foreach>
    </if>
    order by create_date desc

MAPPER:

Page goodsPage(Page page, @Param("query") ListGoodsDTO listGoodsDTO);

SERVICEIMPL:

@Override
public Page selectGoodsList(ListGoodsDTO listGoodsDTO) {
Page page = new Page<>(listGoodsDTO.getCurrent(), listGoodsDTO.getLimit());
Page goodsPage = countManageMapper.goodsPage(page, listGoodsDTO);
return goodsPage;
}

posted @ 2023-05-24 16:27  RHsama  阅读(38)  评论(0编辑  收藏  举报