|
@@ -26,6 +26,9 @@ using Yitter.IdGenerator;
|
|
using ZhonTai.Admin.Domain.Pkg;
|
|
using ZhonTai.Admin.Domain.Pkg;
|
|
using ZhonTai.Admin.Domain.TenantPkg;
|
|
using ZhonTai.Admin.Domain.TenantPkg;
|
|
using ZhonTai.Admin.Services.Pkg;
|
|
using ZhonTai.Admin.Services.Pkg;
|
|
|
|
+using ZhonTai.Admin.Domain.Platform;
|
|
|
|
+using ZhonTai.Admin.Repositories.Platform;
|
|
|
|
+using ZhonTai.Admin.Core.Auth;
|
|
|
|
|
|
namespace ZhonTai.Admin.Services.Tenant;
|
|
namespace ZhonTai.Admin.Services.Tenant;
|
|
|
|
|
|
@@ -47,6 +50,7 @@ public class TenantService : BaseService, ITenantService, IDynamicApi
|
|
private IUserOrgRepository _userOrgRepository => LazyGetRequiredService<IUserOrgRepository>();
|
|
private IUserOrgRepository _userOrgRepository => LazyGetRequiredService<IUserOrgRepository>();
|
|
private IPasswordHasher<UserEntity> _passwordHasher => LazyGetRequiredService<IPasswordHasher<UserEntity>>();
|
|
private IPasswordHasher<UserEntity> _passwordHasher => LazyGetRequiredService<IPasswordHasher<UserEntity>>();
|
|
private ITenantPkgRepository _tenantPkgRepository => LazyGetRequiredService<ITenantPkgRepository>();
|
|
private ITenantPkgRepository _tenantPkgRepository => LazyGetRequiredService<ITenantPkgRepository>();
|
|
|
|
+ private IPlatformUserRepository _platformUserRepository => LazyGetRequiredService<PlatformUserRepository>();
|
|
|
|
|
|
public TenantService()
|
|
public TenantService()
|
|
{
|
|
{
|
|
@@ -300,11 +304,29 @@ public class TenantService : BaseService, ITenantService, IDynamicApi
|
|
};
|
|
};
|
|
await _userRoleRepository.InsertAsync(userRole);
|
|
await _userRoleRepository.InsertAsync(userRole);
|
|
|
|
|
|
|
|
+ //新增平台用户
|
|
|
|
+ string invite = await CreateInviteCode();
|
|
|
|
+ var platfromUser = new PlatformUserEntity()
|
|
|
|
+ {
|
|
|
|
+ TenantId = tenantId,
|
|
|
|
+ Name = user.UserName,
|
|
|
|
+ Phone = user.Mobile,
|
|
|
|
+ Password = user.Password,
|
|
|
|
+ Role = "1",
|
|
|
|
+ ParentId = "0_",
|
|
|
|
+ InviteCode = invite
|
|
|
|
+ };
|
|
|
|
+ await _platformUserRepository.InsertAsync(platfromUser);
|
|
|
|
+ long platfromUserId = platfromUser.Id;
|
|
|
|
+
|
|
//更新租户的用户和部门
|
|
//更新租户的用户和部门
|
|
tenant.UserId = userId;
|
|
tenant.UserId = userId;
|
|
tenant.OrgId = org.Id;
|
|
tenant.OrgId = org.Id;
|
|
|
|
+ tenant.PlatfromUserId = platfromUserId;
|
|
await _tenantRepository.UpdateAsync(tenant);
|
|
await _tenantRepository.UpdateAsync(tenant);
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
return tenant.Id;
|
|
return tenant.Id;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -412,6 +434,14 @@ public class TenantService : BaseService, ITenantService, IDynamicApi
|
|
//清除租户下所有用户权限缓存
|
|
//清除租户下所有用户权限缓存
|
|
await LazyGetRequiredService<PkgService>().ClearUserPermissionsAsync(new List<long> { tenant.Id });
|
|
await LazyGetRequiredService<PkgService>().ClearUserPermissionsAsync(new List<long> { tenant.Id });
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ //更新平台用户
|
|
|
|
+ await _platformUserRepository.UpdateDiy.SetSource(new PlatformUserEntity()
|
|
|
|
+ {
|
|
|
|
+ Id=tenant.PlatfromUserId,
|
|
|
|
+ Name = input.RealName,
|
|
|
|
+ Phone = input.Phone,
|
|
|
|
+ }).UpdateColumns(m => new { m.Name, m.Phone }).ExecuteAffrowsAsync(); ;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -544,4 +574,14 @@ public class TenantService : BaseService, ITenantService, IDynamicApi
|
|
entity.Enabled = input.Enabled;
|
|
entity.Enabled = input.Enabled;
|
|
await _tenantRepository.UpdateAsync(entity);
|
|
await _tenantRepository.UpdateAsync(entity);
|
|
}
|
|
}
|
|
|
|
+ private async Task<string> CreateInviteCode()
|
|
|
|
+ {
|
|
|
|
+ string invite = StringHelper.GenerateRandomNumber();
|
|
|
|
+ var count = await _platformUserRepository.Select.Where(m => m.InviteCode == invite).CountAsync();
|
|
|
|
+ if (count > 0)
|
|
|
|
+ {
|
|
|
|
+ invite = await CreateInviteCode();
|
|
|
|
+ }
|
|
|
|
+ return invite;
|
|
|
|
+ }
|
|
}
|
|
}
|