Procházet zdrojové kódy

//类目1-3

release_toaliyun_real
xhxu před 3 roky
rodič
revize
4afb77da3c
2 změnil soubory, kde provedl 18 přidání a 1 odebrání
  1. +1
    -0
      mallinkService/src/main/java/com/iformall/service/TtGoodsCategoryService.java
  2. +17
    -1
      mallinkService/src/main/java/com/iformall/service/impl/TtGoodsCategoryServiceImpl.java

+ 1
- 0
mallinkService/src/main/java/com/iformall/service/TtGoodsCategoryService.java Zobrazit soubor

@@ -43,4 +43,5 @@ public interface TtGoodsCategoryService {




List<GoodsCategory> categoryGet(Integer categoryId); List<GoodsCategory> categoryGet(Integer categoryId);

} }

+ 17
- 1
mallinkService/src/main/java/com/iformall/service/impl/TtGoodsCategoryServiceImpl.java Zobrazit soubor

@@ -2,6 +2,7 @@ package com.iformall.service.impl;


import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.github.binarywang.wxpay.bean.bank.BankingResult;
import com.iformall.domain.po.TtGoodsCategory; import com.iformall.domain.po.TtGoodsCategory;
import com.iformall.domain.po.WxCoupon; import com.iformall.domain.po.WxCoupon;
import com.iformall.domain.po.base.BaseEntity; import com.iformall.domain.po.base.BaseEntity;
@@ -16,12 +17,15 @@ import com.iformall.mapper.TtGoodsCategoryMapper;
import com.iformall.service.TtGoodsCategoryService; import com.iformall.service.TtGoodsCategoryService;
import com.iformall.service.TtMerchantPoiService; import com.iformall.service.TtMerchantPoiService;
import com.iformall.utils.DateUtils; import com.iformall.utils.DateUtils;
import com.iformall.utils.RedisCacheUtils;
import com.microsoft.schemas.vml.STExt; import com.microsoft.schemas.vml.STExt;
import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.error.WxErrorException;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;


@@ -39,6 +43,10 @@ public class TtGoodsCategoryServiceImpl implements TtGoodsCategoryService {
@Autowired @Autowired
private TtMerchantPoiService ttMerchantPoiService; private TtMerchantPoiService ttMerchantPoiService;


@Autowired
@Qualifier("objectCommonRedisTemplate")
RedisTemplate<String, Object> categoryRedisTemplate;

@Override @Override
public List<TtGoodsCategory> findTreeList() { public List<TtGoodsCategory> findTreeList() {
TtGoodsCategory record = new TtGoodsCategory(); TtGoodsCategory record = new TtGoodsCategory();
@@ -478,9 +486,17 @@ public class TtGoodsCategoryServiceImpl implements TtGoodsCategoryService {


@Override @Override
public List<GoodsCategory> categoryGet(Integer categoryId) { public List<GoodsCategory> categoryGet(Integer categoryId) {
TtWebService ttWebService = ttMerchantPoiService.getTtWebService(null);
String key = "goods_category:"+categoryId;
List<GoodsCategory> cacheListObject = RedisCacheUtils.getCacheListObject(categoryRedisTemplate, key, GoodsCategory.class);
if(cacheListObject != null && cacheListObject.size() > 0){
return cacheListObject;
}
try { try {
TtWebService ttWebService = ttMerchantPoiService.getTtWebService(null);
List<GoodsCategory> goodsCategories = ttWebService.getGoodsService().categoryGet(categoryId, null); List<GoodsCategory> goodsCategories = ttWebService.getGoodsService().categoryGet(categoryId, null);
if(goodsCategories != null && goodsCategories.size() > 0){
RedisCacheUtils.cache(categoryRedisTemplate,key,goodsCategories,24*3600);
}
return goodsCategories; return goodsCategories;
} catch (WxErrorException e) { } catch (WxErrorException e) {
e.printStackTrace(); e.printStackTrace();


Načítá se…
Zrušit
Uložit