From aae48957ba971ed0a1bfbfa182701cd22bbe8694 Mon Sep 17 00:00:00 2001 From: inleft <inleft@qq.com> Date: Wed, 31 Aug 2022 18:12:16 +0800 Subject: [PATCH] 新增编辑页 查询接口 --- snowy-base/snowy-system/src/main/java/vip/xiaonuo/sys/modular/file/service/impl/SysFileInfoServiceImpl.java | 47 ++++++++++++++++++++++++++--------------------- 1 files changed, 26 insertions(+), 21 deletions(-) diff --git a/snowy-base/snowy-system/src/main/java/vip/xiaonuo/sys/modular/file/service/impl/SysFileInfoServiceImpl.java b/snowy-base/snowy-system/src/main/java/vip/xiaonuo/sys/modular/file/service/impl/SysFileInfoServiceImpl.java index 8497ef2..bbbda5d 100644 --- a/snowy-base/snowy-system/src/main/java/vip/xiaonuo/sys/modular/file/service/impl/SysFileInfoServiceImpl.java +++ b/snowy-base/snowy-system/src/main/java/vip/xiaonuo/sys/modular/file/service/impl/SysFileInfoServiceImpl.java @@ -57,8 +57,8 @@ import vip.xiaonuo.core.util.HttpServletUtil; import vip.xiaonuo.core.util.LibreOfficeUtil; import vip.xiaonuo.sys.modular.file.entity.SysFileInfo; -import vip.xiaonuo.sys.modular.file.enums.SysFileLocationEnum; import vip.xiaonuo.sys.modular.file.enums.SysFileInfoExceptionEnum; +import vip.xiaonuo.sys.modular.file.enums.SysFileLocationEnum; import vip.xiaonuo.sys.modular.file.mapper.SysFileInfoMapper; import vip.xiaonuo.sys.modular.file.param.SysFileInfoParam; import vip.xiaonuo.sys.modular.file.result.SysFileInfoResult; @@ -99,7 +99,7 @@ @Override public SysOnlineFileInfoResult onlineAddOrUpdate(SysFileInfoParam sysFileInfoParam) { - if(fileOperator instanceof LocalFileOperator) { + if (fileOperator instanceof LocalFileOperator) { //文件后缀 String fileSuffix = sysFileInfoParam.getFileSuffix(); //文件名称 @@ -107,7 +107,7 @@ //文件id Long id = sysFileInfoParam.getId(); //参数错误 - if(ObjectUtil.isAllEmpty(fileSuffix, fileOriginName, id)) { + if (ObjectUtil.isAllEmpty(fileSuffix, fileOriginName, id)) { throw new ServiceException(SysFileInfoExceptionEnum.ONLINE_EDIT_PARAM_ERROR); } //获取登录用户 @@ -115,19 +115,19 @@ SysFileInfo sysFileInfo; SysOnlineFileInfoResult sysOnlineFileInfoResult; //文件id不为空则表示编辑 - if(ObjectUtil.isNotEmpty(id)) { + if (ObjectUtil.isNotEmpty(id)) { sysFileInfo = this.getById(id); - sysOnlineFileInfoResult= new SysOnlineFileInfoResult(Convert.toStr(sysFileInfo.getId()), sysFileInfo.getFileOriginName(), Convert.toStr(sysLoginUser.getId()), sysLoginUser.getName()); + sysOnlineFileInfoResult = new SysOnlineFileInfoResult(Convert.toStr(sysFileInfo.getId()), sysFileInfo.getFileOriginName(), Convert.toStr(sysLoginUser.getId()), sysLoginUser.getName()); } else { //否则表示新增 Boolean sample = sysFileInfoParam.getSample(); sysFileInfo = createDemo(fileSuffix, fileOriginName, sample, Convert.toStr(sysLoginUser.getId()), sysLoginUser.getName()); - sysOnlineFileInfoResult= new SysOnlineFileInfoResult(Convert.toStr(sysFileInfo.getId()), fileOriginName + SymbolConstant.PERIOD + fileSuffix, Convert.toStr(sysLoginUser.getId()), sysLoginUser.getName()); + sysOnlineFileInfoResult = new SysOnlineFileInfoResult(Convert.toStr(sysFileInfo.getId()), fileOriginName + SymbolConstant.PERIOD + fileSuffix, Convert.toStr(sysLoginUser.getId()), sysLoginUser.getName()); } //设置history sysOnlineFileInfoResult.history = OnlineDocumentUtil.getHistory(sysOnlineFileInfoResult); - if(ObjectUtil.isAllNotEmpty(sysFileInfoParam.getMode(), sysFileInfoParam.getType())) { + if (ObjectUtil.isAllNotEmpty(sysFileInfoParam.getMode(), sysFileInfoParam.getType())) { sysOnlineFileInfoResult.changeType(sysFileInfoParam.getMode(), sysFileInfoParam.getType()); } return sysOnlineFileInfoResult; @@ -160,8 +160,8 @@ } // 根据后缀查询 - if(ObjectUtil.isNotEmpty(sysFileInfoParam.getFileSuffix())) { - if(sysFileInfoParam.getFileSuffix().contains(SymbolConstant.COMMA)) { + if (ObjectUtil.isNotEmpty(sysFileInfoParam.getFileSuffix())) { + if (sysFileInfoParam.getFileSuffix().contains(SymbolConstant.COMMA)) { queryWrapper.in(SysFileInfo::getFileSuffix, Arrays.asList(sysFileInfoParam.getFileSuffix().split(SymbolConstant.COMMA))); } else { queryWrapper.eq(SysFileInfo::getFileSuffix, sysFileInfoParam.getFileSuffix()); @@ -225,6 +225,11 @@ @Override public Long uploadFile(MultipartFile file) { + return this.uploadFileBlog(file, DEFAULT_BUCKET); + } + + @Override + public Long uploadFileBlog(MultipartFile file, String bucket) { // 生成文件的唯一id Long fileId = IdWorker.getId(); @@ -245,7 +250,7 @@ byte[] bytes; try { bytes = file.getBytes(); - fileOperator.storageFile(DEFAULT_BUCKET, finalName, bytes); + fileOperator.storageFile(bucket, finalName, bytes); } catch (IOException e) { throw new ServiceException(SysFileInfoExceptionEnum.ERROR_FILE); } @@ -261,7 +266,7 @@ SysFileInfo sysFileInfo = new SysFileInfo(); sysFileInfo.setId(fileId); sysFileInfo.setFileLocation(SysFileLocationEnum.LOCAL.getCode()); - sysFileInfo.setFileBucket(DEFAULT_BUCKET); + sysFileInfo.setFileBucket(bucket); sysFileInfo.setFileObjectName(finalName); sysFileInfo.setFileOriginName(originalFilename); sysFileInfo.setFileSuffix(fileSuffix); @@ -418,7 +423,7 @@ } int status = (int) jsonObj.get("status"); - String downloadUri = (String) jsonObj.get("url"); + String downloadUri = (String) jsonObj.get("url"); String changesUri = (String) jsonObj.get("changesurl"); String key = (String) jsonObj.get("key"); @@ -427,7 +432,7 @@ //MustSave, Corrupted try { String histDir = OnlineDocumentUtil.getHistoryDir(OnlineDocumentUtil.getStoragePath(id)); - String versionDir = OnlineDocumentUtil.getVersionDir(histDir, OnlineDocumentUtil.getFileVersion(histDir) + 1); + String versionDir = OnlineDocumentUtil.getVersionDir(histDir, OnlineDocumentUtil.getFileVersion(histDir) + 1); File ver = new File(versionDir); File toSave = new File(storagePath); if (!ver.exists()) ver.mkdirs(); @@ -462,11 +467,11 @@ /** * 创建模板文件 * - * @param fileSuffix 文件后缀 + * @param fileSuffix 文件后缀 * @param originalFilename 文件原始名称 - * @param sample 是否创建相同文件内容的模板文件 - * @param userId 用户id - * @param userName 用户名称 + * @param sample 是否创建相同文件内容的模板文件 + * @param userId 用户id + * @param userName 用户名称 * @author xuyuxiang * @date 2021/3/24 11:01 */ @@ -509,8 +514,8 @@ /** * 创建元数据信息 * - * @param fileId 文件id - * @param userId 用户id + * @param fileId 文件id + * @param userId 用户id * @param userName 用户名称 * @author xuyuxiang * @date 2021/3/24 11:19 @@ -518,13 +523,13 @@ public void createMeta(String fileId, String userId, String userName) { // 仅限本地文件 Object localClient = fileOperator.getClient(); - if(ObjectUtil.isNull(localClient)) { + if (ObjectUtil.isNull(localClient)) { throw new ServiceException(SysFileInfoExceptionEnum.CLIENT_INIT_ERROR); } Dict localClientDict = (Dict) localClient; // 拼接获取文档历史路径 String histDir = localClientDict.getStr("currentSavePath") + File.separator + DEFAULT_BUCKET + File.separator + fileId + "-hist"; - if(!FileUtil.exist(histDir)) { + if (!FileUtil.exist(histDir)) { // 历史路径不存在则创建 File dir = new File(histDir); dir.mkdir(); -- Gitblit v1.9.1