Browse Source

单位分级查询

master
wxd 2 years ago
parent
commit
f845a4cc14
  1. 39
      src/Shentun.Peis.Application.Contracts/CustomerOrgs/CustomerOrgBaseDto.cs
  2. 11
      src/Shentun.Peis.Application.Contracts/CustomerOrgs/ParentIdInputDto.cs
  3. 32
      src/Shentun.Peis.Application/CustomerOrgs/CustomerOrgAppService.cs

39
src/Shentun.Peis.Application.Contracts/CustomerOrgs/CustomerOrgBaseDto.cs

@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Shentun.Peis.CustomerOrgs
{
public class CustomerOrgBaseDto
{
//单位Id
public Guid Id { get; set; }
//单位名称
public string DisplayName { get; set; }
//父节点Id
public Guid? ParentId { get; set; }
/// <summary>
/// 短名称
/// </summary>
public string ShortName { get; set; }
/// <summary>
/// 单位编码
/// </summary>
public string CustomerOrgCode { get; set; }
/// <summary>
/// 拼音简码
/// </summary>
public string SimpleCode { get; set; }
public int DisplayOrder { get; set; }
/// <summary>
/// 是否有下级
/// </summary>
public char IsChild { get; set; }
}
}

11
src/Shentun.Peis.Application.Contracts/CustomerOrgs/ParentIdInputDto.cs

@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Shentun.Peis.CustomerOrgs
{
public class ParentIdInputDto
{
public Guid? ParentId { get; set; }
}
}

32
src/Shentun.Peis.Application/CustomerOrgs/CustomerOrgAppService.cs

@ -1,6 +1,7 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Caching.Memory;
using NPOI.POIFS.Properties;
using Shentun.Peis.CustomerOrgRegisters;
using Shentun.Peis.Enums;
using Shentun.Peis.HelperDto;
@ -271,6 +272,37 @@ namespace Shentun.Peis.CustomerOrgs
return dataList.OrderBy(o => o.DisplayOrder).ToList();
}
/// <summary>
/// 根据父ID获取单位列表 分级获取
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("api/app/CustomerOrg/GetCustomerOrgByParentId")]
public async Task<List<CustomerOrgBaseDto>> GetCustomerOrgByParentIdAsync(ParentIdInputDto input)
{
var parentIds = (await Repository.GetQueryableAsync()).Where(m => m.ParentId != null).Select(s => s.ParentId).ToList();
var query = await Repository.GetQueryableAsync();
query = query.Where(m => m.ParentId == input.ParentId);
var entListDto = query.ToList().Select(s => new CustomerOrgBaseDto
{
CustomerOrgCode = s.CustomerOrgCode,
ParentId = s.ParentId,
DisplayName = s.DisplayName,
DisplayOrder = s.DisplayOrder,
Id = s.Id,
ShortName = s.ShortName,
SimpleCode = s.SimpleCode,
IsChild = parentIds.Any() && parentIds.Contains(s.Id) ? 'Y' : 'N',
}).OrderBy(o => o.DisplayOrder).ToList();
return entListDto;
}
/// <summary>
/// 获取单位树型结构
/// </summary>

Loading…
Cancel
Save