提交 dd08f560 编写于 作者: ibizdev's avatar ibizdev

lab_gzf 发布系统代码

上级 2c733d04
...@@ -58,4 +58,27 @@ public class product_categoryFallback implements product_categoryFeignClient{ ...@@ -58,4 +58,27 @@ public class product_categoryFallback implements product_categoryFeignClient{
return null; return null;
} }
public Product_category getDraft(){
return null;
}
public Boolean checkKey(Product_category product_category){
return false;
}
public Boolean save(Product_category product_category){
return false;
}
public Boolean saveBatch(List<Product_category> product_categories){
return false;
}
public Page<Product_category> searchDefault(Product_categorySearchContext context){
return null;
}
} }
...@@ -56,4 +56,24 @@ public interface product_categoryFeignClient { ...@@ -56,4 +56,24 @@ public interface product_categoryFeignClient {
Page<Product_category> select(); Page<Product_category> select();
@RequestMapping(method = RequestMethod.GET, value = "/product_categories/getdraft")
Product_category getDraft();
@RequestMapping(method = RequestMethod.POST, value = "/product_categories/checkkey")
Boolean checkKey(@RequestBody Product_category product_category);
@RequestMapping(method = RequestMethod.POST, value = "/product_categories/save")
Boolean save(@RequestBody Product_category product_category);
@RequestMapping(method = RequestMethod.POST, value = "/product_categories/savebatch")
Boolean saveBatch(@RequestBody List<Product_category> product_categories);
@RequestMapping(method = RequestMethod.POST, value = "/product_categories/searchdefault")
Page<Product_category> searchDefault(@RequestBody Product_categorySearchContext context);
} }
...@@ -27,6 +27,111 @@ import cn.ibizlab.businesscentral.core.odoo_product.domain.Product_category; ...@@ -27,6 +27,111 @@ import cn.ibizlab.businesscentral.core.odoo_product.domain.Product_category;
@Data @Data
public class Product_categorySearchContext extends QueryWrapperContext<Product_category> { public class Product_categorySearchContext extends QueryWrapperContext<Product_category> {
private String n_name_like;//[名称]
public void setN_name_like(String n_name_like) {
this.n_name_like = n_name_like;
if(!ObjectUtils.isEmpty(this.n_name_like)){
this.getSearchCond().like("name", n_name_like);
}
}
private String n_property_valuation_eq;//[库存计价]
public void setN_property_valuation_eq(String n_property_valuation_eq) {
this.n_property_valuation_eq = n_property_valuation_eq;
if(!ObjectUtils.isEmpty(this.n_property_valuation_eq)){
this.getSearchCond().eq("property_valuation", n_property_valuation_eq);
}
}
private String n_property_cost_method_eq;//[成本方法]
public void setN_property_cost_method_eq(String n_property_cost_method_eq) {
this.n_property_cost_method_eq = n_property_cost_method_eq;
if(!ObjectUtils.isEmpty(this.n_property_cost_method_eq)){
this.getSearchCond().eq("property_cost_method", n_property_cost_method_eq);
}
}
private String n_write_uid_text_eq;//[最后更新人]
public void setN_write_uid_text_eq(String n_write_uid_text_eq) {
this.n_write_uid_text_eq = n_write_uid_text_eq;
if(!ObjectUtils.isEmpty(this.n_write_uid_text_eq)){
this.getSearchCond().eq("write_uid_text", n_write_uid_text_eq);
}
}
private String n_write_uid_text_like;//[最后更新人]
public void setN_write_uid_text_like(String n_write_uid_text_like) {
this.n_write_uid_text_like = n_write_uid_text_like;
if(!ObjectUtils.isEmpty(this.n_write_uid_text_like)){
this.getSearchCond().like("write_uid_text", n_write_uid_text_like);
}
}
private String n_parent_id_text_eq;//[上级类别]
public void setN_parent_id_text_eq(String n_parent_id_text_eq) {
this.n_parent_id_text_eq = n_parent_id_text_eq;
if(!ObjectUtils.isEmpty(this.n_parent_id_text_eq)){
this.getSearchCond().eq("parent_id_text", n_parent_id_text_eq);
}
}
private String n_parent_id_text_like;//[上级类别]
public void setN_parent_id_text_like(String n_parent_id_text_like) {
this.n_parent_id_text_like = n_parent_id_text_like;
if(!ObjectUtils.isEmpty(this.n_parent_id_text_like)){
this.getSearchCond().like("parent_id_text", n_parent_id_text_like);
}
}
private String n_create_uid_text_eq;//[创建人]
public void setN_create_uid_text_eq(String n_create_uid_text_eq) {
this.n_create_uid_text_eq = n_create_uid_text_eq;
if(!ObjectUtils.isEmpty(this.n_create_uid_text_eq)){
this.getSearchCond().eq("create_uid_text", n_create_uid_text_eq);
}
}
private String n_create_uid_text_like;//[创建人]
public void setN_create_uid_text_like(String n_create_uid_text_like) {
this.n_create_uid_text_like = n_create_uid_text_like;
if(!ObjectUtils.isEmpty(this.n_create_uid_text_like)){
this.getSearchCond().like("create_uid_text", n_create_uid_text_like);
}
}
private String n_removal_strategy_id_text_eq;//[强制下架策略]
public void setN_removal_strategy_id_text_eq(String n_removal_strategy_id_text_eq) {
this.n_removal_strategy_id_text_eq = n_removal_strategy_id_text_eq;
if(!ObjectUtils.isEmpty(this.n_removal_strategy_id_text_eq)){
this.getSearchCond().eq("removal_strategy_id_text", n_removal_strategy_id_text_eq);
}
}
private String n_removal_strategy_id_text_like;//[强制下架策略]
public void setN_removal_strategy_id_text_like(String n_removal_strategy_id_text_like) {
this.n_removal_strategy_id_text_like = n_removal_strategy_id_text_like;
if(!ObjectUtils.isEmpty(this.n_removal_strategy_id_text_like)){
this.getSearchCond().like("removal_strategy_id_text", n_removal_strategy_id_text_like);
}
}
private Long n_parent_id_eq;//[上级类别]
public void setN_parent_id_eq(Long n_parent_id_eq) {
this.n_parent_id_eq = n_parent_id_eq;
if(!ObjectUtils.isEmpty(this.n_parent_id_eq)){
this.getSearchCond().eq("parent_id", n_parent_id_eq);
}
}
private Long n_create_uid_eq;//[创建人]
public void setN_create_uid_eq(Long n_create_uid_eq) {
this.n_create_uid_eq = n_create_uid_eq;
if(!ObjectUtils.isEmpty(this.n_create_uid_eq)){
this.getSearchCond().eq("create_uid", n_create_uid_eq);
}
}
private Long n_removal_strategy_id_eq;//[强制下架策略]
public void setN_removal_strategy_id_eq(Long n_removal_strategy_id_eq) {
this.n_removal_strategy_id_eq = n_removal_strategy_id_eq;
if(!ObjectUtils.isEmpty(this.n_removal_strategy_id_eq)){
this.getSearchCond().eq("removal_strategy_id", n_removal_strategy_id_eq);
}
}
private Long n_write_uid_eq;//[最后更新人]
public void setN_write_uid_eq(Long n_write_uid_eq) {
this.n_write_uid_eq = n_write_uid_eq;
if(!ObjectUtils.isEmpty(this.n_write_uid_eq)){
this.getSearchCond().eq("write_uid", n_write_uid_eq);
}
}
/** /**
* 启用快速搜索 * 启用快速搜索
......
...@@ -19,6 +19,7 @@ import com.alibaba.fastjson.JSONObject; ...@@ -19,6 +19,7 @@ import com.alibaba.fastjson.JSONObject;
public interface Product_categoryMapper extends BaseMapper<Product_category>{ public interface Product_categoryMapper extends BaseMapper<Product_category>{
Page<Product_category> searchDefault(IPage page, @Param("srf") Product_categorySearchContext context, @Param("ew") Wrapper<Product_category> wrapper) ;
@Override @Override
Product_category selectById(Serializable id); Product_category selectById(Serializable id);
@Override @Override
...@@ -61,4 +62,12 @@ public interface Product_categoryMapper extends BaseMapper<Product_category>{ ...@@ -61,4 +62,12 @@ public interface Product_categoryMapper extends BaseMapper<Product_category>{
@Delete("${sql}") @Delete("${sql}")
boolean deleteBySQL(@Param("sql") String sql, @Param("et")Map param); boolean deleteBySQL(@Param("sql") String sql, @Param("et")Map param);
List<Product_category> selectByParentId(@Param("id") Serializable id) ;
List<Product_category> selectByRemovalStrategyId(@Param("id") Serializable id) ;
List<Product_category> selectByCreateUid(@Param("id") Serializable id) ;
List<Product_category> selectByWriteUid(@Param("id") Serializable id) ;
} }
...@@ -33,6 +33,19 @@ public interface IProduct_categoryService extends IService<Product_category>{ ...@@ -33,6 +33,19 @@ public interface IProduct_categoryService extends IService<Product_category>{
boolean remove(Long key) ; boolean remove(Long key) ;
void removeBatch(Collection<Long> idList) ; void removeBatch(Collection<Long> idList) ;
Product_category get(Long key) ; Product_category get(Long key) ;
Product_category getDraft(Product_category et) ;
boolean checkKey(Product_category et) ;
boolean save(Product_category et) ;
void saveBatch(List<Product_category> list) ;
Page<Product_category> searchDefault(Product_categorySearchContext context) ;
List<Product_category> selectByParentId(Long id) ;
void removeByParentId(Long id) ;
List<Product_category> selectByRemovalStrategyId(Long id) ;
void removeByRemovalStrategyId(Long id) ;
List<Product_category> selectByCreateUid(Long id) ;
void removeByCreateUid(Long id) ;
List<Product_category> selectByWriteUid(Long id) ;
void removeByWriteUid(Long id) ;
/** /**
*自定义查询SQL *自定义查询SQL
* @param sql select * from table where id =#{et.param} * @param sql select * from table where id =#{et.param}
......
...@@ -140,7 +140,99 @@ public class Product_categoryServiceImpl extends ServiceImpl<Product_categoryMap ...@@ -140,7 +140,99 @@ public class Product_categoryServiceImpl extends ServiceImpl<Product_categoryMap
return et; return et;
} }
@Override
public Product_category getDraft(Product_category et) {
fillParentData(et);
return et;
}
@Override
public boolean checkKey(Product_category et) {
return (!ObjectUtils.isEmpty(et.getId()))&&(!Objects.isNull(this.getById(et.getId())));
}
@Override
@Transactional
public boolean save(Product_category et) {
if(!saveOrUpdate(et))
return false;
return true;
}
@Override
@Transactional
public boolean saveOrUpdate(Product_category et) {
if (null == et) {
return false;
} else {
return checkKey(et) ? this.update(et) : this.create(et);
}
}
@Override
@Transactional
public boolean saveBatch(Collection<Product_category> list) {
list.forEach(item->fillParentData(item));
saveOrUpdateBatch(list,batchSize);
return true;
}
@Override
@Transactional
public void saveBatch(List<Product_category> list) {
list.forEach(item->fillParentData(item));
saveOrUpdateBatch(list,batchSize);
}
@Override
public List<Product_category> selectByParentId(Long id) {
return baseMapper.selectByParentId(id);
}
@Override
public void removeByParentId(Long id) {
this.remove(new QueryWrapper<Product_category>().eq("parent_id",id));
}
@Override
public List<Product_category> selectByRemovalStrategyId(Long id) {
return baseMapper.selectByRemovalStrategyId(id);
}
@Override
public void removeByRemovalStrategyId(Long id) {
this.remove(new QueryWrapper<Product_category>().eq("removal_strategy_id",id));
}
@Override
public List<Product_category> selectByCreateUid(Long id) {
return baseMapper.selectByCreateUid(id);
}
@Override
public void removeByCreateUid(Long id) {
this.remove(new QueryWrapper<Product_category>().eq("create_uid",id));
}
@Override
public List<Product_category> selectByWriteUid(Long id) {
return baseMapper.selectByWriteUid(id);
}
@Override
public void removeByWriteUid(Long id) {
this.remove(new QueryWrapper<Product_category>().eq("write_uid",id));
}
/**
* 查询集合 数据集
*/
@Override
public Page<Product_category> searchDefault(Product_categorySearchContext context) {
com.baomidou.mybatisplus.extension.plugins.pagination.Page<Product_category> pages=baseMapper.searchDefault(context.getPages(),context,context.getSelectCond());
return new PageImpl<Product_category>(pages.getRecords(), context.getPageable(), pages.getTotal());
}
......
...@@ -4,6 +4,9 @@ ...@@ -4,6 +4,9 @@
<mapper namespace="cn.ibizlab.businesscentral.core.odoo_product.mapper.Product_categoryMapper"> <mapper namespace="cn.ibizlab.businesscentral.core.odoo_product.mapper.Product_categoryMapper">
<!--该方法用于重写mybatis中selectById方法,以实现查询逻辑属性--> <!--该方法用于重写mybatis中selectById方法,以实现查询逻辑属性-->
<select id="selectById" resultMap="Product_categoryResultMap" databaseId="postgresql">
<![CDATA[select t1.* from (SELECT t1.COMPLETE_NAME, t1.CREATE_DATE, t1.CREATE_UID, t51.NAME AS CREATE_UID_TEXT, t1.ID, t1.NAME, t1.PARENT_ID, t31.NAME AS PARENT_ID_TEXT, t1.PARENT_PATH, t1.REMOVAL_STRATEGY_ID, t61.NAME AS REMOVAL_STRATEGY_ID_TEXT, t1.WRITE_DATE, t1.WRITE_UID, t21.NAME AS WRITE_UID_TEXT FROM PRODUCT_CATEGORY t1 LEFT JOIN RES_USERS t11 ON t1.WRITE_UID = t11.ID LEFT JOIN RES_PARTNER t21 ON t11.PARTNER_ID = t21.ID LEFT JOIN PRODUCT_CATEGORY t31 ON t1.PARENT_ID = t31.ID LEFT JOIN RES_USERS t41 ON t1.CREATE_UID = t41.ID LEFT JOIN RES_PARTNER t51 ON t41.PARTNER_ID = t51.ID LEFT JOIN PRODUCT_REMOVAL t61 ON t1.REMOVAL_STRATEGY_ID = t61.ID ) t1 where id=#{id}]]>
</select>
<!--通过mybatis将查询结果注入到entity中,通过配置autoMapping="true"由mybatis自动处理映射关系 --> <!--通过mybatis将查询结果注入到entity中,通过配置autoMapping="true"由mybatis自动处理映射关系 -->
<resultMap id="Product_categoryResultMap" type="cn.ibizlab.businesscentral.core.odoo_product.domain.Product_category" autoMapping="true"> <resultMap id="Product_categoryResultMap" type="cn.ibizlab.businesscentral.core.odoo_product.domain.Product_category" autoMapping="true">
...@@ -48,9 +51,52 @@ ...@@ -48,9 +51,52 @@
</resultMap> </resultMap>
<!--关系实体暴露select方法供主实体通过外键查询关系实体数据[实体关系名称:DER1N_PRODUCT_CATEGORY__PRODUCT_CATEGORY__PARENT_ID] --> <!--关系实体暴露select方法供主实体通过外键查询关系实体数据[实体关系名称:DER1N_PRODUCT_CATEGORY__PRODUCT_CATEGORY__PARENT_ID] -->
<select id="selectByParentId" resultMap="Product_categoryResultMap">
select t1.* from (
<include refid="Default" />
) t1
where parent_id=#{id}
</select>
<!--关系实体暴露select方法供主实体通过外键查询关系实体数据[实体关系名称:DER1N_PRODUCT_CATEGORY__PRODUCT_REMOVAL__REMOVAL_STRATEGY_ID] --> <!--关系实体暴露select方法供主实体通过外键查询关系实体数据[实体关系名称:DER1N_PRODUCT_CATEGORY__PRODUCT_REMOVAL__REMOVAL_STRATEGY_ID] -->
<select id="selectByRemovalStrategyId" resultMap="Product_categoryResultMap">
select t1.* from (
<include refid="Default" />
) t1
where removal_strategy_id=#{id}
</select>
<!--关系实体暴露select方法供主实体通过外键查询关系实体数据[实体关系名称:DER1N_PRODUCT_CATEGORY__RES_USERS__CREATE_UID] --> <!--关系实体暴露select方法供主实体通过外键查询关系实体数据[实体关系名称:DER1N_PRODUCT_CATEGORY__RES_USERS__CREATE_UID] -->
<select id="selectByCreateUid" resultMap="Product_categoryResultMap">
select t1.* from (
<include refid="Default" />
) t1
where create_uid=#{id}
</select>
<!--关系实体暴露select方法供主实体通过外键查询关系实体数据[实体关系名称:DER1N_PRODUCT_CATEGORY__RES_USERS__WRITE_UID] --> <!--关系实体暴露select方法供主实体通过外键查询关系实体数据[实体关系名称:DER1N_PRODUCT_CATEGORY__RES_USERS__WRITE_UID] -->
<select id="selectByWriteUid" resultMap="Product_categoryResultMap">
select t1.* from (
<include refid="Default" />
) t1
where write_uid=#{id}
</select>
<!--数据集合[Default]-->
<select id="searchDefault" parameterType="cn.ibizlab.businesscentral.core.odoo_product.filter.Product_categorySearchContext" resultMap="Product_categoryResultMap">
select t1.* from (
<include refid="Default" />
)t1
<where><if test="ew!=null and ew.sqlSegment!=null and !ew.emptyOfWhere">${ew.sqlSegment}</if></where>
<if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">${ew.sqlSegment}</if>
</select>
<!--数据查询[Default]-->
<sql id="Default" databaseId="postgresql">
<![CDATA[ SELECT t1.COMPLETE_NAME, t1.CREATE_DATE, t1.CREATE_UID, t51.NAME AS CREATE_UID_TEXT, t1.ID, t1.NAME, t1.PARENT_ID, t31.NAME AS PARENT_ID_TEXT, t1.PARENT_PATH, t1.REMOVAL_STRATEGY_ID, t61.NAME AS REMOVAL_STRATEGY_ID_TEXT, t1.WRITE_DATE, t1.WRITE_UID, t21.NAME AS WRITE_UID_TEXT FROM PRODUCT_CATEGORY t1 LEFT JOIN RES_USERS t11 ON t1.WRITE_UID = t11.ID LEFT JOIN RES_PARTNER t21 ON t11.PARTNER_ID = t21.ID LEFT JOIN PRODUCT_CATEGORY t31 ON t1.PARENT_ID = t31.ID LEFT JOIN RES_USERS t41 ON t1.CREATE_UID = t41.ID LEFT JOIN RES_PARTNER t51 ON t41.PARTNER_ID = t51.ID LEFT JOIN PRODUCT_REMOVAL t61 ON t1.REMOVAL_STRATEGY_ID = t61.ID
]]>
</sql>
<!--数据查询[View]-->
<sql id="View" databaseId="postgresql">
<![CDATA[ SELECT t1.COMPLETE_NAME, t1.CREATE_DATE, t1.CREATE_UID, t51.NAME AS CREATE_UID_TEXT, t1.ID, t1.NAME, t1.PARENT_ID, t31.NAME AS PARENT_ID_TEXT, t1.PARENT_PATH, t1.REMOVAL_STRATEGY_ID, t61.NAME AS REMOVAL_STRATEGY_ID_TEXT, t1.WRITE_DATE, t1.WRITE_UID, t21.NAME AS WRITE_UID_TEXT FROM PRODUCT_CATEGORY t1 LEFT JOIN RES_USERS t11 ON t1.WRITE_UID = t11.ID LEFT JOIN RES_PARTNER t21 ON t11.PARTNER_ID = t21.ID LEFT JOIN PRODUCT_CATEGORY t31 ON t1.PARENT_ID = t31.ID LEFT JOIN RES_USERS t41 ON t1.CREATE_UID = t41.ID LEFT JOIN RES_PARTNER t51 ON t41.PARTNER_ID = t51.ID LEFT JOIN PRODUCT_REMOVAL t61 ON t1.REMOVAL_STRATEGY_ID = t61.ID
]]>
</sql>
</mapper> </mapper>
...@@ -109,6 +109,55 @@ public class Product_categoryResource { ...@@ -109,6 +109,55 @@ public class Product_categoryResource {
return ResponseEntity.status(HttpStatus.OK).body(dto); return ResponseEntity.status(HttpStatus.OK).body(dto);
} }
@ApiOperation(value = "获取产品种类草稿", tags = {"产品种类" }, notes = "获取产品种类草稿")
@RequestMapping(method = RequestMethod.GET, value = "/product_categories/getdraft")
public ResponseEntity<Product_categoryDTO> getDraft() {
return ResponseEntity.status(HttpStatus.OK).body(product_categoryMapping.toDto(product_categoryService.getDraft(new Product_category())));
}
@ApiOperation(value = "检查产品种类", tags = {"产品种类" }, notes = "检查产品种类")
@RequestMapping(method = RequestMethod.POST, value = "/product_categories/checkkey")
public ResponseEntity<Boolean> checkKey(@RequestBody Product_categoryDTO product_categorydto) {
return ResponseEntity.status(HttpStatus.OK).body(product_categoryService.checkKey(product_categoryMapping.toDomain(product_categorydto)));
}
@PreAuthorize("hasPermission(this.product_categoryMapping.toDomain(#product_categorydto),'iBizBusinessCentral-Product_category-Save')")
@ApiOperation(value = "保存产品种类", tags = {"产品种类" }, notes = "保存产品种类")
@RequestMapping(method = RequestMethod.POST, value = "/product_categories/save")
public ResponseEntity<Boolean> save(@RequestBody Product_categoryDTO product_categorydto) {
return ResponseEntity.status(HttpStatus.OK).body(product_categoryService.save(product_categoryMapping.toDomain(product_categorydto)));
}
@PreAuthorize("hasPermission(this.product_categoryMapping.toDomain(#product_categorydtos),'iBizBusinessCentral-Product_category-Save')")
@ApiOperation(value = "批量保存产品种类", tags = {"产品种类" }, notes = "批量保存产品种类")
@RequestMapping(method = RequestMethod.POST, value = "/product_categories/savebatch")
public ResponseEntity<Boolean> saveBatch(@RequestBody List<Product_categoryDTO> product_categorydtos) {
product_categoryService.saveBatch(product_categoryMapping.toDomain(product_categorydtos));
return ResponseEntity.status(HttpStatus.OK).body(true);
}
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','iBizBusinessCentral-Product_category-searchDefault-all') and hasPermission(#context,'iBizBusinessCentral-Product_category-Get')")
@ApiOperation(value = "获取数据集", tags = {"产品种类" } ,notes = "获取数据集")
@RequestMapping(method= RequestMethod.GET , value="/product_categories/fetchdefault")
public ResponseEntity<List<Product_categoryDTO>> fetchDefault(Product_categorySearchContext context) {
Page<Product_category> domains = product_categoryService.searchDefault(context) ;
List<Product_categoryDTO> list = product_categoryMapping.toDto(domains.getContent());
return ResponseEntity.status(HttpStatus.OK)
.header("x-page", String.valueOf(context.getPageable().getPageNumber()))
.header("x-per-page", String.valueOf(context.getPageable().getPageSize()))
.header("x-total", String.valueOf(domains.getTotalElements()))
.body(list);
}
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','iBizBusinessCentral-Product_category-searchDefault-all') and hasPermission(#context,'iBizBusinessCentral-Product_category-Get')")
@ApiOperation(value = "查询数据集", tags = {"产品种类" } ,notes = "查询数据集")
@RequestMapping(method= RequestMethod.POST , value="/product_categories/searchdefault")
public ResponseEntity<Page<Product_categoryDTO>> searchDefault(@RequestBody Product_categorySearchContext context) {
Page<Product_category> domains = product_categoryService.searchDefault(context) ;
return ResponseEntity.status(HttpStatus.OK)
.body(new PageImpl(product_categoryMapping.toDto(domains.getContent()), context.getPageable(), domains.getTotalElements()));
}
} }
...@@ -11,6 +11,7 @@ import java.util.Map; ...@@ -11,6 +11,7 @@ import java.util.Map;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
import cn.ibizlab.businesscentral.util.cache.listener.RedisPublisher; import cn.ibizlab.businesscentral.util.cache.listener.RedisPublisher;
import cn.ibizlab.businesscentral.util.enums.RedisChannelTopic; import cn.ibizlab.businesscentral.util.enums.RedisChannelTopic;
import org.springframework.util.ObjectUtils;
/** /**
* 缓存分层类 * 缓存分层类
...@@ -58,11 +59,16 @@ public class LayeringCache extends AbstractValueAdaptingCache { ...@@ -58,11 +59,16 @@ public class LayeringCache extends AbstractValueAdaptingCache {
@Override @Override
public ValueWrapper get(Object key) { public ValueWrapper get(Object key) {
ValueWrapper wrapper = caffeineCache.get(key); ValueWrapper wrapper = caffeineCache.get(key);
log.debug("查询一级缓存 key:{},value:{}", key,wrapper); Object value=ObjectUtils.isEmpty(wrapper)?null:wrapper.get();
if (wrapper == null) { log.debug("查询一级缓存 key:{} ,value:{}", key,value);
if (ObjectUtils.isEmpty(value)) {
wrapper = redisCache.get(key); wrapper = redisCache.get(key);
caffeineCache.put(key, wrapper == null ? null : wrapper.get()); value=ObjectUtils.isEmpty(wrapper)?null:wrapper.get();
log.debug("查询二级缓存,并将数据放到一级缓存。 key:{}", key); log.debug("查询二级缓存 key:{} ,value:{}", key,value);
if(!ObjectUtils.isEmpty(value)){
caffeineCache.put(key, value);
log.debug("查询二级缓存,并将数据放到一级缓存。 key:{} ,value:{}", key,value);
}
} }
return wrapper; return wrapper;
} }
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册