|
@@ -29,24 +29,44 @@ public class KuaiShouMaterialUploadController {
|
|
@Autowired
|
|
@Autowired
|
|
private IKuaiShouVideoGetService videoGetService;
|
|
private IKuaiShouVideoGetService videoGetService;
|
|
|
|
|
|
- @GetMapping(value = "/video")
|
|
|
|
|
|
+ @PostMapping(value = "/video")
|
|
public Result<JSONObject> video(@RequestBody JSONObject requestJson) throws Exception {
|
|
public Result<JSONObject> video(@RequestBody JSONObject requestJson) throws Exception {
|
|
Result<JSONObject> result = new Result<>();
|
|
Result<JSONObject> result = new Result<>();
|
|
try {
|
|
try {
|
|
Long accountId = requestJson.getLong("accountId");
|
|
Long accountId = requestJson.getLong("accountId");
|
|
|
|
+ if (Check.isNull(accountId)) {
|
|
|
|
+ throw new Exception("请传入账户id");
|
|
|
|
+ }
|
|
CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
|
|
CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
|
|
if (Check.isNull(oauthToken)) {
|
|
if (Check.isNull(oauthToken)) {
|
|
throw new Exception("未获取到账户信息");
|
|
throw new Exception("未获取到账户信息");
|
|
}
|
|
}
|
|
String url = requestJson.getString("url");
|
|
String url = requestJson.getString("url");
|
|
|
|
+ if (Check.isNull(url)) {
|
|
|
|
+ throw new Exception("请传入视频");
|
|
|
|
+ }
|
|
|
|
+ String videoUrl;
|
|
|
|
+ if (!url.contains("https:")) {
|
|
|
|
+ videoUrl = KuaishouInterfaceConstant.HTTPS_PREFIX + url;
|
|
|
|
+ } else {
|
|
|
|
+ videoUrl = url;
|
|
|
|
+ }
|
|
Integer type = requestJson.getInteger("type");
|
|
Integer type = requestJson.getInteger("type");
|
|
|
|
+ if (Check.isNull(type)) {
|
|
|
|
+ throw new Exception("请传入视频类型");
|
|
|
|
+ }
|
|
String signature = requestJson.getString("signature");
|
|
String signature = requestJson.getString("signature");
|
|
- JSONObject videoJson = uploadService.video(url, type, accountId, oauthToken.getAccessToken(), signature);
|
|
|
|
|
|
+ if (Check.isNull(type)) {
|
|
|
|
+ throw new Exception("视频标识错误");
|
|
|
|
+ }
|
|
|
|
+ JSONObject videoJson = uploadService.video(videoUrl, type, accountId, oauthToken.getAccessToken(), signature);
|
|
JSONObject returnJson = new JSONObject();
|
|
JSONObject returnJson = new JSONObject();
|
|
if (videoJson.getBoolean("success")) {
|
|
if (videoJson.getBoolean("success")) {
|
|
result.setSuccess(true);
|
|
result.setSuccess(true);
|
|
- returnJson.put("photoId", videoJson.getLong("photoId"));
|
|
|
|
- result.setResult(requestJson);
|
|
|
|
|
|
+ returnJson.put("photoId", videoJson.getString("photoId"));
|
|
|
|
+ returnJson.put("signature", videoJson.getString("signature"));
|
|
|
|
+ returnJson.put("videoUrl", videoUrl);
|
|
|
|
+ result.setResult(returnJson);
|
|
result.setMessage(videoJson.getString("message"));
|
|
result.setMessage(videoJson.getString("message"));
|
|
} else {
|
|
} else {
|
|
result.setSuccess(false);
|
|
result.setSuccess(false);
|