From 643c09b016eb364edf361356f328d966eabaa233 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?ZR20090193-=E9=99=88=E6=95=AC=E5=8B=87?= Date: Tue, 23 Jan 2024 15:09:52 +0800 Subject: [PATCH] =?UTF-8?q?Saas=E6=9C=8D=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DS.Module.SqlSugar.csproj | 1 - .../DS.Module.SqlSugar/ISaasDbService.cs | 6 + .../DS.Module.SqlSugar/SaasDbService.cs | 24 ++- .../DS.Module.SqlSugar/SqlSugarSetup.cs | 173 ++++++++++++++++++ .../DS.Module.SqlSugar/SysTenantLink.cs | 30 +++ .../Controllers/TenantApplyController.cs | 4 +- .../DS.WMS.AdminApi/Logs/internal-nlog.txt | 98 ++++++++++ ds-wms-service/DS.WMS.AdminApi/Program.cs | 4 +- .../DS.WMS.Core/Code/Entity/CodeCountry.cs | 8 +- ds-wms-service/DS.WMS.Core/DS.WMS.Core.csproj | 1 + .../System/Dtos/TenantApplyAuditReq.cs | 60 ++++++ .../System/Interface/ITenantApplyService.cs | 11 +- .../System/Method/CommonService.cs | 39 ++-- .../System/Method/TenantApplyService.cs | 90 +++++++-- .../DS.WMS.MainApi/Logs/internal-nlog.txt | 98 ++++++++++ ds-wms-service/DS.WMS.MainApi/Program.cs | 3 +- 16 files changed, 601 insertions(+), 49 deletions(-) create mode 100644 ds-wms-service/DS.Module.SqlSugar/SqlSugarSetup.cs create mode 100644 ds-wms-service/DS.Module.SqlSugar/SysTenantLink.cs create mode 100644 ds-wms-service/DS.WMS.Core/System/Dtos/TenantApplyAuditReq.cs diff --git a/ds-wms-service/DS.Module.SqlSugar/DS.Module.SqlSugar.csproj b/ds-wms-service/DS.Module.SqlSugar/DS.Module.SqlSugar.csproj index db1d64ec..ed66cbc1 100644 --- a/ds-wms-service/DS.Module.SqlSugar/DS.Module.SqlSugar.csproj +++ b/ds-wms-service/DS.Module.SqlSugar/DS.Module.SqlSugar.csproj @@ -11,7 +11,6 @@ - diff --git a/ds-wms-service/DS.Module.SqlSugar/ISaasDbService.cs b/ds-wms-service/DS.Module.SqlSugar/ISaasDbService.cs index 4b8b92e0..87786df0 100644 --- a/ds-wms-service/DS.Module.SqlSugar/ISaasDbService.cs +++ b/ds-wms-service/DS.Module.SqlSugar/ISaasDbService.cs @@ -16,4 +16,10 @@ public interface ISaasDbService /// /// public ISqlSugarClient GetMasterDb(); + + /// + /// 主库根据Id获取业务库 + /// + /// + public ISqlSugarClient GetBizDbById(string configId); } \ No newline at end of file diff --git a/ds-wms-service/DS.Module.SqlSugar/SaasDbService.cs b/ds-wms-service/DS.Module.SqlSugar/SaasDbService.cs index e3042a39..8368793c 100644 --- a/ds-wms-service/DS.Module.SqlSugar/SaasDbService.cs +++ b/ds-wms-service/DS.Module.SqlSugar/SaasDbService.cs @@ -1,7 +1,4 @@ -using DS.Module.Core; -using DS.Module.Core.Extensions; using DS.Module.UserModule; -using DS.WMS.Core.System.Entity; using Microsoft.Extensions.DependencyInjection; using SqlSugar; using NLog; @@ -60,4 +57,25 @@ public class SaasDbService:ISaasDbService { return db.GetConnection("1288018625843826688"); } + + /// + /// 主库根据Id获取业务库 + /// + /// + public ISqlSugarClient GetBizDbById(string configId) + { + if(!db.IsAnyConnection(configId)) + { + var connInfo = GetMasterDb().Queryable().First(x => x.TenantId == long.Parse(configId)); + //用非默认ConfigId进行测试 + //添加业务库只在当前上下文有效(原理:SqlSugarScope模式入门文档去看) + db.AddConnection(new ConnectionConfig() { + ConfigId = configId, + ConnectionString = connInfo.Connection, + DbType = connInfo.DbType, + IsAutoCloseConnection = true }); + } + + return db.GetConnection(configId); + } } \ No newline at end of file diff --git a/ds-wms-service/DS.Module.SqlSugar/SqlSugarSetup.cs b/ds-wms-service/DS.Module.SqlSugar/SqlSugarSetup.cs new file mode 100644 index 00000000..dfb91138 --- /dev/null +++ b/ds-wms-service/DS.Module.SqlSugar/SqlSugarSetup.cs @@ -0,0 +1,173 @@ +using DS.Module.Core; +using DS.Module.Core.Data; +using DS.Module.Core.Extensions; +using DS.Module.UserModule; +using Microsoft.Extensions.DependencyInjection; +using NLog; +using SqlSugar; + +namespace DS.Module.SqlSugar; + +/// +/// SqlSugar 启动服务 +/// +public static class SqlSugarSetup +{ + // /// + // /// 数据库连接字符串 + // /// + // private static string DbInfo = AppSetting.Configuration["ConnectionStrings:DbInfo"]; + // + // /// + // /// 数据库类型 + // /// + // private static string DbType = AppSetting.Configuration["ConnectionStrings:DbType"]; + + public static readonly Logger Logger = LogManager.GetCurrentClassLogger(); + // private readonly IUser user; + + // private ILogger _logger; + /// + /// 将模块服务添加到依赖注入服务容器中 + /// + /// 依赖注入服务容器 + /// + public static IServiceCollection AddSqlSugarSetup(this IServiceCollection services) + { + if (services == null) throw new ArgumentNullException(nameof(services)); + Console.WriteLine("开始加载sqlsugar模块"); + Console.WriteLine("数据库配置id:" + AppSetting.app(new string[] { "DBInfo", "DefaultDbConnId" })); + + var dbs = AppSetting.app("DBInfo", "DBS"); + //默认数据库 + List dbList = new List(); + DbConfig defaultdb = new DbConfig() + { + ConnId = AppSetting.app(new string[] { "DBInfo", "DefaultDbConnId" }), + Connection = AppSetting.app(new string[] { "DBInfo", "DefaultDbString" }), + DbType = AppSetting.app(new string[] { "DBInfo", "DefaultDbType" }).ObjToInt() + }; + dbList.Add(defaultdb); + //业务数据库集合 + foreach (var item in dbs) + { + dbList.Add(item); + } + + var connectConfigList = SqlsugarHelper.ReturnConnectionConfig(dbList); + + foreach (var item in dbList) + { + //防止数据库重复,导致的事务异常 + if (connectConfigList.Any(a => a.ConfigId == (dynamic)item.ConnId || a.ConnectionString == item.Connection)) + { + continue; + } + + connectConfigList.Add(new ConnectionConfig() + { + ConnectionString = item.Connection, + DbType = (DbType)item.DbType, + IsAutoCloseConnection = true, + ConfigId = item.ConnId, + InitKeyType = InitKeyType.Attribute, + MoreSettings = new ConnMoreSettings() + { + IsAutoRemoveDataCache = true //自动清理缓存 + }, + // 自定义特性 + ConfigureExternalServices = new ConfigureExternalServices() + { + } + }); + } + var user = services.GetService(); + //全局上下文生效 + SqlSugarScope sqlSugar = new SqlSugarScope(connectConfigList, + db => + { + // 封装AOP + // SqlsugarAopHelper.AopForSqlsugar(db, user, dbList, connectConfigList); + ///* + // * 默认只会配置到第一个数据库,这里按照官方文档进行多数据库/多租户文档的说明进行循环配置 + // */ + foreach (var c in connectConfigList) + { + var dbProvider = db.GetConnectionScope((string)c.ConfigId); + //单例参数配置,所有上下文生效 + dbProvider.Ado.CommandTimeOut = 30; + dbProvider.Aop.OnLogExecuting = (sql, pars) => + { + Logger.Log(LogLevel.Info, + DateTime.Now.ToString() + "\r\n" + + UtilMethods.GetSqlString(c.DbType, sql, pars)); + }; + dbProvider.Aop.DataExecuting = (oldValue, entityInfo) => + { + if (entityInfo.OperationType == DataFilterType.InsertByObject) + { + if (entityInfo.PropertyName == "Id") + { + if (entityInfo.EntityColumnInfo.PropertyInfo.PropertyType == typeof(string)) + { + entityInfo.SetValue(GuidHelper.GetSnowflakeId()); + } + + if (entityInfo.EntityColumnInfo.PropertyInfo.PropertyType == typeof(long)) + { + entityInfo.SetValue(SnowFlakeSingle.Instance.NextId()); + } + } + + if (entityInfo.PropertyName == "CreateTime") + entityInfo.SetValue(DateTime.Now); + if (!user.UserId.IsNullOrEmpty()) + { + if (entityInfo.PropertyName == "TenantId") + entityInfo.SetValue(user.GetTenantId()); + } + + if (entityInfo.PropertyName == "CreateBy") + { + if (!user.UserId.IsNullOrEmpty()) + { + entityInfo.SetValue(user.UserId); + } + else + { + entityInfo.SetValue(1288018625843826688); + } + } + + if (entityInfo.PropertyName == "Deleted") + entityInfo.SetValue(false); + } + + if (entityInfo.OperationType == DataFilterType.UpdateByObject) + { + if (entityInfo.PropertyName == "UpdateTime") + entityInfo.SetValue(DateTime.Now); + if (entityInfo.PropertyName == "UpdateBy" && user != null) + entityInfo.SetValue(user.UserId); + } + }; + dbProvider.Aop.OnError = (exp) => //执行SQL 错误事件 + { + Logger.Error(DateTime.Now.ToString() + "\r\n" + exp.Sql + "\r\n" + exp.Parametres); + }; + + // var tenantId = user.GetTenantId(); + //全局过滤租户 + dbProvider.QueryFilter.AddTableFilter(m => m.TenantId ==long.Parse(user.TenantId)); + //全局过滤机构Id + dbProvider.QueryFilter.AddTableFilter(m => m.OrgId == user.GetOrgId()); + //全局软删除过滤 + dbProvider.QueryFilter.AddTableFilter(m => m.Deleted == false); + } + }); + + services.AddSingleton(sqlSugar); //这边是SqlSugarScope用AddSingleton + + return services; + } +} \ No newline at end of file diff --git a/ds-wms-service/DS.Module.SqlSugar/SysTenantLink.cs b/ds-wms-service/DS.Module.SqlSugar/SysTenantLink.cs new file mode 100644 index 00000000..83521870 --- /dev/null +++ b/ds-wms-service/DS.Module.SqlSugar/SysTenantLink.cs @@ -0,0 +1,30 @@ +using SqlSugar; + +namespace DS.Module.SqlSugar; + +/// +/// 租户数据库链接 +/// +[global::SqlSugar.SugarTable("sys_tenant_dblink")] +public class SysTenantLink +{ + /// + /// ID + /// + [SugarColumn(IsPrimaryKey = true, IsIdentity = true)] + public int Id { get; set; } + + /// + /// 租户id + /// + public long TenantId { get; set; } + /// + /// 数据库类型 + /// + [SugarColumn(ColumnDescription = "数据库类型")] + public global::SqlSugar.DbType DbType { get; set; } = global::SqlSugar.DbType.MySql; + /// + /// 数据库链接字符串 + /// + public string Connection { get; set; } +} \ No newline at end of file diff --git a/ds-wms-service/DS.WMS.AdminApi/Controllers/TenantApplyController.cs b/ds-wms-service/DS.WMS.AdminApi/Controllers/TenantApplyController.cs index 08fb717e..6ada8fbe 100644 --- a/ds-wms-service/DS.WMS.AdminApi/Controllers/TenantApplyController.cs +++ b/ds-wms-service/DS.WMS.AdminApi/Controllers/TenantApplyController.cs @@ -53,10 +53,10 @@ public class TenantApplyController : ApiController /// /// [HttpPost] - [Route("AuditTenantApply")] + [Route("RejectTenantApply")] public DataResult AuditTenantApply([FromBody] CommonAuditInput model) { - var res = _invokeService.AuditTenantApply(model); + var res = _invokeService.RejectTenantApply(model); return res; } diff --git a/ds-wms-service/DS.WMS.AdminApi/Logs/internal-nlog.txt b/ds-wms-service/DS.WMS.AdminApi/Logs/internal-nlog.txt index 9e1e21db..cd80b986 100644 --- a/ds-wms-service/DS.WMS.AdminApi/Logs/internal-nlog.txt +++ b/ds-wms-service/DS.WMS.AdminApi/Logs/internal-nlog.txt @@ -75,3 +75,101 @@ 2024-01-18 17:07:17.6104 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.AdminApi\bin\Debug\net8.0\nlog.config 2024-01-18 17:07:17.6293 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile 2024-01-18 17:07:17.6734 Info Configuration initialized. +2024-01-22 14:38:52.8091 Info Registered target NLog.Targets.FileTarget(Name=allfile) +2024-01-22 14:38:52.8589 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web) +2024-01-22 14:38:52.8973 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console) +2024-01-22 14:38:52.9534 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False +2024-01-22 14:38:53.0071 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.AdminApi\bin\Debug\net8.0\nlog.config +2024-01-22 14:38:53.0277 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile +2024-01-22 14:38:53.0749 Info Configuration initialized. +2024-01-22 14:59:07.8924 Info Registered target NLog.Targets.FileTarget(Name=allfile) +2024-01-22 14:59:07.9956 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web) +2024-01-22 14:59:08.0176 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console) +2024-01-22 14:59:08.0674 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False +2024-01-22 14:59:08.1070 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.AdminApi\bin\Debug\net8.0\nlog.config +2024-01-22 14:59:08.1251 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile +2024-01-22 14:59:08.1577 Info Configuration initialized. +2024-01-22 15:29:02.4814 Info Registered target NLog.Targets.FileTarget(Name=allfile) +2024-01-22 15:29:02.5203 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web) +2024-01-22 15:29:02.5437 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console) +2024-01-22 15:29:02.5710 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False +2024-01-22 15:29:02.5996 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.AdminApi\bin\Debug\net8.0\nlog.config +2024-01-22 15:29:02.5996 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile +2024-01-22 15:29:02.6366 Info Configuration initialized. +2024-01-22 15:52:51.1603 Info Registered target NLog.Targets.FileTarget(Name=allfile) +2024-01-22 15:52:51.1888 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web) +2024-01-22 15:52:51.2173 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console) +2024-01-22 15:52:51.2668 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False +2024-01-22 15:52:51.3120 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.AdminApi\bin\Debug\net8.0\nlog.config +2024-01-22 15:52:51.3349 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile +2024-01-22 15:52:51.3947 Info Configuration initialized. +2024-01-22 15:56:06.0488 Info Registered target NLog.Targets.FileTarget(Name=allfile) +2024-01-22 15:56:06.1718 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web) +2024-01-22 15:56:06.2141 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console) +2024-01-22 15:56:06.3018 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False +2024-01-22 15:56:06.3672 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.AdminApi\bin\Debug\net8.0\nlog.config +2024-01-22 15:56:06.3909 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile +2024-01-22 15:56:06.4373 Info Configuration initialized. +2024-01-22 15:58:13.8365 Info Registered target NLog.Targets.FileTarget(Name=allfile) +2024-01-22 15:58:13.9157 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web) +2024-01-22 15:58:13.9290 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console) +2024-01-22 15:58:13.9556 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False +2024-01-22 15:58:13.9749 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.AdminApi\bin\Debug\net8.0\nlog.config +2024-01-22 15:58:13.9749 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile +2024-01-22 15:58:14.0035 Info Configuration initialized. +2024-01-22 16:01:26.1904 Info Registered target NLog.Targets.FileTarget(Name=allfile) +2024-01-22 16:01:26.2958 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web) +2024-01-22 16:01:26.3156 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console) +2024-01-22 16:01:26.3762 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False +2024-01-22 16:01:26.4229 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.AdminApi\bin\Debug\net8.0\nlog.config +2024-01-22 16:01:26.4515 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile +2024-01-22 16:01:26.4898 Info Configuration initialized. +2024-01-22 17:30:08.6155 Info Registered target NLog.Targets.FileTarget(Name=allfile) +2024-01-22 17:30:08.6359 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web) +2024-01-22 17:30:08.6546 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console) +2024-01-22 17:30:08.6732 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False +2024-01-22 17:30:08.6964 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.AdminApi\bin\Debug\net8.0\nlog.config +2024-01-22 17:30:08.7108 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile +2024-01-22 17:30:08.7447 Info Configuration initialized. +2024-01-22 17:33:29.3882 Info Registered target NLog.Targets.FileTarget(Name=allfile) +2024-01-22 17:33:29.4266 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web) +2024-01-22 17:33:29.4588 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console) +2024-01-22 17:33:29.5174 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False +2024-01-22 17:33:29.5750 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.AdminApi\bin\Debug\net8.0\nlog.config +2024-01-22 17:33:29.5977 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile +2024-01-22 17:33:29.6287 Info Configuration initialized. +2024-01-22 17:45:44.0418 Info Registered target NLog.Targets.FileTarget(Name=allfile) +2024-01-22 17:45:44.1647 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web) +2024-01-22 17:45:44.1940 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console) +2024-01-22 17:45:44.2352 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False +2024-01-22 17:45:44.2693 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.AdminApi\bin\Debug\net8.0\nlog.config +2024-01-22 17:45:44.2889 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile +2024-01-22 17:45:44.3228 Info Configuration initialized. +2024-01-22 17:50:03.3190 Info Registered target NLog.Targets.FileTarget(Name=allfile) +2024-01-22 17:50:03.4275 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web) +2024-01-22 17:50:03.4584 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console) +2024-01-22 17:50:03.5223 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False +2024-01-22 17:50:03.5595 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.AdminApi\bin\Debug\net8.0\nlog.config +2024-01-22 17:50:03.5764 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile +2024-01-22 17:50:03.6170 Info Configuration initialized. +2024-01-22 17:57:46.6775 Info Registered target NLog.Targets.FileTarget(Name=allfile) +2024-01-22 17:57:46.7001 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web) +2024-01-22 17:57:46.7125 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console) +2024-01-22 17:57:46.7274 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False +2024-01-22 17:57:46.7432 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.AdminApi\bin\Debug\net8.0\nlog.config +2024-01-22 17:57:46.7432 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile +2024-01-22 17:57:46.7677 Info Configuration initialized. +2024-01-22 18:00:11.0252 Info Registered target NLog.Targets.FileTarget(Name=allfile) +2024-01-22 18:00:11.0766 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web) +2024-01-22 18:00:11.1221 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console) +2024-01-22 18:00:11.1815 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False +2024-01-22 18:00:11.2302 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.AdminApi\bin\Debug\net8.0\nlog.config +2024-01-22 18:00:11.2558 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile +2024-01-22 18:00:11.3142 Info Configuration initialized. +2024-01-23 09:24:14.0758 Info Registered target NLog.Targets.FileTarget(Name=allfile) +2024-01-23 09:24:14.1128 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web) +2024-01-23 09:24:14.1407 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console) +2024-01-23 09:24:14.1732 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False +2024-01-23 09:24:14.2152 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.AdminApi\bin\Debug\net8.0\nlog.config +2024-01-23 09:24:14.2321 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile +2024-01-23 09:24:14.2606 Info Configuration initialized. diff --git a/ds-wms-service/DS.WMS.AdminApi/Program.cs b/ds-wms-service/DS.WMS.AdminApi/Program.cs index 41f05cb8..8196fb73 100644 --- a/ds-wms-service/DS.WMS.AdminApi/Program.cs +++ b/ds-wms-service/DS.WMS.AdminApi/Program.cs @@ -27,11 +27,11 @@ builder.Host builder.Services.AddAppWebInstal(); builder.Services.AddCorsInstall(); +builder.Services.AddUserModuleInstall(); //用户服务 builder.Services.AddSqlsugarInstall(); builder.Services.AddSwaggerInstall(); -builder.Services.AddUserModuleInstall(); //用户服务 builder.Services.AddJwtInstall(); - +builder.Services.AddSaasDbInstall();//分库服务 var app = builder.Build(); diff --git a/ds-wms-service/DS.WMS.Core/Code/Entity/CodeCountry.cs b/ds-wms-service/DS.WMS.Core/Code/Entity/CodeCountry.cs index 2066e21b..8d817d7e 100644 --- a/ds-wms-service/DS.WMS.Core/Code/Entity/CodeCountry.cs +++ b/ds-wms-service/DS.WMS.Core/Code/Entity/CodeCountry.cs @@ -35,7 +35,7 @@ public class CodeCountry: BaseModel public string Capital { get; set; } /// - /// 关税 + /// 关税等级 /// public int Tariff { get; set; } /// @@ -44,12 +44,12 @@ public class CodeCountry: BaseModel public int TonnageTax { get; set; } /// - /// 国家代码2 + /// 国家3字代码 /// - public string CountryCode2 { get; set; } + public string CountryCode3 { get; set; } /// - /// 解释说明 + /// 国家描述 /// public string Explain { get; set; } diff --git a/ds-wms-service/DS.WMS.Core/DS.WMS.Core.csproj b/ds-wms-service/DS.WMS.Core/DS.WMS.Core.csproj index bc172061..ea7b5066 100644 --- a/ds-wms-service/DS.WMS.Core/DS.WMS.Core.csproj +++ b/ds-wms-service/DS.WMS.Core/DS.WMS.Core.csproj @@ -32,6 +32,7 @@ + diff --git a/ds-wms-service/DS.WMS.Core/System/Dtos/TenantApplyAuditReq.cs b/ds-wms-service/DS.WMS.Core/System/Dtos/TenantApplyAuditReq.cs new file mode 100644 index 00000000..c090532b --- /dev/null +++ b/ds-wms-service/DS.WMS.Core/System/Dtos/TenantApplyAuditReq.cs @@ -0,0 +1,60 @@ +using DS.Module.Core.Data; + +namespace DS.WMS.Core.System.Dtos; + +/// +/// 企业用户注册审核 +/// +public class TenantApplyAuditReq +{ + /// + /// 审核信息 + /// + public CommonAuditInput AuditInfo { get; set; } + /// + /// 授权用户数 + /// + public int AuthUserNum { get; set; } + /// + /// 授权Ids + /// + public List PermissionIds { get; set; } + + /// + /// 模块授权列表 + /// + public List PermissionAuthList { get; set; } + /// + /// 数据库信息 + /// + public DbInfo DbInfo { get; set; } +} +/// +/// 模块授权 +/// +public class PermissionAuth +{ + /// + /// 模块Id + /// + public long PermissionId { get; set; } + + /// + /// 授权数 + /// + public int AuthNum { get; set; } +} +/// +/// 数据库链接信息 +/// +public class DbInfo +{ + /// + /// 数据库类型 + /// + public SqlSugar.DbType DbType { get; set; } = SqlSugar.DbType.MySql; + /// + /// 数据库链接字符串 + /// + public string Connection { get; set; } +} \ No newline at end of file diff --git a/ds-wms-service/DS.WMS.Core/System/Interface/ITenantApplyService.cs b/ds-wms-service/DS.WMS.Core/System/Interface/ITenantApplyService.cs index ce5818b8..6a1ec453 100644 --- a/ds-wms-service/DS.WMS.Core/System/Interface/ITenantApplyService.cs +++ b/ds-wms-service/DS.WMS.Core/System/Interface/ITenantApplyService.cs @@ -41,9 +41,16 @@ public interface ITenantApplyService public DataResult GetTenantAuditInfo(string id); /// - /// 企业用户审批 + /// 企业用户审批 驳回 /// /// /// - public DataResult AuditTenantApply(CommonAuditInput req); + public DataResult RejectTenantApply(CommonAuditInput req); + + /// + /// 企业用户审批 - 通过 + /// + /// + /// + Task TenantApplyAudit(TenantApplyAuditReq req); } \ No newline at end of file diff --git a/ds-wms-service/DS.WMS.Core/System/Method/CommonService.cs b/ds-wms-service/DS.WMS.Core/System/Method/CommonService.cs index 9d19fc3d..eef46669 100644 --- a/ds-wms-service/DS.WMS.Core/System/Method/CommonService.cs +++ b/ds-wms-service/DS.WMS.Core/System/Method/CommonService.cs @@ -10,9 +10,8 @@ using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection; using SqlSugar; using System.Diagnostics; -using System.IdentityModel.Tokens.Jwt; -using System.Net; using System.Runtime.InteropServices; +using DS.Module.SqlSugar; using Mapster; using Microsoft.IdentityModel.Tokens; using Newtonsoft.Json; @@ -27,6 +26,7 @@ public class CommonService : ICommonService private readonly IServiceProvider _serviceProvider; private readonly ISqlSugarClient db; private readonly IUser user; + private readonly ISaasDbService saasService; private readonly IHttpContextAccessor IhttpContext; private readonly IWebHostEnvironment _environment; @@ -39,6 +39,7 @@ public class CommonService : ICommonService _serviceProvider = serviceProvider; db = _serviceProvider.GetRequiredService(); user = _serviceProvider.GetRequiredService(); + saasService = _serviceProvider.GetRequiredService(); IhttpContext = _serviceProvider.GetRequiredService(); _environment = _serviceProvider.GetRequiredService(); } @@ -345,16 +346,16 @@ public class CommonService : ICommonService { return DataResult.Failed("密码错误!"); } - //取第一个机构 - var orgRelation = db.Queryable() - .First(x => x.UserId == userInfo.Id); + // //取第一个机构 + // var orgRelation = db.Queryable() + // .First(x => x.UserId == userInfo.Id); var tokenModel = new JwtHelper.JwtTokenModel { Uid = userInfo.Id.ToString(), - OrgId = orgRelation.OrgId.ToString(), + // OrgId = orgRelation.OrgId.ToString(), TenantId = userInfo.TenantId.ToString(), }; - var token = JwtHelper.Encrypt(tokenModel,false,true); + var token = JwtHelper.Encrypt(tokenModel,false,false); return DataResult.Success(token); } @@ -367,19 +368,19 @@ public class CommonService : ICommonService { var userId = long.Parse(user.UserId); var tenantId = user.GetTenantId(); - //取第一个机构 - var orgRelations = db.Queryable() - .LeftJoin((a,b)=>a.OrgId==b.Id) - .Where(a => a.UserId == userId) - .Select() - .ToList(); + // //取第一个机构 + // var orgRelations = db.Queryable() + // .LeftJoin((a,b)=>a.OrgId==b.Id) + // .Where(a => a.UserId == userId) + // .Select() + // .ToList(); var tokenModel = new JwtHelper.JwtTokenModel { Uid = user.UserId, - OrgId = user.GetOrgId().ToString(), + // OrgId = user.GetOrgId().ToString(), TenantId = tenantId.ToString(), }; - var refreshToken = JwtHelper.Encrypt(tokenModel,true,true); + var refreshToken = JwtHelper.Encrypt(tokenModel,true,false); var data = db.Queryable().Filter(null, true).Where(x => x.Id == userId) .Select(a => new CurrentUserViewModel @@ -393,7 +394,7 @@ public class CommonService : ICommonService ClientId = a.ClientId, IsLimitClient = a.IsLimitClient, RefreshToken = refreshToken, - UserOrgs = orgRelations, + // UserOrgs = orgRelations, // OrgId = a.OrgId.ToString(), CompanyName = a.CustomerName }) .Mapper(it => @@ -456,12 +457,12 @@ public class CommonService : ICommonService //超级管理员 if (userInfo.UserType == 0) { - list = db.Queryable().Where(x => + list = db.Queryable().Where(x => x.MenuType == 1 && x.IsHidden == false && (x.PermissionType == 1 || x.PermissionType == 0)) .OrderBy(x => x.SortCode) .Select(a => new RouteItem { - Id = a.PermissionId, + Id = a.Id, Path = a.Url, Name = a.PermissionName, Component = a.Component, @@ -476,7 +477,7 @@ public class CommonService : ICommonService foreach (var item in list) { - var childs = db.Queryable().Filter(null, true) + var childs = db.Queryable().Filter(null, true) .Where(x => x.MenuType == 2 && x.ParentId == item.Id && x.IsHidden == false && (x.PermissionType == 1 || x.PermissionType == 0)) .OrderBy(x => x.SortCode) diff --git a/ds-wms-service/DS.WMS.Core/System/Method/TenantApplyService.cs b/ds-wms-service/DS.WMS.Core/System/Method/TenantApplyService.cs index 25bbe7c1..4d0feb0e 100644 --- a/ds-wms-service/DS.WMS.Core/System/Method/TenantApplyService.cs +++ b/ds-wms-service/DS.WMS.Core/System/Method/TenantApplyService.cs @@ -1,6 +1,7 @@ using DS.Module.Core; using DS.Module.Core.Data; using DS.Module.Core.Extensions; +using DS.Module.SqlSugar; using DS.Module.UserModule; using DS.WMS.Core.System.Dtos; using DS.WMS.Core.System.Entity; @@ -9,6 +10,7 @@ using Mapster; using Masuit.Tools.Systems; using Microsoft.Extensions.DependencyInjection; using SqlSugar; +using SysTenantLink = DS.Module.SqlSugar.SysTenantLink; namespace DS.WMS.Core.System.Method; @@ -17,7 +19,7 @@ public class TenantApplyService : ITenantApplyService private readonly IServiceProvider _serviceProvider; private readonly ISqlSugarClient db; private readonly IUser user; - + private readonly ISaasDbService saasService; /// /// /// @@ -26,6 +28,7 @@ public class TenantApplyService : ITenantApplyService { _serviceProvider = serviceProvider; db = _serviceProvider.GetRequiredService(); + saasService = _serviceProvider.GetRequiredService(); user = _serviceProvider.GetRequiredService(); } @@ -61,11 +64,11 @@ public class TenantApplyService : ITenantApplyService return DataResult.Success(data); } /// - /// 企业用户审批 + /// 企业用户审批 - 驳回 /// /// /// - public DataResult AuditTenantApply(CommonAuditInput req) + public DataResult RejectTenantApply(CommonAuditInput req) { var userId = user.UserId; @@ -82,42 +85,99 @@ public class TenantApplyService : ITenantApplyService } if (req.Status == 1) + { + return DataResult.Failed("非法状态!"); + } + else + { + apply.AuditStatus = (AuditStatusEnum)(int)req.Status; + apply.AuditNote = req.AuditNote; + db.Updateable(req).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand(); + return DataResult.Successed("驳回成功!"); + } + + } + /// + /// 企业用户审批 - 通过 + /// + /// + /// + public async Task TenantApplyAudit(TenantApplyAuditReq req) + { + var userId = user.UserId; + + + var apply = db.Queryable().Where(x => x.Id == req.AuditInfo.Id).First(); + + if (apply.IsNull()) + { + return DataResult.Failed("企业用户信息不存在!"); + } + + if (apply.AuditStatus == AuditStatusEnum.Approve) + { + return DataResult.Failed("已审批通过!"); + } + if (req.PermissionIds.Count==0 ) + { + return DataResult.Failed("请勾选权限模块!"); + } + + if (req.AuditInfo.Status == 1) { try { //开启事务 - db.Ado.BeginTran(); - apply.AuditStatus = (AuditStatusEnum)(int)req.Status; - apply.AuditNote = req.AuditNote; - db.Updateable(apply).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand(); - + await db.Ado.BeginTranAsync(); + apply.AuditStatus = (AuditStatusEnum)(int)req.AuditInfo.Status; + apply.AuditNote = req.AuditInfo.AuditNote; + await db.Updateable(apply).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync(); + + + var entity = apply.Adapt(); + var tenant = db.Insertable(entity).ExecuteReturnEntityAsync(); + + var link = req.DbInfo.Adapt(); + link.TenantId = tenant.Id; + await db.Insertable(link).ExecuteReturnEntityAsync(); + + var permissions = db.Queryable().Where(x => req.PermissionIds.Contains(x.Id)).ToList(); + + var tenantPerList = new List(); + foreach (var item in permissions) + { + var tenantPer = item.Adapt(); + tenantPer.PermissionId = item.Id; + + tenantPerList.Add(tenantPer); + } + await db.Insertable(tenantPerList).ExecuteReturnEntityAsync(); //TODO 处理租户相关数据 + + + // var client = company.Adapt();; // client.CODENAME = PinYinUtil.GetFristLetter(company.SHORTNAME); // client.GID = clientId.ToString(); // client.STATUS = 0; // db.Insertable(client).ExecuteCommand(); - db.Ado.CommitTran(); + await db.Ado.CommitTranAsync(); return DataResult.Successed("审批成功!"); } catch (Exception ex) { - db.Ado.RollbackTran(); + await db.Ado.RollbackTranAsync(); return DataResult.Failed("审批失败!" + ",请联系管理员!"); } } else { - apply.AuditStatus = (AuditStatusEnum)(int)req.Status; - apply.AuditNote = req.AuditNote; - db.Updateable(req).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand(); - return DataResult.Successed("驳回成功!"); + return DataResult.Failed("非法状态!"); } } - #endregion diff --git a/ds-wms-service/DS.WMS.MainApi/Logs/internal-nlog.txt b/ds-wms-service/DS.WMS.MainApi/Logs/internal-nlog.txt index 18002578..865d5aec 100644 --- a/ds-wms-service/DS.WMS.MainApi/Logs/internal-nlog.txt +++ b/ds-wms-service/DS.WMS.MainApi/Logs/internal-nlog.txt @@ -966,3 +966,101 @@ 2024-01-18 14:48:33.0934 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.MainApi\bin\Debug\net8.0\nlog.config 2024-01-18 14:48:33.1122 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile 2024-01-18 14:48:33.1658 Info Configuration initialized. +2024-01-22 15:18:57.1479 Info Registered target NLog.Targets.FileTarget(Name=allfile) +2024-01-22 15:18:57.1686 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web) +2024-01-22 15:18:57.1844 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console) +2024-01-22 15:18:57.2066 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False +2024-01-22 15:18:57.2354 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.MainApi\bin\Debug\net8.0\nlog.config +2024-01-22 15:18:57.2480 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile +2024-01-22 15:18:57.2769 Info Configuration initialized. +2024-01-22 16:11:53.9861 Info Registered target NLog.Targets.FileTarget(Name=allfile) +2024-01-22 16:11:54.0302 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web) +2024-01-22 16:11:54.0712 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console) +2024-01-22 16:11:54.1114 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False +2024-01-22 16:11:54.1588 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.MainApi\bin\Debug\net8.0\nlog.config +2024-01-22 16:11:54.1834 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile +2024-01-22 16:11:54.2363 Info Configuration initialized. +2024-01-22 16:17:28.5416 Info Registered target NLog.Targets.FileTarget(Name=allfile) +2024-01-22 16:17:28.7349 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web) +2024-01-22 16:17:28.7731 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console) +2024-01-22 16:17:28.8478 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False +2024-01-22 16:17:28.8949 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.MainApi\bin\Debug\net8.0\nlog.config +2024-01-22 16:17:28.9140 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile +2024-01-22 16:17:28.9622 Info Configuration initialized. +2024-01-22 16:19:31.3193 Info Registered target NLog.Targets.FileTarget(Name=allfile) +2024-01-22 16:19:31.4294 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web) +2024-01-22 16:19:31.4543 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console) +2024-01-22 16:19:31.5105 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False +2024-01-22 16:19:31.5425 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.MainApi\bin\Debug\net8.0\nlog.config +2024-01-22 16:19:31.5582 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile +2024-01-22 16:19:31.6040 Info Configuration initialized. +2024-01-22 16:22:11.3077 Info Registered target NLog.Targets.FileTarget(Name=allfile) +2024-01-22 16:22:11.3525 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web) +2024-01-22 16:22:11.4058 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console) +2024-01-22 16:22:11.4603 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False +2024-01-22 16:22:11.5181 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.MainApi\bin\Debug\net8.0\nlog.config +2024-01-22 16:22:11.5392 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile +2024-01-22 16:22:11.5904 Info Configuration initialized. +2024-01-22 16:23:57.5375 Info Registered target NLog.Targets.FileTarget(Name=allfile) +2024-01-22 16:23:57.6010 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web) +2024-01-22 16:23:57.6645 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console) +2024-01-22 16:23:57.7428 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False +2024-01-22 16:23:57.8082 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.MainApi\bin\Debug\net8.0\nlog.config +2024-01-22 16:23:57.8326 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile +2024-01-22 16:23:57.9674 Info Configuration initialized. +2024-01-22 16:25:22.1126 Info Registered target NLog.Targets.FileTarget(Name=allfile) +2024-01-22 16:25:22.1912 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web) +2024-01-22 16:25:22.2641 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console) +2024-01-22 16:25:22.3211 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False +2024-01-22 16:25:22.3911 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.MainApi\bin\Debug\net8.0\nlog.config +2024-01-22 16:25:22.4242 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile +2024-01-22 16:25:22.4972 Info Configuration initialized. +2024-01-22 16:30:03.5352 Info Registered target NLog.Targets.FileTarget(Name=allfile) +2024-01-22 16:30:03.7027 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web) +2024-01-22 16:30:03.8252 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console) +2024-01-22 16:30:03.9327 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False +2024-01-22 16:30:04.0564 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.MainApi\bin\Debug\net8.0\nlog.config +2024-01-22 16:30:04.0944 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile +2024-01-22 16:30:04.1599 Info Configuration initialized. +2024-01-22 16:36:41.7569 Info Registered target NLog.Targets.FileTarget(Name=allfile) +2024-01-22 16:36:41.8678 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web) +2024-01-22 16:36:41.8983 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console) +2024-01-22 16:36:41.9574 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False +2024-01-22 16:36:41.9998 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.MainApi\bin\Debug\net8.0\nlog.config +2024-01-22 16:36:42.0175 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile +2024-01-22 16:36:42.0638 Info Configuration initialized. +2024-01-22 17:09:45.8109 Info Registered target NLog.Targets.FileTarget(Name=allfile) +2024-01-22 17:09:45.8727 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web) +2024-01-22 17:09:45.8855 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console) +2024-01-22 17:09:45.9162 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False +2024-01-22 17:09:45.9538 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.MainApi\bin\Debug\net8.0\nlog.config +2024-01-22 17:09:45.9705 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile +2024-01-22 17:09:46.0098 Info Configuration initialized. +2024-01-22 17:18:56.9648 Info Registered target NLog.Targets.FileTarget(Name=allfile) +2024-01-22 17:18:57.0166 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web) +2024-01-22 17:18:57.0491 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console) +2024-01-22 17:18:57.0920 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False +2024-01-22 17:18:57.1469 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.MainApi\bin\Debug\net8.0\nlog.config +2024-01-22 17:18:57.1705 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile +2024-01-22 17:18:57.2093 Info Configuration initialized. +2024-01-22 17:23:26.9678 Info Registered target NLog.Targets.FileTarget(Name=allfile) +2024-01-22 17:23:27.0791 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web) +2024-01-22 17:23:27.1138 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console) +2024-01-22 17:23:27.1776 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False +2024-01-22 17:23:27.2255 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.MainApi\bin\Debug\net8.0\nlog.config +2024-01-22 17:23:27.2460 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile +2024-01-22 17:23:27.2884 Info Configuration initialized. +2024-01-22 17:26:00.9683 Info Registered target NLog.Targets.FileTarget(Name=allfile) +2024-01-22 17:26:01.0832 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web) +2024-01-22 17:26:01.1089 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console) +2024-01-22 17:26:01.1548 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False +2024-01-22 17:26:01.1881 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.MainApi\bin\Debug\net8.0\nlog.config +2024-01-22 17:26:01.2052 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile +2024-01-22 17:26:01.2354 Info Configuration initialized. +2024-01-22 18:00:25.0523 Info Registered target NLog.Targets.FileTarget(Name=allfile) +2024-01-22 18:00:25.0941 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web) +2024-01-22 18:00:25.1050 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console) +2024-01-22 18:00:25.1268 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False +2024-01-22 18:00:25.1412 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.MainApi\bin\Debug\net8.0\nlog.config +2024-01-22 18:00:25.1494 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile +2024-01-22 18:00:25.1659 Info Configuration initialized. diff --git a/ds-wms-service/DS.WMS.MainApi/Program.cs b/ds-wms-service/DS.WMS.MainApi/Program.cs index 5ac06909..163bc2a3 100644 --- a/ds-wms-service/DS.WMS.MainApi/Program.cs +++ b/ds-wms-service/DS.WMS.MainApi/Program.cs @@ -30,10 +30,11 @@ builder.Host builder.Services.AddAppWebInstal(); builder.Services.AddCorsInstall(); +builder.Services.AddUserModuleInstall(); //用户服务 builder.Services.AddSqlsugarInstall(); builder.Services.AddSwaggerInstall(); -builder.Services.AddUserModuleInstall(); //用户服务 builder.Services.AddJwtInstall(); +builder.Services.AddSaasDbInstall();//分库服务 // builder.Services.AddEndpointsApiExplorer(); // builder.Services.AddSwaggerGen();