From e9e1c1722d1690a60033256c3dabf5bf1098301b Mon Sep 17 00:00:00 2001 From: wanghu Date: Wed, 9 Sep 2026 15:54:50 +0800 Subject: [PATCH] uploud --- src/YhCore.Model/Dto/FileDtos.cs | 4 ++-- src/YhCore.Service/Impl/FileService.cs | 14 +++++++------- src/YhCore.Service/Impl/WYSHRoleService.cs | 2 +- src/YhCore.Service/Interfaces/IFileService.cs | 10 +++++----- src/YhCore.WebApi/appsettings.json | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/YhCore.Model/Dto/FileDtos.cs b/src/YhCore.Model/Dto/FileDtos.cs index 16bbfef..4def423 100644 --- a/src/YhCore.Model/Dto/FileDtos.cs +++ b/src/YhCore.Model/Dto/FileDtos.cs @@ -2,7 +2,7 @@ namespace YhCore.Model.Dto { /// /// 文件信息(旧 BestSchool.Entity.FileObj,GetEnclosure/FileSave/FileSaveImage/FileMergeSave 共用)。 - /// fileurl 为相对路径(如 /UploadFile/docprint/20260101/{guid}.jpg,与旧库数据格式一致); + /// fileurl 为相对路径(如 /upload/docprint/20260101/{guid}.jpg,与旧库数据格式一致); /// host 为文件访问主机前缀(旧 AuthConfig.weboa_url,新 Config.FileWebPath)。 /// public class FileObj @@ -19,7 +19,7 @@ namespace YhCore.Model.Dto /// 文件真实名称(含扩展名)。 public string filename { get; set; } - /// 相对访问路径(如 /UploadFile/docprint/20260101/{guid}.jpg)。 + /// 相对访问路径(如 /upload/docprint/20260101/{guid}.jpg)。 public string fileurl { get; set; } /// 文件主机前缀(Config.FileWebPath)。 diff --git a/src/YhCore.Service/Impl/FileService.cs b/src/YhCore.Service/Impl/FileService.cs index 4e013fe..261aaa5 100644 --- a/src/YhCore.Service/Impl/FileService.cs +++ b/src/YhCore.Service/Impl/FileService.cs @@ -71,7 +71,7 @@ namespace YhCore.Service.Impl if (appType.ToLower() == "noticemsg") appType = "notice"; string dtStr = DateTime.Now.ToString("yyyyMMdd"); string physicalDir = Path.Combine(StorageRoot(), appType, dtStr); - string outFilePath = "/UploadFile/" + appType + "/" + dtStr + "/"; + string outFilePath = "/upload/" + appType + "/" + dtStr + "/"; if (!Directory.Exists(physicalDir)) Directory.CreateDirectory(physicalDir); @@ -109,7 +109,7 @@ namespace YhCore.Service.Impl if (appType.ToLower() == "noticemsg") appType = "notice"; string dtStr = DateTime.Now.ToString("yyyyMMdd"); string physicalDir = Path.Combine(StorageRoot(), appType, dtStr); - string outFilePath = "/UploadFile/" + appType + "/" + dtStr + "/"; + string outFilePath = "/upload/" + appType + "/" + dtStr + "/"; if (!Directory.Exists(physicalDir)) Directory.CreateDirectory(physicalDir); @@ -169,7 +169,7 @@ namespace YhCore.Service.Impl if (appType.ToLower() == "noticemsg") appType = "notice"; string dtStr = DateTime.Now.ToString("yyyyMMdd"); string physicalDir = Path.Combine(StorageRoot(), appType, dtStr); - string outFilePath = "/UploadFile/" + appType + "/" + dtStr + "/"; + string outFilePath = "/upload/" + appType + "/" + dtStr + "/"; if (!Directory.Exists(physicalDir)) Directory.CreateDirectory(physicalDir); @@ -214,22 +214,22 @@ namespace YhCore.Service.Impl if (string.IsNullOrEmpty(fileUrl)) return ""; - // 相对路径如 /UploadFile/docprint/20260101/{guid}.jpg → Config.FilePath + 子路径 + // 相对路径如 /upload/docprint/20260101/{guid}.jpg → Config.FilePath + 子路径 var relative = fileUrl.TrimStart('/'); - const string prefix = "UploadFile/"; + const string prefix = "upload/"; if (relative.StartsWith(prefix, StringComparison.OrdinalIgnoreCase)) relative = relative.Substring(prefix.Length); return Path.Combine(StorageRoot(), relative.Replace('/', Path.DirectorySeparatorChar)); } - /// 存储根目录(旧 Server.MapPath("~/UploadFile/");Config.FilePath 缺省时退回进程目录/UploadFile)。 + /// 存储根目录(旧 Server.MapPath("~/upload/");Config.FilePath 缺省时退回进程目录/upload)。 public static string StorageRoot() { if (!string.IsNullOrEmpty(Config.FilePath)) return Config.FilePath; - return Path.Combine(AppContext.BaseDirectory, "UploadFile"); + return Path.Combine(AppContext.BaseDirectory, "upload"); } } } diff --git a/src/YhCore.Service/Impl/WYSHRoleService.cs b/src/YhCore.Service/Impl/WYSHRoleService.cs index e8cc4cd..758ba92 100644 --- a/src/YhCore.Service/Impl/WYSHRoleService.cs +++ b/src/YhCore.Service/Impl/WYSHRoleService.cs @@ -27,7 +27,7 @@ namespace YhCore.Service.Impl /// 降级说明: /// 1. 旧 SendMessage/SendUnread/Backlog(短信、已读未读、待办中心)新项目缺失,全部降级为纯落库; /// 2. 教师/头像改走教务 SDK(Yh.SchClass.OpenApi),教师标识用 teaId(TeaSerId)对齐新教务; - /// 3. 签名存文件系统(DES 加密,Config.FilePath 替代旧 Server.MapPath("~/UploadFile/")); + /// 3. 签名存文件系统(DES 加密,Config.FilePath 替代旧 Server.MapPath("~/upload/")); /// 4. 旧 ServiceResult 的 Data/OtherData/Page 三段合并为单个 Result 对象 /// (getshenheFlow / getStepInfo / getStepByJE / getdocOftable)。 /// Excel 导入导出与审批单 PDF(DownMBOfSHRole/UpfileExcelSHRole/downUpfileSHRoleFK/ExceltotalListSHRole/ diff --git a/src/YhCore.Service/Interfaces/IFileService.cs b/src/YhCore.Service/Interfaces/IFileService.cs index 3a0c087..c043f70 100644 --- a/src/YhCore.Service/Interfaces/IFileService.cs +++ b/src/YhCore.Service/Interfaces/IFileService.cs @@ -7,8 +7,8 @@ namespace YhCore.Service.Interfaces { /// /// 公共文件服务(移植旧 BestSchool.Service.Common.GetEnclosure/FileSaveEnclosure + - /// BestSchool.Common.UpLoadFile.FileSave/FileSaveImage/FileChunkSave/FileMergeSave)。 - /// 存储约定:物理根目录 = Config.FilePath(≈旧 ~/UploadFile/),相对路径仍存 /UploadFile/{AppType}/{yyyyMMdd}/{guid}{ext} + /// BestSchool.Common.upload.FileSave/FileSaveImage/FileChunkSave/FileMergeSave)。 + /// 存储约定:物理根目录 = Config.FilePath(≈旧 ~/upload/),相对路径仍存 /upload/{AppType}/{yyyyMMdd}/{guid}{ext} /// (与旧库数据格式一致,兼容历史记录);host 取 Config.FileWebPath(≈旧 AuthConfig.weboa_url)。 /// 旧 ToOfficeHelper.OfficeConvertToPDF(Office COM 转 PDF)新项目缺失,降级:上传不做转 PDF, /// 预览时本地无 .pdf 则降级 officeapps.live.com 在线预览。 @@ -21,10 +21,10 @@ namespace YhCore.Service.Interfaces /// 存储附件信息(旧 FileSaveEnclosure:Common_UpFiles 落库,返回 SerID;文件名非法字符替换为 _)。 Task SaveEnclosureAsync(FileObj file, string appType); - /// 单文件上传(旧 UpLoadFile.FileSave:扩展名白名单 + 保存 + 返回 FileObj)。 + /// 单文件上传(旧 upload.FileSave:扩展名白名单 + 保存 + 返回 FileObj)。 Task SaveFileAsync(string appType, IFormFile file); - /// 图片多文件上传(旧 UpLoadFile.FileSaveImage:jpg/gif/png/jpeg)。 + /// 图片多文件上传(旧 upload.FileSaveImage:jpg/gif/png/jpeg)。 Task> SaveFileImageAsync(string appType, IFormFileCollection files); /// 保存分片(旧 FileChunkSave:临时目录 {guid}/ 下按索引存块)。 @@ -33,7 +33,7 @@ namespace YhCore.Service.Interfaces /// 合并分片(旧 FileMergeSave:按块合并 → 正式目录 + FileObj)。 Task MergeSaveAsync(string appType, string guid, string fileName); - /// 相对路径 → 物理路径(fileurl 以 /UploadFile/ 开头 → Config.FilePath + 子路径)。 + /// 相对路径 → 物理路径(fileurl 以 /upload/ 开头 → Config.FilePath + 子路径)。 string MapPhysicalPath(string fileUrl); } } diff --git a/src/YhCore.WebApi/appsettings.json b/src/YhCore.WebApi/appsettings.json index 55b2b7c..b3d077a 100644 --- a/src/YhCore.WebApi/appsettings.json +++ b/src/YhCore.WebApi/appsettings.json @@ -10,7 +10,7 @@ "Redis": { "ConnectionString": "localhost:6379,defaultDatabase=0" }, - "FILE_PATH": "UploadFile", + "FILE_PATH": "upload", "FILE_WEB_PATH": "", "wkhtmltopdf_path": "", "yh": {