From 361e8babc2e2b25eab34d8031ea3b58846498bac Mon Sep 17 00:00:00 2001
From: qwj <qwjzorro@163.com>
Date: 星期三, 02 八月 2023 17:04:01 +0800
Subject: [PATCH] 更新文件服务

---
 DocumentFile.Service/Controllers/DocumentController.cs |   57 +++++++++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 51 insertions(+), 6 deletions(-)

diff --git a/DocumentFile.Service/Controllers/DocumentController.cs b/DocumentFile.Service/Controllers/DocumentController.cs
index 7fa7452..57da744 100644
--- a/DocumentFile.Service/Controllers/DocumentController.cs
+++ b/DocumentFile.Service/Controllers/DocumentController.cs
@@ -20,16 +20,58 @@
         }
 
         /// <summary>
-        /// 涓婁紶鏂囦欢锛坵ord锛�
+        /// 涓婁紶鏂囦欢妯℃澘锛坉oc銆乨ocx锛�
         /// </summary>
+        /// <param name="code">绉熸埛鍞竴鏍囪瘑code</param>
+        /// <param name="formFile">鏂囦欢</param>
         /// <returns></returns>
         [HttpPost]
-        public async Task<IActionResult> UploadDocument(IFormFile formFile)
+        public async Task<IActionResult> UploadDocTemplate([FromForm]string code,IFormFile formFile)
         {
             ReturnMsg msg = new ReturnMsg();
             if(formFile.Length>0)
             {
-                msg = await this._uploadService.HandleUploadWordFile(formFile);                
+                msg = await this._uploadService.HandleUploadTemplateFile(formFile,code);                
+            }
+            else
+            {
+                msg.error = "璇蜂笂浼犳枃浠�";
+            }
+
+            return new JsonResult(msg);
+        }
+
+        /// <summary>
+        /// 涓婁紶鏂囦欢锛坉oc銆乨ocx锛�
+        /// </summary>
+        /// <returns></returns>
+        [HttpPost]
+        public async Task<IActionResult> UploadDocInstance([FromForm] string code, IFormFile formFile)
+        {
+            ReturnMsg msg = new ReturnMsg();
+            if (formFile.Length > 0)
+            {
+                msg = await this._uploadService.HandleUploadWordFile(formFile, code);
+            }
+            else
+            {
+                msg.error = "璇蜂笂浼犳枃浠�";
+            }
+
+            return new JsonResult(msg);
+        }
+
+        /// <summary>
+        /// 涓婁紶鍥剧墖锛坖pg銆乯peg銆乸ng锛�
+        /// </summary>
+        /// <returns></returns>
+        [HttpPost]
+        public async Task<IActionResult> UploadPhoto([FromForm] string code, IFormFile formFile)
+        {
+            ReturnMsg msg = new ReturnMsg();
+            if (formFile.Length > 0)
+            {
+                msg = await this._uploadService.HandleUploadImageFile(formFile, code);
             }
             else
             {
@@ -45,15 +87,18 @@
         /// <param name="url"></param>
         /// <returns></returns>
         [HttpPost]
-        public IActionResult Download([FromBody] string url)
+        public IActionResult Download([FromForm] string url)
         {
             try
             {
                 if (!string.IsNullOrEmpty(url))
                 {
                     var _webRootPath = AppDomain.CurrentDomain.BaseDirectory;
-
-                    return new FileStreamResult(new FileStream(_webRootPath + url, FileMode.Open), "application/octet-stream");// { FileDownloadName = FileName };
+                    var path = _webRootPath + url;
+                    if (System.IO.File.Exists(path))
+                    {
+                        return new FileStreamResult(new FileStream(path, FileMode.Open), "application/octet-stream");// { FileDownloadName = FileName };
+                    }
                 }
             }
             catch (Exception ex)

--
Gitblit v1.9.1