From 90858c80d9921b555119f41060c1f883f6e6ffc5 Mon Sep 17 00:00:00 2001 From: username@email.com <yzy2002yzy@163.com> Date: 星期四, 26 十二月 2024 12:49:35 +0800 Subject: [PATCH] 提交 --- DocumentFile.Service/Controllers/DocumentController.cs | 111 ++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 101 insertions(+), 10 deletions(-) diff --git a/DocumentFile.Service/Controllers/DocumentController.cs b/DocumentFile.Service/Controllers/DocumentController.cs index 57da744..3521756 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 { @@ -19,19 +17,40 @@ _uploadService = uploadService; } + ///// <summary> + ///// 涓婁紶鏂囦欢妯℃澘锛坉oc銆乨ocx锛� + ///// </summary> + ///// <param name="code">绉熸埛鍞竴鏍囪瘑code</param> + ///// <param name="formFile">鏂囦欢</param> + ///// <returns></returns> + //[HttpPost] + //public async Task<IActionResult> UploadDocTemplate([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> - /// 涓婁紶鏂囦欢妯℃澘锛坉oc銆乨ocx锛� + /// 涓婁紶鏂囦欢锛坉oc銆乨ocx锛� + /// 鏈湴鎸囧畾璺緞 /// </summary> - /// <param name="code">绉熸埛鍞竴鏍囪瘑code</param> - /// <param name="formFile">鏂囦欢</param> /// <returns></returns> [HttpPost] - public async Task<IActionResult> UploadDocTemplate([FromForm]string code,IFormFile formFile) + public async Task<IActionResult> UploadDocWithPath([FromForm]string code, [FromForm] string path, IFormFile formFile) { ReturnMsg msg = new ReturnMsg(); - if(formFile.Length>0) + if (formFile.Length > 0) { - msg = await this._uploadService.HandleUploadTemplateFile(formFile,code); + msg = await this._uploadService.HandleUploadWordFile(formFile,code,path); } else { @@ -51,7 +70,7 @@ ReturnMsg msg = new ReturnMsg(); if (formFile.Length > 0) { - msg = await this._uploadService.HandleUploadWordFile(formFile, code); + msg = await this._uploadService.HandleUploadWordFile(formFile, code, ""); } else { @@ -82,6 +101,78 @@ } /// <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="delurl"></param> + /// <returns></returns> + [HttpPost] + public IActionResult FileLastWriteTime([FromForm] string delurl) + { + ReturnMsg msg = new ReturnMsg(); + try + { + if (delurl != null && delurl.Length > 0) + { + var dir = AppDomain.CurrentDomain.BaseDirectory; + + if (!string.IsNullOrEmpty(delurl)) + { + var path = dir + delurl; + if (System.IO.File.Exists(path)) + { + var lastWriteTime = System.IO.File.GetLastWriteTime(path); + msg.lastWriteTime = lastWriteTime.ToString(); + } + } + msg.code = 1; + } + } + catch (Exception ex) + { + NLogProvider.GetInstance().Error(ex); + } + return new JsonResult(msg); + } + + + /// <summary> /// 涓嬭浇鏂囦欢 /// </summary> /// <param name="url"></param> -- Gitblit v1.9.1