From 4c4ae7711f7886810735ce7152ec62baf523ddb3 Mon Sep 17 00:00:00 2001
From: qwj <qwjzorro@163.com>
Date: 星期三, 16 八月 2023 16:37:44 +0800
Subject: [PATCH] 增加删除文件接口

---
 DocumentFile.Service/Controllers/DocumentController.cs |   39 ++++++++++++++++++++++++++++++++++++---
 1 files changed, 36 insertions(+), 3 deletions(-)

diff --git a/DocumentFile.Service/Controllers/DocumentController.cs b/DocumentFile.Service/Controllers/DocumentController.cs
index 1046bff..640da0c 100644
--- a/DocumentFile.Service/Controllers/DocumentController.cs
+++ b/DocumentFile.Service/Controllers/DocumentController.cs
@@ -1,6 +1,4 @@
-锘縰sing Microsoft.AspNetCore.Http;
-using Microsoft.AspNetCore.Mvc;
-using System.ComponentModel.DataAnnotations;
+锘縰sing Microsoft.AspNetCore.Mvc;
 
 namespace DocumentFile.Service.Controllers
 {
@@ -82,6 +80,41 @@
         }
 
         /// <summary>
+        /// 鍒犻櫎鏂囦欢
+        /// </summary>
+        /// <param name="delurl"></param>
+        /// <returns></returns>
+        [HttpPost]
+        public IActionResult DeleteFile([FromForm] string[] delurl)
+        {
+            ReturnMsg msg = new ReturnMsg();
+            try
+            {
+                if(delurl!=null && delurl.Length > 0)
+                {
+                    var dir = AppDomain.CurrentDomain.BaseDirectory;
+                    foreach (var item in delurl)
+                    {
+                        if (!string.IsNullOrEmpty(item))
+                        {
+                            var path = dir + item;
+                            if (System.IO.File.Exists(path))
+                            {
+                                System.IO.File.Delete(path);
+                            }
+                        }
+                    }
+                    msg.code = 1;
+                }                
+            }
+            catch (Exception ex)
+            {
+                NLogProvider.GetInstance().Error(ex);
+            }
+            return new JsonResult(msg);
+        }
+
+        /// <summary>
         /// 涓嬭浇鏂囦欢
         /// </summary>
         /// <param name="url"></param>

--
Gitblit v1.9.1