|
@@ -4,19 +4,17 @@ import cn.com.ctop.common.module.entity.CtopOauthToken;
|
|
import cn.com.ctop.common.module.service.ICtopOauthTokenService;
|
|
import cn.com.ctop.common.module.service.ICtopOauthTokenService;
|
|
import cn.com.ctop.common.module.utils.Check;
|
|
import cn.com.ctop.common.module.utils.Check;
|
|
import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
|
|
import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
|
|
|
|
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouImageGet;
|
|
|
|
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet;
|
|
|
|
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouImageGetService;
|
|
import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouMaterialUploadService;
|
|
import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouMaterialUploadService;
|
|
|
|
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouVideoGetService;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import org.jeecg.common.api.vo.Result;
|
|
import org.jeecg.common.api.vo.Result;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
-import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
|
-import org.springframework.web.multipart.MultipartFile;
|
|
|
|
-
|
|
|
|
-import javax.servlet.http.HttpServletRequest;
|
|
|
|
-import java.util.Map;
|
|
|
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
@RestController
|
|
@RestController
|
|
@RequestMapping("/kusiShouUpload")
|
|
@RequestMapping("/kusiShouUpload")
|
|
@@ -26,31 +24,87 @@ public class KuaiShouMaterialUploadController {
|
|
private IKuaiShouMaterialUploadService uploadService;
|
|
private IKuaiShouMaterialUploadService uploadService;
|
|
@Autowired
|
|
@Autowired
|
|
private ICtopOauthTokenService oauthTokenService;
|
|
private ICtopOauthTokenService oauthTokenService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IKuaiShouImageGetService iKuaiShouImageGetService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IKuaiShouVideoGetService videoGetService;
|
|
|
|
|
|
- @PostMapping(value = "/video", consumes = "multipart/form-data;charset=utf-8")
|
|
|
|
- public Map<String, Object> video(@RequestParam("multipartFile") MultipartFile multipartFile, String type, Long accountId, String code, HttpServletRequest request) throws Exception {
|
|
|
|
|
|
+ @GetMapping(value = "/video")
|
|
|
|
+ public Result<JSONObject> video(@RequestBody JSONObject requestJson) throws Exception {
|
|
|
|
+ Result<JSONObject> result = new Result<>();
|
|
|
|
+ try {
|
|
|
|
+ Long accountId = requestJson.getLong("accountId");
|
|
|
|
+ CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
|
|
|
|
+ if (Check.isNull(oauthToken)) {
|
|
|
|
+ throw new Exception("未获取到账户信息");
|
|
|
|
+ }
|
|
|
|
+ String url = requestJson.getString("url");
|
|
|
|
+ Integer type = requestJson.getInteger("type");
|
|
|
|
+ String signature = requestJson.getString("signature");
|
|
|
|
+ JSONObject videoJson = uploadService.video(url, type, accountId, oauthToken.getAccessToken(), signature);
|
|
|
|
+ JSONObject returnJson = new JSONObject();
|
|
|
|
+ if (videoJson.getBoolean("success")) {
|
|
|
|
+ result.setSuccess(true);
|
|
|
|
+ returnJson.put("photoId", videoJson.getLong("photoId"));
|
|
|
|
+ result.setResult(requestJson);
|
|
|
|
+ result.setMessage(videoJson.getString("message"));
|
|
|
|
+ } else {
|
|
|
|
+ result.setSuccess(false);
|
|
|
|
+ result.setMessage(videoJson.getString("message"));
|
|
|
|
+ }
|
|
|
|
|
|
- CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
|
|
|
|
- if (Check.isNull(oauthToken)) {
|
|
|
|
- throw new Exception("未获取到账户信息");
|
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ result.setSuccess(false);
|
|
|
|
+ result.setMessage(e.getMessage());
|
|
}
|
|
}
|
|
|
|
|
|
- uploadService.video(multipartFile, type, accountId, oauthToken.getAccessToken(), code);
|
|
|
|
- return null;
|
|
|
|
|
|
+
|
|
|
|
+ return result;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- @PostMapping(value = "/image", consumes = "multipart/form-data;charset=utf-8")
|
|
|
|
- public Result<JSONObject> image(@RequestParam("requestJson") JSONObject requestJson) throws Exception {
|
|
|
|
- Result<JSONObject> result = new Result<>();
|
|
|
|
|
|
+ @GetMapping(value = "/checkVideo")
|
|
|
|
+ public Result<JSONObject> video(String signature, Long accountId) {
|
|
|
|
+ Result<JSONObject> result = new Result();
|
|
try {
|
|
try {
|
|
- Long accountId = requestJson.getLong("accountId");
|
|
|
|
|
|
+ JSONObject returnJson = new JSONObject();
|
|
|
|
+ QueryWrapper<KuaiShouVideoGet> videoGetQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ videoGetQueryWrapper.eq("signature", signature);
|
|
|
|
+ videoGetQueryWrapper.eq("account_id", accountId);
|
|
|
|
+ videoGetQueryWrapper.last("limit 1");
|
|
|
|
+ KuaiShouVideoGet videoGet = videoGetService.getOne(videoGetQueryWrapper);
|
|
|
|
+ if (Check.isNull(videoGet)) {
|
|
|
|
+ returnJson.put("isExistence", false); // 未存在
|
|
|
|
+ } else {
|
|
|
|
+ returnJson.put("isExistence", true);
|
|
|
|
+ returnJson.put("videoUrl", videoGet.getUrl());
|
|
|
|
+ returnJson.put("photoId", videoGet.getPhotoId());
|
|
|
|
+ returnJson.put("signature", signature);
|
|
|
|
+ }
|
|
|
|
+ result.setSuccess(true);
|
|
|
|
+ result.setResult(returnJson);
|
|
|
|
+
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ result.setSuccess(false);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+
|
|
|
|
+ @PostMapping(value = "/image")
|
|
|
|
+ public Result<JSONArray> image(@RequestBody JSONObject requestJson) throws Exception {
|
|
|
|
+ Result<JSONArray> result = new Result<>();
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ Long accountId = requestJson.getLong("accountId");
|
|
CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
|
|
CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
|
|
if (Check.isNull(oauthToken)) {
|
|
if (Check.isNull(oauthToken)) {
|
|
throw new Exception("未获取到账户信息");
|
|
throw new Exception("未获取到账户信息");
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ JSONArray returnArr = new JSONArray();
|
|
JSONArray imageArr = requestJson.getJSONArray("uploadImageArr");
|
|
JSONArray imageArr = requestJson.getJSONArray("uploadImageArr");
|
|
if (!Check.isNull(imageArr)) {
|
|
if (!Check.isNull(imageArr)) {
|
|
for (int i = 0; i < imageArr.size(); i++) {
|
|
for (int i = 0; i < imageArr.size(); i++) {
|
|
@@ -62,14 +116,31 @@ public class KuaiShouMaterialUploadController {
|
|
} else {
|
|
} else {
|
|
imageUrl = url;
|
|
imageUrl = url;
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
String signature = imageJson.getString("signature");
|
|
String signature = imageJson.getString("signature");
|
|
- uploadService.kuauiShouImageUpload(url, signature, accountId, oauthToken.getAccessToken());
|
|
|
|
|
|
+ QueryWrapper<KuaiShouImageGet> imageGetQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ imageGetQueryWrapper.eq("signature", signature);
|
|
|
|
+ imageGetQueryWrapper.eq("account_id", accountId);
|
|
|
|
+ imageGetQueryWrapper.last("limit 1");
|
|
|
|
+ KuaiShouImageGet imageGet = iKuaiShouImageGetService.getOne(imageGetQueryWrapper);
|
|
|
|
+ if (Check.isNull(imageGet)) {
|
|
|
|
+ String imageToken = uploadService.kuauiShouImageUpload(imageUrl, signature, accountId, oauthToken.getAccessToken());
|
|
|
|
+ if (!Check.isNull(imageToken)) {
|
|
|
|
+ JSONObject returnJson = new JSONObject();
|
|
|
|
+ returnJson.put("url", imageUrl);
|
|
|
|
+ returnJson.put("signature", signature);
|
|
|
|
+ returnArr.add(returnJson);
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ JSONObject returnJson = new JSONObject();
|
|
|
|
+ returnJson.put("url", imageUrl);
|
|
|
|
+ returnJson.put("signature", signature);
|
|
|
|
+ returnArr.add(returnJson);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
result.setSuccess(true);
|
|
result.setSuccess(true);
|
|
|
|
+ result.setResult(returnArr);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
result.setSuccess(false);
|
|
result.setSuccess(false);
|