添加一个实体库
This commit is contained in:
parent
1a265b0637
commit
54ec2b977b
|
|
@ -1,7 +1,7 @@
|
|||
using GenerateSeeds;
|
||||
using System.Text;
|
||||
|
||||
var connectionString = "Server=.;Database=hzy_microservices_sqlserver_20230227;User ID=sa;Password=123456;MultipleActiveResultSets=true;Encrypt=True;TrustServerCertificate=True;";
|
||||
var connectionString = "Server=192.168.195.2;Database=MiaoYu;User ID=zpc;Password=zpc;MultipleActiveResultSets=true;Encrypt=True;TrustServerCertificate=True;";
|
||||
|
||||
IFreeSql fsql = new FreeSql.FreeSqlBuilder()
|
||||
.UseConnectionString(FreeSql.DataType.SqlServer, connectionString)
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
CoreRedisStartup,
|
||||
CoreIdentityStartup,
|
||||
AdminRepositoryStartup,
|
||||
ChatAdminRepositoryStartup,
|
||||
CoreSwaggerJwtStartup,
|
||||
SharedAdminStartup>]
|
||||
public class ApiAdminStartup : AppStartupBase<ApiAdminStartup>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
namespace MiaoYu.Api.Admin.ApplicationServices.DevelopmentTools.LowCode.Impl;
|
||||
using MiaoYu.Repository.ChatAI.Admin.Entities;
|
||||
|
||||
namespace MiaoYu.Api.Admin.ApplicationServices.DevelopmentTools.LowCode.Impl;
|
||||
|
||||
/// <summary>
|
||||
/// 服务 Low_Code_TableService
|
||||
|
|
@ -10,9 +12,11 @@ public class LowCodeTableService : ApplicationService<IRepository<LowCodeTable>>
|
|||
private readonly IDatabaseTableService _databaseTableService;
|
||||
private readonly ICodeGenerationService _codeGenerationService;
|
||||
|
||||
public LowCodeTableService(IRepository<LowCodeTable> defaultRepository,
|
||||
public LowCodeTableService(
|
||||
IRepository<LowCodeTable> defaultRepository,
|
||||
LowCodeTableInfoService lowCodeTableInfoService,
|
||||
IRepository<LowCodeTableInfo> lowCodeTableInfoRepository,
|
||||
IRepository<T_Image_Config> imageConfig,
|
||||
IDatabaseTableService databaseTableService,
|
||||
ICodeGenerationService codeGenerationService) : base(defaultRepository)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
<ProjectReference Include="..\MiaoYu.Core.Swagger\MiaoYu.Core.Swagger.csproj" />
|
||||
<ProjectReference Include="..\MiaoYu.Core\MiaoYu.Core.csproj" />
|
||||
<ProjectReference Include="..\MiaoYu.Repository.Admin\MiaoYu.Repository.Admin.csproj" />
|
||||
<ProjectReference Include="..\MiaoYu.Repository.ChatAI.Admin\MiaoYu.Repository.ChatAI.Admin.csproj" />
|
||||
<ProjectReference Include="..\MiaoYu.Shared.Admin\MiaoYu.Shared.Admin.csproj" />
|
||||
<ProjectReference Include="..\MiaoYu.Shared\MiaoYu.Shared.csproj" />
|
||||
</ItemGroup>
|
||||
|
|
|
|||
|
|
@ -80,3 +80,4 @@ global using System.Reflection;
|
|||
global using System.Text;
|
||||
global using System.Text.Encodings.Web;
|
||||
global using System.Text.Unicode;
|
||||
global using MiaoYu.Repository.ChatAI.Admin;
|
||||
|
|
@ -21,6 +21,10 @@
|
|||
//"ConnectionString": "user id=hzy_admin_oracle_20221213;password=123456; data source=//127.0.0.1:1521/orcl;Pooling=true;Min Pool Size=1"
|
||||
},
|
||||
"ChatAdminRepositoryOptions": {
|
||||
//默认数据库类型 SqlServer 、MySql 、PostgreSql、Oracle
|
||||
"DefaultDatabaseType": "SqlServer",
|
||||
//是否监控EFCore程序
|
||||
"IsMonitorEFCore": true,
|
||||
"ConnectionString": "Server=192.168.195.2;Database=MiaoYu;User ID=zpc;Password=zpc;MultipleActiveResultSets=true;Encrypt=True;TrustServerCertificate=True;"
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -366,5 +366,20 @@
|
|||
删除标识
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:MiaoYu.Core.EntityFramework.Models.DefaultEntityV4">
|
||||
<summary>
|
||||
妙语聊天项目
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:MiaoYu.Core.EntityFramework.Models.ITenantEntity">
|
||||
<summary>
|
||||
多租户
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:MiaoYu.Core.EntityFramework.Models.ITenantEntity.TenantId">
|
||||
<summary>
|
||||
所属租户
|
||||
</summary>
|
||||
</member>
|
||||
</members>
|
||||
</doc>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,23 @@
|
|||
using HZY.Framework.Repository.EntityFramework.Models;
|
||||
|
||||
|
||||
namespace MiaoYu.Core.EntityFramework.Models;
|
||||
|
||||
/// <summary>
|
||||
/// 妙语聊天项目
|
||||
/// </summary>
|
||||
public class DefaultEntityV4 : EntityIdentity<int>, ITenantEntity
|
||||
{
|
||||
public virtual Guid TenantId { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 多租户
|
||||
/// </summary>
|
||||
public interface ITenantEntity : IEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// 所属租户
|
||||
/// </summary>
|
||||
Guid TenantId { get; set; }
|
||||
}
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
namespace MiaoYu.Repository.ChatAI.Admin
|
||||
{
|
||||
/// <summary>
|
||||
/// 后台管理系统数据库上下文
|
||||
/// 后台管理系统数据库上下文
|
||||
/// </summary>
|
||||
[DbContextConfig($"Repository.*.Entities.*")]
|
||||
public class ChatAdminDbContext : DbContext, IBaseDbContext
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ using MiaoYu.Repository.ChatAI.Admin.Models;
|
|||
namespace MiaoYu.Repository.ChatAI.Admin
|
||||
{
|
||||
/// <summary>
|
||||
/// 程序启动器
|
||||
/// 程序启动器
|
||||
/// </summary>
|
||||
[ImportStartupModule<CoreEntityFrameworkStartup>]
|
||||
public class ChatAdminRepositoryStartup : StartupModule<ChatAdminRepositoryStartup>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,40 @@
|
|||
using FreeSql.DatabaseModel;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using FreeSql.DataAnnotations;
|
||||
using MiaoYu.Core.EntityFramework.Models;
|
||||
|
||||
namespace MiaoYu.Repository.ChatAI.Admin.Entities
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 图片表
|
||||
/// </summary>
|
||||
[EntityDescription(FieldIgnored = true)]
|
||||
public partial class T_Image_Config : DefaultEntityV4
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 图片Id
|
||||
/// </summary>
|
||||
public int ImageId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 图片名称
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 图片url
|
||||
/// </summary>
|
||||
|
||||
public string Url { get; set; }
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
using FreeSql.DatabaseModel;@{
|
||||
var gen = Model as RazorModel;
|
||||
|
||||
Func<string, string> GetAttributeString = attr => {
|
||||
if (string.IsNullOrEmpty(attr)) return "";
|
||||
return string.Concat(", ", attr.Trim('[', ']'));
|
||||
};
|
||||
Func<string, string> GetDefaultValue = defval => {
|
||||
if (string.IsNullOrEmpty(defval)) return "";
|
||||
return " = " + defval + ";";
|
||||
};
|
||||
}@{
|
||||
switch (gen.fsql.Ado.DataType) {
|
||||
case FreeSql.DataType.PostgreSQL:
|
||||
@:using System;
|
||||
@:using System.Collections;
|
||||
@:using System.Collections.Generic;
|
||||
@:using System.Linq;
|
||||
@:using System.Reflection;
|
||||
@:using System.Threading.Tasks;
|
||||
@:using Newtonsoft.Json;
|
||||
@:using FreeSql.DataAnnotations;
|
||||
@:using System.Net;
|
||||
@:using Newtonsoft.Json.Linq;
|
||||
@:using System.Net.NetworkInformation;
|
||||
@:using NpgsqlTypes;
|
||||
@:using Npgsql.LegacyPostgis;
|
||||
break;
|
||||
case FreeSql.DataType.SqlServer:
|
||||
case FreeSql.DataType.MySql:
|
||||
default:
|
||||
@:using System;
|
||||
@:using System.Collections;
|
||||
@:using System.Collections.Generic;
|
||||
@:using System.Linq;
|
||||
@:using System.Reflection;
|
||||
@:using System.Threading.Tasks;
|
||||
@:using Newtonsoft.Json;
|
||||
@:using FreeSql.DataAnnotations;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
namespace @gen.NameSpace {
|
||||
|
||||
@if (string.IsNullOrEmpty(gen.table.Comment) == false) {
|
||||
@:/// <summary>
|
||||
@:/// @gen.table.Comment.Replace("\r\n", "\n").Replace("\n", "\r\n /// ")
|
||||
@:/// </summary>
|
||||
}
|
||||
[JsonObject(MemberSerialization.OptIn)@GetAttributeString(gen.GetTableAttribute())]
|
||||
public partial class @gen.GetCsName(gen.FullTableName) {
|
||||
|
||||
@foreach (var col in gen.columns) {
|
||||
|
||||
if (string.IsNullOrEmpty(col.Comment) == false) {
|
||||
@:/// <summary>
|
||||
@:/// @col.Comment.Replace("\r\n", "\n").Replace("\n", "\r\n /// ")
|
||||
@:/// </summary>
|
||||
}
|
||||
@:@("[JsonProperty" + GetAttributeString(gen.GetColumnAttribute(col, true)) + "]")
|
||||
@:public @gen.GetCsType(col) @gen.GetCsName(col.Name) { get; set; }@GetDefaultValue(gen.GetColumnDefaultValue(col, false))
|
||||
@:
|
||||
}
|
||||
}
|
||||
@gen.GetMySqlEnumSetDefine()
|
||||
}
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
|
||||
FreeSql.Generator -Razor "__razor.cshtml.txt" -NameOptions 1,0,0,0 -NameSpace MiaoYu.Repository.ChatAI.Admin.Entities -DB "SqlServer,data source=192.168.195.2;initial catalog=MiaoYu;User Id=zpc;Password=zpc;TrustServerCertificate=true;pooling=true;max pool size=2" -FileName "{name}.cs"
|
||||
|
|
@ -4,6 +4,8 @@
|
|||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||
<DocumentationFile>$(MSBuildProjectName).xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
@ -19,7 +21,6 @@
|
|||
|
||||
<ItemGroup>
|
||||
<Folder Include="Entities\" />
|
||||
<Folder Include="Migrations\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,61 @@
|
|||
<?xml version="1.0"?>
|
||||
<doc>
|
||||
<assembly>
|
||||
<name>MiaoYu.Repository.ChatAI.Admin</name>
|
||||
</assembly>
|
||||
<members>
|
||||
<member name="T:MiaoYu.Repository.ChatAI.Admin.ChatAdminDbContext">
|
||||
<summary>
|
||||
后台管理系统数据库上下文
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:MiaoYu.Repository.ChatAI.Admin.ChatAdminDbContext.UnitOfWork">
|
||||
<summary>
|
||||
工作单元
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:MiaoYu.Repository.ChatAI.Admin.ChatAdminDbContext.OnModelCreating(Microsoft.EntityFrameworkCore.ModelBuilder)">
|
||||
<summary>
|
||||
模型创建
|
||||
</summary>
|
||||
<param name="modelBuilder"></param>
|
||||
</member>
|
||||
<member name="T:MiaoYu.Repository.ChatAI.Admin.ChatAdminRepositoryStartup">
|
||||
<summary>
|
||||
程序启动器
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:MiaoYu.Repository.ChatAI.Admin.ChatAdminRepositoryStartup.ConfigureServices(Microsoft.AspNetCore.Builder.WebApplicationBuilder)">
|
||||
<summary>
|
||||
程序启动器
|
||||
</summary>
|
||||
<param name="webApplicationBuilder"></param>
|
||||
</member>
|
||||
<member name="M:MiaoYu.Repository.ChatAI.Admin.ChatAdminRepositoryStartup.Configure(Microsoft.AspNetCore.Builder.WebApplication)">
|
||||
<summary>
|
||||
Configure
|
||||
</summary>
|
||||
<param name="webApplication"></param>
|
||||
</member>
|
||||
<member name="T:MiaoYu.Repository.ChatAI.Admin.Entities.T_Image_Config">
|
||||
<summary>
|
||||
图片表
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:MiaoYu.Repository.ChatAI.Admin.Entities.T_Image_Config.ImageId">
|
||||
<summary>
|
||||
图片Id
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:MiaoYu.Repository.ChatAI.Admin.Entities.T_Image_Config.Name">
|
||||
<summary>
|
||||
图片名称
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:MiaoYu.Repository.ChatAI.Admin.Entities.T_Image_Config.Url">
|
||||
<summary>
|
||||
图片url
|
||||
</summary>
|
||||
</member>
|
||||
</members>
|
||||
</doc>
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
using MiaoYu.Repository.ChatAI.Admin.Entities;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MiaoYu.Repository.ChatAI.Admin.Migrations
|
||||
{
|
||||
[DbContext(typeof(ChatAdminDbContext))]
|
||||
public class ChatAdminDbContextModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "8.0.2")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
modelBuilder.Entity<T_Image_Config>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("PK__T_Image___3214EC072BCFE4E5");
|
||||
|
||||
entity.ToTable(tb => tb.HasComment("图片表"));
|
||||
|
||||
entity.Property(e => e.ImageId).HasComment("图片Id");
|
||||
entity.Property(e => e.Name)
|
||||
.HasMaxLength(50)
|
||||
.HasComment("图片名称");
|
||||
entity.Property(e => e.TenantId).HasComment("租户");
|
||||
entity.Property(e => e.Url)
|
||||
.HasMaxLength(500)
|
||||
.HasComment("图片地址");
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user