|
@@ -24,13 +24,18 @@ import com.fdkankan.scene.entity.ScenePlus;
|
|
|
import com.fdkankan.scene.service.ISceneEditService;
|
|
|
import com.fdkankan.scene.service.IScenePlusService;
|
|
|
import com.fdkankan.scene.service.ISceneProService;
|
|
|
+import com.fdkankan.scene.service.ISceneUploadService;
|
|
|
import com.fdkankan.scene.vo.BaseDataParamVO;
|
|
|
import com.fdkankan.scene.vo.BaseSceneParamVO;
|
|
|
+import com.fdkankan.scene.vo.DeleteFileParamVO;
|
|
|
import com.fdkankan.scene.vo.LocalesParamVO;
|
|
|
import com.fdkankan.scene.vo.SceneAuthVO;
|
|
|
import java.io.IOException;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Objects;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -58,6 +63,8 @@ public class SceneEditServiceImpl implements ISceneEditService {
|
|
|
private UploadToOssUtil uploadToOssUtil;
|
|
|
@Value("${oss.bucket:4dkankan}")
|
|
|
private String bucket;
|
|
|
+ @Autowired
|
|
|
+ private ISceneUploadService sceneUploadService;
|
|
|
|
|
|
@Override
|
|
|
public SceneAuthVO getAuth(BaseSceneParamVO param) throws Exception{
|
|
@@ -125,36 +132,46 @@ public class SceneEditServiceImpl implements ISceneEditService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public ResultData deleteTour(BaseSceneParamVO param) throws IOException {
|
|
|
+ public ResultData deleteTour(BaseSceneParamVO param) throws Exception {
|
|
|
String userEditPath = String.format(UploadFilePath.USER_EDIT_PATH, param.getNum());
|
|
|
String tourJsonPath = userEditPath + "tour.json";
|
|
|
String tourJson = uploadToOssUtil.getObjectContent(bucket, tourJsonPath);
|
|
|
JSONArray tours = JSON.parseArray(tourJson);
|
|
|
if(CollUtil.isNotEmpty(tours)){
|
|
|
- tours.parallelStream().forEach(o -> {
|
|
|
+ List<String> fileNames = new ArrayList<>();
|
|
|
+ for (Object o : tours) {
|
|
|
JSONObject tour = (JSONObject)o;
|
|
|
- try {
|
|
|
- JSONObject enter = tour.getJSONObject("enter");
|
|
|
+
|
|
|
+ JSONObject enter = tour.getJSONObject("enter");
|
|
|
+ if(Objects.nonNull(enter)){
|
|
|
String enterOver = enter.getString("cover");
|
|
|
if(StrUtil.isNotEmpty(enterOver)){
|
|
|
- uploadToOssUtil.delete(userEditPath + enterOver);
|
|
|
+ fileNames.add(enterOver);
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- JSONObject exit = tour.getJSONObject("exit");
|
|
|
- String exitOver = enter.getString("cover");
|
|
|
- if(StrUtil.isNotEmpty(exitOver)){
|
|
|
- uploadToOssUtil.delete(userEditPath + exitOver);
|
|
|
- }
|
|
|
|
|
|
- String music = tour.getString("music");
|
|
|
- if(StrUtil.isNotEmpty(music)){
|
|
|
- uploadToOssUtil.delete(userEditPath + music);
|
|
|
+ JSONObject exit = tour.getJSONObject("exit");
|
|
|
+ if(Objects.nonNull(exit)){
|
|
|
+ String exitOver = exit.getString("cover");
|
|
|
+ if(StrUtil.isNotEmpty(exitOver)){
|
|
|
+ fileNames.add(exitOver);
|
|
|
}
|
|
|
- }catch (IOException e){
|
|
|
+ }
|
|
|
|
|
|
+ String music = tour.getString("music");
|
|
|
+ if(StrUtil.isNotEmpty(music)){
|
|
|
+ fileNames.add( music);
|
|
|
}
|
|
|
- });
|
|
|
+ }
|
|
|
+
|
|
|
+ //批量删除资源文件
|
|
|
+ sceneUploadService.delete(
|
|
|
+ DeleteFileParamVO.builder()
|
|
|
+ .num(param.getNum()).bizType("tour").fileNames(fileNames)
|
|
|
+ .build());
|
|
|
}
|
|
|
+ //删除tour.json文件
|
|
|
uploadToOssUtil.delete(tourJsonPath);
|
|
|
|
|
|
return ResultData.ok();
|