设置静态国际化+测试ok
continuous-integration/drone/push Build is passing

This commit is contained in:
2024-10-16 10:40:38 +08:00
parent 8be3cc9e78
commit 663a6c7f5c
5 changed files with 53 additions and 23 deletions
@@ -71,23 +71,9 @@ namespace IRaCIS.Core.Infra.EFCore
bool autoSave = false, bool ignoreQueryFilter = false) where T : Entity;
}
public class Repository : IRepository
public class Repository(IRaCISDBContext _dbContext, IMapper _mapper, IUserInfo _userInfo) : IRepository
{
#region
private IRaCISDBContext _dbContext { get; }
public IMapper _mapper { get; set; }
public IUserInfo _userInfo { get; set; }
public IStringLocalizer _localizer { get; set; }
public Repository(IRaCISDBContext dbContext, IMapper mapper, IUserInfo userInfo, IStringLocalizer localizer)
{
_localizer = localizer;
_dbContext = dbContext;
_mapper = mapper;
_userInfo = userInfo;
}
/// <summary>
/// 设置是使用哪个仓储 默认不跟踪
@@ -171,7 +157,7 @@ namespace IRaCIS.Core.Infra.EFCore
if (dbEntity == null)
{
throw new BusinessValidationFailedException(_localizer["Repository_UpdateError"]);
throw new BusinessValidationFailedException(I18n.T("Repository_UpdateError"));
}
var dbBeforEntity = dbEntity.Clone();
@@ -450,7 +436,6 @@ namespace IRaCIS.Core.Infra.EFCore
}
#endregion
@@ -100,7 +100,7 @@ namespace IRaCIS.Core.Infra.EFCore
if (dbEntity == null)
{
throw new BusinessValidationFailedException(_localizer["Repository_UpdateError"]);
throw new BusinessValidationFailedException(I18n.T("Repository_UpdateError"));
}
var dbBeforEntity = dbEntity.Clone();
@@ -156,7 +156,7 @@ namespace IRaCIS.Core.Infra.EFCore
if (searchEntity == null)
{
throw new BusinessValidationFailedException(_localizer["Repository_UpdateError"]);
throw new BusinessValidationFailedException(I18n.T("Repository_UpdateError"));
}
_dbContext.EntityModifyPartialFiled(searchEntity, updateFactory);
@@ -208,7 +208,7 @@ namespace IRaCIS.Core.Infra.EFCore
if (waitDelete == null)
{
throw new BusinessValidationFailedException(_localizer["Repository_DeleteError"]);
throw new BusinessValidationFailedException(I18n.T("Repository_DeleteError"));
}
await DeleteAsync(waitDelete, autoSave);