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