Authored by unknown

分享图片资源位 添加缓存

... ... @@ -25,6 +25,7 @@ import com.yoho.service.model.response.AreaRspBo;
import com.yoho.service.model.union.bo.*;
import com.yoho.service.model.union.request.*;
import com.yoho.service.model.union.response.*;
import com.yoho.unions.common.redis.GlobalRedisValueCache;
import com.yoho.unions.common.service.IQNUploadService;
import com.yoho.unions.constant.SendModelEnum;
import com.yoho.unions.dal.*;
... ... @@ -169,6 +170,9 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
private RedisHashCache redisHashCache;
@Autowired
private GlobalRedisValueCache globalRedisValueCache;
@Autowired
private ISendSmsService sendSmsService;
@Autowired
private IQNUploadService qNUploadService;
... ... @@ -220,6 +224,7 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
private final String yohoCardUrlPre = "http://yhgidcard.static.yhbimg.com/yohocard";
private long EXPIRE_TIME = 3 * 24 * 3600;
private long IMG_URL_EXPIRE_TIME = 24 * 3600;//一天
//发送方式(优惠券或者返现)
private static final String SEND_MODE="unions.send.mode";
// 优惠券金额
... ... @@ -1161,7 +1166,9 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
bo.setInviteShareId(configReader.getString(UNION_INVITE_SHAREID, ""));//列表分享的活动id
//调用接口返回
ResourcesBO resourcesBO=getResourcesBO();
setImgUrl(bo,resourcesBO);
logger.info("queryUnionTypeByUid,uid is {},result is {}",uid,bo);
//设置缓存
addToRedis(ShareOrdersKeyEnum.UNION_TYPE, uid, bo, key);
... ... @@ -4376,6 +4383,11 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
}
private ResourcesBO getResourcesBO() {
// 从缓存查询
ResourcesBO resourcesCache=globalRedisValueCache.get(ShareOrdersKeyEnum.IMG_RESOURCE_URL.getKey(),ResourcesBO.class);
if(resourcesCache!=null){
return resourcesCache;
}
ResourcesBO bo;//find by service call
ResourcesRequestBody request = new ResourcesRequestBody();
request.setContentCode("b8ce2b9c4b3baf75551d4d7888306e40");
... ... @@ -4385,6 +4397,8 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
//调用ResourcesServices.home
bo = serviceCaller.call(ResourcesServices.getResourcesPrimaryHome, request, ResourcesBO.class);
logger.debug("UnionShareServiceImpl ResourcesBO bo{}",JSON.toJSONString(bo));
// 存缓存
globalRedisValueCache.set(ShareOrdersKeyEnum.IMG_RESOURCE_URL.getKey(),ResourcesBO.class,IMG_URL_EXPIRE_TIME,TimeUnit.SECONDS);
return bo;
}
... ...