68 lines
2.0 KiB
C#
68 lines
2.0 KiB
C#
using Infrastructure.Attribute;
|
|
using Microsoft.AspNetCore.Http;
|
|
using SqlSugar;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using ARW.Model;
|
|
using ARW.Repository;
|
|
using ARW.Repository.Business.Custom.Regions;
|
|
using ARW.Service.Api.IBusinessService.Custom.Regions;
|
|
using ARW.Model.Dto.Api.Custom.Regions;
|
|
using ARW.Model.Models.Business.Custom.Regions;
|
|
using ARW.Model.Vo.Api.Custom.Regions;
|
|
|
|
namespace ARW.Service.Api.BusinessService.Custom.Regions
|
|
{
|
|
/// <summary>
|
|
/// 省市区数据表接口实现类Api
|
|
///
|
|
/// @author admin
|
|
/// @date 2023-06-09
|
|
/// </summary>
|
|
[AppService(ServiceType = typeof(IRegionServiceApi), ServiceLifetime = LifeTime.Transient)]
|
|
public class RegionServiceImplApi : BaseService<Region>, IRegionServiceApi
|
|
{
|
|
private readonly RegionRepository _RegionRepository;
|
|
|
|
public RegionServiceImplApi(RegionRepository RegionRepository)
|
|
{
|
|
this._RegionRepository = RegionRepository;
|
|
}
|
|
|
|
#region Api接口代码
|
|
|
|
|
|
/// <summary>
|
|
/// 查询省市区数据表树形列表(Api)
|
|
/// </summary>
|
|
/// <param name="parm"></param>
|
|
/// <returns></returns>
|
|
public async Task<List<RegionVoApi>> GetRegionTreeListApi(RegionQueryDtoApi parm)
|
|
{
|
|
//开始拼装查询条件d
|
|
var predicate = Expressionable.Create<Region>();
|
|
|
|
var query = _RegionRepository
|
|
.Queryable()
|
|
.Where(predicate.ToExpression())
|
|
.OrderBy(s => s.RegionId, OrderByType.Asc)
|
|
.Select(s => new RegionVoApi
|
|
{
|
|
RegionId = s.RegionId,
|
|
RegionPid = s.RegionPid,
|
|
Label = s.RegionName,
|
|
Value = s.RegionCode,
|
|
});
|
|
|
|
return await query.ToTreeAsync(it => it.Children, it => it.RegionPid, 0);
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
}
|
|
}
|