wet 2 years ago
parent 0eda6cab96
commit 8f325385fe

@ -44,6 +44,7 @@ namespace Myshipping.Core.MQ
_userService = _serviceScope.ServiceProvider.GetService<ISysUserService>(); _userService = _serviceScope.ServiceProvider.GetService<ISysUserService>();
_sysUserRep = _serviceScope.ServiceProvider.GetService<SqlSugarRepository<SysUser>>(); _sysUserRep = _serviceScope.ServiceProvider.GetService<SqlSugarRepository<SysUser>>();
_sysTenantRep = _serviceScope.ServiceProvider.GetService<SqlSugarRepository<SysTenant>>(); _sysTenantRep = _serviceScope.ServiceProvider.GetService<SqlSugarRepository<SysTenant>>();
} }
public override void Dispose() public override void Dispose()
@ -116,14 +117,16 @@ namespace Myshipping.Core.MQ
tenant.Email = $"{tenant.Id}"; tenant.Email = $"{tenant.Id}";
tenant.TenantType = TenantTypeEnum.COMMON; tenant.TenantType = TenantTypeEnum.COMMON;
var newTenant = _sysTenantRep.InsertReturnEntity(tenant); var newTenant = _sysTenantRep.InsertReturnEntity(tenant);
_tenantService.InitNewTenant(tenant); _tenantService.InitNewTenant(tenant);
} }
} }
else if (type == "UserJoin") //用户加入公司 else if (type == "UserJoin") //用户加入公司
{ {
} }
else if (type == "UserLeave") //用户离职 else if (type == "UserLeave") //用户离职
{ {
@ -131,6 +134,55 @@ namespace Myshipping.Core.MQ
} }
else if (type == "CompanyUserSync") //公司及员工数据同步 else if (type == "CompanyUserSync") //公司及员工数据同步
{ {
/////同步租户
var comp = jobj.GetJObjectValue("company");
var compid = comp.GetStringValue("CompId");
var compname = comp.GetStringValue("CompName");
var adminShowName = comp.GetStringValue("AdminShowName");
var findTenant = _sysTenantRep.FirstOrDefault(x => x.CompId == compid); //先根据关联ID查找
if (findTenant == null)
{
findTenant = _sysTenantRep.FirstOrDefault(x => x.Name == compname); //再根据公司全称查找
}
if (findTenant == null) //找不到,新建
{
var tenant = new SysTenant();
tenant.Id = YitIdHelper.NextId();
tenant.Name = compname;
tenant.AdminName = adminShowName;
tenant.Email = $"{tenant.Id}";
tenant.TenantType = TenantTypeEnum.COMMON;
findTenant = _sysTenantRep.InsertReturnEntity(tenant);
_tenantService.InitNewTenant(tenant);
}
////同步用户
var user = jobj.GetJArrayValue("users");
///租户id
var tenantid = findTenant.Id;
foreach (var item in user)
{
}
} }

@ -3880,6 +3880,11 @@
租户类型 租户类型
</summary> </summary>
</member> </member>
<member name="P:Myshipping.Core.Entity.SysTenant.CompId">
<summary>
大简云公司ID
</summary>
</member>
<member name="T:Myshipping.Core.Entity.SysTimer"> <member name="T:Myshipping.Core.Entity.SysTimer">
<summary> <summary>
定时任务 定时任务

Loading…
Cancel
Save