mybatis按照id查询出来的顺序进行排序

service层

List<GoodsSpu> goodsSpuList = baseMapper.queryGoodsSpuListByOrderBySpuIdList(PageParam.initial(page, queryDto), MapUtils.buildKeyValueMap("spuIdList", orderBySpuIdList, "spuIdStr", spuIdSb.substring(0, spuIdSb.length() - 1)));

 

mapper层

/**
 * 通过商品id查询商品列表
 * @param pagination
 * @param spuMap (spuIdList   spuIdStr商品id集合拼成的字符串)
 * @return
 */
List<GoodsSpu> queryGoodsSpuListByOrderBySpuIdList(Pagination pagination, Map<Object, Object> spuMap);

xml

<!-- 根据spuIdList的顺序查询出商品信息的列表 -->
<select id="queryGoodsSpuListByOrderBySpuIdList" parameterType="java.util.Map" resultType="GoodsSpu">
    select
    <include refid="Base_Column_List"/>
    from goods_spu where spu_id in
    <foreach collection="spuIdList" item="spuId" separator="," open="(" close=")">
        #{spuId}
    </foreach>
    and flag_del = 0
    order by field(
    spu_id, ${spuIdStr}
    )
</select>

通过查询出的id进行排序的方式。

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值