Authored by zhaoqing

刷新CDN

  1 +package com.yohobuy.platform.operations.model;
  2 +
  3 +/**
  4 + * Created by qing.zhao on 2019/10/28.
  5 + */
  6 +public class FreshCdnUrlBO {
  7 + private String url;
  8 + private String auth_code = "cdn_url_refresh";
  9 +
  10 + public String getUrl() {
  11 + return url;
  12 + }
  13 +
  14 + public void setUrl(String url) {
  15 + this.url = url;
  16 + }
  17 +
  18 + public String getAuth_code() {
  19 + return auth_code;
  20 + }
  21 +
  22 + public void setAuth_code(String auth_code) {
  23 + this.auth_code = auth_code;
  24 + }
  25 +}
@@ -2,6 +2,7 @@ package com.yohobuy.platform.operations.service.impl; @@ -2,6 +2,7 @@ package com.yohobuy.platform.operations.service.impl;
2 2
3 import com.alibaba.fastjson.JSON; 3 import com.alibaba.fastjson.JSON;
4 import com.google.common.collect.Lists; 4 import com.google.common.collect.Lists;
  5 +import com.yoho.tools.common.beans.Response;
5 import com.yohobuy.platform.common.convert.BeanConvert; 6 import com.yohobuy.platform.common.convert.BeanConvert;
6 import com.yohobuy.platform.common.convert.Convert; 7 import com.yohobuy.platform.common.convert.Convert;
7 import com.yohobuy.platform.common.error.ErrorCode; 8 import com.yohobuy.platform.common.error.ErrorCode;
@@ -31,6 +32,7 @@ import com.yohobuy.platform.operations.convert.ActivtyTemplatedFloorConvert; @@ -31,6 +32,7 @@ import com.yohobuy.platform.operations.convert.ActivtyTemplatedFloorConvert;
31 import com.yohobuy.platform.operations.helper.ActTempFloorHelper; 32 import com.yohobuy.platform.operations.helper.ActTempFloorHelper;
32 import com.yohobuy.platform.operations.helper.ActivityTemplatedFloorDetailHelper; 33 import com.yohobuy.platform.operations.helper.ActivityTemplatedFloorDetailHelper;
33 import com.yohobuy.platform.operations.model.ActivtyTemplatedVo; 34 import com.yohobuy.platform.operations.model.ActivtyTemplatedVo;
  35 +import com.yohobuy.platform.operations.model.FreshCdnUrlBO;
34 import com.yohobuy.platform.operations.service.check.ActivtyTemplatedCheckService; 36 import com.yohobuy.platform.operations.service.check.ActivtyTemplatedCheckService;
35 import com.yohobuy.platform.operations.service.check.WebShareCheckService; 37 import com.yohobuy.platform.operations.service.check.WebShareCheckService;
36 import org.apache.commons.collections.CollectionUtils; 38 import org.apache.commons.collections.CollectionUtils;
@@ -41,9 +43,12 @@ import org.slf4j.LoggerFactory; @@ -41,9 +43,12 @@ import org.slf4j.LoggerFactory;
41 import org.springframework.beans.factory.annotation.Autowired; 43 import org.springframework.beans.factory.annotation.Autowired;
42 import org.springframework.beans.factory.annotation.Value; 44 import org.springframework.beans.factory.annotation.Value;
43 import org.springframework.stereotype.Service; 45 import org.springframework.stereotype.Service;
  46 +import org.springframework.web.client.RestTemplate;
44 47
  48 +import javax.annotation.Resource;
45 import java.util.ArrayList; 49 import java.util.ArrayList;
46 import java.util.List; 50 import java.util.List;
  51 +import java.util.Map;
47 import java.util.Optional; 52 import java.util.Optional;
48 53
49 /** 54 /**
@@ -86,7 +91,8 @@ public class ActivtyTemplatedService implements BaseService<ActivtyTemplatedBo> @@ -86,7 +91,8 @@ public class ActivtyTemplatedService implements BaseService<ActivtyTemplatedBo>
86 91
87 @Value("${activity.url:http://activity.yoho.cn/feature/}") 92 @Value("${activity.url:http://activity.yoho.cn/feature/}")
88 private String activityUrl; 93 private String activityUrl;
89 - 94 + @Resource(name="restTemplate")
  95 + RestTemplate restTemplate;
90 96
91 @Override 97 @Override
92 public int add(ActivtyTemplatedBo bo) throws PlatformException { 98 public int add(ActivtyTemplatedBo bo) throws PlatformException {
@@ -557,6 +563,23 @@ public class ActivtyTemplatedService implements BaseService<ActivtyTemplatedBo> @@ -557,6 +563,23 @@ public class ActivtyTemplatedService implements BaseService<ActivtyTemplatedBo>
557 if (CollectionUtils.isNotEmpty(atftList)){ 563 if (CollectionUtils.isNotEmpty(atftList)){
558 atftMapper.insertBatch(atftList); 564 atftMapper.insertBatch(atftList);
559 } 565 }
  566 + //调用接口刷新CDN
  567 + logger.info("ActivtyTemplatedService :: upateActivityTemplate fresh cdn begin");
  568 + String url = "https://activity.yoho.cn/feature/"+bo.getId()+".html";
  569 + FreshCdnUrlBO freshCdnUrlBO = new FreshCdnUrlBO();
  570 + freshCdnUrlBO.setUrl(url);
  571 + logger.info("ActivtyTemplatedService :: upateActivityTemplate fresh cdn begin url is {}, auth_code is {}", url, freshCdnUrlBO.getAuth_code());
  572 + try{
  573 + Response<Object> resp = restTemplate.postForObject("/service/account/v1/Profile/getMenuByPid", freshCdnUrlBO, Response.class);
  574 + if (resp.getCode() == 200){
  575 + logger.info("ActivtyTemplatedService :: upateActivityTemplate fresh cdn success");
  576 + }else {
  577 + logger.error("ActivtyTemplatedService :: upateActivityTemplate fresh cdn error, code is {},message is {}, date is {}",resp.getCode(),resp.getMessage(),resp.getData());
  578 + }
  579 + }catch (Exception e){
  580 + logger.error("ActivtyTemplatedService :: upateActivityTemplate fresh cdn error, error is {}", e);
  581 + }
  582 +
560 } 583 }
561 584
562 /** 585 /**