From 5b6a33b320199d6d7c08d7e905f5488d59e2d589 Mon Sep 17 00:00:00 2001 From: liaoxujun@qq.com <liaoxujun@qq.com> Date: 星期一, 21 八月 2023 14:58:36 +0800 Subject: [PATCH] 修正INITQ --- DocumentFile.Service/Controllers/DocumentController.cs | 119 ++++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 109 insertions(+), 10 deletions(-) diff --git a/DocumentFile.Service/Controllers/DocumentController.cs b/DocumentFile.Service/Controllers/DocumentController.cs index 7fa7452..ad042ab 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,17 +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> - /// 涓婁紶鏂囦欢锛坵ord锛� + /// 涓婁紶鏂囦欢锛坉oc銆乨ocx锛� + /// 鏈湴鎸囧畾璺緞 /// </summary> /// <returns></returns> [HttpPost] - public async Task<IActionResult> UploadDocument(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.HandleUploadWordFile(formFile); + msg = await this._uploadService.HandleUploadWordFile(formFile,code,path); } else { @@ -40,20 +61,98 @@ } /// <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 + { + msg.error = "璇蜂笂浼犳枃浠�"; + } + + return new JsonResult(msg); + } + + /// <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> /// <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