|
@@ -38,6 +38,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Qualifier;
|
|
import org.springframework.beans.factory.annotation.Qualifier;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.util.ObjectUtils;
|
|
import org.springframework.util.ObjectUtils;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
@@ -844,37 +845,35 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
return ResultData.ok();
|
|
return ResultData.ok();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Transactional
|
|
@Override
|
|
@Override
|
|
- public ResultData saveInitialPage(SceneEditParamVO base) throws Exception{
|
|
|
|
- if(StrUtil.isEmpty(base.getNum()) || StrUtil.isEmpty(base.getInitialPoint())){
|
|
|
|
- throw new BusinessException(ErrorCode.FAILURE_CODE_3001);
|
|
|
|
- }
|
|
|
|
|
|
+ public ResultData saveInitialPage(FileNameAndDataParamVO param) throws Exception{
|
|
|
|
|
|
- ScenePro scenePro = findBySceneNum(base.getNum());
|
|
|
|
|
|
+ ScenePro scenePro = this.findBySceneNum(param.getNum());
|
|
if(scenePro == null){
|
|
if(scenePro == null){
|
|
throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
|
|
throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
|
|
}
|
|
}
|
|
|
|
|
|
- String imagesDirPath = String.format(ConstantFilePath.IMAGESBUFFER_FORMAT, base.getNum());
|
|
|
|
- String path1 = imagesDirPath + "thumbBigImg.jpg";
|
|
|
|
- String path2 = imagesDirPath + "thumbSmallImg.jpg";
|
|
|
|
|
|
+ //更新缩略图url
|
|
|
|
+ String thumbUrl = this.ossUrlPrefix + String.format(UploadFilePath.USER_EDIT_PATH, param.getNum()) + param.getFileName();
|
|
|
|
+ scenePro.setThumb(thumbUrl);
|
|
|
|
+ this.updateById(scenePro);
|
|
|
|
+
|
|
|
|
+ SceneEditInfo sceneEditInfo = sceneEditInfoService.getBySceneProId(scenePro.getId());
|
|
|
|
+ if(sceneEditInfo == null){
|
|
|
|
+ sceneEditInfo = new SceneEditInfo();
|
|
|
|
+ sceneEditInfo.setSceneProId(scenePro.getId());
|
|
|
|
+ sceneEditInfo.setEntry(param.getData());
|
|
|
|
+ sceneEditInfoService.save(sceneEditInfo);
|
|
|
|
+ }else{
|
|
|
|
+ sceneEditInfoService.update(
|
|
|
|
+ new LambdaUpdateWrapper<SceneEditInfo>()
|
|
|
|
+ .set(SceneEditInfo::getEntry, param.getData())
|
|
|
|
+ .setSql("version = version + 1")
|
|
|
|
+ .eq(SceneEditInfo::getId, sceneEditInfo.getId()));
|
|
|
|
|
|
- //生成缩略图
|
|
|
|
- //按指定大小把图片进行缩和放(会遵循原图高宽比例)
|
|
|
|
- //此处把图片压成1024×512的缩略图
|
|
|
|
- Thumbnails.of(path1).size(1024,512).toFile(path2);//变为1024×512
|
|
|
|
|
|
|
|
- String strsceneInfos = FileUtils.readFile(ConstantFilePath.SCENE_PATH + "data/data" + scenePro.getNum() + File.separator + "scene.json");
|
|
|
|
- JSONObject scenejson = new JSONObject();
|
|
|
|
- if(strsceneInfos!=null) {
|
|
|
|
- scenejson = JSONObject.parseObject(strsceneInfos);
|
|
|
|
}
|
|
}
|
|
- String sceneJsonPath = String.format(ConstantFilePath.SCENE_PATH_FORMAT, scenePro.getNum());
|
|
|
|
- Map map = new HashMap();
|
|
|
|
- map.put("entry", JSONObject.parseObject(base.getInitialPoint()));
|
|
|
|
- map.put("thumbImg", 1);
|
|
|
|
- map.put("version", scenejson.getIntValue("version")+1);
|
|
|
|
- FileUtils.writeJsonFile(sceneJsonPath, map);
|
|
|
|
|
|
|
|
return ResultData.ok();
|
|
return ResultData.ok();
|
|
}
|
|
}
|