更新 Admin.NET/Admin.NET.Core/Service/Tenant/SysTenantService.cs

This commit is contained in:
twt_2008 2024-12-14 14:18:49 +08:00
parent c59bac812b
commit 97b9148baa

View File

@ -24,6 +24,7 @@ public class SysTenantService : IDynamicApiController, ITransient
private readonly SysRoleMenuService _sysRoleMenuService;
private readonly SysConfigService _sysConfigService;
private readonly SysCacheService _sysCacheService;
private readonly IEventPublisher _eventPublisher;
public SysTenantService(SqlSugarRepository<SysTenant> sysTenantRep,
SqlSugarRepository<SysOrg> sysOrgRep,
@ -36,7 +37,8 @@ public class SysTenantService : IDynamicApiController, ITransient
SysUserRoleService sysUserRoleService,
SysRoleMenuService sysRoleMenuService,
SysConfigService sysConfigService,
SysCacheService sysCacheService)
SysCacheService sysCacheService,
IEventPublisher eventPublisher)
{
_sysTenantRep = sysTenantRep;
_sysOrgRep = sysOrgRep;
@ -50,6 +52,7 @@ public class SysTenantService : IDynamicApiController, ITransient
_sysRoleMenuService = sysRoleMenuService;
_sysConfigService = sysConfigService;
_sysCacheService = sysCacheService;
_eventPublisher = eventPublisher;
}
/// <summary>
@ -254,6 +257,9 @@ public class SysTenantService : IDynamicApiController, ITransient
1310000000801 // 关于项目
};
await _sysRoleMenuService.GrantRoleMenu(new RoleMenuInput() { Id = newRole.Id, MenuIdList = menuIdList });
//发布新增租户事件
await _eventPublisher.PublishAsync(CommonConst.InitTenant, tenant);
}
/// <summary>
@ -295,6 +301,9 @@ public class SysTenantService : IDynamicApiController, ITransient
await _sysOrgRep.AsDeleteable().Where(u => u.TenantId == input.Id).ExecuteCommandAsync();
await _sysPosRep.AsDeleteable().Where(u => u.TenantId == input.Id).ExecuteCommandAsync();
//发布删除租户事件
await _eventPublisher.PublishAsync(CommonConst.DeleteTenant, input);
}
/// <summary>