|
|
@ -26,6 +26,8 @@ using Volo.Abp.TenantManagement; |
|
|
|
using Win_in.Sfs.Scp.WebApi.Asns; |
|
|
|
using Volo.Abp.Domain.Entities; |
|
|
|
using System.Security.Cryptography; |
|
|
|
using IdentityModel; |
|
|
|
using Microsoft.Extensions.Options; |
|
|
|
|
|
|
|
namespace Win_in.Sfs.Scp.WebApi |
|
|
|
{ |
|
|
@ -39,12 +41,19 @@ namespace Win_in.Sfs.Scp.WebApi |
|
|
|
public class X12AsnAppService : ReadOnlyAppService<X12Asn, X12AsnDTO, Guid, RequestDTO>, IX12AsnAppService |
|
|
|
{ |
|
|
|
private readonly IX12AsnRepository _x12AsnRepository; |
|
|
|
private readonly ITenantRepository _tenantRepository; |
|
|
|
private readonly IOptions<AsnOptions> _options; |
|
|
|
|
|
|
|
public X12AsnAppService( |
|
|
|
IX12AsnRepository repository |
|
|
|
, ITenantRepository tenantRepository |
|
|
|
, IOptions<AsnOptions> options |
|
|
|
|
|
|
|
) : base(repository) |
|
|
|
{ |
|
|
|
_x12AsnRepository = repository; |
|
|
|
_tenantRepository = tenantRepository; |
|
|
|
_options = options; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
@ -55,6 +64,7 @@ namespace Win_in.Sfs.Scp.WebApi |
|
|
|
|
|
|
|
[HttpGet] |
|
|
|
[Route("{id}")] |
|
|
|
[HiddenApi] |
|
|
|
public override async Task<X12AsnDTO> GetAsync(Guid id) |
|
|
|
{ |
|
|
|
return await base.GetAsync(id); |
|
|
@ -68,6 +78,7 @@ namespace Win_in.Sfs.Scp.WebApi |
|
|
|
/// <returns></returns>
|
|
|
|
[HttpGet] |
|
|
|
[Route("paged-list")] |
|
|
|
[HiddenApi] |
|
|
|
public override async Task<PagedResultDto<X12AsnDTO>> GetListAsync(RequestDTO requestDTO) |
|
|
|
{ |
|
|
|
return await base.GetListAsync(requestDTO); |
|
|
@ -84,6 +95,12 @@ namespace Win_in.Sfs.Scp.WebApi |
|
|
|
[Route("unread-list")] |
|
|
|
public async Task<ListResultDto<X12AsnDTO>> GetUnreadListAsync(string site, int count, bool autoUpdateStatus) |
|
|
|
{ |
|
|
|
Validator.CheckSite(_tenantRepository, site); |
|
|
|
|
|
|
|
if (count < 1 || count > _options.Value.MaxCount) |
|
|
|
{ |
|
|
|
throw new AbpValidationException($"Count must bigger than 1 and smaller than {_options.Value.MaxCount}"); |
|
|
|
} |
|
|
|
|
|
|
|
var entities = await _x12AsnRepository.GetUnreadListAsync(site, count, autoUpdateStatus); |
|
|
|
|
|
|
@ -102,12 +119,14 @@ namespace Win_in.Sfs.Scp.WebApi |
|
|
|
/// <returns></returns>
|
|
|
|
/// <exception cref="BadHttpRequestException"></exception>
|
|
|
|
[HttpGet] |
|
|
|
[Route("between-id")] |
|
|
|
[Route("between-uid")] |
|
|
|
public async Task<ListResultDto<X12AsnDTO>> GetListAsync(string site, long beginUid, long endUid) |
|
|
|
{ |
|
|
|
Validator.CheckSite(_tenantRepository, site); |
|
|
|
|
|
|
|
if (endUid < beginUid) |
|
|
|
{ |
|
|
|
throw new AbpValidationException("beginUid is bigger than endUid"); |
|
|
|
throw new AbpValidationException("beginUid can not bigger than endUid"); |
|
|
|
} |
|
|
|
|
|
|
|
var entities = await _x12AsnRepository.GetListAsync(p => p.Site == site && p.UID >= beginUid && p.UID <= endUid); |
|
|
@ -129,9 +148,11 @@ namespace Win_in.Sfs.Scp.WebApi |
|
|
|
[Route("between-date")] |
|
|
|
public async Task<ListResultDto<X12AsnDTO>> GetListAsync(string site, DateTime beginDate, DateTime endDate) |
|
|
|
{ |
|
|
|
Validator.CheckSite(_tenantRepository, site); |
|
|
|
|
|
|
|
if (endDate < beginDate) |
|
|
|
{ |
|
|
|
throw new AbpValidationException("beginDate is after endDate"); |
|
|
|
throw new AbpValidationException("beginDate can not after endDate"); |
|
|
|
} |
|
|
|
|
|
|
|
var entities = await _x12AsnRepository.GetListAsync(p => p.Site == site && p.EffectiveDate >= beginDate && p.EffectiveDate <= endDate); |
|
|
@ -149,9 +170,11 @@ namespace Win_in.Sfs.Scp.WebApi |
|
|
|
/// <returns></returns>
|
|
|
|
/// <exception cref="BadHttpRequestException"></exception>
|
|
|
|
[HttpGet] |
|
|
|
[Route("by-id")] |
|
|
|
[Route("by-uid")] |
|
|
|
public async Task<ActionResult<X12AsnDTO>> GetAsync(string site, long uid) |
|
|
|
{ |
|
|
|
Validator.CheckSite(_tenantRepository, site); |
|
|
|
|
|
|
|
var entity = await _x12AsnRepository.FirstOrDefaultAsync(p => p.Site == site && p.UID == uid); |
|
|
|
|
|
|
|
if (entity == null) |
|
|
@ -176,6 +199,8 @@ namespace Win_in.Sfs.Scp.WebApi |
|
|
|
[Route("by-number")] |
|
|
|
public async Task<ActionResult<X12AsnDTO>> GetAsync(string site, string number) |
|
|
|
{ |
|
|
|
Validator.CheckSite(_tenantRepository, site); |
|
|
|
|
|
|
|
var entity = await _x12AsnRepository.FirstOrDefaultAsync(p => p.Site == site && p.BillNum == number); |
|
|
|
|
|
|
|
if (entity == null) |
|
|
@ -207,6 +232,7 @@ namespace Win_in.Sfs.Scp.WebApi |
|
|
|
[Route("update-status")] |
|
|
|
public async Task<ActionResult<X12AsnDTO>> UpdateStatusAsync(string site, string number, EnumExchangeDataStatus status) |
|
|
|
{ |
|
|
|
Validator.CheckSite(_tenantRepository, site); |
|
|
|
|
|
|
|
var entity = await _x12AsnRepository.FirstOrDefaultAsync(p => p.Site == site && p.BillNum == number); |
|
|
|
|
|
|
|