You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
139 lines
4.0 KiB
C#
139 lines
4.0 KiB
C#
using DS.Module.Core;
|
|
using DS.Module.Core.Data;
|
|
using DS.WMS.Core.Code.Dtos;
|
|
using DS.WMS.Core.Op.Dtos;
|
|
using DS.WMS.Core.Op.Entity;
|
|
using DS.WMS.Core.Op.Interface;
|
|
using DS.WMS.Core.Sys.Dtos;
|
|
using DS.WMS.Core.Sys.Interface;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using NPOI.HPSF;
|
|
using SharpCompress.Common;
|
|
using SixLabors.ImageSharp.Drawing;
|
|
using System.IO;
|
|
using System.Text;
|
|
using System.Web;
|
|
|
|
namespace DS.WMS.MainApi.Controllers;
|
|
|
|
/// <summary>
|
|
/// 业务附件模块
|
|
/// </summary>
|
|
public class OpFileController : ApiController
|
|
{
|
|
private readonly IOpFileService _invokeService;
|
|
|
|
/// <summary>
|
|
/// 构造函数
|
|
/// </summary>
|
|
/// <param name="invokeService"></param>
|
|
public OpFileController(IOpFileService invokeService)
|
|
{
|
|
_invokeService = invokeService;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 添加附件
|
|
/// </summary>
|
|
/// <param name="file">文件信息</param>
|
|
/// <param name="req">业务附件请求实体</param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
[Route("AddFile")]
|
|
public async Task<DataResult<string>> AddFile(IFormFile file, [FromForm] OpFileReq req)
|
|
{
|
|
var res = _invokeService.AddFile( file, req);
|
|
return await res;
|
|
}
|
|
/// <summary>
|
|
/// 多附件上传
|
|
/// </summary>
|
|
/// <param name="formCollection">文件信息</param>
|
|
/// <param name="req">业务附件请求实体</param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
[Route("AddMultiFiles")]
|
|
public async Task<DataResult<string>> AddMultiFiles(IFormCollection formCollection, [FromForm] OpFileReq req)
|
|
{
|
|
var res = _invokeService.AddMultiFiles(formCollection, req);
|
|
return await res;
|
|
}
|
|
/// <summary>
|
|
/// 获取业务附件
|
|
/// </summary>
|
|
/// <param name="id">业务id</param>
|
|
/// <returns></returns>
|
|
[HttpGet]
|
|
[Route("GetOpFileList")]
|
|
public DataResult<List<OpFileRes>> GetOpFileList([FromQuery] string id)
|
|
{
|
|
var res = _invokeService.GetOpFileList(id);
|
|
return res;
|
|
}
|
|
/// <summary>
|
|
/// 批量删除附件
|
|
/// </summary>
|
|
/// <param name="req"></param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
[Route("BatchDelFiles")]
|
|
public async Task<DataResult<string>> BatchDelFiles([FromBody]IdModel req)
|
|
{
|
|
var res = _invokeService.BatchDelFiles(req);
|
|
return await res;
|
|
}
|
|
|
|
///// <summary>
|
|
///// 下载业务附件
|
|
///// </summary>
|
|
///// <param name="id">附件id</param>
|
|
///// <returns></returns>
|
|
//[HttpGet]
|
|
//[Route("DownloadOpFile")]
|
|
//public async Task<IActionResult> DownloadOpFile([FromQuery] string id)
|
|
//{
|
|
// var res = await _invokeService.DownloadFile(id);
|
|
// return res;
|
|
//}
|
|
|
|
/// <summary>
|
|
/// 下载业务附件
|
|
/// </summary>
|
|
/// <param name="id">附件id</param>
|
|
/// <returns></returns>
|
|
[HttpGet]
|
|
[Route("DownloadOpFileInfo")]
|
|
[ProducesResponseType(typeof(FileResult), StatusCodes.Status200OK)]
|
|
//[AllowAnonymous]
|
|
public async Task<IActionResult> DownloadOpFileInfo([FromQuery] string id)
|
|
{
|
|
var res = _invokeService.GetOpFileDownLoad(id);
|
|
//var fileName = HttpUtility.UrlEncode(res.Data.FileName, Encoding.GetEncoding("UTF-8"));
|
|
var path = res.Data.FilePath;
|
|
var fileName = res.Data.FileName;
|
|
|
|
byte[] byteArr = System.IO.File.ReadAllBytes(res.Data.FilePath);
|
|
string mimeType = "application/octet-stream";
|
|
return new FileContentResult(byteArr, mimeType)
|
|
{
|
|
FileDownloadName = fileName
|
|
};
|
|
|
|
}
|
|
/// <summary>
|
|
/// 多附件上传-测试
|
|
/// </summary>
|
|
/// <param name="formCollection">文件信息</param>
|
|
/// <param name="req">业务附件请求实体</param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
[AllowAnonymous]
|
|
[Route("AddMultiFilesTest")]
|
|
public async Task<DataResult<string>> AddMultiFilesTest(IFormCollection formCollection, [FromForm] OpFileReq req)
|
|
{
|
|
var res = _invokeService.AddMultiFilesTest(formCollection, req);
|
|
return await res;
|
|
}
|
|
} |