Authored by zhaoqing

刷新CDN

package com.yohobuy.platform.operations.model;
/**
* Created by qing.zhao on 2019/10/28.
*/
public class FreshCdnUrlBO {
private String url;
private String auth_code = "cdn_url_refresh";
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getAuth_code() {
return auth_code;
}
public void setAuth_code(String auth_code) {
this.auth_code = auth_code;
}
}
... ...
... ... @@ -2,6 +2,7 @@ package com.yohobuy.platform.operations.service.impl;
import com.alibaba.fastjson.JSON;
import com.google.common.collect.Lists;
import com.yoho.tools.common.beans.Response;
import com.yohobuy.platform.common.convert.BeanConvert;
import com.yohobuy.platform.common.convert.Convert;
import com.yohobuy.platform.common.error.ErrorCode;
... ... @@ -31,6 +32,7 @@ import com.yohobuy.platform.operations.convert.ActivtyTemplatedFloorConvert;
import com.yohobuy.platform.operations.helper.ActTempFloorHelper;
import com.yohobuy.platform.operations.helper.ActivityTemplatedFloorDetailHelper;
import com.yohobuy.platform.operations.model.ActivtyTemplatedVo;
import com.yohobuy.platform.operations.model.FreshCdnUrlBO;
import com.yohobuy.platform.operations.service.check.ActivtyTemplatedCheckService;
import com.yohobuy.platform.operations.service.check.WebShareCheckService;
import org.apache.commons.collections.CollectionUtils;
... ... @@ -41,9 +43,12 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
/**
... ... @@ -86,7 +91,8 @@ public class ActivtyTemplatedService implements BaseService<ActivtyTemplatedBo>
@Value("${activity.url:http://activity.yoho.cn/feature/}")
private String activityUrl;
@Resource(name="restTemplate")
RestTemplate restTemplate;
@Override
public int add(ActivtyTemplatedBo bo) throws PlatformException {
... ... @@ -557,6 +563,23 @@ public class ActivtyTemplatedService implements BaseService<ActivtyTemplatedBo>
if (CollectionUtils.isNotEmpty(atftList)){
atftMapper.insertBatch(atftList);
}
//调用接口刷新CDN
logger.info("ActivtyTemplatedService :: upateActivityTemplate fresh cdn begin");
String url = "https://activity.yoho.cn/feature/"+bo.getId()+".html";
FreshCdnUrlBO freshCdnUrlBO = new FreshCdnUrlBO();
freshCdnUrlBO.setUrl(url);
logger.info("ActivtyTemplatedService :: upateActivityTemplate fresh cdn begin url is {}, auth_code is {}", url, freshCdnUrlBO.getAuth_code());
try{
Response<Object> resp = restTemplate.postForObject("/service/account/v1/Profile/getMenuByPid", freshCdnUrlBO, Response.class);
if (resp.getCode() == 200){
logger.info("ActivtyTemplatedService :: upateActivityTemplate fresh cdn success");
}else {
logger.error("ActivtyTemplatedService :: upateActivityTemplate fresh cdn error, code is {},message is {}, date is {}",resp.getCode(),resp.getMessage(),resp.getData());
}
}catch (Exception e){
logger.error("ActivtyTemplatedService :: upateActivityTemplate fresh cdn error, error is {}", e);
}
}
/**
... ...