|
@@ -92,7 +92,8 @@ public class VideoApiService {
|
|
|
}
|
|
|
if (res.getInteger("code") != 0) {
|
|
|
log.error("publishVideo error, uid:{} videoUrl={} coverUrl={} title={} res={}", uid, videoUrl, coverUrl, title, res);
|
|
|
- throw new CommonException(ExceptionEnum.VIDEO_PUBLISH_FAILED.getCode(), res.getString("msg"));
|
|
|
+ throw new CommonException(ExceptionEnum.VIDEO_PUBLISH_FAILED.getCode(),
|
|
|
+ ExceptionEnum.VIDEO_PUBLISH_FAILED.getMsg() + "," + res.getString("msg"));
|
|
|
}
|
|
|
JSONObject data = res.getJSONObject("data");
|
|
|
Long videoId = data.getLong("id");
|
|
@@ -136,33 +137,46 @@ public class VideoApiService {
|
|
|
|
|
|
public JSONObject getVideoInfo(Long videoId) {
|
|
|
String url = videoApiHost + "/longvideoapi/openapi/video/getVideoInfo";
|
|
|
+ JSONObject res = null;
|
|
|
try {
|
|
|
JSONObject param = new JSONObject();
|
|
|
param.put("videoId", videoId);
|
|
|
String post = httpPoolClient.post(url, param.toJSONString());
|
|
|
- JSONObject res = JSONObject.parseObject(post);
|
|
|
- if (res.getInteger("code") != 0) {
|
|
|
- log.error("getVideoInfo error, videoId={} res={}", videoId, res);
|
|
|
- throw new CommonException(ExceptionEnum.VIDEO_PUBLISH_FAILED.getCode(), res.getString("msg"));
|
|
|
- }
|
|
|
- return res.getJSONObject("data");
|
|
|
+ res = JSONObject.parseObject(post);
|
|
|
} catch (Exception e) {
|
|
|
log.error("getVideoInfo error", e);
|
|
|
}
|
|
|
- return null;
|
|
|
+ if (Objects.isNull(res)) {
|
|
|
+ throw new CommonException(ExceptionEnum.VIDEO_INFO_FAILED);
|
|
|
+ }
|
|
|
+ if (res.getInteger("code") != 0) {
|
|
|
+ log.error("getVideoInfo error, videoId={} res={}", videoId, res);
|
|
|
+ throw new CommonException(ExceptionEnum.VIDEO_INFO_FAILED.getCode(),
|
|
|
+ ExceptionEnum.VIDEO_INFO_FAILED.getMsg() + "," + res.getString("msg"));
|
|
|
+ }
|
|
|
+ return res.getJSONObject("data");
|
|
|
}
|
|
|
|
|
|
public void deleteVideo(Long uid, Long videoId) {
|
|
|
String url = videoApiHost + "/longvideoapi/openapi/video/delete";
|
|
|
+ JSONObject res = null;
|
|
|
try {
|
|
|
JSONObject param = new JSONObject();
|
|
|
param.put("loginUid", uid);
|
|
|
param.put("videoId", videoId);
|
|
|
String post = httpPoolClient.post(url, param.toJSONString());
|
|
|
- JSONObject res = JSONObject.parseObject(post);
|
|
|
+ res = JSONObject.parseObject(post);
|
|
|
} catch (Exception e) {
|
|
|
log.error("deleteVideo error", e);
|
|
|
}
|
|
|
+ if (Objects.isNull(res)) {
|
|
|
+ throw new CommonException(ExceptionEnum.VIDEO_DELETE_FAILED);
|
|
|
+ }
|
|
|
+ if (res.getInteger("code") != 0) {
|
|
|
+ log.error("getVideoInfo error, videoId={} res={}", videoId, res);
|
|
|
+ throw new CommonException(ExceptionEnum.VIDEO_DELETE_FAILED.getCode(),
|
|
|
+ ExceptionEnum.VIDEO_DELETE_FAILED.getMsg() + "," + res.getString("msg"));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
}
|