using Ewide.Core; using Furion.DatabaseAccessor; using Furion.DependencyInjection; using Furion.DynamicApiController; using Furion.FriendlyException; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; namespace Ewide.Application.Service { /// /// 片区相关 /// [ApiDescriptionSettings(Name = "HouseZone", Order = 180)] public class HouseZoneService : IHouseZoneService, IDynamicApiController, ITransient { [HttpGet("/houseZone/list")] public async Task GetHouseZoneList([FromQuery] HouseZoneInput input) { var areaCode = input.AreaCode.Substring(0, 9); var _sysOrgRep = Db.GetRepository(); var road = await _sysOrgRep.DetachedEntities.FirstOrDefaultAsync(p => p.AreaCode == areaCode); if (road == null) throw Oops.Oh("街道编码错误"); return await _sysOrgRep.DetachedEntities .Where(p => p.Pid == road.Id) .Where(p => p.Type == (int)OrgType.片区) .OrderBy(p => p.Sort) .Select(p => new { p.Id, p.Name }) .ToListAsync(); } } }