Browse Source

[fix]部分API在swagger中忽略

master
贾荣国 3 years ago
parent
commit
abd5583505
  1. 34
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/Asns/X12AsnAppService.cs
  2. 4
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/Parts/PartAppService.cs
  3. 4
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/PurchaseOrders/PurchaseOrderAppService.cs
  4. 4
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/Receipts/ReceiptAppService.cs
  5. 4
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/Suppliers/SuppliersAppService.cs
  6. 4
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/UnplannedReceipts/UnplannedReceiptAppService.cs
  7. 3
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/AsnOptions.cs
  8. 2
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/EnumExchangeDataErrorCode.cs
  9. 0
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/HiddenApiAttribute.cs
  10. 4
      WebApiService/src/Win_in.Sfs.Scp.WebApi.HttpApi.Host/AsnBackgroundWorker/AsnBackgroundWorker.cs
  11. 9
      WebApiService/src/Win_in.Sfs.Scp.WebApi.HttpApi.Host/AsnBackgroundWorker/EnumExchangeDataErrorCode.cs
  12. 20
      WebApiService/src/Win_in.Sfs.Scp.WebApi.HttpApi.Host/HiddenApiFilter.cs
  13. 2
      WebApiService/src/Win_in.Sfs.Scp.WebApi.HttpApi.Host/WebApiHttpApiHostModule.cs
  14. 1
      WebApiService/src/Win_in.Sfs.Scp.WebApi.HttpApi.Host/appsettings.json

34
WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/Asns/X12AsnAppService.cs

@ -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);

4
WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/Parts/PartAppService.cs

@ -58,6 +58,7 @@ namespace Win_in.Sfs.Scp.WebApi
[HttpGet]
[Route("{id}")]
[HiddenApi]
public override async Task<PartDTO> GetAsync(Guid id)
{
return await base.GetAsync(id);
@ -70,7 +71,8 @@ namespace Win_in.Sfs.Scp.WebApi
/// <param name="requestDTO">请求条件DTO(Request condition DTO)</param>
/// <returns></returns>
[HttpGet]
[Route("")]
[Route("paged-list")]
[HiddenApi]
public override async Task<PagedResultDto<PartDTO>> GetListAsync(RequestDTO requestDTO)
{
return await base.GetListAsync(requestDTO);

4
WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/PurchaseOrders/PurchaseOrderAppService.cs

@ -55,6 +55,7 @@ namespace Win_in.Sfs.Scp.WebApi
/// <returns></returns>
[HttpGet]
[Route("{id}")]
[HiddenApi]
public override async Task<PurchaseOrderDTO> GetAsync(Guid id)
{
return await base.GetAsync(id);
@ -66,7 +67,8 @@ namespace Win_in.Sfs.Scp.WebApi
/// </summary>
/// <returns></returns>
[HttpGet]
[Route("")]
[Route("paged-list")]
[HiddenApi]
public override async Task<PagedResultDto<PurchaseOrderDTO>> GetListAsync(RequestDTO input)
{
return await base.GetListAsync(input);

4
WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/Receipts/ReceiptAppService.cs

@ -55,6 +55,7 @@ namespace Win_in.Sfs.Scp.WebApi
/// <returns></returns>
[HttpGet]
[Route("{id}")]
[HiddenApi]
public override async Task<ReceiptDTO> GetAsync(Guid id)
{
return await base.GetAsync(id);
@ -67,7 +68,8 @@ namespace Win_in.Sfs.Scp.WebApi
/// <param name="requestDTO">请求条件DTO(Request condition DTO)</param>
/// <returns></returns>
[HttpGet]
[Route("")]
[Route("paged-list")]
[HiddenApi]
public override async Task<PagedResultDto<ReceiptDTO>> GetListAsync(RequestDTO requestDTO)
{
return await base.GetListAsync(requestDTO);

4
WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/Suppliers/SuppliersAppService.cs

@ -51,6 +51,7 @@ namespace Win_in.Sfs.Scp.WebApi
/// <returns></returns>
[HttpGet]
[Route("{id}")]
[HiddenApi]
public override async Task<SupplierDTO> GetAsync(Guid id)
{
return await base.GetAsync(id);
@ -63,7 +64,8 @@ namespace Win_in.Sfs.Scp.WebApi
/// <param name="requestDTO">请求条件DTO(Request condition DTO)</param>
/// <returns></returns>
[HttpGet]
[Route("")]
[Route("paged-list")]
[HiddenApi]
public override async Task<PagedResultDto<SupplierDTO>> GetListAsync(RequestDTO requestDTO)
{
return await base.GetListAsync(requestDTO);

4
WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/UnplannedReceipts/UnplannedReceiptAppService.cs

@ -57,6 +57,7 @@ namespace Win_in.Sfs.Scp.WebApi
/// <returns></returns>
[HttpGet]
[Route("{id}")]
[HiddenApi]
public override async Task<UnplannedReceiptDTO> GetAsync(Guid id)
{
return await base.GetAsync(id);
@ -69,7 +70,8 @@ namespace Win_in.Sfs.Scp.WebApi
/// <param name="requestDTO">请求条件DTO(Request condition DTO)</param>
/// <returns></returns>
[HttpGet]
[Route("")]
[Route("paged-list")]
[HiddenApi]
public override async Task<PagedResultDto<UnplannedReceiptDTO>> GetListAsync(RequestDTO requestDTO)
{
return await base.GetListAsync(requestDTO);

3
WebApiService/src/Win_in.Sfs.Scp.WebApi.HttpApi.Host/AsnBackgroundWorker/AsnBgWorker.cs → WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/AsnOptions.cs

@ -2,12 +2,13 @@ using System.Collections.Generic;
namespace Win_in.Sfs.Scp.WebApi;
public class AsnBgWorker
public class AsnOptions
{
public bool Active { get; set; } = false;
public int PeriodSeconds { get; set; } = 60;
public int RetryTimes { get; set; } = 3;
public int BatchSize { get; set; } = 10;
public int MaxCount { get; set; } = 100;
public List<string> Sites { get; set; } =new() ;
public string Receiver { get; set; } = "IACNA_ID";
}

2
WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/EnumExchangeDataErrorCode.cs

@ -1,4 +1,4 @@
namespace Win_in.Sfs.Scp.WebApi.Asns;
namespace Win_in.Sfs.Scp.WebApi;
public enum EnumExchangeDataErrorCode
{

0
WebApiService/src/Win_in.Sfs.Scp.WebApi.HttpApi.Host/HiddenApiAttribute.cs → WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/HiddenApiAttribute.cs

4
WebApiService/src/Win_in.Sfs.Scp.WebApi.HttpApi.Host/AsnBackgroundWorker/AsnBackgroundWorker.cs

@ -24,11 +24,11 @@ namespace Win_in.Sfs.Scp.WebApi;
public class AsnBackgroundWorker : AsyncPeriodicBackgroundWorkerBase
{
private readonly IOptions<AsnBgWorker> _options;
private readonly IOptions<AsnOptions> _options;
public AsnBackgroundWorker(
AbpAsyncTimer timer,
IOptions<AsnBgWorker> options,
IOptions<AsnOptions> options,
IServiceScopeFactory serviceScopeFactory
) : base(timer, serviceScopeFactory)
{

9
WebApiService/src/Win_in.Sfs.Scp.WebApi.HttpApi.Host/AsnBackgroundWorker/EnumExchangeDataErrorCode.cs

@ -1,9 +0,0 @@
namespace Win_in.Sfs.Scp.WebApi;
public enum EnumExchangeDataErrorCode
{
None = 0,
UnknownDataType = 1,
WrongDataFormat = 2,
Exception = 9,
}

20
WebApiService/src/Win_in.Sfs.Scp.WebApi.HttpApi.Host/HiddenApiFilter.cs

@ -13,23 +13,27 @@ public class HiddenApiFilter : IDocumentFilter
{
public void Apply(OpenApiDocument swaggerDoc, DocumentFilterContext context)
{
foreach (ApiDescription apiDescription in context.ApiDescriptions)
foreach (var apiDescription in context.ApiDescriptions)
{
if (apiDescription.TryGetMethodInfo(out MethodInfo method))
if (!apiDescription.TryGetMethodInfo(out var method))
{
if (method.ReflectedType.CustomAttributes.Any(t => t.AttributeType == typeof(HiddenApiAttribute))
|| method.CustomAttributes.Any(t => t.AttributeType == typeof(HiddenApiAttribute)))
continue;
}
if (!method.ReflectedType.CustomAttributes.Any(t => t.AttributeType == typeof(HiddenApiAttribute)) &&
method.CustomAttributes.All(t => t.AttributeType != typeof(HiddenApiAttribute)))
{
string key = "/" + apiDescription.RelativePath;
continue;
}
var key = "/" + apiDescription.RelativePath;
if (key.Contains("?"))
{
int idx = key.IndexOf("?", System.StringComparison.Ordinal);
var idx = key.IndexOf("?", System.StringComparison.Ordinal);
key = key.Substring(0, idx);
}
swaggerDoc.Paths.Remove(key);
}
}
}
}
}

2
WebApiService/src/Win_in.Sfs.Scp.WebApi.HttpApi.Host/WebApiHttpApiHostModule.cs

@ -78,7 +78,7 @@ namespace Win_in.Sfs.Scp.WebApi
ConfigureMultiTenancy(configuration);
ConfigureAuthorization(context,configuration);
context.Services.AddScoped<IConnectionStringResolver, MultiTenantConnectionStringResolver>();
Configure<AsnBgWorker>(configuration.GetSection("AsnBgWorker"));
Configure<AsnOptions>(configuration.GetSection("AsnOptions"));
}

1
WebApiService/src/Win_in.Sfs.Scp.WebApi.HttpApi.Host/appsettings.json

@ -39,6 +39,7 @@
"PeriodSeconds": 10,
"RetryTimes": 3,
"BatchSize": 10,
"MaxCount": 100,
"Receiver": "IACNA_ID",
"Sites": [ "T8", "T5" ]
},

Loading…
Cancel
Save