admin/src/Oms.Application/Services/System/CountryService.cs
2026-06-25 19:59:06 +08:00

42 lines
1.3 KiB
C#

using Fake.Application;
using Microsoft.AspNetCore.Mvc;
using Oms.Application.Dtos.System;
using Oms.Domain.SystemAggregate.Repositories;
namespace Oms.Application.Services.System;
/// <summary>
/// 国家 API 服务。
/// </summary>
[ApiExplorerSettings(GroupName = "OMS-System")]
public class CountryService : ApplicationService
{
private ICountryRepository CountryRepository => LazyServiceProvider.GetRequiredService<ICountryRepository>();
/// <summary>
/// 查询国家列表。
/// </summary>
/// <returns>国家列表,返回全部有效国家主数据。</returns>
/// <remarks>
/// 核心业务逻辑:
/// 1. 查询全部国家主数据。
/// 2. 按国家代码和英文名稳定排序。
/// 3. 返回页面选择器可直接消费的静态结果集。
/// </remarks>
[HttpGet("/system/country/list")]
public async Task<List<CountryOutput>> GetListAsync()
{
return (await CountryRepository.GetListAsync())
.OrderBy(x => x.CountryCode)
.ThenBy(x => x.EnglishName)
.Select(x => new CountryOutput
{
Id = x.Id,
ChineseName = x.ChineseName,
EnglishName = x.EnglishName,
CountryCode = x.CountryCode
})
.ToList();
}
}