|
@ -82,14 +82,14 @@ namespace Win_in.Sfs.Scp.WebApi |
|
|
/// <returns></returns>
|
|
|
/// <returns></returns>
|
|
|
[HttpGet] |
|
|
[HttpGet] |
|
|
[Route("unread-list")] |
|
|
[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 entities = await _x12AsnRepository.GetUnreadListAsync(site, count, autoUpdateStatus); |
|
|
|
|
|
|
|
|
var dtos = BuildDtos(entities); |
|
|
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>
|
|
|
/// <exception cref="BadHttpRequestException"></exception>
|
|
|
[HttpGet] |
|
|
[HttpGet] |
|
|
[Route("between-id")] |
|
|
[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) |
|
|
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 entities = await _x12AsnRepository.GetListAsync(p => p.Site == site && p.UID >= beginUid && p.UID <= endUid); |
|
|
|
|
|
|
|
|
var dtos = BuildDtos(entities); |
|
|
var dtos = BuildDtos(entities); |
|
|
|
|
|
|
|
|
return dtos; |
|
|
return new ListResultDto<X12AsnDTO>(dtos); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
@ -127,18 +127,18 @@ namespace Win_in.Sfs.Scp.WebApi |
|
|
/// <exception cref="BadHttpRequestException"></exception>
|
|
|
/// <exception cref="BadHttpRequestException"></exception>
|
|
|
[HttpGet] |
|
|
[HttpGet] |
|
|
[Route("between-date")] |
|
|
[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) |
|
|
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 entities = await _x12AsnRepository.GetListAsync(p => p.Site == site && p.EffectiveDate >= beginDate && p.EffectiveDate <= endDate); |
|
|
|
|
|
|
|
|
var dtos = BuildDtos(entities); |
|
|
var dtos = BuildDtos(entities); |
|
|
|
|
|
|
|
|
return dtos; |
|
|
return new ListResultDto<X12AsnDTO>(dtos); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
@ -150,13 +150,14 @@ namespace Win_in.Sfs.Scp.WebApi |
|
|
/// <exception cref="BadHttpRequestException"></exception>
|
|
|
/// <exception cref="BadHttpRequestException"></exception>
|
|
|
[HttpGet] |
|
|
[HttpGet] |
|
|
[Route("by-id")] |
|
|
[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); |
|
|
var entity = await _x12AsnRepository.FirstOrDefaultAsync(p => p.Site == site && p.UID == uid); |
|
|
|
|
|
|
|
|
if (entity == null) |
|
|
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); |
|
|
var dto = BuildDto(entity); |
|
@ -173,13 +174,13 @@ namespace Win_in.Sfs.Scp.WebApi |
|
|
/// <exception cref="BadHttpRequestException"></exception>
|
|
|
/// <exception cref="BadHttpRequestException"></exception>
|
|
|
[HttpGet] |
|
|
[HttpGet] |
|
|
[Route("by-number")] |
|
|
[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); |
|
|
var entity = await _x12AsnRepository.FirstOrDefaultAsync(p => p.Site == site && p.BillNum == number); |
|
|
|
|
|
|
|
|
if (entity == null) |
|
|
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); |
|
|
var dto = BuildDto(entity); |
|
@ -204,14 +205,14 @@ namespace Win_in.Sfs.Scp.WebApi |
|
|
/// <exception cref="BadHttpRequestException"></exception>
|
|
|
/// <exception cref="BadHttpRequestException"></exception>
|
|
|
[HttpPost] |
|
|
[HttpPost] |
|
|
[Route("update-status")] |
|
|
[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); |
|
|
var entity = await _x12AsnRepository.FirstOrDefaultAsync(p => p.Site == site && p.BillNum == number); |
|
|
|
|
|
|
|
|
if (entity == null) |
|
|
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); |
|
|
var result = await _x12AsnRepository.UpdateStatusAsync(entity.Id, status); |
|
|