|
|
|
@ -18,6 +18,9 @@ using Furion.RemoteRequest.Extensions;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Web;
|
|
|
|
|
using Myshipping.Application.Enum;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using Myshipping.Application.Service.BookingPrintTemplate.Dto;
|
|
|
|
|
using Myshipping.Core.Entity;
|
|
|
|
|
|
|
|
|
|
namespace Myshipping.Application
|
|
|
|
|
{
|
|
|
|
@ -28,11 +31,15 @@ namespace Myshipping.Application
|
|
|
|
|
public class BookingPrintTemplateService : IBookingPrintTemplateService, IDynamicApiController, ITransient
|
|
|
|
|
{
|
|
|
|
|
private readonly SqlSugarRepository<BookingPrintTemplate> _rep;
|
|
|
|
|
private readonly SqlSugarRepository<BookingPrinttemplateRight> _repRight;
|
|
|
|
|
private readonly SqlSugarRepository<SysUser> _repUser;
|
|
|
|
|
private readonly ILogger<BookingPrintTemplate> _logger;
|
|
|
|
|
|
|
|
|
|
public BookingPrintTemplateService(SqlSugarRepository<BookingPrintTemplate> rep, ILogger<BookingPrintTemplate> logger)
|
|
|
|
|
public BookingPrintTemplateService(SqlSugarRepository<BookingPrintTemplate> rep, SqlSugarRepository<BookingPrinttemplateRight> repRight, SqlSugarRepository<SysUser> repUser, ILogger<BookingPrintTemplate> logger)
|
|
|
|
|
{
|
|
|
|
|
_rep = rep;
|
|
|
|
|
_repRight = repRight;
|
|
|
|
|
_repUser = repUser;
|
|
|
|
|
_logger = logger;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -251,5 +258,48 @@ namespace Myshipping.Application
|
|
|
|
|
var result = new FileStreamResult(new FileStream(fileFullPath, FileMode.Open), "application/octet-stream") { FileDownloadName = fileName };
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 新增打印模板权限
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="input"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[SqlSugarUnitOfWork]
|
|
|
|
|
[HttpPost("/BookingPrintTemplate/AddPrinttemplateRight")]
|
|
|
|
|
public async Task AddPrinttemplateRight(BookingPrinttemplateRightDto input)
|
|
|
|
|
{
|
|
|
|
|
if (input == null)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
throw Oops.Bah("未上传正确数据");
|
|
|
|
|
}
|
|
|
|
|
await _repRight.DeleteAsync(x => x.SysUserId == input.SysUserId);
|
|
|
|
|
foreach (var item in input.PrintTemplateId)
|
|
|
|
|
{
|
|
|
|
|
BookingPrinttemplateRight right = new BookingPrinttemplateRight();
|
|
|
|
|
right.SysUserId = input.SysUserId;
|
|
|
|
|
right.PrintTemplateId = item;
|
|
|
|
|
await _repRight.InsertAsync(right);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取打印模板权限
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet("/BookingPrintTemplate/GetPrinttemplateRightList")]
|
|
|
|
|
public async Task<dynamic> GetPrinttemplateRightList(long userId)
|
|
|
|
|
{
|
|
|
|
|
var list = await _repRight.AsQueryable().InnerJoin<BookingPrintTemplate>((d, t) => d.PrintTemplateId == t.Id && t.TenantId == UserManager.TENANT_ID).
|
|
|
|
|
WhereIF(userId != 0, x => x.SysUserId == userId).
|
|
|
|
|
Select((d, t) => new
|
|
|
|
|
{
|
|
|
|
|
TypeCode = t.TypeCode,
|
|
|
|
|
TypeName = t.TypeName,
|
|
|
|
|
FilePath = t.FilePath,
|
|
|
|
|
FileName = t.FileName,
|
|
|
|
|
TenantName = t.TenantName,
|
|
|
|
|
UserName = _repUser.Where(x => x.Id == d.SysUserId).Select(x => x.Name).FirstAsync().Result
|
|
|
|
|
}).ToListAsync();
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|