diff --git a/aspnet-core/modules/saas/LINGYUN.Abp.Saas.Application/LINGYUN/Abp/Saas/Tenants/TenantAppService.cs b/aspnet-core/modules/saas/LINGYUN.Abp.Saas.Application/LINGYUN/Abp/Saas/Tenants/TenantAppService.cs index b5564d8fa..b18b9cee6 100644 --- a/aspnet-core/modules/saas/LINGYUN.Abp.Saas.Application/LINGYUN/Abp/Saas/Tenants/TenantAppService.cs +++ b/aspnet-core/modules/saas/LINGYUN.Abp.Saas.Application/LINGYUN/Abp/Saas/Tenants/TenantAppService.cs @@ -39,7 +39,8 @@ public async virtual Task GetAsync(Guid id) var tenant = await TenantRepository.FindAsync(id); if (tenant == null) { - throw new UserFriendlyException(L["TenantNotFoundById", id]); + throw new BusinessException(AbpSaasErrorCodes.TenantIdOrNameNotFound) + .WithData("Tenant", id); } return ObjectMapper.Map(tenant); @@ -50,7 +51,8 @@ public async virtual Task GetAsync(string name) var tenant = await TenantRepository.FindByNameAsync(name); if (tenant == null) { - throw new UserFriendlyException(L["TenantNotFoundByName", name]); + throw new BusinessException(AbpSaasErrorCodes.TenantIdOrNameNotFound) + .WithData("Tenant", name); } return ObjectMapper.Map(tenant); } diff --git a/aspnet-core/modules/saas/LINGYUN.Abp.Saas.Domain.Shared/LINGYUN/Abp/Saas/AbpSaasErrorCodes.cs b/aspnet-core/modules/saas/LINGYUN.Abp.Saas.Domain.Shared/LINGYUN/Abp/Saas/AbpSaasErrorCodes.cs index 851e4642d..ed946d9a7 100644 --- a/aspnet-core/modules/saas/LINGYUN.Abp.Saas.Domain.Shared/LINGYUN/Abp/Saas/AbpSaasErrorCodes.cs +++ b/aspnet-core/modules/saas/LINGYUN.Abp.Saas.Domain.Shared/LINGYUN/Abp/Saas/AbpSaasErrorCodes.cs @@ -3,11 +3,23 @@ public static class AbpSaasErrorCodes { public const string Namespace = "Saas"; - + /// + /// 已经存在名为 {DisplayName} 的版本! + /// public const string DuplicateEditionDisplayName = Namespace + ":010001"; + /// + /// 试图删除正在使用的版本: {DisplayName}! + /// public const string DeleteUsedEdition = Namespace + ":010002"; + /// + /// 已经存在名为 {Name} 的租户! + /// public const string DuplicateTenantName = Namespace + ":020001"; /// + /// 租户: {Tenant} 不存在! + /// + public const string TenantIdOrNameNotFound = Namespace + ":020002"; + /// /// 无效的默认连接字符串 /// public const string InvalidDefaultConnectionString = Namespace + ":020101"; diff --git a/aspnet-core/modules/saas/LINGYUN.Abp.Saas.Domain.Shared/LINGYUN/Abp/Saas/Localization/Resources/en.json b/aspnet-core/modules/saas/LINGYUN.Abp.Saas.Domain.Shared/LINGYUN/Abp/Saas/Localization/Resources/en.json index 1f6f1d75c..e6cc69449 100644 --- a/aspnet-core/modules/saas/LINGYUN.Abp.Saas.Domain.Shared/LINGYUN/Abp/Saas/Localization/Resources/en.json +++ b/aspnet-core/modules/saas/LINGYUN.Abp.Saas.Domain.Shared/LINGYUN/Abp/Saas/Localization/Resources/en.json @@ -4,6 +4,7 @@ "Saas:010001": "Unable to create duplicate editions {DisplayName}!", "Saas:010002": "Tried to delete the edition in use: {DisplayName}!", "Saas:020001": "Unable to create duplicate tenants {Name}!", + "Saas:020002": "Tenant: {Tenant} not found!", "Saas:020101": "The default connection string cannot open a connection to the database!", "Saas:020102": "The database pointed to by the default connection string already exists!", "Saas:020103": "Unable to open the database connection pointed to by {Name}!", @@ -47,8 +48,6 @@ "Features:ExpirationReminderDaysDesc": "Send a reminder to the administrator when the resource has how many days left to expire", "Features:ExpiredRecoveryTime": "Expired Recovery Time", "Features:ExpiredRecoveryTimeDesc": "If the resource expiration is not handled for a long time, tenant resources will be reclaimed", - "TenantNotFoundById": "Tenant: {0} not found!", - "TenantNotFoundByName": "Tenant: {0} not found!", "UnActived": "UnActived", "RecycleStrategy:Reserve": "Reserve", "RecycleStrategy:Recycle": "Recycle" diff --git a/aspnet-core/modules/saas/LINGYUN.Abp.Saas.Domain.Shared/LINGYUN/Abp/Saas/Localization/Resources/zh-Hans.json b/aspnet-core/modules/saas/LINGYUN.Abp.Saas.Domain.Shared/LINGYUN/Abp/Saas/Localization/Resources/zh-Hans.json index 4f974c1ef..684aa2ec5 100644 --- a/aspnet-core/modules/saas/LINGYUN.Abp.Saas.Domain.Shared/LINGYUN/Abp/Saas/Localization/Resources/zh-Hans.json +++ b/aspnet-core/modules/saas/LINGYUN.Abp.Saas.Domain.Shared/LINGYUN/Abp/Saas/Localization/Resources/zh-Hans.json @@ -4,6 +4,7 @@ "Saas:010001": "已经存在名为 {DisplayName} 的版本!", "Saas:010002": "试图删除正在使用的版本: {DisplayName}!", "Saas:020001": "已经存在名为 {Name} 的租户!", + "Saas:020002": "租户: {Tenant} 不存在!", "Saas:020101": "无法打开默认连接字符串指向的数据库连接!", "Saas:020102": "默认连接字符串指向的数据库已经存在!", "Saas:020103": "无法打开 {Name} 指向的数据库连接!", @@ -47,8 +48,6 @@ "Features:ExpirationReminderDaysDesc": "当资源还有多少天过期时, 给管理员发送提醒", "Features:ExpiredRecoveryTime": "过期回收时长", "Features:ExpiredRecoveryTimeDesc": "当资源超期多久没有处理, 将回收租户资源", - "TenantNotFoundById": "租户: {0} 不存在!", - "TenantNotFoundByName": "租户: {0} 不存在!", "UnActived": "未启用", "RecycleStrategy:Reserve": "保留", "RecycleStrategy:Recycle": "回收"