tp
This commit is contained in:
parent
9555a41107
commit
d30bb18514
@ -1,16 +1,19 @@
|
|||||||
FROM mcr.microsoft.com/dotnet/sdk:8.0.303 AS base
|
# 使用 SDK 镜像进行构建
|
||||||
|
FROM mcr.microsoft.com/dotnet/sdk:8.0.303 AS build
|
||||||
ARG BUILD_CONFIGURATION=Release
|
ARG BUILD_CONFIGURATION=Release
|
||||||
WORKDIR /src
|
WORKDIR /src
|
||||||
COPY . /src
|
|
||||||
RUN dotnet restore "src/InterfaceForward.Api/InterfaceForward.Api.csproj"
|
|
||||||
WORKDIR "/src/src/InterfaceForward.Api"
|
|
||||||
RUN dotnet build "InterfaceForward.Api.csproj" -c $BUILD_CONFIGURATION -o /app/build
|
|
||||||
|
|
||||||
FROM base AS publish
|
# 仅复制必要的文件
|
||||||
ARG BUILD_CONFIGURATION=Release
|
COPY src/InterfaceForward.Api/InterfaceForward.Api.csproj src/InterfaceForward.Api/
|
||||||
|
RUN dotnet restore "src/InterfaceForward.Api/InterfaceForward.Api.csproj"
|
||||||
|
|
||||||
|
# 复制其余文件并进行构建
|
||||||
|
COPY . .
|
||||||
|
WORKDIR "/src/src/InterfaceForward.Api"
|
||||||
RUN dotnet publish "InterfaceForward.Api.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
|
RUN dotnet publish "InterfaceForward.Api.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
|
||||||
|
|
||||||
FROM base AS final
|
# 使用运行时镜像
|
||||||
|
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY --from=publish /app/publish .
|
COPY --from=build /app/publish .
|
||||||
ENTRYPOINT ["dotnet", "InterfaceForward.Api.dll"]
|
ENTRYPOINT ["dotnet", "InterfaceForward.Api.dll"]
|
||||||
@ -1,5 +1,7 @@
|
|||||||
using FreeRedis;
|
using FreeRedis;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using Serilog;
|
||||||
|
|
||||||
namespace InterfaceForward.Application.Helpers;
|
namespace InterfaceForward.Application.Helpers;
|
||||||
|
|
||||||
public static class RedisHelper
|
public static class RedisHelper
|
||||||
@ -24,7 +26,7 @@ public static class RedisHelper
|
|||||||
_client.Serialize = obj => JsonConvert.SerializeObject(obj);
|
_client.Serialize = obj => JsonConvert.SerializeObject(obj);
|
||||||
_client.Deserialize = (json, type) => JsonConvert.DeserializeObject(json, type);
|
_client.Deserialize = (json, type) => JsonConvert.DeserializeObject(json, type);
|
||||||
if (showLogInfo)
|
if (showLogInfo)
|
||||||
_client.Notice += (s, e) => Console.WriteLine(Environment.NewLine + e.Log);
|
_client.Notice += (s, e) => Log.Information(Environment.NewLine + e.Log);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,8 +4,11 @@ using Fake.EventBus.RabbitMQ;
|
|||||||
using Fake.Modularity;
|
using Fake.Modularity;
|
||||||
using Fake.ObjectMapping.AutoMapper;
|
using Fake.ObjectMapping.AutoMapper;
|
||||||
using Fake.RabbitMQ;
|
using Fake.RabbitMQ;
|
||||||
|
using FreeRedis;
|
||||||
using InterfaceForward.Application.Contracts;
|
using InterfaceForward.Application.Contracts;
|
||||||
|
using InterfaceForward.Application.Helpers;
|
||||||
using InterfaceForward.Repositories;
|
using InterfaceForward.Repositories;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
namespace InterfaceForward.Application;
|
namespace InterfaceForward.Application;
|
||||||
@ -28,6 +31,11 @@ public class InterfaceForwardApplicationModule:FakeModule
|
|||||||
|
|
||||||
context.Services.Configure<InterfaceRelayOptions>(configuration.GetSection("InterfaceRelay"));
|
context.Services.Configure<InterfaceRelayOptions>(configuration.GetSection("InterfaceRelay"));
|
||||||
|
|
||||||
|
var options = configuration.GetSection("Redis").Get<ConnectionStringBuilder>();
|
||||||
|
if (options == null)
|
||||||
|
throw new FakeException("未找到Redis相关配置,请检查配置文件中是否包含名为Redis的节点");
|
||||||
|
RedisHelper.Init(options, showLogInfo: System.Diagnostics.Debugger.IsAttached);
|
||||||
|
|
||||||
// 预热
|
// 预热
|
||||||
NatashaInitializer.Preheating();
|
NatashaInitializer.Preheating();
|
||||||
|
|
||||||
|
|||||||
@ -54,6 +54,18 @@ public class ServiceProviderInterfaceService : ApplicationService
|
|||||||
return tree;
|
return tree;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 服务商接口分页列表
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="input"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost("Interface/ServiceProviderInterfacePaginatedList")]
|
||||||
|
public async Task<PagedResult<ServiceProviderInterfacePaginatedOutputValueObject>>
|
||||||
|
ServiceProviderInterfacePaginatedListAsync(ServiceProviderInterfacePaginatedInputObjectValue input)
|
||||||
|
{
|
||||||
|
return await InterfaceRepository.GetServiceProviderInterfacePaginatedListAsync(input);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取服务商接口下拉列表
|
/// 获取服务商接口下拉列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -46,6 +46,19 @@ public class SystemInterfaceService : ApplicationService
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 系统接口分页列表
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="input"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost("Interface/SystemInterfacePaginatedList")]
|
||||||
|
public async Task<PagedResult<SystemInterfacePaginatedOutputValueObject>>
|
||||||
|
SystemInterfacePaginatedListAsync(SystemInterfacePaginatedInputObjectValue input)
|
||||||
|
{
|
||||||
|
return await _interfaceRepository.GetSystemInterfacePaginatedListAsync(input);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 系统接口树形列表
|
/// 系统接口树形列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -46,5 +46,8 @@ namespace InterfaceForward.Repositories.Interface.Services
|
|||||||
/// <param name="spId"></param>
|
/// <param name="spId"></param>
|
||||||
/// /// <returns></returns>
|
/// /// <returns></returns>
|
||||||
Task<string> GetCurrentCodeBySpId(int spId);
|
Task<string> GetCurrentCodeBySpId(int spId);
|
||||||
|
|
||||||
|
Task<PagedResult<SystemInterfacePaginatedOutputValueObject>> GetSystemInterfacePaginatedListAsync(SystemInterfacePaginatedInputObjectValue input);
|
||||||
|
Task<PagedResult<ServiceProviderInterfacePaginatedOutputValueObject>> GetServiceProviderInterfacePaginatedListAsync(ServiceProviderInterfacePaginatedInputObjectValue input);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -131,4 +131,65 @@ public class InterfaceRepository : BasicRepository<InterfaceEntity>, IInterfaceR
|
|||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public async Task<PagedResult<SystemInterfacePaginatedOutputValueObject>>
|
||||||
|
GetSystemInterfacePaginatedListAsync(SystemInterfacePaginatedInputObjectValue input)
|
||||||
|
{
|
||||||
|
// 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)
|
||||||
|
;
|
||||||
|
|
||||||
|
var keyword = input.NameOrCode?.Trim();
|
||||||
|
query.WhereIF(input.Category != 0, a => a.Category == input.Category) // 默认“请选择”对应0,数据源在数据库字典中配置
|
||||||
|
.WhereIF(!string.IsNullOrEmpty(keyword), a => a.Name.Contains(keyword)
|
||||||
|
|| 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<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);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public async Task<PagedResult<ServiceProviderInterfacePaginatedOutputValueObject>>
|
||||||
|
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);
|
||||||
|
|
||||||
|
query
|
||||||
|
.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,
|
||||||
|
})
|
||||||
|
.OrderByDescending(a => a.UpdateTime)
|
||||||
|
.ToPagedListAsync(input.PageIndex, input.PageSize);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -0,0 +1,24 @@
|
|||||||
|
using InterfaceForward.Domain.Shared.Dtos;
|
||||||
|
|
||||||
|
namespace InterfaceForward.Repositories.Interface.ValueObjects;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 服务商接口分页
|
||||||
|
/// </summary>
|
||||||
|
public class ServiceProviderInterfacePaginatedInputObjectValue : PagedQueryInput
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 服务商Id
|
||||||
|
/// </summary>
|
||||||
|
public int ServiceProviderId { get; set; }
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
/// 接口名
|
||||||
|
///</summary>
|
||||||
|
public string? Name { get; set; }
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
/// 接口代码
|
||||||
|
///</summary>
|
||||||
|
public string? Code { get; set; }
|
||||||
|
}
|
||||||
@ -0,0 +1,47 @@
|
|||||||
|
namespace InterfaceForward.Repositories.Interface.ValueObjects;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public class ServiceProviderInterfacePaginatedOutputValueObject
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 接口Id
|
||||||
|
/// </summary>
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
/// 接口名
|
||||||
|
///</summary>
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
/// 接口代码
|
||||||
|
///</summary>
|
||||||
|
public string Code { get; set; }
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
/// 请求协议
|
||||||
|
///</summary>
|
||||||
|
public string RequestProtocol { get; set; }
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
/// 请求方式
|
||||||
|
///</summary>
|
||||||
|
public string RequestMethod { get; set; }
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
/// 请求地址
|
||||||
|
///</summary>
|
||||||
|
public string RequestAddress { get; set; }
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
/// 接口描述
|
||||||
|
///</summary>
|
||||||
|
public string Description { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新时间
|
||||||
|
/// </summary>
|
||||||
|
public DateTime? UpdateTime { get; set; }
|
||||||
|
}
|
||||||
@ -0,0 +1,20 @@
|
|||||||
|
using InterfaceForward.Domain.Shared.Dtos;
|
||||||
|
|
||||||
|
namespace InterfaceForward.Repositories.Interface.ValueObjects
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 分页查询系统接口
|
||||||
|
/// </summary>
|
||||||
|
public class SystemInterfacePaginatedInputObjectValue : PagedQueryInput
|
||||||
|
{
|
||||||
|
///<summary>
|
||||||
|
/// 接口分组,默认请选择对应0值
|
||||||
|
///</summary>
|
||||||
|
public int Category { get; set; }
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
/// 接口名
|
||||||
|
///</summary>
|
||||||
|
public string NameOrCode { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,48 @@
|
|||||||
|
namespace InterfaceForward.Repositories.Interface.ValueObjects
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public class SystemInterfacePaginatedOutputValueObject
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 接口Id
|
||||||
|
/// </summary>
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
/// 接口分组
|
||||||
|
///</summary>
|
||||||
|
public string Category { get; set; }
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
/// 接口名
|
||||||
|
///</summary>
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
/// 接口代码
|
||||||
|
///</summary>
|
||||||
|
public string Code { get; set; }
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
/// 请求协议
|
||||||
|
///</summary>
|
||||||
|
public string RequestProtocol { get; set; }
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
/// 接口描述
|
||||||
|
///</summary>
|
||||||
|
public string Description { get; set; }
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
/// 映射数
|
||||||
|
///</summary>
|
||||||
|
public int MapCount { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新时间
|
||||||
|
/// </summary>
|
||||||
|
public DateTime? UpdateTime { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user