
Project Introduction
Project Structure
Admin Source Code Project
Admin.Core
├── 01.sln // Project files
│ ├── Directory.Build.props // Specify Target Framework and NuGet package versions
│ └── ZhonTai.sln.EasyRun.json // Use Tye to configure multiple startup projects for running and debugging microservices
├── 02.build // Build
│ └── Directory.Build.props // NuGet package properties
├── 03.gateways // Build
│ └── ZhonTai.Gateway.Yarp.Host // Yarp gateway project
│ └── Core // Gateway core
├── 04.modules // Module projects
│ ├── admin // Permission Management
│ │ ├── ZhonTai.Admin // Permission API project
│ │ │ ├── Core // API core
│ │ │ ├── GrpcServices // gRPC API implementation
│ │ │ ├── Repositories // Repository implementation
│ │ │ ├── Resources // i18n resource files
│ │ │ └── Services // HTTP API implementation
│ │ ├── ZhonTai.Admin.Contracts // Permission contract project
│ │ │ ├── Core // Contract core
│ │ │ ├── Domain // Domain: table entities, enums, repository interface definitions
│ │ │ └── Services // Service interfaces, input/output class definitions
│ │ ├── ZhonTai.Admin.Core // Permission system core project
│ │ │ ├── Aop // AOP (Aspect-Oriented Programming)
│ │ │ ├── Attributes // Dependency injection and other attribute definitions
│ │ │ ├── Auth // User and token information
│ │ │ ├── Base // Base service convenience properties and methods
│ │ │ ├── Configs // Configuration entity class definitions
│ │ │ ├── Consts // System, cache, database key, filter name, subscription name constant definitions
│ │ │ ├── Conventions // API grouping conventions
│ │ │ ├── Db // Data sync and generation, transactions, database registration operations
│ │ │ ├── Dto // Import, export, paging, query, sorting DTO definitions
│ │ │ ├── Entities // Add, update, delete, tenant, member, version base classes, filter interface definitions
│ │ │ ├── Enums // Enum types
│ │ │ ├── Exceptions // Exceptions
│ │ │ ├── Extensions // Feature method extensions
│ │ │ ├── Filters // Filters
│ │ │ ├── GrpcServices // gRPC service interfaces
│ │ │ ├── Handlers // Permission, response, authentication, log handlers
│ │ │ ├── Helpers // Import/export, API, policy, upload, user helper classes
│ │ │ ├── Middlewares // Exception middleware
│ │ │ ├── Protos // gRPC Proto data type definitions
│ │ │ ├── Records // Record type definitions
│ │ │ ├── RegisterModules // Autofac module injection
│ │ │ ├── Repositories // Base repository interfaces and implementations
│ │ │ ├── Resources // i18n resource files
│ │ │ ├── Startup // Host application, middleware, context configuration
│ │ │ ├── TaskScheduler // Task scheduler wrapper
│ │ │ ├── Tools // Cache tools
│ │ │ ├── AppInfo.cs // Application global information
│ │ │ ├── AppInfoBase.cs // Application global information base class
│ │ │ ├── AppSettings.cs // Application configuration
│ │ │ ├── BaseController.cs // Base controller
│ │ │ ├── HostApp.cs // Host application
│ │ │ ├── HostInfo.cs // Host information
│ │ │ └── ModuleInfo.cs // Module information
│ │ ├── ZhonTai.Admin.Host // API startup project
│ │ │ ├── ConfigCenter // Configuration center files
│ │ │ ├── InitData // Initialization data
│ │ │ ├── appsettings.json // System application configuration
│ │ │ ├── Dockerfile // Dockerfile
│ │ │ ├── ip2region.xdb // IP address to region database
│ │ │ ├── nlog.config // NLog configuration file
│ │ │ └── Program.cs // Application startup class
│ │ └── ZhonTai.Tests // Permission test project
│ │ ├── Controllers // API tests
│ │ ├── Repositories // Repository tests
│ │ └── Services // Service tests
│ ├── dev // Online Development
│ │ ├── ZhonTai.Module.Dev.Api // Development API project
│ │ │ ├── Core // API core
│ │ │ └── Services // HTTP API implementation
│ │ ├── ZhonTai.Module.Dev.Api.Contracts // Development contract project
│ │ │ ├── Core // Contract core
│ │ │ ├── Domain // Domain: table entities, enums, repository interface definitions
│ │ │ ├── Resources // i18n files
│ │ │ └── Services // Service interfaces, input/output class definitions
│ │ ├── ZhonTai.Module.Dev.Host // API startup project
│ │ │ ├── ConfigCenter // Configuration center files
│ │ │ ├── InitData // Initialization data
│ │ │ ├── Templates // Code generation template files
│ │ │ ├── appsettings.json // System application configuration
│ │ │ ├── Dockerfile // Dockerfile
│ │ │ ├── nlog.config // NLog configuration file
│ │ │ └── Program.cs // Application startup class
│ └── im // Instant Messaging
│ └── ZhonTai.IMServer.Host // IM server startup project
│ ├── Core // Core folder
│ ├── appsettings.json // System application configuration
│ └── nlog.config // NLog configuration file
└── 05.platform // Platform projects
├── ZhonTai.ApiUI // API documentation library
├── ZhonTai.Common // Common utility library
├── ZhonTai.DynamicApi // Dynamic API library
└── ZhonTai.Plugin.Lazy.SlideCaptcha.Core // Slide captcha pluginApp API Project
Create a new project MyCompanyName.MyProjectName using the ZhonTai.Template.App template, with the following file structure:
MyCompanyName.MyProjectName
├── MyCompanyName.MyProjectName.Api // API project
│ ├── Core // API core
│ ├── Repositories // Repository implementation
│ └── Services // Service implementation
├── MyCompanyName.MyProjectName.Api.Contracts // Contract project
│ ├── Core // Contract core
│ ├── Domain // Domain: entities, repository interface definitions
│ ├── Resources // i18n resource files
│ └── Services // Service interfaces, input/output class definitions
├── MyCompanyName.MyProjectName.Host // API startup project
│ ├── ConfigCenter // Configuration center files
│ ├── InitData // Initialization data
│ ├── appsettings.json // System application configuration
│ ├── Dockerfile // Dockerfile
│ ├── ip2region.xdb // IP address to region database
│ └── nlog.config // NLog configuration file
└── MyCompanyName.MyProjectName.Tests // Test project
├── Controllers // API tests
├── Repositories // Repository tests
└── Services // Service testsConfiguration Files
appsettings.json Application Configuration
appsettings.json
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.AspNetCore": "Warning",
"Microsoft.Hosting.Lifetime": "Information",
"Microsoft.Extensions.Diagnostics.HealthChecks": "Warning"
}
},
"AllowedHosts": "*",
"Kestrel": {
"Endpoints": {
"Default": {
"Url": "http://*:18010"
},
"Grpc": {
"Url": "http://*:18011",
"Protocols": "Http2"
}
}
},
// Remote configuration
"RpcConfig": {
// HTTP remote configuration
"Http": {
"Enable": true,
// Client assembly name list, auto-includes ZhonTai.Admin.Contracts if not configured
"AssemblyNames": [ "ZhonTai.Admin.Contracts" ]
},
// gRPC remote configuration
"Grpc": {
"Enable": true,
// Client assembly name list, auto-includes ZhonTai.Admin.Core if not configured
"AssemblyNames": [ "ZhonTai.Admin.Core" ],
// Server assembly name list
"ServerAssemblyNames": [ "ZhonTai.Admin" ]
},
// Remote address list
"Endpoints": [
{
"Name": "admin",
"HttpUrl": "http://localhost:18010",
"GrpcUrl": "http://localhost:18011"
}
]
},
// Application configuration
"AppSettings": {
// Use configuration center
"UseConfigCenter": true,
// Configuration center path
"ConfigCenterPath": "ConfigCenter"
},
// Distributed transaction
"CAP": {
"RabbitMq": {
"HostName": "",
"Port": 5672,
"UserName": "",
"Password": ""
}
},
/*
// Send email verification code
await AppInfo.GetRequiredService<ICapPublisher>().PublishAsync(SubscribeNames.EmailSingleSend,
new EamilSingleSendEvent
{
ToEmail = new EamilSingleSendEvent.Models.EmailModel
{
Address = ""
},
Subject = "ZhonTai Admin Account Email Verification Code",
Body = code
});
*/
// Email configuration
"Email": {
// Host
"Host": "smtp.qq.com",
// Port 465, 587, 25
"Port": 465,
// Use SSL
"UseSsl": true,
// Email account
"UserName": "",
// Email password
"Password": "",
// Sender
"FromEmail": {
// Name
"Name": "",
// Address
"Address": ""
},
// Recipient
"ToEmail": {
// Name
"Name": "",
// Address
"Address": ""
}
},
// Task scheduler configuration
"TaskScheduler": {
// Process startup info
"ProcessStartInfo": {
"FileName": "C:/grpcurl_1.8.7/grpcurl",
// Working directory
"WorkingDirectory": ""
},
// Alert email
"AlerEmail": {
"Enable": true,
"Address": ""
},
// Module list
"Modules": [
{
// Module name
"Name": "admin",
// HTTP request URL
"HttpUrl": "http://localhost:18010",
// gRPC request URL
"GrpcUrl": "http://localhost:18011"
}
]
},
// Slide captcha
"SlideCaptcha": {
// Cache expiration duration
"ExpirySeconds": 300,
// Cache prefix
"StoreageKeyPrefix": "app:captcha:",
// Tolerance value (validation tolerance range for gap position matching)
"Tolerant": 0.02,
// Background image configuration
"Backgrounds": [
{
"Type": "file",
"Data": "wwwroot/captcha/jigsaw/backgrounds/1.jpg"
},
{
"Type": "file",
"Data": "wwwroot/captcha/jigsaw/backgrounds/2.jpg"
},
{
"Type": "file",
"Data": "wwwroot/captcha/jigsaw/backgrounds/3.jpg"
},
{
"Type": "file",
"Data": "wwwroot/captcha/jigsaw/backgrounds/4.jpg"
},
{
"Type": "file",
"Data": "wwwroot/captcha/jigsaw/backgrounds/5.jpg"
}
],
// If Templates not configured, use default template
"Templates": [
//{
// "Slider": {
// "Type": "file",
// "Data": "wwwroot/captcha/jigsaw/templates/1/transparent.png"
// },
// "Hole": {
// "Type": "file",
// "Data": "wwwroot/captcha/jigsaw/templates/1/dark.png"
// }
//}
]
}
}dbconfig.json Database Configuration
dbconfig.json
{
"DbConfig": {
// Database registration key
"key": "sysdb",
// Assembly name, auto-fetch entity tables; leave empty for ConfigureFreeSql custom configuration
"assemblyNames": [ "MyCompanyName.MySys.Api" ],
// Specify entity database list; leave empty to sync all database table entities
"includeEntityDbs": [],
// Exclude entity database list; specify database table entities not to sync
"excludeEntityDbs": [],
// Monitor all operations
"monitorCommand": false,
// Monitor CRUD operations
"curd": true,
// Monitor sync structure scripts
"syncStructureSql": false,
// Monitor sync data CRUD operations
"syncDataCurd": false,
// Create database
"createDb": true,
//SqlServer,PostgreSQL,Oracle,OdbcOracle,OdbcSqlServer,OdbcMySql,OdbcPostgreSQL,Odbc,OdbcDameng,MsAccess
// Create database connection string
//default_authentication_plugin = caching_sha2_password
//MySql "Server=localhost; Port=3306; Database=mysql; Uid=root; Pwd=pwd; Charset=utf8mb4;Min pool size=1;Allow User Variables=True"
//default_authentication_plugin = mysql_native_password
//MySql "Server=localhost; Port=3306; Database=mysql; Uid=root; Pwd=pwd; Charset=utf8mb4;SslMode=none;Min pool size=1;Allow User Variables=True"
//SqlServer "Data Source=.;Integrated Security=True;Initial Catalog=master;Encrypt=True;TrustServerCertificate=True;Pooling=true;Min Pool Size=1"
//PostgreSQL "Host=localhost;Port=5432;Username=postgres;Password=; Database=postgres;Pooling=true;Minimum Pool Size=1"
//Oracle "user id=SYS;password=pwd; data source=//127.0.0.1:1521/XE;Pooling=true;Min Pool Size=1"
"createDbConnectionString": "",
// Create database script; complex scripts can be placed in createdbsql.txt
//MySql "CREATE DATABASE `sysdb` CHARACTER SET 'utf8mb4' COLLATE 'utf8mb4_general_ci'"
//SqlServer "CREATE DATABASE [sysdb]"
//PostgreSQL "CREATE DATABASE \"sysdb\" WITH ENCODING = 'UTF8'"
"createDbSql": "",
// Sync structure
"syncStructure": true,
// Sync structure batch entity count
"syncStructureEntityBatchSize": 1,
// Sync data batch size; default 500 per batch, too large may cause memory overflow
"syncDataBatchSize": 500,
// Sync data
"syncData": true,
// Use with caution in production; ensure table data is up-to-date before enabling.
// To exclude certain tables, configure syncDataExcludeTables first, then execute data update
// Sync update data
"syncUpdateData": false,
//// Sync data path
"SyncDataPath": "InitData/App",
// Sync data include tables; specify tables to sync, leave empty to sync all
"syncDataIncludeTables": [],
// Sync data exclude tables; specify tables not to sync
"syncDataExcludeTables": [],
// Sync data operation user
"syncDataUser": {
"id": 161223411986501,
"userName": "admin",
"name": "Admin",
"tenantId": 161223412138053
},
// Do not enable data generation during initialization. Before publishing to production, enable to update data package if needed. Remember to disable after use.
// Disable syncStructure, syncData, and createDb before enabling data generation
// Generate data
"generateData": false,
// Database configuration https://github.com/dotnetcore/FreeSql/wiki/getting-started
// Connection string syntax https://www.connectionstrings.com
// Database types MySql = 0, SqlServer = 1, PostgreSQL = 2, Oracle = 3, Sqlite = 4, OdbcOracle = 5, OdbcSqlServer = 6, OdbcMySql = 7, OdbcPostgreSQL = 8, Odbc = 9, OdbcDameng = 10, MsAccess = 11, Dameng = 12, OdbcKingbaseES = 13, ShenTong = 14, KingbaseES = 15, Firebird = 16
"type": "Sqlite",
// Connection string
//default_authentication_plugin = caching_sha2_password
//MySql "Server=localhost; Port=3306; Database=sysdb; Uid=root; Pwd=pwd; Charset=utf8mb4;Min pool size=1;Allow User Variables=True"
//default_authentication_plugin = mysql_native_password
//MySql "Server=localhost; Port=3306; Database=sysdb; Uid=root; Pwd=pwd; Charset=utf8mb4;SslMode=none;Min pool size=1;Allow User Variables=True"
//SqlServer "Data Source=.;Integrated Security=True;Initial Catalog=sysdb;Encrypt=True;TrustServerCertificate=True;Pooling=true;Min Pool Size=1"
//PostgreSQL "Host=localhost;Port=5432;Username=postgres;Password=; Database=sysdb;Pooling=true;Minimum Pool Size=1"
//Sqlite "Data Source=|DataDirectory|\\sysdb.db; Pooling=true;Min Pool Size=1"
//"Oracle" "user id=SYS;password=pwd; data source=//127.0.0.1:1521/XE;Pooling=true;Min Pool Size=1",
"connectionString": "Data Source=|DataDirectory|\\sysdb.db; Pooling=true;Min Pool Size=1",
// Specify assembly
//FreeSql.MySql.MySqlProvider`1,FreeSql.Provider.MySqlConnector
"providerType": "",
// Read-write separation slave list
"slaveList": [
//{
// Weight
// "Weight": 1,
// // Connection string
// "ConnectionString": "Data Source=|DataDirectory|\\sysdb.db; Pooling=true;Min Pool Size=1"
//}
],
// Idle time (minutes); set idleTime=0 to disable auto-recovery, 1440=1 day
"idleTime": 1440,
// Force update EntityUpdate data on insert
"forceUpdate": false,
// Multiple databases
// Define DbKeys enum in Core/Consts
// Use repository: public ModuleRepository(UnitOfWorkManagerCloud muowm) : base(DbKeys.sysdb, muowm)
// Use FreeSqlCloud: freeSqlCloud.Use(DbKeys.sysdb);
"dbs": [
{
// Permission database
"key": "admindb",
// Assembly name, auto-fetch entity tables
"assemblyNames": [ "ZhonTai.Admin" ],
// Specify entity database list; leave empty to sync all database table entities
"includeEntityDbs": [],
// Exclude entity database list; specify database table entities not to sync
"excludeEntityDbs": [ "Log" ],
// Monitor all operations
"monitorCommand": false,
// Monitor CRUD operations
"curd": true,
// Monitor sync structure scripts
"syncStructureSql": false,
// Monitor sync data CRUD operations
"syncDataCurd": false,
// Create database
"createDb": true,
//SqlServer,PostgreSQL,Oracle,OdbcOracle,OdbcSqlServer,OdbcMySql,OdbcPostgreSQL,Odbc,OdbcDameng,MsAccess
// Create database connection string
//default_authentication_plugin = caching_sha2_password
//MySql "Server=localhost; Port=3306; Database=mysql; Uid=root; Pwd=pwd; Charset=utf8mb4;Min pool size=1;Allow User Variables=True"
//default_authentication_plugin = mysql_native_password
//MySql "Server=localhost; Port=3306; Database=mysql; Uid=root; Pwd=pwd; Charset=utf8mb4;SslMode=none;Min pool size=1;Allow User Variables=True"
//SqlServer "Data Source=.;User Id=sa;Password=pwd;Initial Catalog=master;TrustServerCertificate=true;Pooling=true;Min Pool Size=1"
//PostgreSQL "Host=localhost;Port=5432;Username=postgres;Password=; Database=postgres;Pooling=true;Minimum Pool Size=1"
//Oracle "user id=SYS;password=pwd; data source=127.0.0.1:1521/XE;Pooling=true;Min Pool Size=1"
"createDbConnectionString": "",
// Create database script; complex scripts can be placed in createdbsql.txt
//MySql "CREATE DATABASE `admindb` CHARACTER SET 'utf8mb4' COLLATE 'utf8mb4_general_ci'"
//SqlServer "CREATE DATABASE [admindb]"
//PostgreSQL "CREATE DATABASE \"admindb\" WITH ENCODING = 'UTF8'"
"createDbSql": "",
// Sync structure
"syncStructure": true,
// Sync structure batch entity count
"syncStructureEntityBatchSize": 1,
// Sync data batch size; default 500 per batch, too large may cause memory overflow
"syncDataBatchSize": 500,
// Sync data
"syncData": true,
// Sync update data; use with caution in production. To exclude tables, configure syncDataExcludeTables first
"syncUpdateData": false,
// Sync data path
"SyncDataPath": "InitData/App",
// Sync all tables ["base_dict_type", "base_dict", "base_user", "base_user_staff", "base_org", "base_role", "base_api", "base_view", "base_permission", "base_permission_api", "base_user_role", "base_user_org", "base_role_permission", "base_tenant", "base_tenant_permission"]
// Sync specified tables ["base_api", "base_view", "base_permission", "base_permission_api"]
// Sync data include tables; specify tables to sync, leave empty to sync all
"syncDataIncludeTables": [],
// Sync exclude tables ["base_user"]
// Sync data exclude tables; specify tables not to sync
"syncDataExcludeTables": [],
// Sync data operation user
"syncDataUser": {
"id": 161223411986501,
"userName": "admin",
"name": "Admin",
"tenantId": 161223412138053
},
// Do not enable data generation during initialization. Before publishing to production, enable to update data package if needed. Remember to disable after use.
// Disable syncStructure, syncData, and createDb before enabling data generation
// Generate data
"generateData": false,
// Database configuration https://github.com/dotnetcore/FreeSql/wiki/getting-started
// Connection string syntax https://www.connectionstrings.com
// Database types MySql = 0, SqlServer = 1, PostgreSQL = 2, Oracle = 3, Sqlite = 4, OdbcOracle = 5, OdbcSqlServer = 6, OdbcMySql = 7, OdbcPostgreSQL = 8, Odbc = 9, OdbcDameng = 10, MsAccess = 11, Dameng = 12, OdbcKingbaseES = 13, ShenTong = 14, KingbaseES = 15, Firebird = 16
"type": "Sqlite",
// Connection string
//default_authentication_plugin = caching_sha2_password
//MySql "Server=localhost; Port=3306; Database=admindb; Uid=root; Pwd=pwd; Charset=utf8mb4;Min pool size=1;Allow User Variables=True"
//default_authentication_plugin = mysql_native_password
//MySql "Server=localhost; Port=3306; Database=admindb; Uid=root; Pwd=pwd; Charset=utf8mb4;SslMode=none;Min pool size=1;Allow User Variables=True"
//SqlServer "Data Source=.;Integrated Security=True;Initial Catalog=admindb;Pooling=true;Min Pool Size=1"
//PostgreSQL "Host=localhost;Port=5432;Username=postgres;Password=; Database=admindb;Pooling=true;Minimum Pool Size=1"
//Sqlite "Data Source=|DataDirectory|\\admindb.db; Pooling=true;Min Pool Size=1"
//"Oracle" "user id=SYS;password=pwd; data source=127.0.0.1:1521/XE;Pooling=true;Min Pool Size=1",
"connectionString": "Data Source=|DataDirectory|\\admindb.db; Pooling=true;Min Pool Size=1",
// Specify assembly
//FreeSql.MySql.MySqlProvider`1,FreeSql.Provider.MySqlConnector
"providerType": "",
// Read-write separation slave list
"slaveList": [
//{
// Weight
// "Weight": 1,
// Connection string
// "ConnectionString": "Data Source=|DataDirectory|\\admindb.db; Pooling=true;Min Pool Size=1"
//}
]
},
{
// Log database
"key": "logdb",
// Assembly name, auto-fetch entity tables
"assemblyNames": [ "ZhonTai.Admin" ],
// Specify entity database list; leave empty to sync all database table entities
"includeEntityDbs": [ "Log" ],
// Exclude entity database list; specify database table entities not to sync
"excludeEntityDbs": [],
// Monitor all operations
"monitorCommand": false,
// Monitor CRUD operations
"curd": true,
// Monitor sync structure scripts
"syncStructureSql": false,
// Monitor sync data CRUD operations
"syncDataCurd": false,
// Create database
"createDb": true,
//SqlServer,PostgreSQL,Oracle,OdbcOracle,OdbcSqlServer,OdbcMySql,OdbcPostgreSQL,Odbc,OdbcDameng,MsAccess
// Create database connection string
//default_authentication_plugin = caching_sha2_password
//MySql "Server=localhost; Port=3306; Database=mysql; Uid=root; Pwd=pwd; Charset=utf8mb4;Min pool size=1;Allow User Variables=True"
//default_authentication_plugin = mysql_native_password
//MySql "Server=localhost; Port=3306; Database=mysql; Uid=root; Pwd=pwd; Charset=utf8mb4;SslMode=none;Min pool size=1;Allow User Variables=True"
//SqlServer "Data Source=.;User Id=sa;Password=pwd;Initial Catalog=master;TrustServerCertificate=true;Pooling=true;Min Pool Size=1"
//PostgreSQL "Host=localhost;Port=5432;Username=postgres;Password=; Database=postgres;Pooling=true;Minimum Pool Size=1"
//Oracle "user id=SYS;password=pwd; data source=127.0.0.1:1521/XE;Pooling=true;Min Pool Size=1"
"createDbConnectionString": "",
// Create database script; complex scripts can be placed in createdbsql.txt
//MySql "CREATE DATABASE `logdb` CHARACTER SET 'utf8mb4' COLLATE 'utf8mb4_general_ci'"
//SqlServer "CREATE DATABASE [logdb]"
//PostgreSQL "CREATE DATABASE \"logdb\" WITH ENCODING = 'UTF8'"
"createDbSql": "",
// Sync structure
"syncStructure": true,
// Sync structure batch entity count
"syncStructureEntityBatchSize": 1,
// Sync data batch size; default 500 per batch, too large may cause memory overflow
"syncDataBatchSize": 500,
// Sync data
"syncData": false,
// Sync update data; use with caution in production. To exclude tables, configure syncDataExcludeTables first
"syncUpdateData": false,
// Do not enable data generation during initialization. Before publishing to production, enable to update data package if needed. Remember to disable after use.
// Disable syncStructure, syncData, and createDb before enabling data generation
// Generate data
"generateData": false,
// Database configuration https://github.com/dotnetcore/FreeSql/wiki/getting-started
// Connection string syntax https://www.connectionstrings.com
// Database types MySql = 0, SqlServer = 1, PostgreSQL = 2, Oracle = 3, Sqlite = 4, OdbcOracle = 5, OdbcSqlServer = 6, OdbcMySql = 7, OdbcPostgreSQL = 8, Odbc = 9, OdbcDameng = 10, MsAccess = 11, Dameng = 12, OdbcKingbaseES = 13, ShenTong = 14, KingbaseES = 15, Firebird = 16
"type": "Sqlite",
// Connection string
//MySql "Server=localhost; Port=3306; Database=logdb; Uid=root; Pwd=pwd; Charset=utf8mb4;Min pool size=1;Allow User Variables=True"
//default_authentication_plugin = mysql_native_password
//MySql "Server=localhost; Port=3306; Database=logdb; Uid=root; Pwd=pwd; Charset=utf8mb4;SslMode=none;Min pool size=1;Allow User Variables=True"
//SqlServer "Data Source=.;Integrated Security=True;Initial Catalog=logdb;Pooling=true;Min Pool Size=1"
//PostgreSQL "Host=localhost;Port=5432;Username=postgres;Password=; Database=logdb;Pooling=true;Minimum Pool Size=1"
//Sqlite "Data Source=|DataDirectory|\\logdb.db; Pooling=true;Min Pool Size=1"
//"Oracle" "user id=SYS;password=pwd; data source=127.0.0.1:1521/XE;Pooling=true;Min Pool Size=1",
"connectionString": "Data Source=|DataDirectory|\\logdb.db; Pooling=true;Min Pool Size=1",
// Specify assembly
//FreeSql.MySql.MySqlProvider`1,FreeSql.Provider.MySqlConnector
"providerType": "",
// Read-write separation slave list
"slaveList": [
//{
// Weight
// "Weight": 1,
// Connection string
// "ConnectionString": "Data Source=|DataDirectory|\\admindb.db; Pooling=true;Min Pool Size=1"
//}
]
}
]
}
}appconfig.json Custom Application Configuration
appconfig.json
{
"AppConfig": {
// Application type: Controllers, ControllersWithViews, MVC
"appType": "Controllers",
// API URL
"urls": [ "http://*:18010" ],
// CORS URLs
"corUrls": [],
// Assembly names
"assemblyNames": [ "MyCompanyName.MySys.Api", "ZhonTai.Admin" ],
// Enum list assembly names
"EnumListAssemblyNames": [ "MyCompanyName.MySys.Api", "MyCompanyName.MySys.Api.Contracts" ],
// Tenant
"tenant": true,
// Distributed transaction unique identifier; leave empty to skip distributed transaction tables
"distributeKey": "",
// Validation
"validate": {
// Login
"login": true,
// Permission
"permission": true,
// Data permission
"dataPermission": true,
// API data permission
"apiDataPermission": true
},
// Swagger API documentation, access path /swagger
"swagger": {
// Enable
"enable": true,
// Enable enum schema filter
"enableEnumSchemaFilter": true,
// Enable ordered tags document filter
"enableOrderTagsDocumentFilter": true,
// Enable enum property names
"enableJsonStringEnumConverter": false,
// Enable SchemaId namespace
"enableSchemaIdNamespace": false,
// Assembly list for SchemaId namespace
"assemblyNameList": [],
// Route prefix, e.g. microservice doc URL: doc/module/swagger
"routePrefix": "doc/sys/swagger",
// Address
"url": "http://localhost:18010",
// Project list
"projects": [
{
"name": "MyCompanyName.MySys",
"code": "sys",
"version": "v10.0.1",
"description": "MyCompanyName.MySys"
}
,
{
"name": "ZhonTai Admin",
"code": "admin",
"version": "v10.0.1",
"description": "Permission Management"
}
]
},
// New API documentation display
"apiUI": {
// Enable
"enable": true,
// Route prefix, e.g. microservice doc URL: doc/module
"routePrefix": "doc/sys",
// Footer
"footer": {
"enable": false,
"content": "Copyright<a-icon type=\"copyright\" /> 2022-<a target=\"_blank\" href=\"https:www.zhontai.net\">ZhonTai Admin</a>"
}
},
// MiniProfiler performance analyzer
"miniProfiler": false,
// AOP (Aspect-Oriented Programming)
"aop": {
// Transaction
"transaction": true
},
// Log
"log": {
// Operation log
"operation": true,
// Log recording method: Grpc | Cap
"method": "Grpc"
},
// Rate limit
"rateLimit": false,
// Verification code
"varifyCode": {
// Enable
"enable": true,
// Font list
"fonts": [ "Times New Roman", "Verdana", "Arial", "Gungsuh", "Impact" ]
},
// Default password
"defaultPassword": "123asd",
// Dynamic API
"dynamicApi": {
// Result formatting
"formatResult": true
},
// Implement standard identity password hash
"passwordHasher": false,
// Kestrel server configuration
"Kestrel": {
// HTTP keep-alive max duration (seconds), 600 = 10 minutes
"KeepAliveTimeout": 600,
// Request header send max duration (seconds), 600 = 10 minutes
"RequestHeadersTimeout": 600,
// Max request body size (bytes); null = no limit; 104857600 = 100 MB
"maxRequestBodySize": 104857600
},
// Health check
"healthChecks": {
// Enable
"enable": true,
// Access path
"path": "/health"
},
// Preflight max age for CORS (seconds), default 30 minutes
"PreflightMaxAge": 1800,
// Enable task scheduler management UI
"TaskSchedulerUI": {
// Enable
"enable": true,
// Access path
"path": "/task"
},
// ID Generator
"IdGenerator": {
"DataCenterId": 0, // Data center ID (default 0), ensure globally unique
"WorkerId": 1, // Machine code, must be globally unique (or unique within same DataCenterId)
"WorkerIdBitLength": 6, // Machine code bit length, determines max WorkerId, default 6, range [1, 19]
"SeqBitLength": 6, // Sequence bit length, default 6, range [3, 21]. Default 6 is fine for <50K req/s; use 10+ for 50K-500K req/s
"CachePrefix": "zhontai:workerid" // Cache prefix
},
// IP address geolocation
"IP2Region": {
// Enable
"Enable": true,
// Absolute database path; defaults to website root /ip2region.xdb
"DbPath": ""
},
// Language configuration
"Lang": {
// Enable
"EnableJson": true,
// Default language
"DefaultLang": "zh-CN",
// Language list
"Langs": [ "zh-CN", "en" ],
// Request culture provider list
"RequestCultureProviders": [] //["QueryString","Cookie","AcceptLanguageHeader"]
}
}
}cacheconfig.json Cache Configuration
cacheconfig.json
{
"CacheConfig": {
// Cache type Memory = 0,Redis = 1
"type": "Memory",
// Rate limit cache type: Memory=0, Redis=1
"typeRateLimit": "Memory",
// Redis configuration
"redis": {
// Connection string
"connectionString": "127.0.0.1:6379,password=,defaultDatabase=0",
// Rate limit connection string
"connectionStringRateLimit": "127.0.0.1:6379,password=,defaultDatabase=0"
}
}
}jwtconfig.json JWT Configuration
jwtconfig.json
{
"JwtConfig": {
// Issuer
"issuer": "admin.core",
// Audience
"audience": "admin.core",
// Security key, custom
"securityKey": "73A74C69E2CF4522A7C69375CA0354D8",
// Expiration (minutes), 120 = 2 hours
"expires": 120,
// Refresh expiration (minutes), 1440 = 1 day
"refreshExpires": 1440
}
}ossconfig.json OSS File Upload Configuration
ossconfig.json
{
"OssConfig": {
// Local upload configuration
"LocalUploadConfig": {
// Upload directory
"Directory": "upload",
// Date directory
"DateTimeDirectory": "yyyy/MM/dd",
"Md5": false,
// Max file size
"MaxSize": 104857600,
// Include extension list
"IncludeExtension": [],
// Exclude extension list
"ExcludeExtension": [ ".exe", ".dll", ".jar" ]
},
// File storage provider
"Provider": "Minio",
// OSS configuration list
"OSSConfigs": [
//Minio
{
"Provider": "Minio",
"Endpoint": "127.0.0.1:9006",
"Region": "",
"AccessKey": "minio",
"SecretKey": "minio",
"IsEnableHttps": false,
"IsEnableCache": true,
"BucketName": "admin",
"Url": "", // File external link
"Md5": false,
"Enable": false
},
// Alibaba Cloud
{
"Provider": "Aliyun",
"Endpoint": "oss-cn-shenzhen.aliyuncs.com",
"Region": "",
"AccessKey": "",
"SecretKey": "",
"IsEnableHttps": true,
"IsEnableCache": true,
"BucketName": "admin",
"Url": "",
"Md5": false,
"Enable": false
},
// Tencent Cloud
{
"Provider": "QCloud",
"Endpoint": "", //AppId
"Region": "",
"AccessKey": "",
"SecretKey": "",
"IsEnableHttps": true,
"IsEnableCache": true,
"BucketName": "admin",
"Url": "",
"Md5": false,
"Enable": false
},
// Qiniu
{
"Provider": "Qiniu",
"Endpoint": "",
"Region": "",
"AccessKey": "",
"SecretKey": "",
"IsEnableHttps": true,
"IsEnableCache": true,
"BucketName": "admin",
"Url": "",
"Md5": false,
"Enable": false
},
// Huawei Cloud
{
"Provider": "HuaweiCloud",
"Endpoint": "",
"Region": "",
"AccessKey": "",
"SecretKey": "",
"IsEnableHttps": true,
"IsEnableCache": true,
"BucketName": "admin",
"Url": "",
"Md5": false,
"Enable": false
}
]
}
}ratelimitconfig.json Rate Limit Configuration
ratelimitconfig.json
{
/*
https://github.com/stefanprodan/AspNetCoreRateLimit/wiki/IpRateLimitMiddleware
https://github.com/stefanprodan/AspNetCoreRateLimit/wiki/Using-Redis-as-a-distributed-counter-store
*/
"RateLimitConfig": {
// Enable
"Enable": false,
// Rate limit method: Client=client rate limiting, Ip=IP rate limiting; default is client
"Method": "Client",
// Client ID type: Token, UserId, ClientIdHeader; default is Token
"ClientIdType": "Token",
// Cache prefix
"CachePrefix": "zhontai:ratelimit", // Cache prefix
// IP rate limiting configuration
"IpRateLimiting": {
"EnableEndpointRateLimiting": true,
"StackBlockedRequests": false,
"RealIpHeader": "X-Real-IP",
"IpWhitelist": [], // "127.0.0.1"
"EndpointWhitelist": [
"get:/api/admin/auth/refresh",
"*:/*.*GrpcService/*"
], // "get:/api/a", "*:/api/b"
"ClientWhitelist": [],
"HttpStatusCode": 429,
"QuotaExceededResponse": {
"Content": "{{\"code\":429,\"msg\":\"Too many requests!\",\"success\": false}}",
"ContentType": "application/json; charset=utf-8",
"StatusCode": 429
},
"GeneralRules": [
{
"Endpoint": "*:/api/*",
"Period": "1s",
"Limit": 3
},
{
"Endpoint": "*:/api/*",
"Period": "10m",
"Limit": 200
}
]
},
// Client rate limiting configuration
"ClientRateLimiting": {
"EnableEndpointRateLimiting": true,
"ClientIdHeader": "X-ClientId",
"IpWhitelist": [], // "127.0.0.1"
"EndpointWhitelist": [
"get:/api/admin/auth/refresh",
"*:/*.*GrpcService/*"
], // "get:/api/a", "*:/api/b"
"ClientWhitelist": [],
"HttpStatusCode": 429,
"QuotaExceededResponse": {
"Content": "{{\"code\":429,\"msg\":\"Too many requests!\",\"success\": false}}",
"ContentType": "application/json; charset=utf-8",
"StatusCode": 429
},
"GeneralRules": [
{
"Endpoint": "*:/api/*",
"Period": "1s",
"Limit": 3
},
{
"Endpoint": "*:/api/*",
"Period": "10m",
"Limit": 200
}
]
}
}
}imconfig.json IM Configuration
imconfig.json
{
"ImConfig": {
// Enable
"Enable": false,
// IM server cluster addresses
"Servers": [ "127.0.0.1:17010" ],
// WebSocket business endpoint address
"Server": "ws://127.0.0.1:17010",
// Redis connection string
"RedisConnectionString": "127.0.0.1:6379,password=,defaultDatabase=6"
}
}