50 lines
1.9 KiB
C#
50 lines
1.9 KiB
C#
using HZY.Framework.DependencyInjection.Attributes;
|
|
using MiaoYu.Api.Admin.ApplicationServices.DevelopmentTools.LowCode.Abstractions;
|
|
using MiaoYu.Repository.ChatAI.Admin.Entities;
|
|
|
|
namespace MiaoYu.Api.Admin.ApplicationServices.DevelopmentTools.LowCode.Providers;
|
|
|
|
/// <summary>
|
|
/// MiaoYuChat 数据源提供者
|
|
/// </summary>
|
|
[Component]
|
|
public class MiaoYuChatDataSourceProvider : IDataSourceProvider, IScopedDependency
|
|
{
|
|
private readonly IRepository<T_Image_Config> _repository;
|
|
|
|
public MiaoYuChatDataSourceProvider(IRepository<T_Image_Config> repository)
|
|
{
|
|
_repository = repository;
|
|
}
|
|
|
|
public DataSourceConfig Config => new DataSourceConfig
|
|
{
|
|
DatabaseKey = DataSourceConstants.MiaoYuChat,
|
|
DisplayName = "喵语AI聊天",
|
|
EntityNamespace = typeof(ChatAdminRepositoryStartup).Namespace!,
|
|
ModelPathTemplate = "{RootPath}\\{Namespace}\\Entities\\Apps",
|
|
ServicePathTemplate = "{AppPath}\\ApplicationServices\\Apps\\MiaoYuChat",
|
|
ControllerPathTemplate = "{AppPath}\\Controllers\\Apps\\MiaoYuChat",
|
|
ClientIndexPathTemplate = "{RootPath}\\admin-client\\src\\views\\apps\\{TableName}s",
|
|
ClientInfoPathTemplate = "{RootPath}\\admin-client\\src\\views\\apps\\{TableName}s",
|
|
ClientServicePathTemplate = "{RootPath}\\admin-client\\src\\services\\apps\\{TableName}s",
|
|
TemplatePath = "/wwwroot/code_generation/templatev4/",
|
|
NamingStrategy = EntityNamingStrategy.KeepOriginal,
|
|
Order = 2,
|
|
EnableEntityPrefix = false,
|
|
EntityPrefix = "Chat",
|
|
UsesPluralPath = false
|
|
};
|
|
|
|
public List<DbTableInfo> GetTables()
|
|
{
|
|
var tables = _repository.UnitOfWork.FreeSqlOrm.DbFirst.GetTablesByDatabase();
|
|
// 标记数据源来源
|
|
tables.ForEach(t => t.Schema = t.Schema + "." + Config.DatabaseKey);
|
|
return tables;
|
|
}
|
|
|
|
public DbContext GetDbContext() => _repository.GetContext()!;
|
|
}
|
|
|