| | |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.core.domain.R; |
| | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | import java.util.Optional; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | public R<IPage<ShopWithdraw>> list(@ApiParam("页码") @RequestParam Integer pageNum, |
| | | @ApiParam("每一页数据大小") Integer pageSize, |
| | | ShopWithdraw shopWithdraw) { |
| | | |
| | | List<Shop> list = shopService.list(new LambdaUpdateWrapper<Shop>().like(StringUtils.isNotEmpty(shopWithdraw.getShopName()), Shop::getName, shopWithdraw.getShopName()).eq(Shop::getDelFlag, 0)); |
| | | List<Integer> collect1 = list.stream().map(Shop::getId).collect(Collectors.toList()); |
| | | Page<ShopWithdraw> page = shopWithdrawService.page(Page.of(pageNum, pageSize), new LambdaQueryWrapper<ShopWithdraw>() |
| | | .like(StringUtils.isNotEmpty(shopWithdraw.getShopName()), ShopWithdraw::getShopName, shopWithdraw.getShopName())); |
| | | page.getRecords().forEach(item-> item.setShopName(shopService.getById(item.getShopId()).getName())); |
| | | .in(collect1.size() > 0, ShopWithdraw::getShopId, collect1)); |
| | | List<ShopWithdraw> records = page.getRecords(); |
| | | List<Integer> collect = records.stream().map(ShopWithdraw::getShopId).collect(Collectors.toList()); |
| | | List<Shop> shops = null; |
| | | if(collect.size() > 0){ |
| | | shops = shopService.listByIds(collect); |
| | | } |
| | | for(ShopWithdraw item : records){ |
| | | Optional<Shop> first = shops.stream().filter(s -> s.getId().equals(item.getId())).findFirst(); |
| | | if(first.isPresent()){ |
| | | item.setShopName(first.get().getName()); |
| | | } |
| | | } |
| | | return R.ok(page); |
| | | } |
| | | |