111
This commit is contained in:
parent
a2d8a2919c
commit
6fb8ea0558
@ -274,7 +274,7 @@ public class DefaultForwardFlow : IForwardFlow
|
|||||||
|
|
||||||
msg.RequestUri = new Uri(targetInterface.RequestAddress);
|
msg.RequestUri = new Uri(targetInterface.RequestAddress);
|
||||||
|
|
||||||
msg.Method = new HttpMethod(targetInterface.RequestMethod.ToUpper());
|
msg.Method = new HttpMethod(targetInterface.RequestMethod.ToString().ToUpper());
|
||||||
|
|
||||||
// 将参数绑定到query
|
// 将参数绑定到query
|
||||||
var builder = new UriBuilder(targetInterface.RequestAddress);
|
var builder = new UriBuilder(targetInterface.RequestAddress);
|
||||||
|
|||||||
@ -1,38 +1,33 @@
|
|||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using InterfaceForward.Repositories.Dictionary.Services;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
namespace InterfaceForward.Application.Services.App
|
namespace InterfaceForward.Application.Services.App;
|
||||||
{
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 字典服务
|
/// 字典服务
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[ApiExplorerSettings(GroupName = "应用服务")]
|
[ApiExplorerSettings(GroupName = "应用服务")]
|
||||||
public class DictionaryService : ApplicationService
|
public class DictionaryService : ApplicationService
|
||||||
{
|
{
|
||||||
private readonly IDictionaryRepository _dictionaryRepository;
|
private static readonly Dictionary<string, List<EnumCacheEntry>> EnumCache = new();
|
||||||
private static readonly Dictionary<string, Dictionary<string, int>> EnumCache = new();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
public DictionaryService(
|
|
||||||
IDictionaryRepository dictionaryRepository)
|
|
||||||
{
|
|
||||||
_dictionaryRepository = dictionaryRepository;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 列表
|
/// 列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="type">类型</param>
|
/// <param name="type">枚举类型</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet("Dictionary/GetList")]
|
[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>
|
/// <summary>
|
||||||
@ -40,8 +35,8 @@ namespace InterfaceForward.Application.Services.App
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="enumTypeName">枚举类型名称</param>
|
/// <param name="enumTypeName">枚举类型名称</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet("Dictionary/GetKvsByEnumTypeName")]
|
[NonAction]
|
||||||
public Dictionary<string, int> GetKvsByEnumTypeName(string enumTypeName)
|
private List<EnumCacheEntry> GetKvsByEnumTypeName(string enumTypeName)
|
||||||
{
|
{
|
||||||
// Check if the type is already cached
|
// Check if the type is already cached
|
||||||
if (EnumCache.TryGetValue(enumTypeName, out var res))
|
if (EnumCache.TryGetValue(enumTypeName, out var res))
|
||||||
@ -65,20 +60,30 @@ namespace InterfaceForward.Application.Services.App
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Retrieve the descriptions and values
|
// Retrieve the descriptions and values
|
||||||
var enumDict = new Dictionary<string, int>();
|
var list = new List<EnumCacheEntry>();
|
||||||
foreach (var value in enumType.GetEnumValues())
|
foreach (var value in enumType.GetEnumValues())
|
||||||
{
|
{
|
||||||
var name = value.ToString();
|
var name = value.ToString();
|
||||||
var fieldInfo = enumType.GetField(name);
|
var fieldInfo = enumType.GetField(name);
|
||||||
var descriptionAttribute = fieldInfo.GetCustomAttribute<DescriptionAttribute>();
|
var descriptionAttribute = fieldInfo.GetCustomAttribute<DescriptionAttribute>();
|
||||||
string description = descriptionAttribute != null ? descriptionAttribute.Description : name;
|
string description = descriptionAttribute != null ? descriptionAttribute.Description : name;
|
||||||
enumDict[description] = (int)value;
|
list.Add(new EnumCacheEntry
|
||||||
|
{
|
||||||
|
Key = (int)value,
|
||||||
|
Value = description
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cache the result
|
// 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!;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -45,7 +45,7 @@ public class InterfaceForwardCommon(
|
|||||||
.ToObject<ForwardCoreContextCache>();
|
.ToObject<ForwardCoreContextCache>();
|
||||||
if (cacheContext == null)
|
if (cacheContext == null)
|
||||||
{
|
{
|
||||||
var systemInterface = await interfaceForwardQuery.GetInterfaceByCodeAsync(upStreamCode);
|
var systemInterface = await interfaceForwardQuery.GetInterfaceByCodesAsync(upStreamCode);
|
||||||
if (systemInterface == null) throw new BusinessException(message: "系统接口不存在");
|
if (systemInterface == null) throw new BusinessException(message: "系统接口不存在");
|
||||||
|
|
||||||
logRepository.AppRequestLog.InterfaceCode = systemInterface.Code;
|
logRepository.AppRequestLog.InterfaceCode = systemInterface.Code;
|
||||||
|
|||||||
@ -59,7 +59,7 @@ public class InterfaceMapPublishService(
|
|||||||
public async Task<InterfaceMapPublishedDifferenceVO> GetPublishCompareAsync([Required] string interfaceCode,
|
public async Task<InterfaceMapPublishedDifferenceVO> GetPublishCompareAsync([Required] string interfaceCode,
|
||||||
[Required] int serviceProviderId, string version)
|
[Required] int serviceProviderId, string version)
|
||||||
{
|
{
|
||||||
var systemInterface = await interfaceForwardQuery.GetInterfaceByCodeAsync(interfaceCode);
|
var systemInterface = await interfaceForwardQuery.GetInterfaceByCodesAsync(interfaceCode);
|
||||||
if (systemInterface == null) throw new BusinessException(message: "系统接口不存在");
|
if (systemInterface == null) throw new BusinessException(message: "系统接口不存在");
|
||||||
|
|
||||||
var serviceProvider = await interfaceForwardQuery.GetServiceProviderByIdAsync(serviceProviderId);
|
var serviceProvider = await interfaceForwardQuery.GetServiceProviderByIdAsync(serviceProviderId);
|
||||||
@ -98,7 +98,7 @@ public class InterfaceMapPublishService(
|
|||||||
[HttpPost("InterfaceMap/Publish")]
|
[HttpPost("InterfaceMap/Publish")]
|
||||||
public async Task<bool> PublishAsync(InterfaceMapPublishInput input)
|
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: "系统接口不存在");
|
if (systemInterface == null) throw new BusinessException(message: "系统接口不存在");
|
||||||
|
|
||||||
var serviceProvider = await interfaceForwardQuery.GetServiceProviderByIdAsync(input.ServiceProviderId);
|
var serviceProvider = await interfaceForwardQuery.GetServiceProviderByIdAsync(input.ServiceProviderId);
|
||||||
@ -151,7 +151,7 @@ public class InterfaceMapPublishService(
|
|||||||
[HttpPost("InterfaceMap/PublishRollback")]
|
[HttpPost("InterfaceMap/PublishRollback")]
|
||||||
public async Task<bool> PublishRollbackAsync(InterfaceMapRollbackInput input)
|
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: "系统接口不存在");
|
if (systemInterface == null) throw new BusinessException(message: "系统接口不存在");
|
||||||
var serviceProvider = await interfaceForwardQuery.GetServiceProviderByIdAsync(input.ServiceProviderId);
|
var serviceProvider = await interfaceForwardQuery.GetServiceProviderByIdAsync(input.ServiceProviderId);
|
||||||
if (serviceProvider == null) throw new BusinessException(message: "服务商不存在");
|
if (serviceProvider == null) throw new BusinessException(message: "服务商不存在");
|
||||||
|
|||||||
@ -37,7 +37,7 @@ public class InterfaceDto
|
|||||||
///<summary>
|
///<summary>
|
||||||
/// 请求方式
|
/// 请求方式
|
||||||
///</summary>
|
///</summary>
|
||||||
public string RequestMethod { get; set; } = null!;
|
public RequestMethod RequestMethod { get; set; }
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
/// 内容类型
|
/// 内容类型
|
||||||
|
|||||||
@ -2,17 +2,17 @@
|
|||||||
|
|
||||||
public enum ContentType
|
public enum ContentType
|
||||||
{
|
{
|
||||||
FormUrlEncoded = 17,
|
FormUrlEncoded = 1,
|
||||||
FormData = 18,
|
FormData,
|
||||||
Json = 19,
|
Json,
|
||||||
Xml = 20,
|
Xml,
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum ResponseContentType
|
public enum ResponseContentType
|
||||||
{
|
{
|
||||||
Json = 33,
|
Json = 1,
|
||||||
Xml = 34,
|
Xml,
|
||||||
pdf = 35,
|
pdf,
|
||||||
Base64 = 36,
|
Base64,
|
||||||
csv = 44
|
csv
|
||||||
}
|
}
|
||||||
@ -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("服务商")]
|
|
||||||
服务商
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -5,9 +5,9 @@ namespace InterfaceForward.Domain.Shared.Enum;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public enum FieldPosition
|
public enum FieldPosition
|
||||||
{
|
{
|
||||||
Header = 5,
|
Header = 1,
|
||||||
Body = 6,
|
Body,
|
||||||
Query = 7,
|
Query,
|
||||||
Url = 32,
|
Url,
|
||||||
Nothing = 42 //不处理
|
Nothing //不处理
|
||||||
}
|
}
|
||||||
@ -8,15 +8,15 @@ public enum InterfaceReturnConfigType
|
|||||||
/// 状态码
|
/// 状态码
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Description("状态码")]
|
[Description("状态码")]
|
||||||
StatusCode = 101,
|
StatusCode = 1,
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// PDF标签上传
|
/// PDF标签上传
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Description("PDF标签上传")]
|
[Description("PDF标签上传")]
|
||||||
PdfLabel = 102,
|
PdfLabel,
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 错误信息返回
|
/// 错误信息返回
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Description("错误信息返回")]
|
[Description("错误信息返回")]
|
||||||
ErrorMsg = 103,
|
ErrorMsg,
|
||||||
}
|
}
|
||||||
@ -11,7 +11,7 @@ public enum LabelType
|
|||||||
/// Url
|
/// Url
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Description("Url")]
|
[Description("Url")]
|
||||||
Url,
|
Url = 1,
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Base64
|
/// Base64
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -0,0 +1,20 @@
|
|||||||
|
using System.ComponentModel;
|
||||||
|
|
||||||
|
namespace InterfaceForward.Domain.Shared.Enum;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 选择类型
|
||||||
|
/// </summary>
|
||||||
|
public enum LogListInputTypeEnum
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 应用
|
||||||
|
/// </summary>
|
||||||
|
[Description("应用")]
|
||||||
|
应用 = 1,
|
||||||
|
/// <summary>
|
||||||
|
/// 服务商
|
||||||
|
/// </summary>
|
||||||
|
[Description("服务商")]
|
||||||
|
服务商
|
||||||
|
}
|
||||||
@ -1,6 +0,0 @@
|
|||||||
namespace InterfaceForward.Domain.Shared.Enum;
|
|
||||||
|
|
||||||
public enum MessageType
|
|
||||||
{
|
|
||||||
Error, Info, Debug, Warn, Notice
|
|
||||||
}
|
|
||||||
@ -1,7 +1,6 @@
|
|||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
|
||||||
namespace InterfaceForward.Domain.Shared.Enum
|
namespace InterfaceForward.Domain.Shared.Enum;
|
||||||
{
|
|
||||||
|
|
||||||
public enum OptionType
|
public enum OptionType
|
||||||
{
|
{
|
||||||
@ -14,35 +13,3 @@ namespace InterfaceForward.Domain.Shared.Enum
|
|||||||
[Description("修改")]
|
[Description("修改")]
|
||||||
修改 = 3
|
修改 = 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
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
@ -11,7 +11,7 @@ public enum ParameterParseTypeEnum
|
|||||||
/// JSON
|
/// JSON
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Description("JSON")]
|
[Description("JSON")]
|
||||||
Json,
|
Json = 1,
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// XML
|
/// XML
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -2,12 +2,12 @@ namespace InterfaceForward.Domain.Shared.Enum;
|
|||||||
|
|
||||||
public enum ParameterType
|
public enum ParameterType
|
||||||
{
|
{
|
||||||
String = 8,
|
String = 1,
|
||||||
Float = 9,
|
Float,
|
||||||
Object = 10,
|
Object,
|
||||||
Boolean = 11,
|
Boolean,
|
||||||
Array = 12,
|
Array,
|
||||||
Integer = 43,
|
Integer,
|
||||||
DateTime = 114,
|
DateTime,
|
||||||
DateTimeOffset = 115,
|
DateTimeOffset,
|
||||||
}
|
}
|
||||||
12
src/InterfaceForward.Domain.Shared/Enum/RequestMethod.cs
Normal file
12
src/InterfaceForward.Domain.Shared/Enum/RequestMethod.cs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
namespace InterfaceForward.Domain.Shared.Enum;
|
||||||
|
|
||||||
|
public enum RequestMethod
|
||||||
|
{
|
||||||
|
GET = 1,
|
||||||
|
POST = 2,
|
||||||
|
PUT,
|
||||||
|
DELETE,
|
||||||
|
OPTIONS,
|
||||||
|
HEAD,
|
||||||
|
PATCH
|
||||||
|
}
|
||||||
@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
public enum RequestProtocol
|
public enum RequestProtocol
|
||||||
{
|
{
|
||||||
Http = 13,
|
Http = 1,
|
||||||
Https = 14,
|
Https,
|
||||||
WCF = 39,
|
WCF,
|
||||||
SOAP = 49
|
SOAP
|
||||||
}
|
}
|
||||||
@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
public enum ServiceProviderType
|
public enum ServiceProviderType
|
||||||
{
|
{
|
||||||
运输服务商 = 21,
|
运输服务商 = 1,
|
||||||
轨迹服务商 = 22,
|
轨迹服务商,
|
||||||
关务服务商 = 23,
|
关务服务商,
|
||||||
保险服务商 = 24
|
保险服务商
|
||||||
}
|
}
|
||||||
@ -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; }
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,11 +0,0 @@
|
|||||||
using InterfaceForward.Repositories.Dictionary.Entitys;
|
|
||||||
|
|
||||||
namespace InterfaceForward.Repositories.Dictionary.Services
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 字典仓储实现
|
|
||||||
/// </summary>
|
|
||||||
public class DictionaryRepository : BasicRepository<DictionaryEntity>, IDictionaryRepository, IScopedDependency
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,12 +0,0 @@
|
|||||||
using InterfaceForward.Repositories.Dictionary.Entitys;
|
|
||||||
|
|
||||||
namespace InterfaceForward.Repositories.Dictionary.Services
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 字典仓储
|
|
||||||
/// </summary>
|
|
||||||
public interface IDictionaryRepository
|
|
||||||
{
|
|
||||||
ISugarQueryable<DictionaryEntity> AsQueryable();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -8,7 +8,6 @@ namespace InterfaceForward.Repositories.Interface.Entitys;
|
|||||||
[SugarTable("t_interface")]
|
[SugarTable("t_interface")]
|
||||||
public class InterfaceEntity : FullAuditedAggregateRoot<int>
|
public class InterfaceEntity : FullAuditedAggregateRoot<int>
|
||||||
{
|
{
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
/// 自增主键
|
/// 自增主键
|
||||||
///</summary>
|
///</summary>
|
||||||
@ -61,7 +60,7 @@ public class InterfaceEntity : FullAuditedAggregateRoot<int>
|
|||||||
/// 请求方式
|
/// 请求方式
|
||||||
///</summary>
|
///</summary>
|
||||||
[SugarColumn(ColumnName = "RequestMethod")]
|
[SugarColumn(ColumnName = "RequestMethod")]
|
||||||
public int RequestMethod { get; set; }
|
public RequestMethod RequestMethod { get; set; }
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
/// 内容类型
|
/// 内容类型
|
||||||
|
|||||||
@ -1,7 +1,5 @@
|
|||||||
using InterfaceForward.Domain.Shared.Enum;
|
using InterfaceForward.Domain.Shared.Enum;
|
||||||
using InterfaceForward.Application.Contracts.Dtos.Interface;
|
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.Entitys;
|
||||||
using InterfaceForward.Repositories.Interface.ValueObjects;
|
using InterfaceForward.Repositories.Interface.ValueObjects;
|
||||||
using InterfaceForward.Repositories.Parameter.VO;
|
using InterfaceForward.Repositories.Parameter.VO;
|
||||||
@ -21,8 +19,6 @@ public class InterfaceRepository : BasicRepository<InterfaceEntity>, IInterfaceR
|
|||||||
{
|
{
|
||||||
// t_interface驱动t_interface_map,数据量上来可以在t_interface_map UpStreamId字段建立索引
|
// t_interface驱动t_interface_map,数据量上来可以在t_interface_map UpStreamId字段建立索引
|
||||||
var query = AsQueryable()
|
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)
|
.Where(a => a.IsUpStream)
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -33,13 +29,13 @@ public class InterfaceRepository : BasicRepository<InterfaceEntity>, IInterfaceR
|
|||||||
|
|
||||||
return await query
|
return await query
|
||||||
.OrderBy(a => a.CreateTime)
|
.OrderBy(a => a.CreateTime)
|
||||||
.Select((a, d, e) => new SystemInterfaceTreeListValueObject
|
.Select(a => new SystemInterfaceTreeListValueObject
|
||||||
{
|
{
|
||||||
Id = a.Id,
|
Id = a.Id,
|
||||||
CategoryId = a.Category,
|
CategoryId = a.Category,
|
||||||
Name = a.Name,
|
Name = a.Name,
|
||||||
Code = a.Code,
|
Code = a.Code,
|
||||||
RequestProtocol = d.Name,
|
RequestProtocol = a.RequestProtocol,
|
||||||
Description = a.Description,
|
Description = a.Description,
|
||||||
MapCount = SqlFunc.Subqueryable<InterfaceMapEntity>().Where(x => x.UpStreamId == a.Id && !x.IsDeleted)
|
MapCount = SqlFunc.Subqueryable<InterfaceMapEntity>().Where(x => x.UpStreamId == a.Id && !x.IsDeleted)
|
||||||
.DistinctCount(x => x.ServiceProviderId),
|
.DistinctCount(x => x.ServiceProviderId),
|
||||||
@ -52,8 +48,6 @@ public class InterfaceRepository : BasicRepository<InterfaceEntity>, IInterfaceR
|
|||||||
GetServiceProviderInterfaceListAsync(ServiceProviderInterfaceTreeListInputObjectValue input)
|
GetServiceProviderInterfaceListAsync(ServiceProviderInterfaceTreeListInputObjectValue input)
|
||||||
{
|
{
|
||||||
var query = AsQueryable()
|
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.IsUpStream)
|
||||||
.Where(a => a.ServiceProviderId == input.ServiceProviderId);
|
.Where(a => a.ServiceProviderId == input.ServiceProviderId);
|
||||||
|
|
||||||
@ -63,18 +57,7 @@ public class InterfaceRepository : BasicRepository<InterfaceEntity>, IInterfaceR
|
|||||||
;
|
;
|
||||||
return await query
|
return await query
|
||||||
.OrderBy(a => a.CreateTime)
|
.OrderBy(a => a.CreateTime)
|
||||||
.Select((a, b, c) => new ServiceProviderInterfaceTreeListOutputValueObject
|
.Select<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,
|
|
||||||
})
|
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,10 +77,12 @@ public class InterfaceRepository : BasicRepository<InterfaceEntity>, IInterfaceR
|
|||||||
public async Task<List<SystemInterfaceDropdownValueObject>> GetSystemInterfaceDropdownListAsync()
|
public async Task<List<SystemInterfaceDropdownValueObject>> GetSystemInterfaceDropdownListAsync()
|
||||||
{
|
{
|
||||||
// 获取所有接口分组
|
// 获取所有接口分组
|
||||||
var groups = await Context.Queryable<DictionaryEntity>()
|
// var groups = await Context.Queryable<DictionaryEntity>()
|
||||||
.Where(x => x.Type == InterfaceGroup)
|
// .Where(x => x.Type == InterfaceGroup)
|
||||||
.Select(x => new { x.Id, x.Name })
|
// .Select(x => new { x.Id, x.Name })
|
||||||
.ToListAsync();
|
// .ToListAsync();
|
||||||
|
|
||||||
|
var groups = new List<string>() { "全部" };
|
||||||
|
|
||||||
// 获取所有接口
|
// 获取所有接口
|
||||||
var interfaces = await AsQueryable()
|
var interfaces = await AsQueryable()
|
||||||
@ -109,8 +94,9 @@ public class InterfaceRepository : BasicRepository<InterfaceEntity>, IInterfaceR
|
|||||||
return groups.Select(x => new SystemInterfaceDropdownValueObject
|
return groups.Select(x => new SystemInterfaceDropdownValueObject
|
||||||
{
|
{
|
||||||
Id = Guid.NewGuid().ToString(),
|
Id = Guid.NewGuid().ToString(),
|
||||||
GroupName = x.Name,
|
GroupName = x,
|
||||||
Interfaces = interfaces.Where(y => y.Category == x.Id)
|
Interfaces = interfaces
|
||||||
|
//.Where(y => y.Category == x.Id)
|
||||||
.Select(y => new SystemInterfaceItemValueObject
|
.Select(y => new SystemInterfaceItemValueObject
|
||||||
{
|
{
|
||||||
Id = y.Id,
|
Id = y.Id,
|
||||||
@ -138,9 +124,6 @@ public class InterfaceRepository : BasicRepository<InterfaceEntity>, IInterfaceR
|
|||||||
{
|
{
|
||||||
// t_interface驱动t_interface_map,数据量上来可以在t_interface_map UpStreamId字段建立索引
|
// t_interface驱动t_interface_map,数据量上来可以在t_interface_map UpStreamId字段建立索引
|
||||||
var query = AsQueryable()
|
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)
|
.Where(a => a.IsUpStream)
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -150,18 +133,22 @@ public class InterfaceRepository : BasicRepository<InterfaceEntity>, IInterfaceR
|
|||||||
|| a.Code.Contains(keyword)) // 默认为空,支持模糊搜索
|
|| 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,
|
Id = a.Id,
|
||||||
Category = c.Name,
|
Category = a.Category,
|
||||||
Name = a.Name,
|
Name = a.Name,
|
||||||
Code = a.Code,
|
Code = a.Code,
|
||||||
RequestProtocol = d.Name,
|
RequestProtocol = a.RequestProtocol,
|
||||||
Description = a.Description,
|
Description = a.Description,
|
||||||
MapCount = SqlFunc.Subqueryable<InterfaceMapEntity>().Where(x => x.UpStreamId == a.Id && !x.IsDeleted)
|
MapCount = SqlFunc.Subqueryable<InterfaceMapEntity>().Where(x => x.UpStreamId == a.Id && !x.IsDeleted)
|
||||||
.DistinctCount(x => x.ServiceProviderId),
|
.DistinctCount(x => x.ServiceProviderId),
|
||||||
UpdateTime = a.UpdateTime,
|
UpdateTime = a.UpdateTime,
|
||||||
}).OrderByDescending(a => a.UpdateTime).ToPagedListAsync(input.PageIndex, input.PageSize);
|
})
|
||||||
|
.OrderByDescending(a => a.UpdateTime)
|
||||||
|
.ToPagedListAsync(input.PageIndex, input.PageSize);
|
||||||
|
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@ -169,8 +156,6 @@ public class InterfaceRepository : BasicRepository<InterfaceEntity>, IInterfaceR
|
|||||||
GetServiceProviderInterfacePaginatedListAsync(ServiceProviderInterfacePaginatedInputObjectValue input)
|
GetServiceProviderInterfacePaginatedListAsync(ServiceProviderInterfacePaginatedInputObjectValue input)
|
||||||
{
|
{
|
||||||
var query = AsQueryable()
|
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.IsUpStream)
|
||||||
.Where(a => a.ServiceProviderId == input.ServiceProviderId);
|
.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.Name), a => a.Name.Contains(input.Name!)) // 默认为空,支持模糊搜索
|
||||||
.WhereIF(!string.IsNullOrEmpty(input.Code), a => a.Code.Contains(input.Code!)) // 默认为空,支持模糊搜索
|
.WhereIF(!string.IsNullOrEmpty(input.Code), a => a.Code.Contains(input.Code!)) // 默认为空,支持模糊搜索
|
||||||
;
|
;
|
||||||
return await query.Select((a, b, c) => new ServiceProviderInterfacePaginatedOutputValueObject
|
return await query.Select<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,
|
|
||||||
})
|
|
||||||
.OrderByDescending(a => a.UpdateTime)
|
.OrderByDescending(a => a.UpdateTime)
|
||||||
.ToPagedListAsync(input.PageIndex, input.PageSize);
|
.ToPagedListAsync(input.PageIndex, input.PageSize);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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>
|
/// <summary>
|
||||||
///
|
///
|
||||||
@ -23,12 +26,22 @@ public class ServiceProviderInterfacePaginatedOutputValueObject
|
|||||||
///<summary>
|
///<summary>
|
||||||
/// 请求协议
|
/// 请求协议
|
||||||
///</summary>
|
///</summary>
|
||||||
public string RequestProtocol { get; set; }
|
public int RequestProtocol { get; set; }
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
/// 请求方式
|
/// 请求方式
|
||||||
///</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>
|
///<summary>
|
||||||
/// 请求地址
|
/// 请求地址
|
||||||
|
|||||||
@ -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>
|
/// <summary>
|
||||||
///
|
///
|
||||||
@ -23,12 +26,22 @@ public class ServiceProviderInterfaceTreeListOutputValueObject: HasCategoryId
|
|||||||
///<summary>
|
///<summary>
|
||||||
/// 请求协议
|
/// 请求协议
|
||||||
///</summary>
|
///</summary>
|
||||||
public string RequestProtocol { get; set; }
|
public RequestProtocol RequestProtocol { get; set; }
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
/// 请求方式
|
/// 请求方式
|
||||||
///</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>
|
///<summary>
|
||||||
/// 请求地址
|
/// 请求地址
|
||||||
|
|||||||
@ -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>
|
/// <summary>
|
||||||
///
|
///
|
||||||
@ -13,7 +16,12 @@
|
|||||||
///<summary>
|
///<summary>
|
||||||
/// 接口分组
|
/// 接口分组
|
||||||
///</summary>
|
///</summary>
|
||||||
public string Category { get; set; }
|
public int Category { get; set; }
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
/// 接口分组Name
|
||||||
|
///</summary>
|
||||||
|
public string CategoryName => "全部";
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
/// 接口名
|
/// 接口名
|
||||||
@ -28,7 +36,12 @@
|
|||||||
///<summary>
|
///<summary>
|
||||||
/// 请求协议
|
/// 请求协议
|
||||||
///</summary>
|
///</summary>
|
||||||
public string RequestProtocol { get; set; }
|
public RequestProtocol RequestProtocol { get; set; }
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
/// 请求协议Name
|
||||||
|
///</summary>
|
||||||
|
public string RequestProtocolName => ((RequestProtocol)RequestProtocol).GetDescription();
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
/// 接口描述
|
/// 接口描述
|
||||||
|
|||||||
@ -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
|
public class HasCategoryId
|
||||||
{
|
{
|
||||||
@ -31,7 +34,12 @@
|
|||||||
///<summary>
|
///<summary>
|
||||||
/// 请求协议
|
/// 请求协议
|
||||||
///</summary>
|
///</summary>
|
||||||
public string RequestProtocol { get; set; }
|
public RequestProtocol RequestProtocol { get; set; }
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
/// 请求协议
|
||||||
|
///</summary>
|
||||||
|
public string RequestProtocolName => ((RequestProtocol)RequestProtocol).GetDescription();
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
/// 接口描述
|
/// 接口描述
|
||||||
|
|||||||
@ -3,7 +3,6 @@ using InterfaceForward.Domain.Shared.Enum;
|
|||||||
using InterfaceForward.Domain.Shared.Helpers;
|
using InterfaceForward.Domain.Shared.Helpers;
|
||||||
using InterfaceForward.Repositories.App.Entitys;
|
using InterfaceForward.Repositories.App.Entitys;
|
||||||
using InterfaceForward.Repositories.App.ValueObjects;
|
using InterfaceForward.Repositories.App.ValueObjects;
|
||||||
using InterfaceForward.Repositories.Dictionary.Entitys;
|
|
||||||
using InterfaceForward.Repositories.Interface.Entitys;
|
using InterfaceForward.Repositories.Interface.Entitys;
|
||||||
using InterfaceForward.Repositories.Parameter.Entities;
|
using InterfaceForward.Repositories.Parameter.Entities;
|
||||||
using InterfaceForward.Repositories.ServiceProvider.Entitys;
|
using InterfaceForward.Repositories.ServiceProvider.Entitys;
|
||||||
@ -143,9 +142,9 @@ ORDER BY `b`.`Sort` ASC").ToListAsync();
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="interfaceCode"></param>
|
/// <param name="interfaceCode"></param>
|
||||||
/// <returns></returns>
|
/// <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();
|
return res.FirstOrDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,7 +193,7 @@ ORDER BY `b`.`Sort` ASC").ToListAsync();
|
|||||||
|
|
||||||
if (serviceProvider.AuthInterfaceCode != null)
|
if (serviceProvider.AuthInterfaceCode != null)
|
||||||
{
|
{
|
||||||
var authInterface = await GetInterfaceByCodeAsync(serviceProvider.AuthInterfaceCode);
|
var authInterface = await GetInterfaceByCodesAsync(serviceProvider.AuthInterfaceCode);
|
||||||
if (authInterface == null)
|
if (authInterface == null)
|
||||||
{
|
{
|
||||||
throw new BusinessException($"授权接口{serviceProvider.AuthInterfaceCode}不存在");
|
throw new BusinessException($"授权接口{serviceProvider.AuthInterfaceCode}不存在");
|
||||||
@ -321,13 +320,10 @@ ORDER BY `b`.`Sort` ASC").ToListAsync();
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private async Task<List<InterfaceDto>> GetInterfaceByCodesAsync(params string[] interfaceCodes)
|
private async Task<List<InterfaceDto>> GetInterfaceByCodesAsync(params string[] interfaceCodes)
|
||||||
{
|
{
|
||||||
var query = Context.Queryable<InterfaceEntity, DictionaryEntity>(
|
var query = Context.Queryable<InterfaceEntity>()
|
||||||
(a, d) => new JoinQueryInfos(
|
|
||||||
JoinType.Left, a.RequestMethod == d.Id
|
|
||||||
))
|
|
||||||
.Where(a => interfaceCodes.Contains(a.Code) && a.IsDeleted == false)
|
.Where(a => interfaceCodes.Contains(a.Code) && a.IsDeleted == false)
|
||||||
.Filter(null, true)
|
.Filter(null, true)
|
||||||
.Select((a, d) =>
|
.Select(a =>
|
||||||
new InterfaceDto
|
new InterfaceDto
|
||||||
{
|
{
|
||||||
Id = a.Id,
|
Id = a.Id,
|
||||||
@ -338,7 +334,7 @@ ORDER BY `b`.`Sort` ASC").ToListAsync();
|
|||||||
RequestProtocol = a.RequestProtocol,
|
RequestProtocol = a.RequestProtocol,
|
||||||
ContentType = a.ContentType,
|
ContentType = a.ContentType,
|
||||||
ResponseContentType = a.ResponseContentType,
|
ResponseContentType = a.ResponseContentType,
|
||||||
RequestMethod = d.Name,
|
RequestMethod = a.RequestMethod,
|
||||||
IsBatch = a.IsBatch,
|
IsBatch = a.IsBatch,
|
||||||
Limit = a.Limit,
|
Limit = a.Limit,
|
||||||
Qps = a.Qps,
|
Qps = a.Qps,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user