当前位置:   article > 正文

MyBatis-Plus 关联查询

MyBatis-Plus 关联查询

1、mapper 

  1. public interface WmsSendOrderLinesMapper extends BaseMapperPlus<WmsSendOrderLinesMapper, WmsSendOrderLines, WmsSendOrderLinesVo> {
  2. List<WmsSendOrderLines> getBindProductLines(@Param(Constants.WRAPPER) Wrapper<WmsSendOrderLinesBo> queryWrapper);
  3. }

2、xml

  1. <select id="getBindProductLines" resultType="com.smart.wms.send.bean.WmsSendOrderLines">
  2. select wsol.*, wp.bind_id
  3. from wms_send_order_lines wsol
  4. left join wms_product wp on wp.id = wsol.product_id
  5. ${ew.getCustomSqlSegment}
  6. </select>

3、service

List<WmsSendOrderLines> getBindProductLines(WmsSendOrderLinesBo bo);

4、serviceImpl

  1. @Override
  2. public List<WmsSendOrderLines> getBindProductLines(WmsSendOrderLinesBo bo) {
  3. return baseMapper.getBindProductLines(buildBindQueryWrapper(bo));
  4. }
  5. private QueryWrapper<WmsSendOrderLinesBo> buildBindQueryWrapper(WmsSendOrderLinesBo bo) {
  6. QueryWrapper<WmsSendOrderLinesBo> lqw = Wrappers.query();
  7. lqw.eq(bo.getSendOrderId() != null, "wsol.send_order_id", bo.getSendOrderId());
  8. lqw.in(CollUtil.isNotEmpty(bo.getReturnOrderIds()),"wsol.returnOrderIds", bo.getReturnOrderIds());
  9. lqw.groupBy("wsol.return_order_id,wsol.item_bar_code");
  10. return lqw;
  11. }

5、 controller

  1. @RequestMapping("/test")
  2. public void test() {
  3. List<WmsSendOrderLines> orderLinesList = iWmsSendOrderLinesService.getBindProductLines(wmsSendOrderLinesBo);
  4. }

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/一键难忘520/article/detail/823385
推荐阅读
相关标签
  

闽ICP备14008679号