|
@@ -1,12 +1,17 @@
|
|
package com.fdkankan.scene.service.impl;
|
|
package com.fdkankan.scene.service.impl;
|
|
|
|
|
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.date.DateUtil;
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.fdkankan.common.constant.ErrorCode;
|
|
import com.fdkankan.common.constant.ErrorCode;
|
|
import com.fdkankan.common.constant.PayStatus;
|
|
import com.fdkankan.common.constant.PayStatus;
|
|
import com.fdkankan.common.constant.SceneStatus;
|
|
import com.fdkankan.common.constant.SceneStatus;
|
|
import com.fdkankan.common.constant.ServerCode;
|
|
import com.fdkankan.common.constant.ServerCode;
|
|
|
|
+import com.fdkankan.common.constant.UploadFilePath;
|
|
import com.fdkankan.common.exception.BusinessException;
|
|
import com.fdkankan.common.exception.BusinessException;
|
|
import com.fdkankan.common.response.ResultData;
|
|
import com.fdkankan.common.response.ResultData;
|
|
import com.fdkankan.common.util.DateExtUtil;
|
|
import com.fdkankan.common.util.DateExtUtil;
|
|
@@ -19,11 +24,15 @@ import com.fdkankan.scene.entity.ScenePlus;
|
|
import com.fdkankan.scene.service.ISceneEditService;
|
|
import com.fdkankan.scene.service.ISceneEditService;
|
|
import com.fdkankan.scene.service.IScenePlusService;
|
|
import com.fdkankan.scene.service.IScenePlusService;
|
|
import com.fdkankan.scene.service.ISceneProService;
|
|
import com.fdkankan.scene.service.ISceneProService;
|
|
|
|
+import com.fdkankan.scene.vo.BaseDataParamVO;
|
|
import com.fdkankan.scene.vo.BaseSceneParamVO;
|
|
import com.fdkankan.scene.vo.BaseSceneParamVO;
|
|
import com.fdkankan.scene.vo.LocalesParamVO;
|
|
import com.fdkankan.scene.vo.LocalesParamVO;
|
|
import com.fdkankan.scene.vo.SceneAuthVO;
|
|
import com.fdkankan.scene.vo.SceneAuthVO;
|
|
|
|
+import java.io.IOException;
|
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -47,6 +56,8 @@ public class SceneEditServiceImpl implements ISceneEditService {
|
|
IScenePlusService scenePlusService;
|
|
IScenePlusService scenePlusService;
|
|
@Autowired
|
|
@Autowired
|
|
private UploadToOssUtil uploadToOssUtil;
|
|
private UploadToOssUtil uploadToOssUtil;
|
|
|
|
+ @Value("${oss.bucket:4dkankan}")
|
|
|
|
+ private String bucket;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public SceneAuthVO getAuth(BaseSceneParamVO param) throws Exception{
|
|
public SceneAuthVO getAuth(BaseSceneParamVO param) throws Exception{
|
|
@@ -105,4 +116,47 @@ public class SceneEditServiceImpl implements ISceneEditService {
|
|
uploadToOssUtil.upload(JSON.toJSONBytes(param.getData()), key);
|
|
uploadToOssUtil.upload(JSON.toJSONBytes(param.getData()), key);
|
|
return ResultData.ok();
|
|
return ResultData.ok();
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public ResultData saveTour(BaseDataParamVO param) throws IOException {
|
|
|
|
+ String key = String.format(UploadFilePath.USER_EDIT_PATH, param.getNum()) + "tour.json";
|
|
|
|
+ uploadToOssUtil.upload(param.getData().getBytes(StandardCharsets.UTF_8), key);
|
|
|
|
+ return ResultData.ok();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public ResultData deleteTour(BaseSceneParamVO param) throws IOException {
|
|
|
|
+ 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 -> {
|
|
|
|
+ JSONObject tour = (JSONObject)o;
|
|
|
|
+ try {
|
|
|
|
+ JSONObject enter = tour.getJSONObject("enter");
|
|
|
|
+ String enterOver = enter.getString("cover");
|
|
|
|
+ if(StrUtil.isNotEmpty(enterOver)){
|
|
|
|
+ uploadToOssUtil.delete(userEditPath + 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);
|
|
|
|
+ }
|
|
|
|
+ }catch (IOException e){
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ uploadToOssUtil.delete(tourJsonPath);
|
|
|
|
+
|
|
|
|
+ return ResultData.ok();
|
|
|
|
+ }
|
|
}
|
|
}
|