|
@@ -1,20 +1,24 @@
|
|
|
package cn.com.ctop.common.module.service.impl;
|
|
|
|
|
|
+import cn.com.ctop.common.module.entity.CtopOauthToken;
|
|
|
import cn.com.ctop.common.module.entity.MaterialImageInfo;
|
|
|
+import cn.com.ctop.common.module.entity.MaterialParameter;
|
|
|
+import cn.com.ctop.common.module.enums.MaterialEnum;
|
|
|
import cn.com.ctop.common.module.mapper.MaterialImageInfoMapper;
|
|
|
import cn.com.ctop.common.module.service.IMaterialImageInfoService;
|
|
|
-import cn.com.ctop.common.module.utils.Check;
|
|
|
-import cn.com.ctop.common.module.utils.ResultMapUtils;
|
|
|
-import cn.com.ctop.common.module.utils.StatusCode;
|
|
|
+import cn.com.ctop.common.module.utils.*;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.core.io.FileSystemResource;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.io.File;
|
|
|
import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
/**
|
|
@@ -42,7 +46,6 @@ public class MaterialImageInfoServiceImpl extends ServiceImpl<MaterialImageInfoM
|
|
|
String userId = imageJson.getString("userId");
|
|
|
Long projectId = imageJson.getLong("projectId");
|
|
|
JSONArray imageArr = imageJson.getJSONArray("imageArr");
|
|
|
- System.err.println(imageArr);
|
|
|
for (int i = 0; i < imageArr.size(); i++) {
|
|
|
JSONObject json = imageArr.getJSONObject(i);
|
|
|
if (!Check.isNull(json)) {
|
|
@@ -92,5 +95,91 @@ public class MaterialImageInfoServiceImpl extends ServiceImpl<MaterialImageInfoM
|
|
|
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 上传封面
|
|
|
+ *
|
|
|
+ * @param videoId
|
|
|
+ * @param accountId
|
|
|
+ * @param accessToken
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void uploadImage(String videoId, Long accountId, String accessToken) {
|
|
|
+
|
|
|
+
|
|
|
+ QueryWrapper<MaterialImageInfo> imageInfoQueryWrapper = new QueryWrapper<>();
|
|
|
+ imageInfoQueryWrapper.eq("video_id", videoId);
|
|
|
+ imageInfoQueryWrapper.eq("status", 0);
|
|
|
+ List<MaterialImageInfo> imageList = this.list(imageInfoQueryWrapper);
|
|
|
+ if(){
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+/*
|
|
|
+
|
|
|
+ String localUrl = LoadFileUtil.downLoadFromUrl(url, downloadUrl);
|
|
|
+ FileSystemResource resource = new FileSystemResource(new File(localUrl));
|
|
|
+ Map<String, String> headerMap = new HashMap<>();
|
|
|
+ headerMap.put("Content-Type", "multipart/form-data");
|
|
|
+ JSONObject requestJson = new JSONObject();
|
|
|
+ requestJson.put("file", resource);
|
|
|
+ requestJson.put("signature", materialInfo.getCode());
|
|
|
+ QueryWrapper<MaterialParameter> parameterQueryWrapper = new QueryWrapper<>();
|
|
|
+ parameterQueryWrapper.eq("material_id", materialInfo.getId());
|
|
|
+ parameterQueryWrapper.orderByDesc("create_time").last("limit 1");
|
|
|
+ MaterialParameter materialParameter = materialParameterService.getOne(parameterQueryWrapper);
|
|
|
+ if (!Check.isNull(materialParameter)) {
|
|
|
+ Integer type = MaterialEnum.getTypeBySize(Integer.valueOf(materialParameter.getWidth()), Integer.valueOf(materialParameter.getHeight()));
|
|
|
+ if (!Check.isNull(type) && type != 0) {
|
|
|
+ requestJson.put("type", type);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
-}
|
|
|
+
|
|
|
+ String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.IMAGE_UPLOAD;
|
|
|
+ requestJson.put("type", "2");
|
|
|
+ requestJson.put("upload_type", "1");
|
|
|
+
|
|
|
+
|
|
|
+ for (int i = 0; i < accountArray.size(); i++) {
|
|
|
+ Long accountId = accountArray.getLong(i);
|
|
|
+ QueryWrapper<CtopOauthToken> tokenQueryWrapper = new QueryWrapper<>();
|
|
|
+ tokenQueryWrapper.eq("account_id", accountId);
|
|
|
+ tokenQueryWrapper.eq("media_id", mediaId);
|
|
|
+ tokenQueryWrapper.orderByDesc("create_time");
|
|
|
+ tokenQueryWrapper.last("limit 1");
|
|
|
+ CtopOauthToken ctopOauthToken = oauthTokenMapper.selectOne(tokenQueryWrapper);
|
|
|
+ if (Check.isNull(ctopOauthToken)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ requestJson.put("advertiser_id", accountId);
|
|
|
+ headerMap.put("Access-Token", ctopOauthToken.getAccessToken());
|
|
|
+
|
|
|
+
|
|
|
+ if ("IMAGE".equals(materialInfo.getType())) {
|
|
|
+ // kuaishouInterfaceService.imageGet(accountId, ctopOauthToken.getAccessToken(), dataJson.getString("image_token"));
|
|
|
+ if (!Check.isNull(dataJson)) {
|
|
|
+ String signature = dataJson.getString("signature");
|
|
|
+ String image_token = dataJson.getString("image_token");
|
|
|
+ KuaiShouImageGet imageGet = new KuaiShouImageGet();
|
|
|
+ imageGet.setId(accountId + image_token);
|
|
|
+ imageGet.setAccountId(accountId);
|
|
|
+ imageGet.setUrl(dataJson.getString("url"));
|
|
|
+ imageGet.setWidth(dataJson.getInteger("width"));
|
|
|
+ imageGet.setHeight(dataJson.getInteger("height"));
|
|
|
+ imageGet.setSize(dataJson.getInteger("size"));
|
|
|
+ imageGet.setFormat(dataJson.getString("format"));
|
|
|
+ Integer type = MaterialEnum.getTypeBySize(dataJson.getInteger("width"), dataJson.getInteger("height"));
|
|
|
+ if (!Check.isNull(type)) {
|
|
|
+ imageGet.setMaterialType(type);
|
|
|
+ }
|
|
|
+ imageGet.setSignature(signature);
|
|
|
+ imageGet.setImageToken(image_token);
|
|
|
+ iKuaiShouImageGetService.saveOrUpdate(imageGet);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+*/
|
|
|
+
|
|
|
+
|
|
|
+ }
|