40 lines
1.3 KiB
C#
40 lines
1.3 KiB
C#
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
|
|
{
|
|
/// <summary>
|
|
/// 片区相关
|
|
/// </summary>
|
|
[ApiDescriptionSettings(Name = "HouseZone", Order = 180)]
|
|
public class HouseZoneService : IHouseZoneService, IDynamicApiController, ITransient
|
|
{
|
|
[HttpGet("/houseZone/list")]
|
|
public async Task<dynamic> GetHouseZoneList([FromQuery] HouseZoneInput input)
|
|
{
|
|
var areaCode = input.AreaCode.Substring(0, 9);
|
|
var _sysOrgRep = Db.GetRepository<SysOrg>();
|
|
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();
|
|
}
|
|
}
|
|
}
|