|
|
@ -82,14 +82,14 @@ namespace Win_in.Sfs.Scp.WebApi |
|
|
|
/// <returns></returns>
|
|
|
|
[HttpGet] |
|
|
|
[Route("unread-list")] |
|
|
|
public async Task<List<X12AsnDTO>> GetUnreadListAsync(string site, int count, bool autoUpdateStatus) |
|
|
|
public async Task<ListResultDto<X12AsnDTO>> GetUnreadListAsync(string site, int count, bool autoUpdateStatus) |
|
|
|
{ |
|
|
|
|
|
|
|
var entities = await _x12AsnRepository.GetUnreadListAsync(site, count, autoUpdateStatus); |
|
|
|
|
|
|
|
var dtos = BuildDtos(entities); |
|
|
|
|
|
|
|
return dtos; |
|
|
|
return new ListResultDto<X12AsnDTO>(dtos); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
@ -103,18 +103,18 @@ namespace Win_in.Sfs.Scp.WebApi |
|
|
|
/// <exception cref="BadHttpRequestException"></exception>
|
|
|
|
[HttpGet] |
|
|
|
[Route("between-id")] |
|
|
|
public async Task<List<X12AsnDTO>> GetListAsync(string site, long beginUid, long endUid) |
|
|
|
public async Task<ListResultDto<X12AsnDTO>> GetListAsync(string site, long beginUid, long endUid) |
|
|
|
{ |
|
|
|
if (endUid < beginUid) |
|
|
|
{ |
|
|
|
throw new BadHttpRequestException("beginUid is bigger than endUid"); |
|
|
|
throw new AbpValidationException("beginUid is bigger than endUid"); |
|
|
|
} |
|
|
|
|
|
|
|
var entities = await _x12AsnRepository.GetListAsync(p => p.Site == site && p.UID >= beginUid && p.UID <= endUid); |
|
|
|
|
|
|
|
var dtos = BuildDtos(entities); |
|
|
|
|
|
|
|
return dtos; |
|
|
|
return new ListResultDto<X12AsnDTO>(dtos); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
@ -127,18 +127,18 @@ namespace Win_in.Sfs.Scp.WebApi |
|
|
|
/// <exception cref="BadHttpRequestException"></exception>
|
|
|
|
[HttpGet] |
|
|
|
[Route("between-date")] |
|
|
|
public async Task<List<X12AsnDTO>> GetListAsync(string site, DateTime beginDate, DateTime endDate) |
|
|
|
public async Task<ListResultDto<X12AsnDTO>> GetListAsync(string site, DateTime beginDate, DateTime endDate) |
|
|
|
{ |
|
|
|
if (endDate < beginDate) |
|
|
|
{ |
|
|
|
throw new BadHttpRequestException("beginDate is after endDate"); |
|
|
|
throw new AbpValidationException("beginDate is after endDate"); |
|
|
|
} |
|
|
|
|
|
|
|
var entities = await _x12AsnRepository.GetListAsync(p => p.Site == site && p.EffectiveDate >= beginDate && p.EffectiveDate <= endDate); |
|
|
|
|
|
|
|
var dtos = BuildDtos(entities); |
|
|
|
|
|
|
|
return dtos; |
|
|
|
return new ListResultDto<X12AsnDTO>(dtos); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
@ -150,13 +150,14 @@ namespace Win_in.Sfs.Scp.WebApi |
|
|
|
/// <exception cref="BadHttpRequestException"></exception>
|
|
|
|
[HttpGet] |
|
|
|
[Route("by-id")] |
|
|
|
public async Task<X12AsnDTO> GetAsync(string site, long uid) |
|
|
|
public async Task<ActionResult<X12AsnDTO>> GetAsync(string site, long uid) |
|
|
|
{ |
|
|
|
var entity = await _x12AsnRepository.FirstOrDefaultAsync(p => p.Site == site && p.UID == uid); |
|
|
|
|
|
|
|
if (entity == null) |
|
|
|
{ |
|
|
|
throw new BadHttpRequestException($"ASN of {uid} in {site} is not found"); |
|
|
|
|
|
|
|
throw new AbpValidationException($"ASN of {uid} in {site} is not found"); |
|
|
|
} |
|
|
|
|
|
|
|
var dto = BuildDto(entity); |
|
|
@ -173,13 +174,13 @@ namespace Win_in.Sfs.Scp.WebApi |
|
|
|
/// <exception cref="BadHttpRequestException"></exception>
|
|
|
|
[HttpGet] |
|
|
|
[Route("by-number")] |
|
|
|
public async Task<X12AsnDTO> GetAsync(string site, string number) |
|
|
|
public async Task<ActionResult<X12AsnDTO>> GetAsync(string site, string number) |
|
|
|
{ |
|
|
|
var entity = await _x12AsnRepository.FirstOrDefaultAsync(p => p.Site == site && p.BillNum == number); |
|
|
|
|
|
|
|
if (entity == null) |
|
|
|
{ |
|
|
|
throw new BadHttpRequestException($"ASN of {number} in {site} is not found"); |
|
|
|
throw new AbpValidationException($"ASN of {number} in {site} is not found"); |
|
|
|
} |
|
|
|
|
|
|
|
var dto = BuildDto(entity); |
|
|
@ -204,14 +205,14 @@ namespace Win_in.Sfs.Scp.WebApi |
|
|
|
/// <exception cref="BadHttpRequestException"></exception>
|
|
|
|
[HttpPost] |
|
|
|
[Route("update-status")] |
|
|
|
public async Task<X12AsnDTO> UpdateStatusAsync(string site, string number, EnumExchangeDataStatus status) |
|
|
|
public async Task<ActionResult<X12AsnDTO>> UpdateStatusAsync(string site, string number, EnumExchangeDataStatus status) |
|
|
|
{ |
|
|
|
|
|
|
|
var entity = await _x12AsnRepository.FirstOrDefaultAsync(p => p.Site == site && p.BillNum == number); |
|
|
|
|
|
|
|
if (entity == null) |
|
|
|
{ |
|
|
|
throw new BadHttpRequestException($"ASN of {number} in {site} is not found"); |
|
|
|
throw new AbpValidationException($"ASN of {number} in {site} is not found"); |
|
|
|
} |
|
|
|
|
|
|
|
var result = await _x12AsnRepository.UpdateStatusAsync(entity.Id, status); |
|
|
|