|
|
@@ -10,6 +10,7 @@ import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
+import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
@@ -21,6 +22,10 @@ import java.util.stream.Collectors;
|
|
|
public class BytedanceProductUpdateServiceImpl implements IBytedanceProductUpdateService {
|
|
|
@Resource
|
|
|
BytedanceProductUpdateMapper bytedanceProductUpdateMapper;
|
|
|
+ @Resource
|
|
|
+ private RedisTemplate redis2Template_db5;
|
|
|
+
|
|
|
+ public static final String DOUYIN_MOVIE_SOURCE_APP="ttd652a0ef496310bd01";
|
|
|
|
|
|
|
|
|
//商品上传结果通知群
|
|
|
@@ -41,6 +46,39 @@ public class BytedanceProductUpdateServiceImpl implements IBytedanceProductUpdat
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void authMovieResource() {
|
|
|
+ //原片授权
|
|
|
+ List<JSONObject> authList = bytedanceProductUpdateMapper.getDouyinMovieAuthList();
|
|
|
+ if (!Check.isNull(authList)){
|
|
|
+ try {
|
|
|
+ String tokenKey = "client-token-key_"+ DOUYIN_MOVIE_SOURCE_APP;
|
|
|
+ String token = (String) redis2Template_db5.opsForValue().get(tokenKey);
|
|
|
+ if (Check.isNull(token)){
|
|
|
+ log.warn("没有找到字节小程序access_token,无法进行原片授权");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ for (JSONObject obj : authList){
|
|
|
+ String socialCreditCode = obj.getString("social_credit_code");
|
|
|
+ if (Check.isNull(socialCreditCode)){
|
|
|
+ log.warn("没有找到社会信用代码,跳过授权: " + obj.getString("name"));
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ String url = "https://open.douyin.com/api/resource_library/util/v1/batch_auth_contents/";
|
|
|
+ Map<String, String> headers = new HashMap<>();
|
|
|
+ headers.put("Access-Token", token);
|
|
|
+ Map<String, Object> body = new HashMap<>();
|
|
|
+ body.put("auth_all_album", true);
|
|
|
+ body.put("auth_type", 1);
|
|
|
+ body.put("authed_corp", socialCreditCode);
|
|
|
+ HttpUtils.httpPostRequest(url, body, headers);
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ log.error("获取字节小程序access_token失败", e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 初始化新的字节小程序; 新增字节用的商品库时调用
|
|
|
@@ -51,6 +89,7 @@ public class BytedanceProductUpdateServiceImpl implements IBytedanceProductUpdat
|
|
|
List<JSONObject> iaaPlatformList = bytedanceProductUpdateMapper.getIAAPlatformList();
|
|
|
initNew(iaaPlatformList);
|
|
|
initNew(iapPlatformList);
|
|
|
+ authMovieResource();
|
|
|
}
|
|
|
|
|
|
@Override
|