3 Commits a791ded5b6 ... 5879f119d1

Author SHA1 Message Date
  lifa 5879f119d1 Merge branch 'master' of http://192.144.191.50/zhongjie51/99ditui 1 year ago
  lifa 4186c46577 发布时未能正常加载依赖bug修复 1 year ago
  lifa a935aa6431 新增平台类型参数,以及相关处理 1 year ago

+ 5 - 0
ZhonTai.sln

@@ -27,6 +27,11 @@ EndProject
 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ZhonTai.ApiUI", "src\platform\ZhonTai.ApiUI\ZhonTai.ApiUI.csproj", "{A6911102-A4F8-4000-A997-045F84F73060}"
 EndProject
 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DiTui.Host", "src\hosts\DiTui.Host\DiTui.Host.csproj", "{5202EA7B-B985-4237-9629-883A76ABD359}"
+	ProjectSection(ProjectDependencies) = postProject
+		{6F47A41A-085E-4422-BB73-5A2CBAA07D9F} = {6F47A41A-085E-4422-BB73-5A2CBAA07D9F}
+		{97D32A49-994C-44C5-A167-51E71D173B6F} = {97D32A49-994C-44C5-A167-51E71D173B6F}
+		{BDD8E9DB-896C-4340-A7E6-DFE341DE86C2} = {BDD8E9DB-896C-4340-A7E6-DFE341DE86C2}
+	EndProjectSection
 EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution

+ 4 - 4
src/hosts/DiTui.Host/Configs/dbconfig.json

@@ -21,12 +21,12 @@
   //MySql "Server=localhost; Port=3306; Database=mysql; Uid=root; Pwd=pwd; Charset=utf8mb4;SslMode=none;Min pool size=1"
   //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",
-  "createDbConnectionString": "Server=localhost; Port=3306; Database=mysql; Uid=root; Pwd=pwd; Charset=utf8mb4;",
+  "createDbConnectionString": "Server=192.144.191.50; Port=3306; Database=jiujiu_zhongjie5; Uid=jiujiu_zhongjie5; Pwd=EjmCA6Ff4bSmKk32; Charset=utf8mb4;",
   //建库脚本,复杂建库脚本可放到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": "CREATE DATABASE `admindb` CHARACTER SET 'utf8mb4' COLLATE 'utf8mb4_general_ci'",
+  "createDbSql": "CREATE DATABASE `jiujiu_zhongjie5` CHARACTER SET 'utf8mb4' COLLATE 'utf8mb4_general_ci'",
 
   //同步结构
   "syncStructure": true,
@@ -57,13 +57,13 @@
 
   //数据库配置 https://github.com/dotnetcore/FreeSql/wiki/入门
   //数据库类型 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",
+  "type": "MySql",
   //连接字符串
   //MySql "Server=localhost; Port=3306; Database=admindb; Uid=root; Pwd=pwd; Charset=utf8mb4;SslMode=none;Min pool size=1"
   //SqlServer "Data Source=.;User Id=sa;Password=pwd;Initial Catalog=admindb;TrustServerCertificate=true;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"
-  "connectionString": "Data Source=|DataDirectory|\\admindb.db; Pooling=true;Min Pool Size=1",
+  "connectionString": "Server=192.144.191.50; Port=3306; Database=jiujiu_zhongjie5; Uid=jiujiu_zhongjie5; Pwd=EjmCA6Ff4bSmKk32; Charset=utf8mb4;SslMode=none;Min pool size=1",
 
   //指定程序集
   //FreeSql.MySql.MySqlProvider`1,FreeSql.Provider.MySqlConnector

+ 24 - 8
src/hosts/DiTui.Host/DiTui.Host.csproj

@@ -2,6 +2,7 @@
 	<PropertyGroup>
 		<TargetFramework>net7.0</TargetFramework>
 		<Description>中台接口宿主</Description>
+		<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
 	</PropertyGroup>
 
 	<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
@@ -16,13 +17,21 @@
 	</ItemGroup>
 
 	<ItemGroup Condition="'$(Configuration)'=='Debug'">
-		<PackageReference Include="FreeSql.Provider.MySql" Version="3.2.693" />
-		<PackageReference Include="FreeSql.Provider.SqlServer" Version="3.2.693" />
-		<PackageReference Include="FreeSql.Provider.PostgreSQL" Version="3.2.693" />
-		<PackageReference Include="FreeSql.Provider.Oracle" Version="3.2.693" />
-		<PackageReference Include="FreeSql.Provider.Sqlite" Version="3.2.693" />
-		<PackageReference Include="FreeSql.Provider.MySqlConnector" Version="3.2.693" />
+		<PackageReference Include="FreeSql.Provider.MySql" Version="3.2.695">
+		  <GeneratePathProperty></GeneratePathProperty>
+		</PackageReference>
+		<PackageReference Include="FreeSql.Provider.SqlServer" Version="3.2.695" />
+		<PackageReference Include="FreeSql.Provider.PostgreSQL" Version="3.2.695" />
+		<PackageReference Include="FreeSql.Provider.Oracle" Version="3.2.695" />
+		<PackageReference Include="FreeSql.Provider.Sqlite" Version="3.2.695" />
+		<PackageReference Include="FreeSql.Provider.MySqlConnector" Version="3.2.695" />
 	</ItemGroup>
+
+	<ItemGroup >
+		<PackageReference Include="FreeSql.Provider.MySql" Version="3.2.695"/>
+		<PackageReference Include="FreeSql.Provider.MySqlConnector" Version="3.2.695" />
+	</ItemGroup>
+	
 	
 	<ItemGroup>
 		<ProjectReference Include="..\..\platform\ZhonTai.Admin\ZhonTai.Admin.csproj" />
@@ -34,12 +43,19 @@
 	</ItemGroup>
 
 	<ItemGroup>
-		<PackageReference Include="DotNetCore.CAP.Dashboard" Version="7.1.1" />
-		<PackageReference Include="DotNetCore.CAP.InMemoryStorage" Version="7.1.1" />
+		<PackageReference Include="DotNetCore.CAP.Dashboard" Version="7.1.2" />
+		<PackageReference Include="DotNetCore.CAP.InMemoryStorage" Version="7.1.2" />
+		<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.15.0" />
 		<PackageReference Include="Savorboard.CAP.InMemoryMessageQueue" Version="7.0.0" />
 		<PackageReference Include="SkiaSharp.NativeAssets.Linux.NoDependencies" Version="2.88.3" />
 	</ItemGroup>
 
+	<ItemGroup>
+	  <Reference Include="FreeSql.Provider.MySql">
+	    <HintPath>C:\Users\Frank\.nuget\packages\freesql.provider.mysql\3.2.695\lib\net452\FreeSql.Provider.MySql.dll</HintPath>
+	  </Reference>
+	</ItemGroup>
+
 	<ItemGroup>
 		<Content Update="wwwroot\*\*">
 			<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>

+ 5 - 5
src/hosts/ZhonTai.Host/Configs/dbconfig.json

@@ -21,12 +21,12 @@
   //MySql "Server=localhost; Port=3306; Database=mysql; Uid=root; Pwd=pwd; Charset=utf8mb4;SslMode=none;Min pool size=1"
   //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",
-  "createDbConnectionString": "Server=localhost; Port=3306; Database=mysql; Uid=root; Pwd=pwd; Charset=utf8mb4;",
+  "createDbConnectionString": "Server=192.144.191.50; Port=3306; Database=jiujiu_zhongjie5; Uid=jiujiu_zhongjie5; Pwd=EjmCA6Ff4bSmKk32; Charset=utf8mb4;",
   //建库脚本,复杂建库脚本可放到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": "CREATE DATABASE `admindb` CHARACTER SET 'utf8mb4' COLLATE 'utf8mb4_general_ci'",
+  "createDbSql": "CREATE DATABASE `jiujiu_zhongjie5` CHARACTER SET 'utf8mb4' COLLATE 'utf8mb4_general_ci'",
 
   //同步结构
   "syncStructure": true,
@@ -57,17 +57,17 @@
 
   //数据库配置 https://github.com/dotnetcore/FreeSql/wiki/入门
   //数据库类型 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",
+  "type": "MySql",
   //连接字符串
   //MySql "Server=localhost; Port=3306; Database=admindb; Uid=root; Pwd=pwd; Charset=utf8mb4;SslMode=none;Min pool size=1"
   //SqlServer "Data Source=.;User Id=sa;Password=pwd;Initial Catalog=admindb;TrustServerCertificate=true;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"
-  "connectionString": "Data Source=|DataDirectory|\\admindb.db; Pooling=true;Min Pool Size=1",
+  "connectionString": "Server=192.144.191.50; Port=3306; Database=jiujiu_zhongjie5; Uid=jiujiu_zhongjie5; Pwd=EjmCA6Ff4bSmKk32; Charset=utf8mb4;SslMode=none;Min pool size=1",
 
   //指定程序集
   //FreeSql.MySql.MySqlProvider`1,FreeSql.Provider.MySqlConnector
-  "providerType": "",
+  "providerType": "FreeSql.Provider.MySqlConnector",
 
   //读写分离从库列表
   "slaveList": [

+ 5 - 0
src/hosts/ZhonTai.Host/ZhonTai.Host.csproj

@@ -23,6 +23,11 @@
 		<PackageReference Include="FreeSql.Provider.Sqlite" Version="3.2.693" />
 		<PackageReference Include="FreeSql.Provider.MySqlConnector" Version="3.2.693" />
 	</ItemGroup>
+
+	<ItemGroup>
+		<PackageReference Include="FreeSql.Provider.MySql" Version="3.2.693" />
+		<PackageReference Include="FreeSql.Provider.MySqlConnector" Version="3.2.693" />
+	</ItemGroup>
 	
 	<ItemGroup>
 		<ProjectReference Include="..\..\platform\ZhonTai.Admin\ZhonTai.Admin.csproj" />

+ 35 - 12
src/platform/ZhonTai.Admin/Services/DiTuiAPI/DiTuiAPIService.cs

@@ -1,5 +1,4 @@
 using Microsoft.AspNetCore.Authorization;
-using Microsoft.AspNetCore.Identity;
 using Microsoft.AspNetCore.Mvc;
 using System;
 using System.Diagnostics;
@@ -7,7 +6,6 @@ using System.Threading.Tasks;
 using ZhonTai.Admin.Core.Attributes;
 using ZhonTai.Admin.Core.Consts;
 using ZhonTai.Admin.Core.Dto;
-using ZhonTai.Admin.Domain.User;
 using ZhonTai.Admin.Services.Auth.Dto;
 using ZhonTai.Admin.Services.DiTuiAPI.Dto;
 using ZhonTai.Common.Helpers;
@@ -20,10 +18,8 @@ using System.Security.Claims;
 using ZhonTai.Admin.Core.Auth;
 using ZhonTai.Common.Extensions;
 using System.Linq.Expressions;
-using ZhonTai.Admin.Domain.UserOrg;
-using ZhonTai.Admin.Domain.UserRole;
-using ZhonTai.Admin.Domain.UserStaff;
-using ZhonTai.Admin.Services.User.Dto;
+using Microsoft.AspNetCore.Http;
+using ZhonTai.Admin.Domain.Org;
 
 namespace ZhonTai.Admin.Services.DiTuiAPI
 {
@@ -35,20 +31,24 @@ namespace ZhonTai.Admin.Services.DiTuiAPI
     [DynamicApi(Area = AdminConsts.DiTuiName)]
     public class DiTuiAPIService : BaseService, IDiTuiAPIService, IDynamicApi
     {
-        private IPasswordHasher<PlatformUserEntity> _passwordHasher => LazyGetRequiredService<IPasswordHasher<PlatformUserEntity>>();
         private readonly AppConfig _appConfig;
-        private readonly IUserRepository _userRepository;
         private readonly IPlatformUserRepository _platformUserRepository;
         private readonly ITenantRepository _tenantRepository;
+        private readonly IOrgRepository _orgRepository;
+        private readonly IHttpContextAccessor _httpContextAccessor;
         public DiTuiAPIService(
             IPlatformUserRepository platformUserRepository,
             AppConfig appConfig,
-            ITenantRepository tenantRepository
+            ITenantRepository tenantRepository,
+            IHttpContextAccessor httpContextAccessor,
+            IOrgRepository orgRepository
             )
         {
             _platformUserRepository = platformUserRepository;
             _appConfig = appConfig;
             _tenantRepository = tenantRepository;
+            _httpContextAccessor = httpContextAccessor;
+            _orgRepository = orgRepository;
         }
 
         [HttpPost]
@@ -162,7 +162,7 @@ namespace ZhonTai.Admin.Services.DiTuiAPI
         }
 
         /// <summary>
-        /// 新增用户
+        /// 用户注册
         /// </summary>
         /// <param name="input"></param>
         /// <returns></returns>
@@ -172,12 +172,32 @@ namespace ZhonTai.Admin.Services.DiTuiAPI
         [AdminTransaction]
         public virtual async Task<long> RegisterAsync(RegisterInput input)
         {
+            var platform = _httpContextAccessor.HttpContext.Request.Headers["platform"];
+
+            if (string.IsNullOrEmpty(input.InvitCode))
+            {
+                throw ResultOutput.Exception($"邀请码不可为空");
+            }
+            var org = await _orgRepository.Select.Where(a=> a.Code == platform).DisableGlobalFilter()
+                .FirstAsync(a => new { a.Name, a.TenantId });
+
             Expression<Func<PlatformUserEntity, bool>> where = (a => a.Phone == input.Phone);
             where = where.Or(input.Phone.NotNull(), a => a.Phone == input.Phone)
                 .Or(input.Name.NotNull(), a => a.Name == input.Name);
 
-            var existsUser = await _platformUserRepository.Select.Where(where)
-                .FirstAsync(a => new { a.Name, a.Phone });
+            var existsUser = await _platformUserRepository.Select.Where(where).DisableGlobalFilter().Where(a => a.TenantId == org.TenantId)
+                .FirstAsync(a => new { a.Name, a.Phone, a.TenantId });
+
+            
+            //fsql.Select<TestAddEnum>().DisableGlobalFilter().ToList();
+            var parentUser = await _platformUserRepository.Select.Where(a =>a.TenantId == org.TenantId && a.InviteCode == input.InvitCode).DisableGlobalFilter()
+                .ToOneAsync();
+                //.FirstAsync(a => new { a.Name, a.Phone, a.TenantId, a.Id,a.ParentId });
+
+            if (parentUser == null)
+            {
+                throw ResultOutput.Exception($"未找到邀请人,请确认邀请码");
+            }
 
             if (existsUser != null)
             {
@@ -210,6 +230,9 @@ namespace ZhonTai.Admin.Services.DiTuiAPI
             entity.Password = MD5Encrypt.Encrypt32(input.Password);
             // 注册口注册用户皆为下级角色
             entity.Role = "2";
+            entity.ParentId = parentUser.ParentId + parentUser.Id + "_";
+            entity.TenantId = parentUser.TenantId;
+
             var user = await _platformUserRepository.InsertAsync(entity);
             var userId = user.Id;
 

+ 1 - 1
src/platform/ZhonTai.Admin/ZhonTai.Admin.xml

@@ -5100,7 +5100,7 @@
         </member>
         <member name="M:ZhonTai.Admin.Services.DiTuiAPI.DiTuiAPIService.RegisterAsync(ZhonTai.Admin.Services.DiTuiAPI.Dto.RegisterInput)">
             <summary>
-            新增用户
+            用户注册
             </summary>
             <param name="input"></param>
             <returns></returns>