Skip to content

Commit

Permalink
feat: 语言接口调整只返回中文和英文
Browse files Browse the repository at this point in the history
  • Loading branch information
WangJunZzz committed Nov 15, 2024
1 parent 50e2334 commit ec565dc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ public virtual async Task<List<PageLanguageOutput>> AllListAsync()
{
var languages = await _languageManager.ListAsync();
var list = ObjectMapper.Map<List<Language>, List<PageLanguageOutput>>(languages);
// 前端只支持这2种语言,其他语言不显示
return list.Where(e => e.CultureName == "zh-Hans" || e.CultureName == "en").ToList();
return list.ToList();
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ public EfCoreLanguageRepository(IDbContextProvider<ILanguageManagementDbContext>
public virtual async Task<List<Language>> ListAsync(bool? isEnabled = null)
{
return await (await GetDbSetAsync())
.Where(e => e.CultureName == "zh-Hans" || e.CultureName == "en")
.WhereIf(isEnabled != null, e => e.IsEnabled == isEnabled)
.ToListAsync();
}

/// <summary>
/// 查询语言
/// </summary>
Expand All @@ -27,6 +28,7 @@ public virtual async Task<List<Language>> ListAsync(bool? isEnabled = null)
public async Task<List<Language>> ListAsync(int maxResultCount = 10, int skipCount = 0, string filter = null)
{
return await (await GetDbSetAsync())
.Where(e => e.CultureName == "zh-Hans" || e.CultureName == "en")
.WhereIf(filter.IsNotNullOrWhiteSpace(), e => e.CultureName.Contains(filter) || e.UiCultureName.Contains(filter) || e.DisplayName.Contains(filter))
.OrderByDescending(e => e.CreationTime)
.PageBy(skipCount, maxResultCount)
Expand All @@ -37,9 +39,10 @@ public async Task<List<Language>> ListAsync(int maxResultCount = 10, int skipCou
/// 获取总条数
/// </summary>
/// <param name="filter">查询条件 cultureName or uiCultureName or displayName</param>
public async Task<long> CountAsync( string filter = null)
public async Task<long> CountAsync(string filter = null)
{
return await (await GetDbSetAsync())
.Where(e => e.CultureName == "zh-Hans" || e.CultureName == "en")
.WhereIf(filter.IsNotNullOrWhiteSpace(), e => e.CultureName.Contains(filter) || e.UiCultureName.Contains(filter) || e.DisplayName.Contains(filter))
.CountAsync();
}
Expand Down

0 comments on commit ec565dc

Please sign in to comment.