|
|
|
@ -19,18 +19,12 @@ using static Org.BouncyCastle.Bcpg.Attr.ImageAttrib; |
|
|
|
namespace Shentun.Peis.ReportFormatTemplates |
|
|
|
{ |
|
|
|
//[Authorize]
|
|
|
|
public class ReportFormatTemplateAppService : CrudAppService< |
|
|
|
ReportFormatTemplate, //The Book entity
|
|
|
|
ReportFormatTemplateDto, //Used to show books
|
|
|
|
string, //Primary key of the book entity
|
|
|
|
PagedAndSortedResultRequestDto, //Used for paging/sorting
|
|
|
|
CreateReportFormatTemplateDto, |
|
|
|
UpdateReportFormatTemplateDto> |
|
|
|
public class ReportFormatTemplateAppService : ApplicationService |
|
|
|
{ |
|
|
|
private readonly IRepository<IdentityUser, Guid> _userRepository; |
|
|
|
private readonly IRepository<Report, string> _reportRepository; |
|
|
|
private readonly IRepository<ReportFormat, string> _reportFormatRepository; |
|
|
|
private readonly IRepository<ReportFormatTemplate, string> _reportFormatTemplateRepository; |
|
|
|
private readonly IRepository<ReportFormatTemplate, string> _repository; |
|
|
|
private readonly ReportFormatTemplateManager _manager; |
|
|
|
public ReportFormatTemplateAppService( |
|
|
|
IRepository<ReportFormatTemplate, string> repository, |
|
|
|
@ -38,20 +32,20 @@ namespace Shentun.Peis.ReportFormatTemplates |
|
|
|
IRepository<Report, string> reportRepository, |
|
|
|
IRepository<ReportFormat, string> reportFormatRepository, |
|
|
|
ReportFormatTemplateManager manager) |
|
|
|
: base(repository) |
|
|
|
{ |
|
|
|
_repository = repository; |
|
|
|
_userRepository = userRepository; |
|
|
|
_manager = manager; |
|
|
|
_reportFormatTemplateRepository = repository; |
|
|
|
_reportFormatRepository = reportFormatRepository; |
|
|
|
_reportRepository = reportRepository; |
|
|
|
} |
|
|
|
public async Task<List<ReportFormatTemplateDto>> GetReportTemplateAsync() |
|
|
|
[HttpPost("api/app/ReportFormatTemplate/GetDefalutReportTemplates")] |
|
|
|
public async Task<List<ReportFormatTemplateDto>> GetDefalutReportTemplateAsync() |
|
|
|
{ |
|
|
|
var query = from a in await _reportFormatRepository.GetQueryableAsync() |
|
|
|
join b in await _reportRepository.GetQueryableAsync() on a.ReportId equals b.Id into bb |
|
|
|
from ab in bb.DefaultIfEmpty() |
|
|
|
join c in await _reportFormatTemplateRepository.GetQueryableAsync() on a.Id equals c.ReportFormatId into cc |
|
|
|
join c in await _repository.GetQueryableAsync() on a.Id equals c.ReportFormatId into cc |
|
|
|
from ac in cc.DefaultIfEmpty() |
|
|
|
where (a.IsDefault=='Y' &&ab.IsActive=='Y'&&ac.IsDefault== 'Y') |
|
|
|
select new |
|
|
|
@ -81,32 +75,34 @@ namespace Shentun.Peis.ReportFormatTemplates |
|
|
|
/// <summary>
|
|
|
|
/// 获取通过主键
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="id"></param>
|
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
public override async Task<ReportFormatTemplateDto> GetAsync(string id) |
|
|
|
[HttpPost("api/app/ReportFormatTemplate/GetById")] |
|
|
|
public async Task<ReportFormatTemplateDto> GetByIdAsync(ReportFormatTemplateIdDto input) |
|
|
|
{ |
|
|
|
var entity= await base.GetAsync(id); |
|
|
|
var entity= await _repository.GetAsync(input.Id); |
|
|
|
var aEntity = ObjectMapper.Map<ReportFormatTemplate, ReportFormatTemplateDto>(entity); |
|
|
|
var userList = await _userRepository.GetListAsync(); |
|
|
|
entity.IsDefaulted = entity.IsDefault.Equals('Y'); |
|
|
|
entity.IsSystemed = entity.IsSystem.Equals('Y'); |
|
|
|
entity.CreatorName = EntityHelper.GetSurnameNoSql(userList, entity.CreatorId); |
|
|
|
entity.LastModifierName = EntityHelper.GetSurnameNoSql(userList, entity.LastModifierId); |
|
|
|
return entity; |
|
|
|
aEntity.IsDefaulted = entity.IsDefault.Equals('Y'); |
|
|
|
aEntity.IsSystemed = entity.IsSystem.Equals('Y'); |
|
|
|
aEntity.CreatorName = EntityHelper.GetSurnameNoSql(userList, entity.CreatorId); |
|
|
|
aEntity.LastModifierName = EntityHelper.GetSurnameNoSql(userList, entity.LastModifierId); |
|
|
|
return aEntity; |
|
|
|
} |
|
|
|
|
|
|
|
public async Task<ReportFormatTemplateDto> GetMaxByIdAsync() |
|
|
|
[HttpPost("api/app/ReportFormatTemplate/GetMaxId")] |
|
|
|
public async Task<ReportFormatTemplateDto> GetMaxIdAsync() |
|
|
|
{ |
|
|
|
var ent = (await Repository.GetListAsync()).Max(x => x.Id); |
|
|
|
var ent = (await _repository.GetListAsync()).Max(x => x.Id); |
|
|
|
var entdto = new ReportFormatTemplateDto |
|
|
|
{ |
|
|
|
Id = !string.IsNullOrEmpty(ent)?ent:"0001" |
|
|
|
}; |
|
|
|
return entdto; |
|
|
|
} |
|
|
|
|
|
|
|
public async Task<ReportFormatTemplateDto> GetDefaultAsync(string formatId) |
|
|
|
[HttpPost("api/app/ReportFormatTemplate/GetDefault")] |
|
|
|
public async Task<ReportFormatTemplateDto> GetDefaultAsync(ReportFormatIdInputDto input) |
|
|
|
{ |
|
|
|
var ent = await _manager.GetDefaultAsync(formatId); |
|
|
|
var ent = await _manager.GetDefaultAsync(input.Id); |
|
|
|
|
|
|
|
if (ent != null) |
|
|
|
{ |
|
|
|
@ -144,21 +140,37 @@ namespace Shentun.Peis.ReportFormatTemplates |
|
|
|
/// 获取列表 项目
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
public override async Task<PagedResultDto<ReportFormatTemplateDto>> GetListAsync(PagedAndSortedResultRequestDto input) |
|
|
|
[HttpPost("api/app/ReportFormatTemplate/GetList")] |
|
|
|
public async Task<List<ReportFormatTemplateDto>> GetListAsync(PagedAndSortedResultRequestDto input) |
|
|
|
{ |
|
|
|
var reportList = await _repository.GetListAsync(); |
|
|
|
|
|
|
|
List<ReportFormatTemplateDto> templates = new List<ReportFormatTemplateDto>(); |
|
|
|
|
|
|
|
foreach (var template in reportList) |
|
|
|
{ |
|
|
|
return await base.GetListAsync(input); |
|
|
|
var aEntity = ObjectMapper.Map<ReportFormatTemplate, ReportFormatTemplateDto>(template); |
|
|
|
var userList = await _userRepository.GetListAsync(); |
|
|
|
aEntity.IsDefaulted = template.IsDefault.Equals('Y'); |
|
|
|
aEntity.IsSystemed = template.IsSystem.Equals('Y'); |
|
|
|
aEntity.CreatorName = EntityHelper.GetSurnameNoSql(userList, template.CreatorId); |
|
|
|
aEntity.LastModifierName = EntityHelper.GetSurnameNoSql(userList, template.LastModifierId); |
|
|
|
templates.Add(aEntity); |
|
|
|
} |
|
|
|
|
|
|
|
return templates; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 获取列表 项目 可以带格式ID搜索
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="reportFormatId"></param>
|
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
public async Task<PagedResultDto<ReportFormatTemplateDto>> GetListInReportFormatAsync(string reportFormatId) |
|
|
|
[HttpPost("api/app/ReportFormatTemplate/GetListByReportFormatId")] |
|
|
|
public async Task<PagedResultDto<ReportFormatTemplateDto>> GetListByReportFormatIdAsync(ReportFormatIdInputDto input) |
|
|
|
{ |
|
|
|
int totalCount = 0; |
|
|
|
var entlist = (await Repository.GetListAsync()).Where(m => m.ReportFormatId == reportFormatId); |
|
|
|
var entlist = (await _repository.GetListAsync()).Where(m => m.ReportFormatId == input.Id); |
|
|
|
|
|
|
|
totalCount = entlist.Count(); |
|
|
|
var userList = await _userRepository.GetListAsync(); |
|
|
|
@ -191,20 +203,20 @@ namespace Shentun.Peis.ReportFormatTemplates |
|
|
|
/// 创建
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
public override async Task<ReportFormatTemplateDto> CreateAsync(CreateReportFormatTemplateDto input) |
|
|
|
[HttpPost("api/app/ReportFormatTemplate/Create")] |
|
|
|
public async Task<ReportFormatTemplateDto> CreateAsync(CreateReportFormatTemplateDto input) |
|
|
|
{ |
|
|
|
var createEntity = ObjectMapper.Map<CreateReportFormatTemplateDto, ReportFormatTemplate>(input); |
|
|
|
var entity = await _manager.CreateAsync(createEntity); |
|
|
|
entity = await Repository.InsertAsync(entity); |
|
|
|
entity = await _repository.InsertAsync(entity); |
|
|
|
var dto = ObjectMapper.Map<ReportFormatTemplate, ReportFormatTemplateDto>(entity); |
|
|
|
return dto; |
|
|
|
} |
|
|
|
|
|
|
|
public async Task<ReportFormatTemplateDto> CopyCreateAsync(string id,string newId) |
|
|
|
[HttpPost("api/app/ReportFormatTemplate/CopyCreate")] |
|
|
|
public async Task<ReportFormatTemplateDto> CopyCreateAsync(CopyCreateReportFormatTemplateDto input) |
|
|
|
{ |
|
|
|
var entity = await _manager.CopyCreateAsync(id,newId); |
|
|
|
entity = await Repository.InsertAsync(entity); |
|
|
|
var entity = await _manager.CopyCreateAsync(input.Id, input.NewId); |
|
|
|
entity = await _repository.InsertAsync(entity); |
|
|
|
var dto = ObjectMapper.Map<ReportFormatTemplate, ReportFormatTemplateDto>(entity); |
|
|
|
return dto; |
|
|
|
} |
|
|
|
@ -216,13 +228,13 @@ namespace Shentun.Peis.ReportFormatTemplates |
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPost("api/app/ReportFormatTemplate/Update")] |
|
|
|
public override async Task<ReportFormatTemplateDto> UpdateAsync(string id, UpdateReportFormatTemplateDto input) |
|
|
|
public async Task<ReportFormatTemplateDto> UpdateAsync(UpdateReportFormatTemplateDto input) |
|
|
|
{ |
|
|
|
var entity = await Repository.GetAsync(id); |
|
|
|
var entity = await _repository.GetAsync(input.Id); |
|
|
|
var userList = await _userRepository.GetListAsync(); |
|
|
|
var sourceEntity = ObjectMapper.Map<UpdateReportFormatTemplateDto, ReportFormatTemplate>(input); |
|
|
|
await _manager.UpdateAsync(sourceEntity, entity); |
|
|
|
entity = await Repository.UpdateAsync(entity); |
|
|
|
entity = await _repository.UpdateAsync(entity); |
|
|
|
var dto= ObjectMapper.Map<ReportFormatTemplate, ReportFormatTemplateDto>(entity); |
|
|
|
dto.IsDefaulted = entity.IsDefault.Equals('Y'); |
|
|
|
dto.IsSystemed= entity.IsSystem.Equals('Y'); |
|
|
|
@ -233,17 +245,18 @@ namespace Shentun.Peis.ReportFormatTemplates |
|
|
|
/// <summary>
|
|
|
|
/// 删除
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="id"></param>
|
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
public override Task DeleteAsync(string id) |
|
|
|
[HttpPost("api/app/ReportFormatTemplate/Delete")] |
|
|
|
public Task DeleteAsync(ReportFormatIdInputDto input) |
|
|
|
{ |
|
|
|
return base.DeleteAsync(id); |
|
|
|
return _repository.DeleteAsync(input.Id); |
|
|
|
} |
|
|
|
|
|
|
|
[HttpPut("api/app/reportfomattemplate/updatedefault")] |
|
|
|
public async Task UpdateDefaultAsync(string id) |
|
|
|
[HttpPost("api/app/reportfomattemplate/UpdateDefault")] |
|
|
|
public async Task UpdateDefaultAsync(ReportFormatIdInputDto input) |
|
|
|
{ |
|
|
|
await _manager.UpdateDefaultAsync(id); |
|
|
|
await _manager.UpdateDefaultAsync(input.Id); |
|
|
|
} |
|
|
|
} |
|
|
|
} |