This commit is contained in:
Antinew 2025-07-05 00:45:23 +08:00
parent a2d8a2919c
commit 6fb8ea0558
28 changed files with 261 additions and 348 deletions

View File

@ -274,7 +274,7 @@ public class DefaultForwardFlow : IForwardFlow
msg.RequestUri = new Uri(targetInterface.RequestAddress);
msg.Method = new HttpMethod(targetInterface.RequestMethod.ToUpper());
msg.Method = new HttpMethod(targetInterface.RequestMethod.ToString().ToUpper());
// 将参数绑定到query
var builder = new UriBuilder(targetInterface.RequestAddress);

View File

@ -1,38 +1,33 @@
using System.ComponentModel;
using System.Reflection;
using InterfaceForward.Repositories.Dictionary.Services;
using Microsoft.AspNetCore.Mvc;
namespace InterfaceForward.Application.Services.App
{
namespace InterfaceForward.Application.Services.App;
/// <summary>
/// 字典服务
/// </summary>
[ApiExplorerSettings(GroupName = "应用服务")]
public class DictionaryService : ApplicationService
{
private readonly IDictionaryRepository _dictionaryRepository;
private static readonly Dictionary<string, Dictionary<string, int>> EnumCache = new();
/// <summary>
///
/// </summary>
public DictionaryService(
IDictionaryRepository dictionaryRepository)
{
_dictionaryRepository = dictionaryRepository;
}
private static readonly Dictionary<string, List<EnumCacheEntry>> EnumCache = new();
/// <summary>
/// 列表
/// </summary>
/// <param name="type">类型</param>
/// <param name="type">枚举类型</param>
/// <returns></returns>
[HttpGet("Dictionary/GetList")]
public async Task<dynamic> GetList(string type)
public List<EnumCacheEntry> GetList(string type)
{
return await _dictionaryRepository.AsQueryable().Where(x => x.Type == type).Select(x => new { Key = x.Id, Value = x.Name }).ToListAsync();
// 优先读枚举值
return GetKvsByEnumTypeName(type);
}
[HttpPost("Dictionary/CleanCache")]
public void CleanCache(string type)
{
EnumCache.Clear();
}
/// <summary>
@ -40,8 +35,8 @@ namespace InterfaceForward.Application.Services.App
/// </summary>
/// <param name="enumTypeName">枚举类型名称</param>
/// <returns></returns>
[HttpGet("Dictionary/GetKvsByEnumTypeName")]
public Dictionary<string, int> GetKvsByEnumTypeName(string enumTypeName)
[NonAction]
private List<EnumCacheEntry> GetKvsByEnumTypeName(string enumTypeName)
{
// Check if the type is already cached
if (EnumCache.TryGetValue(enumTypeName, out var res))
@ -65,20 +60,30 @@ namespace InterfaceForward.Application.Services.App
}
// Retrieve the descriptions and values
var enumDict = new Dictionary<string, int>();
var list = new List<EnumCacheEntry>();
foreach (var value in enumType.GetEnumValues())
{
var name = value.ToString();
var fieldInfo = enumType.GetField(name);
var descriptionAttribute = fieldInfo.GetCustomAttribute<DescriptionAttribute>();
string description = descriptionAttribute != null ? descriptionAttribute.Description : name;
enumDict[description] = (int)value;
list.Add(new EnumCacheEntry
{
Key = (int)value,
Value = description
});
}
// Cache the result
EnumCache[enumTypeName] = enumDict;
EnumCache[enumTypeName] = list;
return enumDict;
}
return list;
}
public class EnumCacheEntry
{
public int Key { get; set; }
public string Value { get; set; } = null!;
}
}

View File

@ -45,7 +45,7 @@ public class InterfaceForwardCommon(
.ToObject<ForwardCoreContextCache>();
if (cacheContext == null)
{
var systemInterface = await interfaceForwardQuery.GetInterfaceByCodeAsync(upStreamCode);
var systemInterface = await interfaceForwardQuery.GetInterfaceByCodesAsync(upStreamCode);
if (systemInterface == null) throw new BusinessException(message: "系统接口不存在");
logRepository.AppRequestLog.InterfaceCode = systemInterface.Code;

View File

@ -59,7 +59,7 @@ public class InterfaceMapPublishService(
public async Task<InterfaceMapPublishedDifferenceVO> GetPublishCompareAsync([Required] string interfaceCode,
[Required] int serviceProviderId, string version)
{
var systemInterface = await interfaceForwardQuery.GetInterfaceByCodeAsync(interfaceCode);
var systemInterface = await interfaceForwardQuery.GetInterfaceByCodesAsync(interfaceCode);
if (systemInterface == null) throw new BusinessException(message: "系统接口不存在");
var serviceProvider = await interfaceForwardQuery.GetServiceProviderByIdAsync(serviceProviderId);
@ -98,7 +98,7 @@ public class InterfaceMapPublishService(
[HttpPost("InterfaceMap/Publish")]
public async Task<bool> PublishAsync(InterfaceMapPublishInput input)
{
var systemInterface = await interfaceForwardQuery.GetInterfaceByCodeAsync(input.InterfaceCode);
var systemInterface = await interfaceForwardQuery.GetInterfaceByCodesAsync(input.InterfaceCode);
if (systemInterface == null) throw new BusinessException(message: "系统接口不存在");
var serviceProvider = await interfaceForwardQuery.GetServiceProviderByIdAsync(input.ServiceProviderId);
@ -151,7 +151,7 @@ public class InterfaceMapPublishService(
[HttpPost("InterfaceMap/PublishRollback")]
public async Task<bool> PublishRollbackAsync(InterfaceMapRollbackInput input)
{
var systemInterface = await interfaceForwardQuery.GetInterfaceByCodeAsync(input.InterfaceCode);
var systemInterface = await interfaceForwardQuery.GetInterfaceByCodesAsync(input.InterfaceCode);
if (systemInterface == null) throw new BusinessException(message: "系统接口不存在");
var serviceProvider = await interfaceForwardQuery.GetServiceProviderByIdAsync(input.ServiceProviderId);
if (serviceProvider == null) throw new BusinessException(message: "服务商不存在");

View File

@ -37,7 +37,7 @@ public class InterfaceDto
///<summary>
/// 请求方式
///</summary>
public string RequestMethod { get; set; } = null!;
public RequestMethod RequestMethod { get; set; }
///<summary>
/// 内容类型

View File

@ -2,17 +2,17 @@
public enum ContentType
{
FormUrlEncoded = 17,
FormData = 18,
Json = 19,
Xml = 20,
FormUrlEncoded = 1,
FormData,
Json,
Xml,
}
public enum ResponseContentType
{
Json = 33,
Xml = 34,
pdf = 35,
Base64 = 36,
csv = 44
Json = 1,
Xml,
pdf,
Base64,
csv
}

View File

@ -1,38 +0,0 @@
using System.ComponentModel;
namespace InterfaceForward.Domain.Shared.Enum
{
/// <summary>
/// 接口类型
/// </summary>
public enum InterfaceTypeEnum
{
/// <summary>
/// 系统接口
/// </summary>
[Description("系统接口")]
,
/// <summary>
/// 服务商接口
/// </summary>
[Description("服务商接口")]
}
/// <summary>
/// 选择类型
/// </summary>
public enum LogListInputTypeEnum
{
/// <summary>
/// 应用
/// </summary>
[Description("应用")]
,
/// <summary>
/// 服务商
/// </summary>
[Description("服务商")]
}
}

View File

@ -5,9 +5,9 @@ namespace InterfaceForward.Domain.Shared.Enum;
/// </summary>
public enum FieldPosition
{
Header = 5,
Body = 6,
Query = 7,
Url = 32,
Nothing = 42 //不处理
Header = 1,
Body,
Query,
Url,
Nothing //不处理
}

View File

@ -8,15 +8,15 @@ public enum InterfaceReturnConfigType
/// 状态码
/// </summary>
[Description("状态码")]
StatusCode = 101,
StatusCode = 1,
/// <summary>
/// PDF标签上传
/// </summary>
[Description("PDF标签上传")]
PdfLabel = 102,
PdfLabel,
/// <summary>
/// 错误信息返回
/// </summary>
[Description("错误信息返回")]
ErrorMsg = 103,
ErrorMsg,
}

View File

@ -11,7 +11,7 @@ public enum LabelType
/// Url
/// </summary>
[Description("Url")]
Url,
Url = 1,
/// <summary>
/// Base64
/// </summary>

View File

@ -0,0 +1,20 @@
using System.ComponentModel;
namespace InterfaceForward.Domain.Shared.Enum;
/// <summary>
/// 选择类型
/// </summary>
public enum LogListInputTypeEnum
{
/// <summary>
/// 应用
/// </summary>
[Description("应用")]
= 1,
/// <summary>
/// 服务商
/// </summary>
[Description("服务商")]
}

View File

@ -1,6 +0,0 @@
namespace InterfaceForward.Domain.Shared.Enum;
public enum MessageType
{
Error, Info, Debug, Warn, Notice
}

View File

@ -1,7 +1,6 @@
using System.ComponentModel;
namespace InterfaceForward.Domain.Shared.Enum
{
namespace InterfaceForward.Domain.Shared.Enum;
public enum OptionType
{
@ -14,35 +13,3 @@ namespace InterfaceForward.Domain.Shared.Enum
[Description("修改")]
= 3
}
public enum OptionTypeNoDelete
{
[Description("新增")]
= 1,
[Description("修改")]
= 3
}
public enum OptionTypeNoNull
{
[Description("新增")]
= 1,
[Description("删除")]
= 2,
[Description("修改")]
= 3
}
public enum ButtonType
{
[Description("新增")]
= 1,
[Description("删除")]
= 2,
[Description("修改")]
= 3,
[Description("查看")]
= 4
}
}

View File

@ -11,7 +11,7 @@ public enum ParameterParseTypeEnum
/// JSON
/// </summary>
[Description("JSON")]
Json,
Json = 1,
/// <summary>
/// XML
/// </summary>

View File

@ -2,12 +2,12 @@ namespace InterfaceForward.Domain.Shared.Enum;
public enum ParameterType
{
String = 8,
Float = 9,
Object = 10,
Boolean = 11,
Array = 12,
Integer = 43,
DateTime = 114,
DateTimeOffset = 115,
String = 1,
Float,
Object,
Boolean,
Array,
Integer,
DateTime,
DateTimeOffset,
}

View File

@ -0,0 +1,12 @@
namespace InterfaceForward.Domain.Shared.Enum;
public enum RequestMethod
{
GET = 1,
POST = 2,
PUT,
DELETE,
OPTIONS,
HEAD,
PATCH
}

View File

@ -2,8 +2,8 @@
public enum RequestProtocol
{
Http = 13,
Https = 14,
WCF = 39,
SOAP = 49
Http = 1,
Https,
WCF,
SOAP
}

View File

@ -2,8 +2,8 @@
public enum ServiceProviderType
{
= 21,
= 22,
= 23,
= 24
= 1,
,
,
}

View File

@ -1,41 +0,0 @@
namespace InterfaceForward.Repositories.Dictionary.Entitys
{
///<summary>
/// 字典表
///</summary>
[SugarTable("t_dictionary")]
public class DictionaryEntity : FullAuditedAggregateRoot<int>
{
///<summary>
/// 自增主键
///</summary>
[SugarColumn(ColumnName = "Id", IsPrimaryKey = true, IsIdentity = true)]
public int Id { get; set; }
///<summary>
/// 类型
///</summary>
[SugarColumn(ColumnName = "Type")]
public string Type { get; set; }
///<summary>
/// 名称
///</summary>
[SugarColumn(ColumnName = "Name")]
public string Name { get; set; }
///<summary>
/// 字典描述
///</summary>
[SugarColumn(ColumnName = "Description")]
public string Description { get; set; }
///<summary>
/// 排序
///</summary>
[SugarColumn(ColumnName = "Sort")]
public int Sort { get; set; }
}
}

View File

@ -1,11 +0,0 @@
using InterfaceForward.Repositories.Dictionary.Entitys;
namespace InterfaceForward.Repositories.Dictionary.Services
{
/// <summary>
/// 字典仓储实现
/// </summary>
public class DictionaryRepository : BasicRepository<DictionaryEntity>, IDictionaryRepository, IScopedDependency
{
}
}

View File

@ -1,12 +0,0 @@
using InterfaceForward.Repositories.Dictionary.Entitys;
namespace InterfaceForward.Repositories.Dictionary.Services
{
/// <summary>
/// 字典仓储
/// </summary>
public interface IDictionaryRepository
{
ISugarQueryable<DictionaryEntity> AsQueryable();
}
}

View File

@ -8,7 +8,6 @@ namespace InterfaceForward.Repositories.Interface.Entitys;
[SugarTable("t_interface")]
public class InterfaceEntity : FullAuditedAggregateRoot<int>
{
///<summary>
/// 自增主键
///</summary>
@ -61,7 +60,7 @@ public class InterfaceEntity : FullAuditedAggregateRoot<int>
/// 请求方式
///</summary>
[SugarColumn(ColumnName = "RequestMethod")]
public int RequestMethod { get; set; }
public RequestMethod RequestMethod { get; set; }
///<summary>
/// 内容类型

View File

@ -1,7 +1,5 @@
using InterfaceForward.Domain.Shared.Enum;
using InterfaceForward.Application.Contracts.Dtos.Interface;
using InterfaceForward.Domain.Shared.Dtos;
using InterfaceForward.Repositories.Dictionary.Entitys;
using InterfaceForward.Repositories.Interface.Entitys;
using InterfaceForward.Repositories.Interface.ValueObjects;
using InterfaceForward.Repositories.Parameter.VO;
@ -21,8 +19,6 @@ public class InterfaceRepository : BasicRepository<InterfaceEntity>, IInterfaceR
{
// t_interface驱动t_interface_map数据量上来可以在t_interface_map UpStreamId字段建立索引
var query = AsQueryable()
.LeftJoin<DictionaryEntity>((a, d) => (int)a.RequestProtocol == d.Id)
.LeftJoin<DictionaryEntity>((a, d, e) => a.RequestMethod == e.Id)
.Where(a => a.IsUpStream)
;
@ -33,13 +29,13 @@ public class InterfaceRepository : BasicRepository<InterfaceEntity>, IInterfaceR
return await query
.OrderBy(a => a.CreateTime)
.Select((a, d, e) => new SystemInterfaceTreeListValueObject
.Select(a => new SystemInterfaceTreeListValueObject
{
Id = a.Id,
CategoryId = a.Category,
Name = a.Name,
Code = a.Code,
RequestProtocol = d.Name,
RequestProtocol = a.RequestProtocol,
Description = a.Description,
MapCount = SqlFunc.Subqueryable<InterfaceMapEntity>().Where(x => x.UpStreamId == a.Id && !x.IsDeleted)
.DistinctCount(x => x.ServiceProviderId),
@ -52,8 +48,6 @@ public class InterfaceRepository : BasicRepository<InterfaceEntity>, IInterfaceR
GetServiceProviderInterfaceListAsync(ServiceProviderInterfaceTreeListInputObjectValue input)
{
var query = AsQueryable()
.LeftJoin<DictionaryEntity>((a, b) => (int)a.RequestProtocol == b.Id)
.LeftJoin<DictionaryEntity>((a, b, c) => a.RequestMethod == c.Id)
.Where(a => !a.IsUpStream)
.Where(a => a.ServiceProviderId == input.ServiceProviderId);
@ -63,18 +57,7 @@ public class InterfaceRepository : BasicRepository<InterfaceEntity>, IInterfaceR
;
return await query
.OrderBy(a => a.CreateTime)
.Select((a, b, c) => new ServiceProviderInterfaceTreeListOutputValueObject
{
Id = a.Id,
CategoryId = a.Category,
Name = a.Name,
Code = a.Code,
RequestProtocol = b.Name,
RequestMethod = c.Name,
RequestAddress = a.RequestAddress,
Description = a.Description,
UpdateTime = a.UpdateTime,
})
.Select<ServiceProviderInterfaceTreeListOutputValueObject>()
.ToListAsync();
}
@ -94,10 +77,12 @@ public class InterfaceRepository : BasicRepository<InterfaceEntity>, IInterfaceR
public async Task<List<SystemInterfaceDropdownValueObject>> GetSystemInterfaceDropdownListAsync()
{
// 获取所有接口分组
var groups = await Context.Queryable<DictionaryEntity>()
.Where(x => x.Type == InterfaceGroup)
.Select(x => new { x.Id, x.Name })
.ToListAsync();
// var groups = await Context.Queryable<DictionaryEntity>()
// .Where(x => x.Type == InterfaceGroup)
// .Select(x => new { x.Id, x.Name })
// .ToListAsync();
var groups = new List<string>() { "全部" };
// 获取所有接口
var interfaces = await AsQueryable()
@ -109,8 +94,9 @@ public class InterfaceRepository : BasicRepository<InterfaceEntity>, IInterfaceR
return groups.Select(x => new SystemInterfaceDropdownValueObject
{
Id = Guid.NewGuid().ToString(),
GroupName = x.Name,
Interfaces = interfaces.Where(y => y.Category == x.Id)
GroupName = x,
Interfaces = interfaces
//.Where(y => y.Category == x.Id)
.Select(y => new SystemInterfaceItemValueObject
{
Id = y.Id,
@ -138,9 +124,6 @@ public class InterfaceRepository : BasicRepository<InterfaceEntity>, IInterfaceR
{
// t_interface驱动t_interface_map数据量上来可以在t_interface_map UpStreamId字段建立索引
var query = AsQueryable()
.LeftJoin<DictionaryEntity>((a, c) => a.Category == c.Id)
.LeftJoin<DictionaryEntity>((a, c, d) => (int)a.RequestProtocol == d.Id)
.LeftJoin<DictionaryEntity>((a, c, d, e) => a.RequestMethod == e.Id)
.Where(a => a.IsUpStream)
;
@ -150,18 +133,22 @@ public class InterfaceRepository : BasicRepository<InterfaceEntity>, IInterfaceR
|| a.Code.Contains(keyword)) // 默认为空,支持模糊搜索
;
return await query.Select((a, c, d, e) => new SystemInterfacePaginatedOutputValueObject
var res = await query.Select(a => new SystemInterfacePaginatedOutputValueObject
{
Id = a.Id,
Category = c.Name,
Category = a.Category,
Name = a.Name,
Code = a.Code,
RequestProtocol = d.Name,
RequestProtocol = a.RequestProtocol,
Description = a.Description,
MapCount = SqlFunc.Subqueryable<InterfaceMapEntity>().Where(x => x.UpStreamId == a.Id && !x.IsDeleted)
.DistinctCount(x => x.ServiceProviderId),
UpdateTime = a.UpdateTime,
}).OrderByDescending(a => a.UpdateTime).ToPagedListAsync(input.PageIndex, input.PageSize);
})
.OrderByDescending(a => a.UpdateTime)
.ToPagedListAsync(input.PageIndex, input.PageSize);
return res;
}
/// <inheritdoc />
@ -169,8 +156,6 @@ public class InterfaceRepository : BasicRepository<InterfaceEntity>, IInterfaceR
GetServiceProviderInterfacePaginatedListAsync(ServiceProviderInterfacePaginatedInputObjectValue input)
{
var query = AsQueryable()
.LeftJoin<DictionaryEntity>((a, b) => (int)a.RequestProtocol == b.Id)
.LeftJoin<DictionaryEntity>((a, b, c) => a.RequestMethod == c.Id)
.Where(a => !a.IsUpStream)
.Where(a => a.ServiceProviderId == input.ServiceProviderId);
@ -178,17 +163,7 @@ public class InterfaceRepository : BasicRepository<InterfaceEntity>, IInterfaceR
.WhereIF(!string.IsNullOrEmpty(input.Name), a => a.Name.Contains(input.Name!)) // 默认为空,支持模糊搜索
.WhereIF(!string.IsNullOrEmpty(input.Code), a => a.Code.Contains(input.Code!)) // 默认为空,支持模糊搜索
;
return await query.Select((a, b, c) => new ServiceProviderInterfacePaginatedOutputValueObject
{
Id = a.Id,
Name = a.Name,
Code = a.Code,
RequestProtocol = b.Name,
RequestMethod = c.Name,
RequestAddress = a.RequestAddress,
Description = a.Description,
UpdateTime = a.UpdateTime,
})
return await query.Select<ServiceProviderInterfacePaginatedOutputValueObject>()
.OrderByDescending(a => a.UpdateTime)
.ToPagedListAsync(input.PageIndex, input.PageSize);
}

View File

@ -1,4 +1,7 @@
namespace InterfaceForward.Repositories.Interface.ValueObjects;
using InterfaceForward.Domain.Shared.Enum;
using InterfaceForward.Domain.Shared.Helpers;
namespace InterfaceForward.Repositories.Interface.ValueObjects;
/// <summary>
///
@ -23,12 +26,22 @@ public class ServiceProviderInterfacePaginatedOutputValueObject
///<summary>
/// 请求协议
///</summary>
public string RequestProtocol { get; set; }
public int RequestProtocol { get; set; }
///<summary>
/// 请求方式
///</summary>
public string RequestMethod { get; set; }
public int RequestMethod { get; set; }
///<summary>
/// 请求协议Name
///</summary>
public string RequestProtocolName => ((RequestProtocol)RequestProtocol).GetDescription();
///<summary>
/// 请求方式Name
///</summary>
public string RequestMethodName => ((RequestMethod)RequestMethod).GetDescription();
///<summary>
/// 请求地址

View File

@ -1,4 +1,7 @@
namespace InterfaceForward.Repositories.Interface.ValueObjects;
using InterfaceForward.Domain.Shared.Enum;
using InterfaceForward.Domain.Shared.Helpers;
namespace InterfaceForward.Repositories.Interface.ValueObjects;
/// <summary>
///
@ -23,12 +26,22 @@ public class ServiceProviderInterfaceTreeListOutputValueObject: HasCategoryId
///<summary>
/// 请求协议
///</summary>
public string RequestProtocol { get; set; }
public RequestProtocol RequestProtocol { get; set; }
///<summary>
/// 请求方式
///</summary>
public string RequestMethod { get; set; }
public RequestMethod RequestMethod { get; set; }
///<summary>
/// 请求协议Name
///</summary>
public string RequestProtocolName => RequestProtocol.GetDescription();
///<summary>
/// 请求方式Name
///</summary>
public string RequestMethodName => RequestMethod.GetDescription();
///<summary>
/// 请求地址

View File

@ -1,4 +1,7 @@
namespace InterfaceForward.Repositories.Interface.ValueObjects
using InterfaceForward.Domain.Shared.Enum;
using InterfaceForward.Domain.Shared.Helpers;
namespace InterfaceForward.Repositories.Interface.ValueObjects
{
/// <summary>
///
@ -13,7 +16,12 @@
///<summary>
/// 接口分组
///</summary>
public string Category { get; set; }
public int Category { get; set; }
///<summary>
/// 接口分组Name
///</summary>
public string CategoryName => "全部";
///<summary>
/// 接口名
@ -28,7 +36,12 @@
///<summary>
/// 请求协议
///</summary>
public string RequestProtocol { get; set; }
public RequestProtocol RequestProtocol { get; set; }
///<summary>
/// 请求协议Name
///</summary>
public string RequestProtocolName => ((RequestProtocol)RequestProtocol).GetDescription();
///<summary>
/// 接口描述

View File

@ -1,4 +1,7 @@
namespace InterfaceForward.Repositories.Interface.ValueObjects
using InterfaceForward.Domain.Shared.Enum;
using InterfaceForward.Domain.Shared.Helpers;
namespace InterfaceForward.Repositories.Interface.ValueObjects
{
public class HasCategoryId
{
@ -31,7 +34,12 @@
///<summary>
/// 请求协议
///</summary>
public string RequestProtocol { get; set; }
public RequestProtocol RequestProtocol { get; set; }
///<summary>
/// 请求协议
///</summary>
public string RequestProtocolName => ((RequestProtocol)RequestProtocol).GetDescription();
///<summary>
/// 接口描述

View File

@ -3,7 +3,6 @@ using InterfaceForward.Domain.Shared.Enum;
using InterfaceForward.Domain.Shared.Helpers;
using InterfaceForward.Repositories.App.Entitys;
using InterfaceForward.Repositories.App.ValueObjects;
using InterfaceForward.Repositories.Dictionary.Entitys;
using InterfaceForward.Repositories.Interface.Entitys;
using InterfaceForward.Repositories.Parameter.Entities;
using InterfaceForward.Repositories.ServiceProvider.Entitys;
@ -143,9 +142,9 @@ ORDER BY `b`.`Sort` ASC").ToListAsync();
/// </summary>
/// <param name="interfaceCode"></param>
/// <returns></returns>
public async Task<InterfaceDto?> GetInterfaceByCodeAsync(string interfaceCode)
public async Task<InterfaceDto?> GetInterfaceByCodesAsync(string interfaceCode)
{
var res = await GetInterfaceByCodesAsync(interfaceCode);
var res = await GetInterfaceByCodesAsync(new[] { interfaceCode });
return res.FirstOrDefault();
}
@ -194,7 +193,7 @@ ORDER BY `b`.`Sort` ASC").ToListAsync();
if (serviceProvider.AuthInterfaceCode != null)
{
var authInterface = await GetInterfaceByCodeAsync(serviceProvider.AuthInterfaceCode);
var authInterface = await GetInterfaceByCodesAsync(serviceProvider.AuthInterfaceCode);
if (authInterface == null)
{
throw new BusinessException($"授权接口{serviceProvider.AuthInterfaceCode}不存在");
@ -321,13 +320,10 @@ ORDER BY `b`.`Sort` ASC").ToListAsync();
/// <returns></returns>
private async Task<List<InterfaceDto>> GetInterfaceByCodesAsync(params string[] interfaceCodes)
{
var query = Context.Queryable<InterfaceEntity, DictionaryEntity>(
(a, d) => new JoinQueryInfos(
JoinType.Left, a.RequestMethod == d.Id
))
var query = Context.Queryable<InterfaceEntity>()
.Where(a => interfaceCodes.Contains(a.Code) && a.IsDeleted == false)
.Filter(null, true)
.Select((a, d) =>
.Select(a =>
new InterfaceDto
{
Id = a.Id,
@ -338,7 +334,7 @@ ORDER BY `b`.`Sort` ASC").ToListAsync();
RequestProtocol = a.RequestProtocol,
ContentType = a.ContentType,
ResponseContentType = a.ResponseContentType,
RequestMethod = d.Name,
RequestMethod = a.RequestMethod,
IsBatch = a.IsBatch,
Limit = a.Limit,
Qps = a.Qps,