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 | 45 +++++++++++++++++++++++++++++++++++++++------ 1 files changed, 39 insertions(+), 6 deletions(-) diff --git a/DocumentFile.Service/Controllers/DocumentController.cs b/DocumentFile.Service/Controllers/DocumentController.cs index 57da744..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 { @@ -31,7 +29,7 @@ ReturnMsg msg = new ReturnMsg(); if(formFile.Length>0) { - msg = await this._uploadService.HandleUploadTemplateFile(formFile,code); + msg = await this._uploadService.HandleUploadWordFile(formFile,code,""); } else { @@ -46,12 +44,12 @@ /// </summary> /// <returns></returns> [HttpPost] - public async Task<IActionResult> UploadDocInstance([FromForm] string code, IFormFile formFile) + public async Task<IActionResult> UploadDocInstance([FromForm] string code, [FromForm] string path, IFormFile formFile) { ReturnMsg msg = new ReturnMsg(); if (formFile.Length > 0) { - msg = await this._uploadService.HandleUploadWordFile(formFile, code); + msg = await this._uploadService.HandleUploadWordFile(formFile, code,path); } else { @@ -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