收音机 / 客户端 商品列表
This commit is contained in:
@@ -82,7 +82,7 @@ public class ProductController {
|
||||
*/
|
||||
@GetMapping("list")
|
||||
@OperationLog("商品-列表")
|
||||
public CzgResult<Map<String, Object>> getProductList(@RequestParam Long categoryId) {
|
||||
public CzgResult<Map<String, Object>> getProductList(@RequestParam(required = false) Long categoryId) {
|
||||
return CzgResult.success(productService.getProductCacheList(StpKit.USER.getShopId(), categoryId));
|
||||
}
|
||||
|
||||
|
||||
@@ -338,20 +338,32 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getProductCacheList(Long shopId, Long categoryId) {
|
||||
String key = ADMIN_CLIENT_PRODUCT_LIST + "::" + shopId + "::" + categoryId;
|
||||
String key = ADMIN_CLIENT_PRODUCT_LIST + "::" + shopId;
|
||||
List<ProductDTO> list;
|
||||
if (!redisService.hasKey(key)) {
|
||||
list = initProductCacheByCategoryId(shopId, categoryId);
|
||||
if (categoryId == null) {
|
||||
if (!redisService.hasKey(key)) {
|
||||
ProductDTO param = new ProductDTO();
|
||||
param.setShopId(shopId);
|
||||
list = getProductList(param);
|
||||
redisService.setJsonStr(key, list);
|
||||
} else {
|
||||
list = redisService.getJsonToBeanList(key, ProductDTO.class);
|
||||
}
|
||||
} else {
|
||||
list = redisService.getJsonToBeanList(key, ProductDTO.class);
|
||||
key = key + "::" + categoryId;
|
||||
if (!redisService.hasKey(key)) {
|
||||
list = initProductCacheByCategoryId(shopId, categoryId);
|
||||
} else {
|
||||
list = redisService.getJsonToBeanList(key, ProductDTO.class);
|
||||
}
|
||||
// 重新进行排序
|
||||
list = list.stream()
|
||||
.sorted(Comparator.comparingInt(ProductDTO::getIsSoldStock))
|
||||
.sorted(Comparator.comparingInt(ProductDTO::getIsSale).reversed())
|
||||
.sorted(Comparator.comparingInt(ProductDTO::getSort).reversed())
|
||||
.sorted(Comparator.comparingLong(ProductDTO::getId).reversed())
|
||||
.toList();
|
||||
}
|
||||
// 重新进行排序
|
||||
list = list.stream()
|
||||
.sorted(Comparator.comparingInt(ProductDTO::getIsSoldStock))
|
||||
.sorted(Comparator.comparingInt(ProductDTO::getIsSale).reversed())
|
||||
.sorted(Comparator.comparingInt(ProductDTO::getSort).reversed())
|
||||
.sorted(Comparator.comparingLong(ProductDTO::getId).reversed())
|
||||
.toList();
|
||||
List<ConsInfo> consInfos = consInfoMapper.selectListByQuery(query().eq(ConsInfo::getShopId, shopId).eq(ConsInfo::getStatus, SystemConstants.OneZero.ONE));
|
||||
return Map.of("productList", list, "cons", consInfos);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user