|
|
@ -80,7 +80,7 @@ namespace Myshipping.Application
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 增加订舱打印模板
|
|
|
|
/// 增加订舱打印模板(准备作废)
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <returns></returns>
|
|
|
@ -148,7 +148,7 @@ namespace Myshipping.Application
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 更新订舱打印模板
|
|
|
|
/// 更新订舱打印模板(准备作废)
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <returns></returns>
|
|
|
@ -209,6 +209,81 @@ namespace Myshipping.Application
|
|
|
|
await _rep.UpdateAsync(entity);
|
|
|
|
await _rep.UpdateAsync(entity);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 保存订舱打印模板(新增或修改)
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
/// <param name="file"></param>
|
|
|
|
|
|
|
|
/// <param name="input"></param>
|
|
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
|
|
[HttpPost("/BookingPrintTemplate/save")]
|
|
|
|
|
|
|
|
public async Task<long> Save(IFormFile file, [FromForm] SaveBookingPrintTemplateInput input)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var opt = App.GetOptions<PrintTemplateOptions>();
|
|
|
|
|
|
|
|
if (file != null && file.Length > 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var fileSuffix = Path.GetExtension(file.FileName).ToLower(); // 文件后缀
|
|
|
|
|
|
|
|
if (!opt.fileType.Contains(fileSuffix))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Bah(BookingErrorCode.BOOK114);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BookingPrintTemplate entity = null;
|
|
|
|
|
|
|
|
if (input.Id > 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
entity = _rep.AsQueryable().Filter(null, true).First(x => x.Id == input.Id);
|
|
|
|
|
|
|
|
input.Adapt(entity);
|
|
|
|
|
|
|
|
await _rep.UpdateAsync(entity);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
//新增时必须上传文件
|
|
|
|
|
|
|
|
if (file == null || file.Length == 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Bah(BookingErrorCode.BOOK113);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
entity = input.Adapt<BookingPrintTemplate>();
|
|
|
|
|
|
|
|
await _rep.InsertAsync(entity);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (file != null && file.Length > 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var originalFilename = file.FileName; // 文件原始名称
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var dirAbs = string.Empty;
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(opt.basePath))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
dirAbs = Path.Combine(App.WebHostEnvironment.WebRootPath, opt.relativePath);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
dirAbs = Path.Combine(opt.basePath, opt.relativePath);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!Directory.Exists(dirAbs))
|
|
|
|
|
|
|
|
Directory.CreateDirectory(dirAbs);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 先存库获取Id
|
|
|
|
|
|
|
|
var id = YitIdHelper.NextId();
|
|
|
|
|
|
|
|
var fileSuffix = Path.GetExtension(file.FileName).ToLower();
|
|
|
|
|
|
|
|
var fileSaveName = $"{id}{fileSuffix}".ToLower();
|
|
|
|
|
|
|
|
var fileRelaPath = Path.Combine(opt.relativePath, fileSaveName).ToLower();
|
|
|
|
|
|
|
|
var fileAbsPath = Path.Combine(dirAbs, fileSaveName).ToLower();
|
|
|
|
|
|
|
|
using (var stream = File.Create(fileAbsPath))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
await file.CopyToAsync(stream);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
entity.FileName = originalFilename;
|
|
|
|
|
|
|
|
entity.FilePath = fileRelaPath;
|
|
|
|
|
|
|
|
await _rep.UpdateAsync(entity);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return entity.Id;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 删除订舱打印模板
|
|
|
|
/// 删除订舱打印模板
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
@ -290,13 +365,17 @@ namespace Myshipping.Application
|
|
|
|
|
|
|
|
|
|
|
|
throw Oops.Bah("未上传正确数据");
|
|
|
|
throw Oops.Bah("未上传正确数据");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
await _repRight.DeleteAsync(x => x.SysUserId == input.SysUserId);
|
|
|
|
// await _repRight.DeleteAsync(x => x.SysUserId == input.SysUserId);
|
|
|
|
foreach (var item in input.PrintTemplateId)
|
|
|
|
foreach (var item in input.PrintTemplateId)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
BookingPrinttemplateRight right = new BookingPrinttemplateRight();
|
|
|
|
var ent = _repRight.FirstOrDefault(x => x.SysUserId == input.SysUserId && x.PrintTemplateId == item);
|
|
|
|
right.SysUserId = input.SysUserId;
|
|
|
|
if (ent==null) {
|
|
|
|
right.PrintTemplateId = item;
|
|
|
|
BookingPrinttemplateRight right = new BookingPrinttemplateRight();
|
|
|
|
await _repRight.InsertAsync(right);
|
|
|
|
right.SysUserId = input.SysUserId;
|
|
|
|
|
|
|
|
right.PrintTemplateId = item;
|
|
|
|
|
|
|
|
await _repRight.InsertAsync(right);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
@ -311,6 +390,7 @@ namespace Myshipping.Application
|
|
|
|
WhereIF(userId != 0, d => d.SysUserId == userId).
|
|
|
|
WhereIF(userId != 0, d => d.SysUserId == userId).
|
|
|
|
Select((d, t) => new BookingPrinttemplateDto
|
|
|
|
Select((d, t) => new BookingPrinttemplateDto
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
Id=d.Id,
|
|
|
|
PrintTemplateId=t.Id,
|
|
|
|
PrintTemplateId=t.Id,
|
|
|
|
SysUserId=d.SysUserId,
|
|
|
|
SysUserId=d.SysUserId,
|
|
|
|
TypeCode = t.TypeCode,
|
|
|
|
TypeCode = t.TypeCode,
|
|
|
@ -327,5 +407,19 @@ namespace Myshipping.Application
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return list;
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 删除打印模板权限
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
/// <param name="Ids"></param>
|
|
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
|
|
[HttpGet("/BookingPrintTemplate/DeletePrinttemplateRight")]
|
|
|
|
|
|
|
|
public async Task DeletePrinttemplateRight([FromQuery] List<long> Ids) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await _repRight.DeleteAsync(x => Ids.Contains(x.Id));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|