From 6fb8ea0558b0c6e979568ad1d6817335d3720905 Mon Sep 17 00:00:00 2001
From: Antinew <2357729423@qq.com>
Date: Sat, 5 Jul 2025 00:45:23 +0800
Subject: [PATCH] 111
---
.../ForwardCore/DefaultForwardFlow.cs | 2 +-
.../Services/App/DictionaryService.cs | 155 +++++++++---------
.../Services/InterfaceForwardCommon.cs | 2 +-
.../InterfaceMapPublishService.cs | 6 +-
.../Dtos/InterfaceDto.cs | 2 +-
.../Enum/ContentType.cs | 18 +-
.../Enum/Enums.cs | 38 -----
.../Enum/FieldPosition.cs | 10 +-
.../Enum/InterfaceReturnConfigType.cs | 6 +-
.../Enum/LabelType.cs | 2 +-
.../Enum/LogListInputTypeEnum.cs | 20 +++
.../Enum/MessageType.cs | 6 -
.../Enum/OptionType.cs | 57 ++-----
.../Enum/ParameterParseTypeEnum.cs | 2 +-
.../Enum/ParameterType.cs | 16 +-
.../Enum/RequestMethod.cs | 12 ++
.../Enum/RequestProtocol.cs | 8 +-
.../Enum/ServiceProviderType.cs | 8 +-
.../Dictionary/Entitys/DictionaryEntity.cs | 41 -----
.../Services/DictionaryRepository.cs | 11 --
.../Services/IDictionaryRepository.cs | 12 --
.../Interface/Entitys/InterfaceEntity.cs | 3 +-
.../Interface/Services/InterfaceRepository.cs | 85 ++++------
...iderInterfacePaginatedOutputValueObject.cs | 19 ++-
...viderInterfaceTreeListOutputValueObject.cs | 21 ++-
...stemInterfacePaginatedOutputValueObject.cs | 19 ++-
.../SystemInterfaceTreeListValueObject.cs | 12 +-
.../InterfaceForwardQuery.cs | 16 +-
28 files changed, 261 insertions(+), 348 deletions(-)
delete mode 100644 src/InterfaceForward.Domain.Shared/Enum/Enums.cs
create mode 100644 src/InterfaceForward.Domain.Shared/Enum/LogListInputTypeEnum.cs
delete mode 100644 src/InterfaceForward.Domain.Shared/Enum/MessageType.cs
create mode 100644 src/InterfaceForward.Domain.Shared/Enum/RequestMethod.cs
delete mode 100644 src/InterfaceForward.Repositories/Dictionary/Entitys/DictionaryEntity.cs
delete mode 100644 src/InterfaceForward.Repositories/Dictionary/Services/DictionaryRepository.cs
delete mode 100644 src/InterfaceForward.Repositories/Dictionary/Services/IDictionaryRepository.cs
diff --git a/src/InterfaceForward.Application/ForwardCore/DefaultForwardFlow.cs b/src/InterfaceForward.Application/ForwardCore/DefaultForwardFlow.cs
index 59cd8ae..9188eee 100644
--- a/src/InterfaceForward.Application/ForwardCore/DefaultForwardFlow.cs
+++ b/src/InterfaceForward.Application/ForwardCore/DefaultForwardFlow.cs
@@ -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);
diff --git a/src/InterfaceForward.Application/Services/App/DictionaryService.cs b/src/InterfaceForward.Application/Services/App/DictionaryService.cs
index 2714e60..d2a4346 100644
--- a/src/InterfaceForward.Application/Services/App/DictionaryService.cs
+++ b/src/InterfaceForward.Application/Services/App/DictionaryService.cs
@@ -1,84 +1,89 @@
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;
+
+///
+/// 字典服务
+///
+[ApiExplorerSettings(GroupName = "应用服务")]
+public class DictionaryService : ApplicationService
{
+ private static readonly Dictionary> EnumCache = new();
+
///
- /// 字典服务
+ /// 列表
///
- [ApiExplorerSettings(GroupName = "应用服务")]
- public class DictionaryService : ApplicationService
+ /// 枚举类型
+ ///
+ [HttpGet("Dictionary/GetList")]
+ public List GetList(string type)
{
- private readonly IDictionaryRepository _dictionaryRepository;
- private static readonly Dictionary> EnumCache = new();
-
- ///
- ///
- ///
- public DictionaryService(
- IDictionaryRepository dictionaryRepository)
- {
- _dictionaryRepository = dictionaryRepository;
- }
-
-
- ///
- /// 列表
- ///
- /// 类型
- ///
- [HttpGet("Dictionary/GetList")]
- public async Task GetList(string type)
- {
- return await _dictionaryRepository.AsQueryable().Where(x => x.Type == type).Select(x => new { Key = x.Id, Value = x.Name }).ToListAsync();
- }
-
- ///
- /// 获取枚举下拉列表
- ///
- /// 枚举类型名称
- ///
- [HttpGet("Dictionary/GetKvsByEnumTypeName")]
- public Dictionary GetKvsByEnumTypeName(string enumTypeName)
- {
- // Check if the type is already cached
- if (EnumCache.TryGetValue(enumTypeName, out var res))
- {
- return res;
- }
-
- // Load the assembly
- var assemblyName = "InterfaceForward.Domain.Shared";
- var assembly = Assembly.Load(assemblyName);
- if (assembly == null)
- {
- throw new ArgumentException($"Assembly '{assemblyName}' could not be loaded.");
- }
-
- // Get the enum type
- var enumType = assembly.GetType("InterfaceForward.Domain.Shared.Enum." + enumTypeName);
- if (enumType == null || !enumType.IsEnum)
- {
- throw new ArgumentException($"The type '{enumTypeName}' is not a valid enum.");
- }
-
- // Retrieve the descriptions and values
- var enumDict = new Dictionary();
- foreach (var value in enumType.GetEnumValues())
- {
- var name = value.ToString();
- var fieldInfo = enumType.GetField(name);
- var descriptionAttribute = fieldInfo.GetCustomAttribute();
- string description = descriptionAttribute != null ? descriptionAttribute.Description : name;
- enumDict[description] = (int)value;
- }
-
- // Cache the result
- EnumCache[enumTypeName] = enumDict;
-
- return enumDict;
- }
+ // 优先读枚举值
+ return GetKvsByEnumTypeName(type);
}
-}
+
+ [HttpPost("Dictionary/CleanCache")]
+ public void CleanCache(string type)
+ {
+ EnumCache.Clear();
+ }
+
+ ///
+ /// 获取枚举下拉列表
+ ///
+ /// 枚举类型名称
+ ///
+ [NonAction]
+ private List GetKvsByEnumTypeName(string enumTypeName)
+ {
+ // Check if the type is already cached
+ if (EnumCache.TryGetValue(enumTypeName, out var res))
+ {
+ return res;
+ }
+
+ // Load the assembly
+ var assemblyName = "InterfaceForward.Domain.Shared";
+ var assembly = Assembly.Load(assemblyName);
+ if (assembly == null)
+ {
+ throw new ArgumentException($"Assembly '{assemblyName}' could not be loaded.");
+ }
+
+ // Get the enum type
+ var enumType = assembly.GetType("InterfaceForward.Domain.Shared.Enum." + enumTypeName);
+ if (enumType == null || !enumType.IsEnum)
+ {
+ throw new ArgumentException($"The type '{enumTypeName}' is not a valid enum.");
+ }
+
+ // Retrieve the descriptions and values
+ var list = new List();
+ foreach (var value in enumType.GetEnumValues())
+ {
+ var name = value.ToString();
+ var fieldInfo = enumType.GetField(name);
+ var descriptionAttribute = fieldInfo.GetCustomAttribute();
+ string description = descriptionAttribute != null ? descriptionAttribute.Description : name;
+ list.Add(new EnumCacheEntry
+ {
+ Key = (int)value,
+ Value = description
+ });
+ }
+
+ // Cache the result
+ EnumCache[enumTypeName] = list;
+
+ return list;
+ }
+
+ public class EnumCacheEntry
+ {
+ public int Key { get; set; }
+
+ public string Value { get; set; } = null!;
+ }
+}
\ No newline at end of file
diff --git a/src/InterfaceForward.Application/Services/InterfaceForwardCommon.cs b/src/InterfaceForward.Application/Services/InterfaceForwardCommon.cs
index 1eac2b6..a55973c 100644
--- a/src/InterfaceForward.Application/Services/InterfaceForwardCommon.cs
+++ b/src/InterfaceForward.Application/Services/InterfaceForwardCommon.cs
@@ -45,7 +45,7 @@ public class InterfaceForwardCommon(
.ToObject();
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;
diff --git a/src/InterfaceForward.Application/Services/InterfaceMap/InterfaceMapPublishService.cs b/src/InterfaceForward.Application/Services/InterfaceMap/InterfaceMapPublishService.cs
index f6b43f6..1282ac0 100644
--- a/src/InterfaceForward.Application/Services/InterfaceMap/InterfaceMapPublishService.cs
+++ b/src/InterfaceForward.Application/Services/InterfaceMap/InterfaceMapPublishService.cs
@@ -59,7 +59,7 @@ public class InterfaceMapPublishService(
public async Task 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 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 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: "服务商不存在");
diff --git a/src/InterfaceForward.Domain.Shared/Dtos/InterfaceDto.cs b/src/InterfaceForward.Domain.Shared/Dtos/InterfaceDto.cs
index 53ca5e7..7cb27ef 100644
--- a/src/InterfaceForward.Domain.Shared/Dtos/InterfaceDto.cs
+++ b/src/InterfaceForward.Domain.Shared/Dtos/InterfaceDto.cs
@@ -37,7 +37,7 @@ public class InterfaceDto
///
/// 请求方式
///
- public string RequestMethod { get; set; } = null!;
+ public RequestMethod RequestMethod { get; set; }
///
/// 内容类型
diff --git a/src/InterfaceForward.Domain.Shared/Enum/ContentType.cs b/src/InterfaceForward.Domain.Shared/Enum/ContentType.cs
index 4d569c7..4b729ef 100644
--- a/src/InterfaceForward.Domain.Shared/Enum/ContentType.cs
+++ b/src/InterfaceForward.Domain.Shared/Enum/ContentType.cs
@@ -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
}
\ No newline at end of file
diff --git a/src/InterfaceForward.Domain.Shared/Enum/Enums.cs b/src/InterfaceForward.Domain.Shared/Enum/Enums.cs
deleted file mode 100644
index c2124a2..0000000
--- a/src/InterfaceForward.Domain.Shared/Enum/Enums.cs
+++ /dev/null
@@ -1,38 +0,0 @@
-using System.ComponentModel;
-
-namespace InterfaceForward.Domain.Shared.Enum
-{
- ///
- /// 接口类型
- ///
- public enum InterfaceTypeEnum
- {
- ///
- /// 系统接口
- ///
- [Description("系统接口")]
- 系统接口,
- ///
- /// 服务商接口
- ///
- [Description("服务商接口")]
- 服务商接口
- }
-
- ///
- /// 选择类型
- ///
- public enum LogListInputTypeEnum
- {
- ///
- /// 应用
- ///
- [Description("应用")]
- 应用,
- ///
- /// 服务商
- ///
- [Description("服务商")]
- 服务商
- }
-}
diff --git a/src/InterfaceForward.Domain.Shared/Enum/FieldPosition.cs b/src/InterfaceForward.Domain.Shared/Enum/FieldPosition.cs
index b0ce4fc..faef1cf 100644
--- a/src/InterfaceForward.Domain.Shared/Enum/FieldPosition.cs
+++ b/src/InterfaceForward.Domain.Shared/Enum/FieldPosition.cs
@@ -5,9 +5,9 @@ namespace InterfaceForward.Domain.Shared.Enum;
///
public enum FieldPosition
{
- Header = 5,
- Body = 6,
- Query = 7,
- Url = 32,
- Nothing = 42 //不处理
+ Header = 1,
+ Body,
+ Query,
+ Url,
+ Nothing //不处理
}
\ No newline at end of file
diff --git a/src/InterfaceForward.Domain.Shared/Enum/InterfaceReturnConfigType.cs b/src/InterfaceForward.Domain.Shared/Enum/InterfaceReturnConfigType.cs
index f3271ab..4e35dc8 100644
--- a/src/InterfaceForward.Domain.Shared/Enum/InterfaceReturnConfigType.cs
+++ b/src/InterfaceForward.Domain.Shared/Enum/InterfaceReturnConfigType.cs
@@ -8,15 +8,15 @@ public enum InterfaceReturnConfigType
/// 状态码
///
[Description("状态码")]
- StatusCode = 101,
+ StatusCode = 1,
///
/// PDF标签上传
///
[Description("PDF标签上传")]
- PdfLabel = 102,
+ PdfLabel,
///
/// 错误信息返回
///
[Description("错误信息返回")]
- ErrorMsg = 103,
+ ErrorMsg,
}
\ No newline at end of file
diff --git a/src/InterfaceForward.Domain.Shared/Enum/LabelType.cs b/src/InterfaceForward.Domain.Shared/Enum/LabelType.cs
index 121132c..f8d0b08 100644
--- a/src/InterfaceForward.Domain.Shared/Enum/LabelType.cs
+++ b/src/InterfaceForward.Domain.Shared/Enum/LabelType.cs
@@ -11,7 +11,7 @@ public enum LabelType
/// Url
///
[Description("Url")]
- Url,
+ Url = 1,
///
/// Base64
///
diff --git a/src/InterfaceForward.Domain.Shared/Enum/LogListInputTypeEnum.cs b/src/InterfaceForward.Domain.Shared/Enum/LogListInputTypeEnum.cs
new file mode 100644
index 0000000..057050a
--- /dev/null
+++ b/src/InterfaceForward.Domain.Shared/Enum/LogListInputTypeEnum.cs
@@ -0,0 +1,20 @@
+using System.ComponentModel;
+
+namespace InterfaceForward.Domain.Shared.Enum;
+
+///
+/// 选择类型
+///
+public enum LogListInputTypeEnum
+{
+ ///
+ /// 应用
+ ///
+ [Description("应用")]
+ 应用 = 1,
+ ///
+ /// 服务商
+ ///
+ [Description("服务商")]
+ 服务商
+}
\ No newline at end of file
diff --git a/src/InterfaceForward.Domain.Shared/Enum/MessageType.cs b/src/InterfaceForward.Domain.Shared/Enum/MessageType.cs
deleted file mode 100644
index 73f31a0..0000000
--- a/src/InterfaceForward.Domain.Shared/Enum/MessageType.cs
+++ /dev/null
@@ -1,6 +0,0 @@
-namespace InterfaceForward.Domain.Shared.Enum;
-
-public enum MessageType
-{
- Error, Info, Debug, Warn, Notice
-}
\ No newline at end of file
diff --git a/src/InterfaceForward.Domain.Shared/Enum/OptionType.cs b/src/InterfaceForward.Domain.Shared/Enum/OptionType.cs
index 00396e2..500b61c 100644
--- a/src/InterfaceForward.Domain.Shared/Enum/OptionType.cs
+++ b/src/InterfaceForward.Domain.Shared/Enum/OptionType.cs
@@ -1,48 +1,15 @@
using System.ComponentModel;
-namespace InterfaceForward.Domain.Shared.Enum
+namespace InterfaceForward.Domain.Shared.Enum;
+
+public enum OptionType
{
-
- public enum OptionType
- {
- [Description("无")]
- 无 = 0,
- [Description("新增")]
- 新增 = 1,
- [Description("删除")]
- 删除 = 2,
- [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
- }
-
-}
+ [Description("无")]
+ 无 = 0,
+ [Description("新增")]
+ 新增 = 1,
+ [Description("删除")]
+ 删除 = 2,
+ [Description("修改")]
+ 修改 = 3
+}
\ No newline at end of file
diff --git a/src/InterfaceForward.Domain.Shared/Enum/ParameterParseTypeEnum.cs b/src/InterfaceForward.Domain.Shared/Enum/ParameterParseTypeEnum.cs
index 75eacc4..551a9bf 100644
--- a/src/InterfaceForward.Domain.Shared/Enum/ParameterParseTypeEnum.cs
+++ b/src/InterfaceForward.Domain.Shared/Enum/ParameterParseTypeEnum.cs
@@ -11,7 +11,7 @@ public enum ParameterParseTypeEnum
/// JSON
///
[Description("JSON")]
- Json,
+ Json = 1,
///
/// XML
///
diff --git a/src/InterfaceForward.Domain.Shared/Enum/ParameterType.cs b/src/InterfaceForward.Domain.Shared/Enum/ParameterType.cs
index 75e7ad7..7779156 100644
--- a/src/InterfaceForward.Domain.Shared/Enum/ParameterType.cs
+++ b/src/InterfaceForward.Domain.Shared/Enum/ParameterType.cs
@@ -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,
}
\ No newline at end of file
diff --git a/src/InterfaceForward.Domain.Shared/Enum/RequestMethod.cs b/src/InterfaceForward.Domain.Shared/Enum/RequestMethod.cs
new file mode 100644
index 0000000..2b5c7f7
--- /dev/null
+++ b/src/InterfaceForward.Domain.Shared/Enum/RequestMethod.cs
@@ -0,0 +1,12 @@
+namespace InterfaceForward.Domain.Shared.Enum;
+
+public enum RequestMethod
+{
+ GET = 1,
+ POST = 2,
+ PUT,
+ DELETE,
+ OPTIONS,
+ HEAD,
+ PATCH
+}
\ No newline at end of file
diff --git a/src/InterfaceForward.Domain.Shared/Enum/RequestProtocol.cs b/src/InterfaceForward.Domain.Shared/Enum/RequestProtocol.cs
index febee8f..9192def 100644
--- a/src/InterfaceForward.Domain.Shared/Enum/RequestProtocol.cs
+++ b/src/InterfaceForward.Domain.Shared/Enum/RequestProtocol.cs
@@ -2,8 +2,8 @@
public enum RequestProtocol
{
- Http = 13,
- Https = 14,
- WCF = 39,
- SOAP = 49
+ Http = 1,
+ Https,
+ WCF,
+ SOAP
}
\ No newline at end of file
diff --git a/src/InterfaceForward.Domain.Shared/Enum/ServiceProviderType.cs b/src/InterfaceForward.Domain.Shared/Enum/ServiceProviderType.cs
index 24ad0b2..c52efe2 100644
--- a/src/InterfaceForward.Domain.Shared/Enum/ServiceProviderType.cs
+++ b/src/InterfaceForward.Domain.Shared/Enum/ServiceProviderType.cs
@@ -2,8 +2,8 @@
public enum ServiceProviderType
{
- 运输服务商 = 21,
- 轨迹服务商 = 22,
- 关务服务商 = 23,
- 保险服务商 = 24
+ 运输服务商 = 1,
+ 轨迹服务商,
+ 关务服务商,
+ 保险服务商
}
\ No newline at end of file
diff --git a/src/InterfaceForward.Repositories/Dictionary/Entitys/DictionaryEntity.cs b/src/InterfaceForward.Repositories/Dictionary/Entitys/DictionaryEntity.cs
deleted file mode 100644
index 08b704a..0000000
--- a/src/InterfaceForward.Repositories/Dictionary/Entitys/DictionaryEntity.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-namespace InterfaceForward.Repositories.Dictionary.Entitys
-{
- ///
- /// 字典表
- ///
- [SugarTable("t_dictionary")]
- public class DictionaryEntity : FullAuditedAggregateRoot
- {
-
- ///
- /// 自增主键
- ///
- [SugarColumn(ColumnName = "Id", IsPrimaryKey = true, IsIdentity = true)]
- public int Id { get; set; }
-
- ///
- /// 类型
- ///
- [SugarColumn(ColumnName = "Type")]
- public string Type { get; set; }
-
- ///
- /// 名称
- ///
- [SugarColumn(ColumnName = "Name")]
- public string Name { get; set; }
-
- ///
- /// 字典描述
- ///
- [SugarColumn(ColumnName = "Description")]
- public string Description { get; set; }
-
- ///
- /// 排序
- ///
- [SugarColumn(ColumnName = "Sort")]
- public int Sort { get; set; }
-
- }
-}
\ No newline at end of file
diff --git a/src/InterfaceForward.Repositories/Dictionary/Services/DictionaryRepository.cs b/src/InterfaceForward.Repositories/Dictionary/Services/DictionaryRepository.cs
deleted file mode 100644
index b9c2a80..0000000
--- a/src/InterfaceForward.Repositories/Dictionary/Services/DictionaryRepository.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-using InterfaceForward.Repositories.Dictionary.Entitys;
-
-namespace InterfaceForward.Repositories.Dictionary.Services
-{
- ///
- /// 字典仓储实现
- ///
- public class DictionaryRepository : BasicRepository, IDictionaryRepository, IScopedDependency
- {
- }
-}
diff --git a/src/InterfaceForward.Repositories/Dictionary/Services/IDictionaryRepository.cs b/src/InterfaceForward.Repositories/Dictionary/Services/IDictionaryRepository.cs
deleted file mode 100644
index 2c81c36..0000000
--- a/src/InterfaceForward.Repositories/Dictionary/Services/IDictionaryRepository.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-using InterfaceForward.Repositories.Dictionary.Entitys;
-
-namespace InterfaceForward.Repositories.Dictionary.Services
-{
- ///
- /// 字典仓储
- ///
- public interface IDictionaryRepository
- {
- ISugarQueryable AsQueryable();
- }
-}
diff --git a/src/InterfaceForward.Repositories/Interface/Entitys/InterfaceEntity.cs b/src/InterfaceForward.Repositories/Interface/Entitys/InterfaceEntity.cs
index d47a89c..16099ac 100644
--- a/src/InterfaceForward.Repositories/Interface/Entitys/InterfaceEntity.cs
+++ b/src/InterfaceForward.Repositories/Interface/Entitys/InterfaceEntity.cs
@@ -8,7 +8,6 @@ namespace InterfaceForward.Repositories.Interface.Entitys;
[SugarTable("t_interface")]
public class InterfaceEntity : FullAuditedAggregateRoot
{
-
///
/// 自增主键
///
@@ -61,7 +60,7 @@ public class InterfaceEntity : FullAuditedAggregateRoot
/// 请求方式
///
[SugarColumn(ColumnName = "RequestMethod")]
- public int RequestMethod { get; set; }
+ public RequestMethod RequestMethod { get; set; }
///
/// 内容类型
diff --git a/src/InterfaceForward.Repositories/Interface/Services/InterfaceRepository.cs b/src/InterfaceForward.Repositories/Interface/Services/InterfaceRepository.cs
index 8902598..5533c00 100644
--- a/src/InterfaceForward.Repositories/Interface/Services/InterfaceRepository.cs
+++ b/src/InterfaceForward.Repositories/Interface/Services/InterfaceRepository.cs
@@ -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, IInterfaceR
{
// t_interface驱动t_interface_map,数据量上来可以在t_interface_map UpStreamId字段建立索引
var query = AsQueryable()
- .LeftJoin((a, d) => (int)a.RequestProtocol == d.Id)
- .LeftJoin((a, d, e) => a.RequestMethod == e.Id)
.Where(a => a.IsUpStream)
;
@@ -33,13 +29,13 @@ public class InterfaceRepository : BasicRepository, 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().Where(x => x.UpStreamId == a.Id && !x.IsDeleted)
.DistinctCount(x => x.ServiceProviderId),
@@ -52,8 +48,6 @@ public class InterfaceRepository : BasicRepository, IInterfaceR
GetServiceProviderInterfaceListAsync(ServiceProviderInterfaceTreeListInputObjectValue input)
{
var query = AsQueryable()
- .LeftJoin((a, b) => (int)a.RequestProtocol == b.Id)
- .LeftJoin((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, 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()
.ToListAsync();
}
@@ -94,10 +77,12 @@ public class InterfaceRepository : BasicRepository, IInterfaceR
public async Task> GetSystemInterfaceDropdownListAsync()
{
// 获取所有接口分组
- var groups = await Context.Queryable()
- .Where(x => x.Type == InterfaceGroup)
- .Select(x => new { x.Id, x.Name })
- .ToListAsync();
+ // var groups = await Context.Queryable()
+ // .Where(x => x.Type == InterfaceGroup)
+ // .Select(x => new { x.Id, x.Name })
+ // .ToListAsync();
+
+ var groups = new List() { "全部" };
// 获取所有接口
var interfaces = await AsQueryable()
@@ -109,8 +94,9 @@ public class InterfaceRepository : BasicRepository, 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,
@@ -131,16 +117,13 @@ public class InterfaceRepository : BasicRepository, IInterfaceR
return code;
}
-
+
///
public async Task>
GetSystemInterfacePaginatedListAsync(SystemInterfacePaginatedInputObjectValue input)
{
// t_interface驱动t_interface_map,数据量上来可以在t_interface_map UpStreamId字段建立索引
var query = AsQueryable()
- .LeftJoin((a, c) => a.Category == c.Id)
- .LeftJoin((a, c, d) => (int)a.RequestProtocol == d.Id)
- .LeftJoin((a, c, d, e) => a.RequestMethod == e.Id)
.Where(a => a.IsUpStream)
;
@@ -150,18 +133,22 @@ public class InterfaceRepository : BasicRepository, IInterfaceR
|| a.Code.Contains(keyword)) // 默认为空,支持模糊搜索
;
- return await query.Select((a, c, d, e) => new SystemInterfacePaginatedOutputValueObject
- {
- Id = a.Id,
- Category = c.Name,
- Name = a.Name,
- Code = a.Code,
- RequestProtocol = d.Name,
- Description = a.Description,
- MapCount = SqlFunc.Subqueryable().Where(x => x.UpStreamId == a.Id && !x.IsDeleted)
- .DistinctCount(x => x.ServiceProviderId),
- UpdateTime = a.UpdateTime,
- }).OrderByDescending(a => a.UpdateTime).ToPagedListAsync(input.PageIndex, input.PageSize);
+ var res = await query.Select(a => new SystemInterfacePaginatedOutputValueObject
+ {
+ Id = a.Id,
+ Category = a.Category,
+ Name = a.Name,
+ Code = a.Code,
+ RequestProtocol = a.RequestProtocol,
+ Description = a.Description,
+ MapCount = SqlFunc.Subqueryable().Where(x => x.UpStreamId == a.Id && !x.IsDeleted)
+ .DistinctCount(x => x.ServiceProviderId),
+ UpdateTime = a.UpdateTime,
+ })
+ .OrderByDescending(a => a.UpdateTime)
+ .ToPagedListAsync(input.PageIndex, input.PageSize);
+
+ return res;
}
///
@@ -169,8 +156,6 @@ public class InterfaceRepository : BasicRepository, IInterfaceR
GetServiceProviderInterfacePaginatedListAsync(ServiceProviderInterfacePaginatedInputObjectValue input)
{
var query = AsQueryable()
- .LeftJoin((a, b) => (int)a.RequestProtocol == b.Id)
- .LeftJoin((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, 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()
.OrderByDescending(a => a.UpdateTime)
.ToPagedListAsync(input.PageIndex, input.PageSize);
}
diff --git a/src/InterfaceForward.Repositories/Interface/ValueObjects/ServiceProviderInterfacePaginatedOutputValueObject.cs b/src/InterfaceForward.Repositories/Interface/ValueObjects/ServiceProviderInterfacePaginatedOutputValueObject.cs
index a19a968..652b1ec 100644
--- a/src/InterfaceForward.Repositories/Interface/ValueObjects/ServiceProviderInterfacePaginatedOutputValueObject.cs
+++ b/src/InterfaceForward.Repositories/Interface/ValueObjects/ServiceProviderInterfacePaginatedOutputValueObject.cs
@@ -1,4 +1,7 @@
-namespace InterfaceForward.Repositories.Interface.ValueObjects;
+using InterfaceForward.Domain.Shared.Enum;
+using InterfaceForward.Domain.Shared.Helpers;
+
+namespace InterfaceForward.Repositories.Interface.ValueObjects;
///
///
@@ -23,12 +26,22 @@ public class ServiceProviderInterfacePaginatedOutputValueObject
///
/// 请求协议
///
- public string RequestProtocol { get; set; }
+ public int RequestProtocol { get; set; }
///
/// 请求方式
///
- public string RequestMethod { get; set; }
+ public int RequestMethod { get; set; }
+
+ ///
+ /// 请求协议Name
+ ///
+ public string RequestProtocolName => ((RequestProtocol)RequestProtocol).GetDescription();
+
+ ///
+ /// 请求方式Name
+ ///
+ public string RequestMethodName => ((RequestMethod)RequestMethod).GetDescription();
///
/// 请求地址
diff --git a/src/InterfaceForward.Repositories/Interface/ValueObjects/ServiceProviderInterfaceTreeListOutputValueObject.cs b/src/InterfaceForward.Repositories/Interface/ValueObjects/ServiceProviderInterfaceTreeListOutputValueObject.cs
index bdcbf6f..951d1e6 100644
--- a/src/InterfaceForward.Repositories/Interface/ValueObjects/ServiceProviderInterfaceTreeListOutputValueObject.cs
+++ b/src/InterfaceForward.Repositories/Interface/ValueObjects/ServiceProviderInterfaceTreeListOutputValueObject.cs
@@ -1,4 +1,7 @@
-namespace InterfaceForward.Repositories.Interface.ValueObjects;
+using InterfaceForward.Domain.Shared.Enum;
+using InterfaceForward.Domain.Shared.Helpers;
+
+namespace InterfaceForward.Repositories.Interface.ValueObjects;
///
///
@@ -19,16 +22,26 @@ public class ServiceProviderInterfaceTreeListOutputValueObject: HasCategoryId
/// 接口代码
///
public string Code { get; set; }
-
+
///
/// 请求协议
///
- public string RequestProtocol { get; set; }
+ public RequestProtocol RequestProtocol { get; set; }
///
/// 请求方式
///
- public string RequestMethod { get; set; }
+ public RequestMethod RequestMethod { get; set; }
+
+ ///
+ /// 请求协议Name
+ ///
+ public string RequestProtocolName => RequestProtocol.GetDescription();
+
+ ///
+ /// 请求方式Name
+ ///
+ public string RequestMethodName => RequestMethod.GetDescription();
///
/// 请求地址
diff --git a/src/InterfaceForward.Repositories/Interface/ValueObjects/SystemInterfacePaginatedOutputValueObject.cs b/src/InterfaceForward.Repositories/Interface/ValueObjects/SystemInterfacePaginatedOutputValueObject.cs
index f61f8ff..bf0ff54 100644
--- a/src/InterfaceForward.Repositories/Interface/ValueObjects/SystemInterfacePaginatedOutputValueObject.cs
+++ b/src/InterfaceForward.Repositories/Interface/ValueObjects/SystemInterfacePaginatedOutputValueObject.cs
@@ -1,4 +1,7 @@
-namespace InterfaceForward.Repositories.Interface.ValueObjects
+using InterfaceForward.Domain.Shared.Enum;
+using InterfaceForward.Domain.Shared.Helpers;
+
+namespace InterfaceForward.Repositories.Interface.ValueObjects
{
///
///
@@ -13,7 +16,12 @@
///
/// 接口分组
///
- public string Category { get; set; }
+ public int Category { get; set; }
+
+ ///
+ /// 接口分组Name
+ ///
+ public string CategoryName => "全部";
///
/// 接口名
@@ -28,7 +36,12 @@
///
/// 请求协议
///
- public string RequestProtocol { get; set; }
+ public RequestProtocol RequestProtocol { get; set; }
+
+ ///
+ /// 请求协议Name
+ ///
+ public string RequestProtocolName => ((RequestProtocol)RequestProtocol).GetDescription();
///
/// 接口描述
diff --git a/src/InterfaceForward.Repositories/Interface/ValueObjects/SystemInterfaceTreeListValueObject.cs b/src/InterfaceForward.Repositories/Interface/ValueObjects/SystemInterfaceTreeListValueObject.cs
index a5df236..b4935b5 100644
--- a/src/InterfaceForward.Repositories/Interface/ValueObjects/SystemInterfaceTreeListValueObject.cs
+++ b/src/InterfaceForward.Repositories/Interface/ValueObjects/SystemInterfaceTreeListValueObject.cs
@@ -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 @@
///
/// 请求协议
///
- public string RequestProtocol { get; set; }
+ public RequestProtocol RequestProtocol { get; set; }
+
+ ///
+ /// 请求协议
+ ///
+ public string RequestProtocolName => ((RequestProtocol)RequestProtocol).GetDescription();
///
/// 接口描述
diff --git a/src/InterfaceForward.Repositories/InterfaceForwardQuery.cs b/src/InterfaceForward.Repositories/InterfaceForwardQuery.cs
index 1d1db47..9899552 100644
--- a/src/InterfaceForward.Repositories/InterfaceForwardQuery.cs
+++ b/src/InterfaceForward.Repositories/InterfaceForwardQuery.cs
@@ -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();
///
///
///
- public async Task GetInterfaceByCodeAsync(string interfaceCode)
+ public async Task 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();
///
private async Task> GetInterfaceByCodesAsync(params string[] interfaceCodes)
{
- var query = Context.Queryable(
- (a, d) => new JoinQueryInfos(
- JoinType.Left, a.RequestMethod == d.Id
- ))
+ var query = Context.Queryable()
.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,