Browse Source
Merge pull request #1005 from colinin/use-tenant-not-found-error-code
feat(tenants): error code when tenant does not exist
pull/1010/head
yx lin
1 year ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with
19 additions and
7 deletions
-
aspnet-core/modules/saas/LINGYUN.Abp.Saas.Application/LINGYUN/Abp/Saas/Tenants/TenantAppService.cs
-
aspnet-core/modules/saas/LINGYUN.Abp.Saas.Domain.Shared/LINGYUN/Abp/Saas/AbpSaasErrorCodes.cs
-
aspnet-core/modules/saas/LINGYUN.Abp.Saas.Domain.Shared/LINGYUN/Abp/Saas/Localization/Resources/en.json
-
aspnet-core/modules/saas/LINGYUN.Abp.Saas.Domain.Shared/LINGYUN/Abp/Saas/Localization/Resources/zh-Hans.json
|
|
|
@ -39,7 +39,8 @@ public class TenantAppService : AbpSaasAppServiceBase, ITenantAppService |
|
|
|
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, TenantDto>(tenant); |
|
|
|
@ -50,7 +51,8 @@ public class TenantAppService : AbpSaasAppServiceBase, ITenantAppService |
|
|
|
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, TenantDto>(tenant); |
|
|
|
} |
|
|
|
|
|
|
|
@ -3,11 +3,23 @@ |
|
|
|
public static class AbpSaasErrorCodes |
|
|
|
{ |
|
|
|
public const string Namespace = "Saas"; |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 已经存在名为 {DisplayName} 的版本!
|
|
|
|
/// </summary>
|
|
|
|
public const string DuplicateEditionDisplayName = Namespace + ":010001"; |
|
|
|
/// <summary>
|
|
|
|
/// 试图删除正在使用的版本: {DisplayName}!
|
|
|
|
/// </summary>
|
|
|
|
public const string DeleteUsedEdition = Namespace + ":010002"; |
|
|
|
/// <summary>
|
|
|
|
/// 已经存在名为 {Name} 的租户!
|
|
|
|
/// </summary>
|
|
|
|
public const string DuplicateTenantName = Namespace + ":020001"; |
|
|
|
/// <summary>
|
|
|
|
/// 租户: {Tenant} 不存在!
|
|
|
|
/// </summary>
|
|
|
|
public const string TenantIdOrNameNotFound = Namespace + ":020002"; |
|
|
|
/// <summary>
|
|
|
|
/// 无效的默认连接字符串
|
|
|
|
/// </summary>
|
|
|
|
public const string InvalidDefaultConnectionString = Namespace + ":020101"; |
|
|
|
|
|
|
|
@ -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" |
|
|
|
|
|
|
|
@ -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": "回收" |
|
|
|
|