From 3970ced88b5b456f03fe277c254ca761f05492e0 Mon Sep 17 00:00:00 2001 From: yn147 <2270338776@qq.com> Date: 星期四, 26 十月 2023 14:00:12 +0800 Subject: [PATCH] 直播是否发布门户 --- src/main/java/com/qxueyou/scc/teach/res/service/impl/FileService.java | 73 ++++++++++++++++++++++++++++++++++-- 1 files changed, 68 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/qxueyou/scc/teach/res/service/impl/FileService.java b/src/main/java/com/qxueyou/scc/teach/res/service/impl/FileService.java index a992382..6f983cd 100644 --- a/src/main/java/com/qxueyou/scc/teach/res/service/impl/FileService.java +++ b/src/main/java/com/qxueyou/scc/teach/res/service/impl/FileService.java @@ -27,7 +27,7 @@ /** * 鎵�鏈夋枃浠朵笂浼犵殑鎿嶄綔锛屽崟鐙埌鏂囦欢涓婁紶宸ョ▼鍚庯紝鍚庣画涓氬姟鎿嶄綔闇�瑕佷笅杞芥枃浠惰皟鐢ㄧ殑鏂规硶 - * + * * @author xiadehu * */ @@ -75,13 +75,17 @@ String destPath = getDestPath(name); String fullPath = config.getResRootPath() + "/" + destPath; + //鎴彇涓婁紶鍗庝负浜戠殑缂栫爜 File fileRoot = new File(fullPath.substring(0, fullPath.lastIndexOf("/"))); if (!fileRoot.exists()) { fileRoot.mkdirs(); } + + //鍘嬬缉 FileUtils.copyInputStreamToFile(in, new File(fullPath)); + //鍗庝负浜戠紪鐮佸瓨鍏ユ暟鎹簱 ResFile file = insertFileToDB(name, fullPath, destPath, getFileType(name)); return new Result(true, "success", @@ -96,7 +100,7 @@ /** * 鎻掑叆鏂囦欢淇℃伅鍒版暟鎹簱 - * + * * @param name * @param fullPath * 鍏ㄨ矾寰� @@ -106,7 +110,7 @@ * 鏂囦欢绫诲瀷锛岄潪鏂囦欢鏍煎紡 * @return */ - private ResFile insertFileToDB(String name, String fullPath, String relativePath, String type) { + public ResFile insertFileToDB(String name, String fullPath, String relativePath, String type) { ResFile file = new ResFile(); @@ -127,10 +131,41 @@ return file; } + /** + * 鎻掑叆鏂囦欢淇℃伅鍒版暟鎹簱 + * + * @param name + * @param relativePath + * 鐩稿璺緞 + * @param type + * 鏂囦欢绫诲瀷锛岄潪鏂囦欢鏍煎紡 + * @return + */ + public ResFile insertFileToDBTwo(String name, Long Size, String relativePath, String type) { + + ResFile file = new ResFile(); + + TraceUtils.setCreateTrace(file); + file.setFileName(name); + file.setFileFormat(QFileUtils.getFileFormat(name)); + file.setFileType(type); + // TODO + file.setMd5Hash(null); + file.setPath(relativePath); + file.setSize(Size); + // TODO + file.setTenantId(null); + file.setDeleteFlag(false); + + save(file); + + return file; + + } /** * 鑾峰彇鏂囦欢绫诲瀷 - * + * * @param name * @return */ @@ -141,7 +176,7 @@ /** * 鑾峰彇鏂囦欢鐩爣璺緞 - * + * * @param name * @return */ @@ -208,4 +243,32 @@ } return null; } + + @Override + public Result checkMd5(String md5, String fileName) { +// if(StringUtils.isBlank(md5)){ +// return Result.FAIL; +// } +// +// +// Boolean objectExist; +// objectExist = authOssService.doseObjectExist(resFile.getPath()); +// +// if (objectExist) { +// +// ResFileDO resFileToDB = new ResFileDO(); +// BeanUtils.copyProperties(resFile, resFileToDB); +// resFileToDB.setId(null); +// TraceUtils.setCreateTrace(resFileToDB); +// ResFileDO resFileDB = save(resFileToDB); +// +// Result result = new Result(true, "fileId", resFileDB.getId(), "path", resFileDB.getPath(),"fileName",fileName, +// "fileSize",resFileToDB.getSize(),"fileType",resFileToDB.getFileType(),"hit",true); +// result.setResultCode(201); +// return result; +// +// } + + return Result.FAIL; + } } -- Gitblit v1.8.0