Authored by wangshusheng

Merge branch 'dev_template_hotfix'

... ... @@ -6,6 +6,7 @@ package com.yohobuy.platform.operations.model;
public class FreshCdnUrlBO {
private String url;
private String auth_code = "cdn_url_refresh";
private String request_type;
public String getUrl() {
return url;
... ... @@ -22,4 +23,12 @@ public class FreshCdnUrlBO {
public void setAuth_code(String auth_code) {
this.auth_code = auth_code;
}
public String getRequest_type() {
return request_type;
}
public void setRequest_type(String request_type) {
this.request_type = request_type;
}
}
... ...
... ... @@ -519,6 +519,8 @@ public class ActivtyTemplatedService implements BaseService<ActivtyTemplatedBo>
activtyTemplated.setUpdateTime(DateUtil.getCurrentTimeSeconds());
activtyTemplated.setUpdateUser(this.buildOperatorInfo(bo.getUserInfoResponseBO()));
activtyTemplatedMapper.updateByPrimaryKeySelective(activtyTemplated);
//判断该模板是否是首次添加内容
List<ActivtyTemplatedFloor> floorList = atfMapper.selectByTemplatedId(bo.getTemplateId());
//2.根据模板ID依次删除除主表外其他表的相关数据,activty_templated_floor,activty_templated_floor_detail,activty_templated_floor_table
atfMapper.deleteByTempId(bo.getTemplateId());
atftMapper.deleteByTempId(bo.getTemplateId());
... ... @@ -563,12 +565,25 @@ 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();
if (floorList.size() <= 0 && bo.isPushCdn()){
//首次添加 调用接口预热CDN
logger.info("ActivtyTemplatedService :: upateActivityTemplate warm_up cdn begin");
freshCdnUrlBO.setRequest_type("warm_up");
warmAndFresh(bo, freshCdnUrlBO);
}else if (floorList.size() > 0 ){
//修改 调用接口刷新CDN
logger.info("ActivtyTemplatedService :: upateActivityTemplate refresh cdn begin");
freshCdnUrlBO.setRequest_type("refresh");
warmAndFresh(bo, freshCdnUrlBO);
}
}
private void warmAndFresh(ActivtyTemplatedBo bo, FreshCdnUrlBO freshCdnUrlBO) {
String url = "https://activity.yoho.cn/feature/"+bo.getId()+".html";
freshCdnUrlBO.setUrl(url);
logger.info("ActivtyTemplatedService :: upateActivityTemplate fresh cdn begin url is {}, auth_code is {}", url, freshCdnUrlBO.getAuth_code());
logger.info("ActivtyTemplatedService :: upateActivityTemplate fresh cdn begin url is {},auth_code is {}, type is {}", url, freshCdnUrlBO.getAuth_code(), freshCdnUrlBO.getRequest_type());
try{
Response<Object> resp = restTemplate.postForObject("http://ops-apigateway.yohops.com/release/cdn/refresh", freshCdnUrlBO, Response.class);
if (resp.getCode() == 200){
... ... @@ -579,7 +594,6 @@ public class ActivtyTemplatedService implements BaseService<ActivtyTemplatedBo>
}catch (Exception e){
logger.error("ActivtyTemplatedService :: upateActivityTemplate fresh cdn error, error is {}", e);
}
}
/**
... ...
... ... @@ -24,7 +24,7 @@
<dependency>
<groupId>com.yoho.service.platform.model</groupId>
<artifactId>platform-service-model</artifactId>
<version>1.2.3-6.9.12-SNAPSHOT</version>
<version>1.2.3-6.9.13-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.yoho.dsf.yhplatform</groupId>
... ...