Commit 10e3defb authored by shiyu's avatar shiyu

寄售单详情-返回类目名称

parent 2c7ca810
......@@ -17,10 +17,15 @@ public class CoinVo implements Entity {
private String name;
/**
* 钱币所属类目ID
* 商品所属类目ID
*/
private Integer cid;
/**
* 商品所属类目名称
*/
private String cidName;
/**
* 是否上架
*/
......
......@@ -10,6 +10,7 @@ import com.wwdz.ch.core.consts.CommonEnum;
import com.wwdz.ch.core.consts.ItemStateEnum;
import com.wwdz.ch.core.storage.QiniuStorage;
import com.wwdz.ch.core.type.Result;
import com.wwdz.ch.core.util.CacheUtil;
import com.wwdz.ch.core.util.RedisUtils;
import com.wwdz.ch.core.util.StringUtil;
import com.wwdz.ch.db.bean.ItemOfEs;
......@@ -63,6 +64,9 @@ public class ItemServiceImpl implements ItemService {
@Autowired
RedisUtils redisUtils;
@Autowired
CacheUtil cacheUtil;
@Override
public List<CoinVo> findList(CoinRequestDto coinRequestDto) {
try {
......@@ -94,6 +98,7 @@ public class ItemServiceImpl implements ItemService {
}
}
CoinVo itemVo = convertEntity(item);
itemVo.setCidName(cacheUtil.getCategoryNameByCode(item.getCid()));
//用于展示商品归属的类目(页面级联下拉控件数据展示)
Integer categoryId = item.getCid();
Category category = categoryDao.findById(categoryId);
......
......@@ -91,6 +91,16 @@ public class CacheUtil {
}
public String getCategoryNameByCode(int key) {
try {
return categoryCache.get(key).get(3, TimeUnit.SECONDS);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
/**
* ai机器人缓存
*/
......@@ -126,6 +136,15 @@ public class CacheUtil {
.buildAsync(k -> getSystemUserList(k));
/**
* 类目缓存
*/
public AsyncLoadingCache<Integer, String> categoryCache = Caffeine.newBuilder()
.maximumSize(500)
.expireAfterWrite(30, TimeUnit.MINUTES)
.buildAsync(k -> getCategoryName(k));
/**
* 查询小程序会员
*
......@@ -184,7 +203,7 @@ public class CacheUtil {
/**
* 查询后台用户
* 查询所有类目
*
* @return
*/
......@@ -203,4 +222,16 @@ public class CacheUtil {
return map.get(pid);
}
/**
* 查询所有类目
*
* @return
*/
public String getCategoryName(int id) {
Category category = categoryDao.findById(id);
return category.getName();
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment