Browse Source

Merge commit 'refs/pull/311/head' of https://gitee.com/zuohuaijun/Admin.NET into next

zuohuaijun 4 years ago
parent
commit
4dbcaf8db5
1 changed files with 5 additions and 4 deletions
  1. 5 4
      Admin.NET/Admin.NET.Core/Service/Tenant/SysTenantService.cs

+ 5 - 4
Admin.NET/Admin.NET.Core/Service/Tenant/SysTenantService.cs

@@ -1,4 +1,4 @@
-using Furion.DataEncryption;
+using Furion.DataEncryption;
 using Furion.DependencyInjection;
 using Furion.DependencyInjection;
 using Furion.DynamicApiController;
 using Furion.DynamicApiController;
 using Furion.FriendlyException;
 using Furion.FriendlyException;
@@ -160,12 +160,13 @@ namespace Admin.NET.Core.Service
         [HttpPost("/sysTenant/delete")]
         [HttpPost("/sysTenant/delete")]
         public async Task DeleteTenant(DeleteTenantInput input)
         public async Task DeleteTenant(DeleteTenantInput input)
         {
         {
-            var entity = await _tenantRep.GetFirstAsync(u => u.Id == input.Id);
-            await _tenantRep.DeleteAsync(entity);
+
             var users = await _userRep.AsQueryable().Filter(null, true).Where(u => u.TenantId == input.Id).ToListAsync();
             var users = await _userRep.AsQueryable().Filter(null, true).Where(u => u.TenantId == input.Id).ToListAsync();
             // 超级管理员所在租户为默认租户
             // 超级管理员所在租户为默认租户
             if (users.Any(u => u.UserType == UserTypeEnum.SuperAdmin))
             if (users.Any(u => u.UserType == UserTypeEnum.SuperAdmin))
-                throw Oops.Oh(ErrorCodeEnum.D1023);
+                throw Oops.Oh(ErrorCodeEnum.D1023);                
+            var entity = await _tenantRep.GetFirstAsync(u => u.Id == input.Id);
+            await _tenantRep.DeleteAsync(entity);
 
 
             // 删除与租户相关的表数据
             // 删除与租户相关的表数据
             var userIds = users.Select(u => u.Id).ToList();
             var userIds = users.Select(u => u.Id).ToList();