update 完成选房

This commit is contained in:
2021-05-30 20:28:09 +08:00
parent 0f44438d78
commit ccd914fb81
30 changed files with 650 additions and 43 deletions

View File

@@ -6,6 +6,7 @@ using Furion.FriendlyException;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;
@@ -17,13 +18,28 @@ namespace Ewide.Application.Service
[ApiDescriptionSettings(Name = "HouseZone", Order = 180)]
public class HouseZoneService : IHouseZoneService, IDynamicApiController, ITransient
{
private readonly IRepository<SysOrg> _sysOrgRep;
private readonly IRepository<SysEmp> _sysEmpRep;
public HouseZoneService(
IRepository<SysOrg> sysOrgRep,
IRepository<SysEmp> sysEmpRep
)
{
_sysOrgRep = sysOrgRep;
_sysEmpRep = sysEmpRep;
}
/// <summary>
/// 获取片区列表
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[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("街道编码错误");
if (road == null) throw Oops.Oh("未在组织机构中配置街道");
return await _sysOrgRep.DetachedEntities
.Where(p => p.Pid == road.Id)
.Where(p => p.Type == (int)OrgType.)
@@ -35,5 +51,20 @@ namespace Ewide.Application.Service
})
.ToListAsync();
}
/// <summary>
/// 根据用户Id获取所在片区的Id
/// </summary>
/// <param name="userId"></param>
/// <returns></returns>
[HttpGet("houseZone/getByUser")]
public async Task<string> GetZoneByUser([FromQuery][Required(ErrorMessage = "用户Id不能为空")] string userId)
{
var data = await _sysEmpRep.DetachedEntities.FirstOrDefaultAsync(p => p.Id == userId);
if(data == null) throw Oops.Oh("用户不在组织机构中");
var org = await _sysOrgRep.DetachedEntities.FirstOrDefaultAsync(p => p.Id == data.OrgId && p.Type == (int)OrgType.);
if(org == null) throw Oops.Oh("用户不在片区中");
return org.Id;
}
}
}