booking_auth_dev
wet 2 years ago
commit 3f283ba9b6

@ -0,0 +1,27 @@
using Furion.ConfigurableOptions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Myshipping.Application.ConfigOption
{
public class PrintTemplateOptions : IConfigurableOptions
{
/// <summary>
/// 类型
/// </summary>
public BookingFileStoreType type { get; set; }
/// <summary>
/// 路径
/// </summary>
public string path { get; set; }
/// <summary>
/// 类型
/// </summary>
public string[] fileType { get; set; }
}
}

@ -0,0 +1,35 @@
using System;
using SqlSugar;
using System.ComponentModel;
using Myshipping.Core.Entity;
namespace Myshipping.Application.Entity
{
/// <summary>
/// 订舱打印模板
/// </summary>
[SugarTable("booking_print_template")]
[Description("订舱打印模板")]
public class BookingPrintTemplate : DBEntityTenant
{
/// <summary>
/// 模板类型
/// </summary>
public long? TypeId { get; set; }
/// <summary>
/// 类型名称
/// </summary>
public string TypeName { get; set; }
/// <summary>
/// 文件路径
/// </summary>
public string FilePath { get; set; }
/// <summary>
/// 文件名称
/// </summary>
public string FileName { get; set; }
/// <summary>
/// 租户名称
/// </summary>
public string TenantName { get; set; }
}
}

@ -8,7 +8,7 @@ namespace Myshipping.Application.Entity
///
/// </summary>
[SugarTable("booking_template")]
[Description("订舱模板")]
[Description("订舱收发通模板")]
public class BookingTemplate : DBEntityTenant
{
/// <summary>

@ -21,4 +21,13 @@ namespace Myshipping.Application
[Description("第二通知人")]
Notifypart2 = 40,
}
public enum BookingFileStoreType
{
[Description("本地文件夹")]
Local = 10,
[Description("NAS盘")]
Nas = 20,
}
}

@ -4,6 +4,21 @@
<name>Myshipping.Application</name>
</assembly>
<members>
<member name="P:Myshipping.Application.ConfigOption.PrintTemplateOptions.type">
<summary>
类型
</summary>
</member>
<member name="P:Myshipping.Application.ConfigOption.PrintTemplateOptions.path">
<summary>
路径
</summary>
</member>
<member name="P:Myshipping.Application.ConfigOption.PrintTemplateOptions.fileType">
<summary>
类型
</summary>
</member>
<member name="T:Myshipping.Application.Entity.BookingCtn">
<summary>
@ -904,6 +919,36 @@
主单ID
</summary>
</member>
<member name="T:Myshipping.Application.Entity.BookingPrintTemplate">
<summary>
订舱打印模板
</summary>
</member>
<member name="P:Myshipping.Application.Entity.BookingPrintTemplate.TypeId">
<summary>
模板类型
</summary>
</member>
<member name="P:Myshipping.Application.Entity.BookingPrintTemplate.TypeName">
<summary>
类型名称
</summary>
</member>
<member name="P:Myshipping.Application.Entity.BookingPrintTemplate.FilePath">
<summary>
文件路径
</summary>
</member>
<member name="P:Myshipping.Application.Entity.BookingPrintTemplate.FileName">
<summary>
文件名称
</summary>
</member>
<member name="P:Myshipping.Application.Entity.BookingPrintTemplate.TenantName">
<summary>
租户名称
</summary>
</member>
<member name="T:Myshipping.Application.Entity.BookingTemplate">
<summary>
@ -3239,6 +3284,151 @@
订舱主表输出参数
</summary>
</member>
<member name="T:Myshipping.Application.BookingPrintTemplateService">
<summary>
订舱打印模板服务
</summary>
</member>
<member name="M:Myshipping.Application.BookingPrintTemplateService.Page(Myshipping.Application.QueryBookingPrintTemplateInput)">
<summary>
分页查询订舱打印模板
</summary>
<param name="input"></param>
<returns></returns>
</member>
<member name="M:Myshipping.Application.BookingPrintTemplateService.Add(Microsoft.AspNetCore.Http.IFormFile,Myshipping.Application.AddBookingPrintTemplateInput)">
<summary>
增加订舱打印模板
</summary>
<param name="input"></param>
<returns></returns>
</member>
<member name="M:Myshipping.Application.BookingPrintTemplateService.Update(Microsoft.AspNetCore.Http.IFormFile,Myshipping.Application.UpdateBookingPrintTemplateInput)">
<summary>
更新订舱打印模板
</summary>
<param name="input"></param>
<returns></returns>
</member>
<member name="M:Myshipping.Application.BookingPrintTemplateService.Delete(Myshipping.Application.GetBookingPrintTemplateInput)">
<summary>
删除订舱打印模板
</summary>
<param name="input"></param>
<returns></returns>
</member>
<member name="M:Myshipping.Application.BookingPrintTemplateService.Get(Myshipping.Application.GetBookingPrintTemplateInput)">
<summary>
获取订舱打印模板
</summary>
<param name="input"></param>
<returns></returns>
</member>
<member name="T:Myshipping.Application.BookingPrintTemplateInput">
<summary>
订舱打印模板输入参数
</summary>
</member>
<member name="P:Myshipping.Application.BookingPrintTemplateInput.TypeId">
<summary>
模板类型
</summary>
</member>
<member name="P:Myshipping.Application.BookingPrintTemplateInput.TypeName">
<summary>
类型名称
</summary>
</member>
<member name="P:Myshipping.Application.BookingPrintTemplateInput.TenantId">
<summary>
租户Id
</summary>
</member>
<member name="P:Myshipping.Application.BookingPrintTemplateInput.TenantName">
<summary>
租户名称
</summary>
</member>
<member name="T:Myshipping.Application.AddBookingPrintTemplateInput">
<summary>
订舱打印模板新增输入参数
</summary>
</member>
<member name="T:Myshipping.Application.UpdateBookingPrintTemplateInput">
<summary>
订舱打印模板修改输入参数
</summary>
</member>
<member name="P:Myshipping.Application.UpdateBookingPrintTemplateInput.Id">
<summary>
主键Id
</summary>
</member>
<member name="T:Myshipping.Application.GetBookingPrintTemplateInput">
<summary>
订舱打印模板获取(删除)输入参数
</summary>
</member>
<member name="P:Myshipping.Application.GetBookingPrintTemplateInput.Id">
<summary>
主键Id
</summary>
</member>
<member name="T:Myshipping.Application.QueryBookingPrintTemplateInput">
<summary>
订舱打印模板查询输入参数
</summary>
</member>
<member name="P:Myshipping.Application.QueryBookingPrintTemplateInput.TypeName">
<summary>
类型名称
</summary>
</member>
<member name="P:Myshipping.Application.QueryBookingPrintTemplateInput.FileName">
<summary>
文件名称
</summary>
</member>
<member name="P:Myshipping.Application.QueryBookingPrintTemplateInput.TenantName">
<summary>
租户名称
</summary>
</member>
<member name="T:Myshipping.Application.BookingPrintTemplateOutput">
<summary>
订舱打印模板输出参数
</summary>
</member>
<member name="P:Myshipping.Application.BookingPrintTemplateOutput.Id">
<summary>
主键Id
</summary>
</member>
<member name="P:Myshipping.Application.BookingPrintTemplateOutput.TypeId">
<summary>
模板类型
</summary>
</member>
<member name="P:Myshipping.Application.BookingPrintTemplateOutput.TypeName">
<summary>
类型名称
</summary>
</member>
<member name="P:Myshipping.Application.BookingPrintTemplateOutput.FilePath">
<summary>
文件路径
</summary>
</member>
<member name="P:Myshipping.Application.BookingPrintTemplateOutput.FileName">
<summary>
文件名称
</summary>
</member>
<member name="P:Myshipping.Application.BookingPrintTemplateOutput.TenantId">
<summary>
租户Id
</summary>
</member>
<member name="T:Myshipping.Application.BookingTemplateService">
<summary>
订舱模板服务

@ -0,0 +1,195 @@
using Myshipping.Core;
using Furion.DependencyInjection;
using Furion.DynamicApiController;
using Mapster;
using Microsoft.AspNetCore.Mvc;
using SqlSugar;
using System.Linq;
using System.Threading.Tasks;
using Myshipping.Application.Entity;
using Microsoft.Extensions.Logging;
using Microsoft.AspNetCore.Http;
using Furion;
using Myshipping.Application.ConfigOption;
using System.IO;
using Yitter.IdGenerator;
using Furion.FriendlyException;
namespace Myshipping.Application
{
/// <summary>
/// 订舱打印模板服务
/// </summary>
[ApiDescriptionSettings("Application", Name = "BookingPrintTemplate", Order = 1)]
public class BookingPrintTemplateService : IBookingPrintTemplateService, IDynamicApiController, ITransient
{
private readonly SqlSugarRepository<BookingPrintTemplate> _rep;
private readonly ILogger<BookingPrintTemplate> _logger;
public BookingPrintTemplateService(SqlSugarRepository<BookingPrintTemplate> rep, ILogger<BookingPrintTemplate> logger)
{
_rep = rep;
_logger = logger;
}
/// <summary>
/// 分页查询订舱打印模板
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpGet("/BookingPrintTemplate/page")]
public async Task<dynamic> Page([FromQuery] QueryBookingPrintTemplateInput input)
{
_rep.Context.QueryFilter.Clear();
var entities = await _rep.AsQueryable()
.WhereIF(!string.IsNullOrWhiteSpace(input.TypeName), u => u.TypeName.Contains(input.TypeName.Trim()))
.WhereIF(!string.IsNullOrWhiteSpace(input.FileName), u => u.FileName.Contains(input.FileName.Trim()))
.WhereIF(!string.IsNullOrWhiteSpace(input.TenantName), u => u.FileName.Contains(input.TenantName.Trim()))
.ToPagedListAsync(input.PageNo, input.PageSize);
return entities.XnPagedResult();
}
/// <summary>
/// 增加订舱打印模板
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("/BookingPrintTemplate/add")]
public async Task Add(IFormFile file, [FromForm] AddBookingPrintTemplateInput input)
{
//未上传打印模板文件
if (file == null || file.Length == 0)
{
throw Oops.Oh(ErrorCode.BOOK113);
}
var opt = App.GetOptions<PrintTemplateOptions>();
var originalFilename = file.FileName; // 文件原始名称
var fileSuffix = Path.GetExtension(file.FileName).ToLower(); // 文件后缀
if (!opt.fileType.Contains(fileSuffix))
{
throw Oops.Oh(ErrorCode.BOOK114);
}
var filePath = opt.path;
if (opt.type == BookingFileStoreType.Local)
{
filePath = Path.Combine(App.WebHostEnvironment.WebRootPath, opt.path);
}
if (!Directory.Exists(filePath))
Directory.CreateDirectory(filePath);
// 先存库获取Id
var id = YitIdHelper.NextId();
var fileSaveName = $"{id}{fileSuffix}".ToLower();
var fileFullPath = Path.Combine(filePath, fileSaveName).ToLower();
var newFile = new BookingPrintTemplate
{
Id = id,
FileName = originalFilename,
FilePath = fileFullPath,
TypeId = input.TypeId,
TypeName = input.TypeName,
TenantId = input.TenantId,
TenantName = input.TenantName,
};
await _rep.InsertAsync(newFile);
using (var stream = File.Create(fileFullPath))
{
await file.CopyToAsync(stream);
}
}
/// <summary>
/// 更新订舱打印模板
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("/BookingPrintTemplate/edit")]
public async Task Update(IFormFile file, [FromForm] UpdateBookingPrintTemplateInput input)
{
//未上传打印模板文件
if (file == null || file.Length == 0)
{
throw Oops.Oh(ErrorCode.BOOK113);
}
var opt = App.GetOptions<PrintTemplateOptions>();
var originalFilename = file.FileName; // 文件原始名称
var fileSuffix = Path.GetExtension(file.FileName).ToLower(); // 文件后缀
if (!opt.fileType.Contains(fileSuffix))
{
throw Oops.Oh(ErrorCode.BOOK114);
}
_rep.Context.QueryFilter.Clear();
var entity = _rep.FirstOrDefault(x => x.Id == input.Id);
if (entity == null)
{
throw Oops.Oh(ErrorCode.BOOK112);
}
var filePath = opt.path;
if (opt.type == BookingFileStoreType.Local)
{
filePath = Path.Combine(App.WebHostEnvironment.WebRootPath, opt.path);
}
if (!Directory.Exists(filePath))
Directory.CreateDirectory(filePath);
// 先存库获取Id
var fileSaveName = $"{entity.Id}{fileSuffix}".ToLower();
var fileFullPath = Path.Combine(filePath, fileSaveName).ToLower();
entity.FileName = originalFilename;
entity.FilePath = fileFullPath;
await _rep.UpdateAsync(entity);
using (var stream = File.Create(fileFullPath))
{
await file.CopyToAsync(stream);
}
}
/// <summary>
/// 删除订舱打印模板
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("/BookingPrintTemplate/delete")]
public async Task Delete(GetBookingPrintTemplateInput input)
{
_rep.Context.QueryFilter.Clear();
var entity = await _rep.FirstOrDefaultAsync(u => u.Id == input.Id);
await _rep.DeleteAsync(entity);
}
/// <summary>
/// 获取订舱打印模板
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpGet("/BookingPrintTemplate/detail")]
public async Task<BookingPrintTemplate> Get([FromQuery] GetBookingPrintTemplateInput input)
{
return await _rep.FirstOrDefaultAsync(u => u.Id == input.Id);
}
///// <summary>
///// 获取订舱打印模板列表
///// </summary>
///// <param name="input"></param>
///// <returns></returns>
//[HttpGet("/BookingPrintTemplate/list")]
//public async Task<dynamic> List([FromQuery] QueryBookingPrintTemplateInput input)
//{
// return await _rep.ToListAsync();
//}
}
}

@ -0,0 +1,89 @@
using Myshipping.Core;
using System;
using System.ComponentModel.DataAnnotations;
namespace Myshipping.Application
{
/// <summary>
/// 订舱打印模板输入参数
/// </summary>
public class BookingPrintTemplateInput
{
/// <summary>
/// 模板类型
/// </summary>
public virtual long TypeId { get; set; }
/// <summary>
/// 类型名称
/// </summary>
public virtual string TypeName { get; set; }
/// <summary>
/// 租户Id
/// </summary>
public virtual long TenantId { get; set; }
/// <summary>
/// 租户名称
/// </summary>
public string TenantName { get; set; }
}
/// <summary>
/// 订舱打印模板新增输入参数
/// </summary>
public class AddBookingPrintTemplateInput : BookingPrintTemplateInput
{
}
/// <summary>
/// 订舱打印模板修改输入参数
/// </summary>
public class UpdateBookingPrintTemplateInput
{
/// <summary>
/// 主键Id
/// </summary>
[Required(ErrorMessage = "主键Id不能为空")]
public long Id { get; set; }
}
/// <summary>
/// 订舱打印模板获取(删除)输入参数
/// </summary>
public class GetBookingPrintTemplateInput
{
/// <summary>
/// 主键Id
/// </summary>
[Required(ErrorMessage = "主键Id不能为空")]
public long Id { get; set; }
}
/// <summary>
/// 订舱打印模板查询输入参数
/// </summary>
public class QueryBookingPrintTemplateInput : PageInputBase
{
/// <summary>
/// 类型名称
/// </summary>
public virtual string TypeName { get; set; }
/// <summary>
/// 文件名称
/// </summary>
public virtual string FileName { get; set; }
/// <summary>
/// 租户名称
/// </summary>
public string TenantName { get; set; }
}
}

@ -0,0 +1,41 @@
using System;
namespace Myshipping.Application
{
/// <summary>
/// 订舱打印模板输出参数
/// </summary>
public class BookingPrintTemplateOutput
{
/// <summary>
/// 主键Id
/// </summary>
public long Id { get; set; }
/// <summary>
/// 模板类型
/// </summary>
public long TypeId { get; set; }
/// <summary>
/// 类型名称
/// </summary>
public string TypeName { get; set; }
/// <summary>
/// 文件路径
/// </summary>
public string FilePath { get; set; }
/// <summary>
/// 文件名称
/// </summary>
public string FileName { get; set; }
/// <summary>
/// 租户Id
/// </summary>
public long TenantId { get; set; }
}
}

@ -0,0 +1,18 @@
using Myshipping.Core;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;
using Myshipping.Application.Entity;
using Microsoft.AspNetCore.Http;
namespace Myshipping.Application
{
public interface IBookingPrintTemplateService
{
Task<dynamic> Page([FromQuery] QueryBookingPrintTemplateInput input);
Task Add(IFormFile file, [FromForm] AddBookingPrintTemplateInput input);
Task Update(IFormFile file, [FromForm] UpdateBookingPrintTemplateInput input);
Task Delete(GetBookingPrintTemplateInput input);
Task<BookingPrintTemplate> Get([FromQuery] GetBookingPrintTemplateInput input);
//Task<dynamic> List([FromQuery] QueryBookingPrintTemplateInput input);
}
}

@ -35,7 +35,7 @@ namespace Myshipping.Application
[HttpGet("/BookingTemplate/page")]
public async Task<dynamic> Page([FromQuery] QueryBookingTemplateInput input)
{
var entities = await _rep.AsQueryable()
var entities = await _rep.AsQueryable()
.WhereIF(!string.IsNullOrEmpty(input.Title), u => u.Title.Contains(input.Title))
.WhereIF(input.Type.HasValue, u => u.Type == input.Type)
.ToPagedListAsync(input.PageNo, input.PageSize);

@ -1,3 +1,8 @@
{
//
"PrintTemplate": {
"type": "Local", //NasLocal
"path": "Upload/PrintTemplate",
"fileType": [ ".frx" ]
}
}

@ -407,15 +407,33 @@ public enum ErrorCode
#region 订舱
/// <summary>
/// 已存在同类型且名称相同的模板
/// 已存在同类型且名称相同的收发通模板
/// </summary>
[ErrorCodeItemMetadata("已存在同类型且名称相同的模板")]
[ErrorCodeItemMetadata("已存在同类型且名称相同的收发通模板")]
BOOK101,
/// <summary>
/// 模板不存在
/// 收发通模板不存在
/// </summary>
[ErrorCodeItemMetadata("模板不存在")]
[ErrorCodeItemMetadata("收发通模板不存在")]
BOOK111,
/// <summary>
/// 打印模板不存在
/// </summary>
[ErrorCodeItemMetadata("打印模板不存在")]
BOOK112,
/// <summary>
/// 未上传模板文件
/// </summary>
[ErrorCodeItemMetadata("未上传模板文件")]
BOOK113,
/// <summary>
/// 不允许的文件类型
/// </summary>
[ErrorCodeItemMetadata("不允许的文件类型")]
BOOK114,
#endregion
}

@ -3412,12 +3412,27 @@
</member>
<member name="F:Myshipping.Core.ErrorCode.BOOK101">
<summary>
已存在同类型且名称相同的模板
已存在同类型且名称相同的收发通模板
</summary>
</member>
<member name="F:Myshipping.Core.ErrorCode.BOOK111">
<summary>
模板不存在
收发通模板不存在
</summary>
</member>
<member name="F:Myshipping.Core.ErrorCode.BOOK112">
<summary>
打印模板不存在
</summary>
</member>
<member name="F:Myshipping.Core.ErrorCode.BOOK113">
<summary>
未上传模板文件
</summary>
</member>
<member name="F:Myshipping.Core.ErrorCode.BOOK114">
<summary>
不允许的文件类型
</summary>
</member>
<member name="T:Myshipping.Core.FileExtensionEnum">

@ -334,7 +334,9 @@ public static class SqlSugarSetup
}
if (entityInfo.PropertyName == "TenantName")
{
entityInfo.SetValue(App.User.FindFirst(ClaimConst.CLAINM_TENANT_NAME)?.Value);
var tenantName = ((dynamic)entityInfo.EntityValue).TenantName;
if (string.IsNullOrEmpty(tenantName))
entityInfo.SetValue(App.User.FindFirst(ClaimConst.CLAINM_TENANT_NAME)?.Value);
}
if (entityInfo.PropertyName == "CreatedUserId")
{

@ -21,6 +21,7 @@ using Furion.Logging;
using System.Collections.Generic;
using Newtonsoft.Json.Serialization;
using Newtonsoft.Json;
using Myshipping.Application.ConfigOption;
namespace Myshipping.Web.Core;
@ -38,6 +39,7 @@ public class Startup : AppStartup
services.AddConfigurableOptions<UploadFileOptions>();
services.AddConfigurableOptions<OAuthOptions>();
services.AddConfigurableOptions<EncryptKeyOptions>();
services.AddConfigurableOptions<PrintTemplateOptions>();
#region 上传文件大小限制
long maxRequestBodySize = Convert.ToInt64(App.Configuration["MaxRequestBodySize"]);

Loading…
Cancel
Save