|
@@ -39,6 +39,7 @@ import com.github.pagehelper.Page;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
import com.github.pagehelper.util.StringUtil;
|
|
|
+import com.google.gson.JsonArray;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import net.coobird.thumbnailator.Thumbnails;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
@@ -52,6 +53,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
import tk.mybatis.mapper.entity.Condition;
|
|
|
|
|
|
import java.io.File;
|
|
|
+import java.io.IOException;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -3815,6 +3817,15 @@ public class SceneProServiceImpl extends BaseServiceImpl<SceneProEntity, String>
|
|
|
throw new BaseRuntimeException(SceneConstant.FAILURE_CODE_5005, SceneConstant.FAILURE_MSG_5005);
|
|
|
}
|
|
|
|
|
|
+ if (operaVideoDTO.getId() != null) {
|
|
|
+ produceOneVideo(operaVideoDTO, sceneProEntity);
|
|
|
+ } else {
|
|
|
+ produceSceneVideo(operaVideoDTO, sceneProEntity);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void produceSceneVideo(OperaVideoParam operaVideoDTO, SceneProEntity sceneProEntity) throws Exception {
|
|
|
StringBuffer dataBuf = new StringBuffer()
|
|
|
.append("data").append(File.separator)
|
|
|
.append("data").append(sceneProEntity.getNum())
|
|
@@ -3840,6 +3851,44 @@ public class SceneProServiceImpl extends BaseServiceImpl<SceneProEntity, String>
|
|
|
}
|
|
|
|
|
|
|
|
|
+ private void produceOneVideo(OperaVideoParam operaVideoDTO, SceneProEntity sceneProEntity) throws Exception {
|
|
|
+ StringBuffer dataBuf = new StringBuffer()
|
|
|
+ .append("data").append(File.separator)
|
|
|
+ .append("data").append(sceneProEntity.getNum())
|
|
|
+ .append(File.separator);
|
|
|
+
|
|
|
+ StringBuffer dataBuffer = new StringBuffer(ConstantFilePath.SCENE_PATH).append(dataBuf);
|
|
|
+
|
|
|
+ String strsceneInfos = FileUtils.readFile(dataBuffer + "scene.json");
|
|
|
+ JSONObject scenejson = new JSONObject();
|
|
|
+ if(strsceneInfos != null) {
|
|
|
+ scenejson = JSONObject.parseObject(strsceneInfos);
|
|
|
+ }
|
|
|
+
|
|
|
+ JSONArray newSceneJson = putVideoDataToAllSceneJson(operaVideoDTO, scenejson);
|
|
|
+ FileUtils.writeFile(dataBuffer + "scene.json", newSceneJson.toString());
|
|
|
+
|
|
|
+ Map<String, String> uploadMap = new HashMap<>();
|
|
|
+ uploadMap.put(dataBuffer + "scene.json", dataBuf + "scene.json");
|
|
|
+ uploadToOssUtil.uploadMulFiles(uploadMap);
|
|
|
+
|
|
|
+ sceneProEntity.setVideos(newSceneJson.toString());
|
|
|
+ update(sceneProEntity);
|
|
|
+ }
|
|
|
+
|
|
|
+ private JSONArray putVideoDataToAllSceneJson(OperaVideoParam operaVideoDTO, JSONObject scenejson) {
|
|
|
+ Object data = scenejson.get("data");
|
|
|
+ if (data == null || data instanceof JSONArray == false) {
|
|
|
+ throw new BaseRuntimeException("json数据data异常");
|
|
|
+ }
|
|
|
+ JSONArray jsonArray = (JSONArray) data;
|
|
|
+ for (Object o : jsonArray) {
|
|
|
+ ((JSONObject)o).put("show", operaVideoDTO.getShow());
|
|
|
+ }
|
|
|
+ return jsonArray;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
// todo
|
|
|
private JSONObject putVideoDataToSceneJson(OperaVideoParam operaVideoDTO, JSONObject scenejson) {
|
|
|
Object data = scenejson.get("data");
|