feat 设备连接注册,sap人事范围,部门
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Dlhis.Basic.Organization.Response;
|
||||
using Dlhis.Basic.Organization.Services;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Dlhis.Basic.Organization.Controllers;
|
||||
@@ -11,4 +13,20 @@ namespace Dlhis.Basic.Organization.Controllers;
|
||||
[ApiController]
|
||||
public class DepartmentsController : ControllerBase
|
||||
{
|
||||
private readonly IDepartmentService _departmentService;
|
||||
|
||||
public DepartmentsController(IDepartmentService departmentService)
|
||||
{
|
||||
_departmentService = departmentService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取部门树
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("tree")]
|
||||
public async Task<List<DepartmentTreeResponse>> GetTreeAsync()
|
||||
{
|
||||
return await _departmentService.GetTreeAsync();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Dlhis.Basic.Organization.Controllers;
|
||||
|
||||
/// <summary>
|
||||
/// 人事范围
|
||||
/// </summary>
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class PersonalScopesController : ControllerBase
|
||||
{
|
||||
}
|
||||
26
Src/Dlhis.Basic/Organization/Controllers/WerksController.cs
Normal file
26
Src/Dlhis.Basic/Organization/Controllers/WerksController.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using Dlhis.Basic.Organization.Response;
|
||||
using Dlhis.Basic.Organization.Services;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Dlhis.Basic.Organization.Controllers;
|
||||
|
||||
/// <summary>
|
||||
/// 人事范围
|
||||
/// </summary>
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class WerksController : ControllerBase
|
||||
{
|
||||
private readonly IWerkService _werkService;
|
||||
|
||||
public WerksController(IWerkService werkService)
|
||||
{
|
||||
_werkService = werkService;
|
||||
}
|
||||
|
||||
[HttpGet("list")]
|
||||
public async Task<List<WerkResponse>> GetListAsync()
|
||||
{
|
||||
return await _werkService.GetListAsync();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using SqlSugar;
|
||||
|
||||
namespace Dlhis.Basic.Organization.Response;
|
||||
|
||||
public class DepartmentTreeResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// 部门号
|
||||
/// </summary>
|
||||
public string Code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 部门名称
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 下级部门
|
||||
/// </summary>
|
||||
public List<DepartmentTreeResponse> Next { get; set; }
|
||||
}
|
||||
23
Src/Dlhis.Basic/Organization/Response/WerkResponse.cs
Normal file
23
Src/Dlhis.Basic/Organization/Response/WerkResponse.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using SqlSugar;
|
||||
|
||||
namespace Dlhis.Basic.Organization.Response;
|
||||
|
||||
public class WerkResponse
|
||||
{
|
||||
public long Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 代号
|
||||
/// </summary>
|
||||
public string Code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 名称
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否可见
|
||||
/// </summary>
|
||||
public bool Visible { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
using Dlhis.Basic.Organization.Response;
|
||||
|
||||
namespace Dlhis.Basic.Organization.Services;
|
||||
|
||||
public interface IDepartmentService : IScopeDependency
|
||||
{
|
||||
Task<List<DepartmentTreeResponse>> GetTreeAsync();
|
||||
}
|
||||
8
Src/Dlhis.Basic/Organization/Services/IWerkService.cs
Normal file
8
Src/Dlhis.Basic/Organization/Services/IWerkService.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
using Dlhis.Basic.Organization.Response;
|
||||
|
||||
namespace Dlhis.Basic.Organization.Services;
|
||||
|
||||
public interface IWerkService : IScopeDependency
|
||||
{
|
||||
Task<List<WerkResponse>> GetListAsync();
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
using Dlhis.Basic.Organization.Response;
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
using Kurisu.SqlSugar.Services;
|
||||
using Mapster;
|
||||
|
||||
namespace Dlhis.Basic.Organization.Services.Implements;
|
||||
|
||||
public class DepartmentService : IDepartmentService
|
||||
{
|
||||
private readonly IDbContext _dbContext;
|
||||
|
||||
public DepartmentService(IDbContext dbContext)
|
||||
{
|
||||
_dbContext = dbContext;
|
||||
}
|
||||
|
||||
public async Task<List<DepartmentTreeResponse>> GetTreeAsync()
|
||||
{
|
||||
var departments = await _dbContext.Queryable<DepartmentEntity>().ToListAsync();
|
||||
var tops = departments.Where(x => x.PCode.IsEmpty()).Adapt<List<DepartmentTreeResponse>>();
|
||||
|
||||
tops.ForEach(x =>
|
||||
{
|
||||
RecursionGetNext(x, departments);
|
||||
});
|
||||
|
||||
return tops;
|
||||
}
|
||||
|
||||
|
||||
private void RecursionGetNext(DepartmentTreeResponse current, List<DepartmentEntity> departments)
|
||||
{
|
||||
var next = departments.Where(x => x.PCode == current.Code).ToList();
|
||||
current.Next = next.Adapt<List<DepartmentTreeResponse>>();
|
||||
foreach (var item in next)
|
||||
{
|
||||
RecursionGetNext(item.Adapt<DepartmentTreeResponse>(), departments);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using Dlhis.Basic.Organization.Response;
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
using Kurisu.SqlSugar.Services;
|
||||
|
||||
namespace Dlhis.Basic.Organization.Services.Implements;
|
||||
|
||||
public class WerkService : IWerkService
|
||||
{
|
||||
private readonly IDbContext _dbContext;
|
||||
|
||||
public WerkService(IDbContext dbContext)
|
||||
{
|
||||
_dbContext = dbContext;
|
||||
}
|
||||
|
||||
public async Task<List<WerkResponse>> GetListAsync()
|
||||
{
|
||||
return await _dbContext.Queryable<WerkEntity>()
|
||||
.Select<WerkResponse>()
|
||||
.ToListAsync();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user