PC端/收银机商品查询增加缓存
This commit is contained in:
@@ -2,6 +2,8 @@ package com.czg.controller.admin;
|
|||||||
|
|
||||||
import cn.hutool.core.convert.Convert;
|
import cn.hutool.core.convert.Convert;
|
||||||
import cn.hutool.core.thread.ThreadUtil;
|
import cn.hutool.core.thread.ThreadUtil;
|
||||||
|
import cn.hutool.core.util.ObjUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.czg.annotation.SaStaffCheckPermission;
|
import com.czg.annotation.SaStaffCheckPermission;
|
||||||
import com.czg.config.RabbitPublisher;
|
import com.czg.config.RabbitPublisher;
|
||||||
import com.czg.exception.CzgException;
|
import com.czg.exception.CzgException;
|
||||||
@@ -63,11 +65,22 @@ public class ProductController {
|
|||||||
public CzgResult<List<ProductDTO>> getProductList(ProductDTO param) {
|
public CzgResult<List<ProductDTO>> getProductList(ProductDTO param) {
|
||||||
Long shopId = StpKit.USER.getShopId(0L);
|
Long shopId = StpKit.USER.getShopId(0L);
|
||||||
param.setShopId(shopId);
|
param.setShopId(shopId);
|
||||||
List<ProductDTO> data = productService.getProductList(param);
|
List<ProductDTO> data = getProductCacheList(param);
|
||||||
productService.refreshProductStock(param, data);
|
productService.refreshProductStock(param, data);
|
||||||
return CzgResult.success(data);
|
return CzgResult.success(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<ProductDTO> getProductCacheList(ProductDTO param) {
|
||||||
|
List<ProductDTO> productList = productService.getProductList(param);
|
||||||
|
if (StrUtil.isNotEmpty(param.getName())) {
|
||||||
|
productList = productList.stream().filter(obj -> StrUtil.contains(obj.getName(), param.getName())).toList();
|
||||||
|
}
|
||||||
|
if (ObjUtil.isNotNull(param.getCategoryId())) {
|
||||||
|
productList = productList.stream().filter(obj -> param.getCategoryId().equals(obj.getCategoryId())).toList();
|
||||||
|
}
|
||||||
|
return productList;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商品-详情
|
* 商品-详情
|
||||||
*/
|
*/
|
||||||
@@ -141,6 +154,7 @@ public class ProductController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 商品-删除
|
* 商品-删除
|
||||||
|
*
|
||||||
* @param id 商品ID
|
* @param id 商品ID
|
||||||
*/
|
*/
|
||||||
@DeleteMapping("{id}")
|
@DeleteMapping("{id}")
|
||||||
|
|||||||
Reference in New Issue
Block a user