Authored by Lixiaodi

页码默认值

@@ -3,6 +3,7 @@ package com.yohoufo.order.controller; @@ -3,6 +3,7 @@ package com.yohoufo.order.controller;
3 import com.alibaba.fastjson.JSONObject; 3 import com.alibaba.fastjson.JSONObject;
4 import com.yohobuy.ufo.model.order.bo.DepositDetailBo; 4 import com.yohobuy.ufo.model.order.bo.DepositDetailBo;
5 import com.yohobuy.ufo.model.order.bo.DepositProductBo; 5 import com.yohobuy.ufo.model.order.bo.DepositProductBo;
  6 +import com.yohobuy.ufo.model.order.resp.PageResp;
6 import com.yohoufo.common.ApiResponse; 7 import com.yohoufo.common.ApiResponse;
7 import com.yohoufo.order.service.DepositService; 8 import com.yohoufo.order.service.DepositService;
8 import org.slf4j.Logger; 9 import org.slf4j.Logger;
@@ -32,7 +33,7 @@ public class DepositController { @@ -32,7 +33,7 @@ public class DepositController {
32 return new ApiResponse.ApiResponseBuilder().code(500).message("查询失败").build(); 33 return new ApiResponse.ApiResponseBuilder().code(500).message("查询失败").build();
33 } 34 }
34 35
35 - List<DepositProductBo> depositProductBoList = depositService.queryUserDoposit(uid, page, limit); 36 + PageResp<List<DepositProductBo>> depositProductBoList = depositService.queryUserDoposit(uid, page, limit);
36 LOG.info("queryStoreInfoById result: {}", depositProductBoList); 37 LOG.info("queryStoreInfoById result: {}", depositProductBoList);
37 return new ApiResponse.ApiResponseBuilder().code(200).data(depositProductBoList).build(); 38 return new ApiResponse.ApiResponseBuilder().code(200).data(depositProductBoList).build();
38 } 39 }
@@ -47,7 +48,7 @@ public class DepositController { @@ -47,7 +48,7 @@ public class DepositController {
47 return new ApiResponse.ApiResponseBuilder().code(500).message("查询失败").build(); 48 return new ApiResponse.ApiResponseBuilder().code(500).message("查询失败").build();
48 } 49 }
49 50
50 - List<DepositDetailBo> depositDetailBoList = depositService.queryUserDopositBackDetail(uid, page, limit); 51 + PageResp<List<DepositDetailBo>> depositDetailBoList = depositService.queryUserDopositBackDetail(uid, page, limit);
51 LOG.info("queryUserDopositBackDetail result: {}", depositDetailBoList); 52 LOG.info("queryUserDopositBackDetail result: {}", depositDetailBoList);
52 return new ApiResponse.ApiResponseBuilder().code(200).data(depositDetailBoList).build(); 53 return new ApiResponse.ApiResponseBuilder().code(200).data(depositDetailBoList).build();
53 } 54 }
@@ -67,7 +68,7 @@ public class DepositController { @@ -67,7 +68,7 @@ public class DepositController {
67 return new ApiResponse.ApiResponseBuilder().code(500).message("查询失败").build(); 68 return new ApiResponse.ApiResponseBuilder().code(500).message("查询失败").build();
68 } 69 }
69 70
70 - List<DepositDetailBo> depositDetailBoList = depositService.queryUserProductDopositingDetail(uid, productId, page, limit); 71 + PageResp<List<DepositDetailBo>> depositDetailBoList = depositService.queryUserProductDopositingDetail(uid, productId, page, limit);
71 DepositProductBo countBo = depositService.queryUserDepositProductCountInfo(uid, productId); 72 DepositProductBo countBo = depositService.queryUserDepositProductCountInfo(uid, productId);
72 JSONObject result = new JSONObject(); 73 JSONObject result = new JSONObject();
73 result.put("product", countBo); 74 result.put("product", countBo);
@@ -4,6 +4,7 @@ package com.yohoufo.order.service; @@ -4,6 +4,7 @@ package com.yohoufo.order.service;
4 import com.yohobuy.ufo.model.order.bo.DepositDetailBo; 4 import com.yohobuy.ufo.model.order.bo.DepositDetailBo;
5 import com.yohobuy.ufo.model.order.bo.DepositProductBo; 5 import com.yohobuy.ufo.model.order.bo.DepositProductBo;
6 import com.yohobuy.ufo.model.order.constants.StorageDepositStatusEnum; 6 import com.yohobuy.ufo.model.order.constants.StorageDepositStatusEnum;
  7 +import com.yohobuy.ufo.model.order.resp.PageResp;
7 import com.yohoufo.common.exception.UfoServiceException; 8 import com.yohoufo.common.exception.UfoServiceException;
8 import com.yohoufo.dal.order.model.StorageDeposit; 9 import com.yohoufo.dal.order.model.StorageDeposit;
9 10
@@ -12,11 +13,11 @@ import java.util.List; @@ -12,11 +13,11 @@ import java.util.List;
12 13
13 public interface DepositService { 14 public interface DepositService {
14 15
15 - List<DepositProductBo> queryUserDoposit(Integer uid, Integer page, Integer limit); 16 + PageResp<List<DepositProductBo>> queryUserDoposit(Integer uid, Integer page, Integer limit);
16 17
17 - List<DepositDetailBo> queryUserDopositBackDetail(Integer uid, Integer page, Integer limit); 18 + PageResp<List<DepositDetailBo>> queryUserDopositBackDetail(Integer uid, Integer page, Integer limit);
18 19
19 - List<DepositDetailBo> queryUserProductDopositingDetail(Integer uid, Integer productId, Integer page, Integer limit); 20 + PageResp<List<DepositDetailBo>> queryUserProductDopositingDetail(Integer uid, Integer productId, Integer page, Integer limit);
20 21
21 DepositProductBo queryUserDepositProductCountInfo(Integer uid, Integer productId); 22 DepositProductBo queryUserDepositProductCountInfo(Integer uid, Integer productId);
22 23
1 package com.yohoufo.order.service.impl; 1 package com.yohoufo.order.service.impl;
2 2
  3 +import com.alibaba.fastjson.JSONObject;
3 import com.yohobuy.ufo.model.order.bo.ButtonShowBo; 4 import com.yohobuy.ufo.model.order.bo.ButtonShowBo;
4 import com.yohobuy.ufo.model.order.bo.DepositDetailBo; 5 import com.yohobuy.ufo.model.order.bo.DepositDetailBo;
5 import com.yohobuy.ufo.model.order.bo.DepositProductBo; 6 import com.yohobuy.ufo.model.order.bo.DepositProductBo;
  7 +import com.yohobuy.ufo.model.order.resp.PageResp;
6 import com.yohoufo.common.exception.UfoServiceException; 8 import com.yohoufo.common.exception.UfoServiceException;
7 import com.yohoufo.dal.order.SellerOrderGoodsMapper; 9 import com.yohoufo.dal.order.SellerOrderGoodsMapper;
8 import com.yohoufo.dal.order.StorageDepositMapper; 10 import com.yohoufo.dal.order.StorageDepositMapper;
@@ -43,10 +45,10 @@ public class DepositServiceImpl implements DepositService { @@ -43,10 +45,10 @@ public class DepositServiceImpl implements DepositService {
43 45
44 46
45 @Override 47 @Override
46 - public List<DepositProductBo> queryUserDoposit(Integer uid, Integer page, Integer limit) { 48 + public PageResp<List<DepositProductBo>> queryUserDoposit(Integer uid, Integer page, Integer limit) {
47 int count = storageDepositMapper.queryUserDepositProductCount(uid); 49 int count = storageDepositMapper.queryUserDepositProductCount(uid);
48 if (count == 0) { 50 if (count == 0) {
49 - return new ArrayList<>(); 51 + return new PageResp<>();
50 } 52 }
51 List<Integer> productIdList = storageDepositMapper.queryUserDepositProductId(uid, (page - 1) * limit, limit); 53 List<Integer> productIdList = storageDepositMapper.queryUserDepositProductId(uid, (page - 1) * limit, limit);
52 LOGGER.info("productIdList is {}", productIdList); 54 LOGGER.info("productIdList is {}", productIdList);
@@ -75,14 +77,20 @@ public class DepositServiceImpl implements DepositService { @@ -75,14 +77,20 @@ public class DepositServiceImpl implements DepositService {
75 } 77 }
76 result.add(bo); 78 result.add(bo);
77 } 79 }
78 - return result; 80 + PageResp resp = new PageResp();
  81 + resp.setData(result);
  82 + resp.setPage(page);
  83 + resp.setPageSize(limit);
  84 + resp.setPagetotal((int) Math.ceil(count * 1.0 / limit));
  85 + resp.setTotal(count);
  86 + return resp;
79 } 87 }
80 88
81 @Override 89 @Override
82 - public List<DepositDetailBo> queryUserDopositBackDetail(Integer uid, Integer page, Integer limit) { 90 + public PageResp<List<DepositDetailBo>> queryUserDopositBackDetail(Integer uid, Integer page, Integer limit) {
83 int count = storageDepositMapper.queryUserDopositBackCount(uid); 91 int count = storageDepositMapper.queryUserDopositBackCount(uid);
84 if (count == 0) { 92 if (count == 0) {
85 - return new ArrayList<>(); 93 + return new PageResp<>();
86 } 94 }
87 // 召回或者到期退回的 95 // 召回或者到期退回的
88 List<StorageDeposit> depositList = storageDepositMapper.queryUserDopositBack(uid, (page - 1) * limit, limit); 96 List<StorageDeposit> depositList = storageDepositMapper.queryUserDopositBack(uid, (page - 1) * limit, limit);
@@ -105,15 +113,21 @@ public class DepositServiceImpl implements DepositService { @@ -105,15 +113,21 @@ public class DepositServiceImpl implements DepositService {
105 bo.setButtons(Arrays.asList(ButtonShowBo.detail())); 113 bo.setButtons(Arrays.asList(ButtonShowBo.detail()));
106 result.add(bo); 114 result.add(bo);
107 } 115 }
108 - return result; 116 + PageResp resp = new PageResp();
  117 + resp.setData(result);
  118 + resp.setPage(page);
  119 + resp.setPageSize(limit);
  120 + resp.setPagetotal((int) Math.ceil(count * 1.0 / limit));
  121 + resp.setTotal(count);
  122 + return resp;
109 } 123 }
110 124
111 // 寄存中 125 // 寄存中
112 @Override 126 @Override
113 - public List<DepositDetailBo> queryUserProductDopositingDetail(Integer uid, Integer productId, Integer page, Integer limit) { 127 + public PageResp<List<DepositDetailBo>> queryUserProductDopositingDetail(Integer uid, Integer productId, Integer page, Integer limit) {
114 int count = storageDepositMapper.queryUserProductDopositingCount(uid, productId); 128 int count = storageDepositMapper.queryUserProductDopositingCount(uid, productId);
115 if (count == 0) { 129 if (count == 0) {
116 - return new ArrayList<>(); 130 + return new PageResp<>();
117 } 131 }
118 List<StorageDeposit> depositList = storageDepositMapper.queryUserProductDopositing(uid, productId, (page - 1) * limit, limit); 132 List<StorageDeposit> depositList = storageDepositMapper.queryUserProductDopositing(uid, productId, (page - 1) * limit, limit);
119 List<Integer> skupList = depositList.stream().map(StorageDeposit::getSkup).collect(Collectors.toList()); 133 List<Integer> skupList = depositList.stream().map(StorageDeposit::getSkup).collect(Collectors.toList());
@@ -140,7 +154,13 @@ public class DepositServiceImpl implements DepositService { @@ -140,7 +154,13 @@ public class DepositServiceImpl implements DepositService {
140 bo.setButtons(Arrays.asList(ButtonShowBo.back(), ButtonShowBo.addDepositDays(), depo.getOrderStatus() == 0 ? ButtonShowBo.grounding() : ButtonShowBo.detail("详情"))); 154 bo.setButtons(Arrays.asList(ButtonShowBo.back(), ButtonShowBo.addDepositDays(), depo.getOrderStatus() == 0 ? ButtonShowBo.grounding() : ButtonShowBo.detail("详情")));
141 result.add(bo); 155 result.add(bo);
142 } 156 }
143 - return result; 157 + PageResp resp = new PageResp();
  158 + resp.setData(result);
  159 + resp.setPage(page);
  160 + resp.setPageSize(limit);
  161 + resp.setPagetotal((int) Math.ceil(count * 1.0 / limit));
  162 + resp.setTotal(count);
  163 + return resp;
144 } 164 }
145 165
146 public DepositProductBo queryUserDepositProductCountInfo(Integer uid, Integer productId) { 166 public DepositProductBo queryUserDepositProductCountInfo(Integer uid, Integer productId) {