feat 设备连接注册,sap人事范围,部门

This commit is contained in:
2023-12-28 16:04:00 +08:00
parent 25f7b3270c
commit d7cf07d940
48 changed files with 633 additions and 65 deletions

View File

@@ -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();
}
}

View File

@@ -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
{
}

View 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();
}
}

View File

@@ -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; }
}

View 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; }
}

View File

@@ -0,0 +1,8 @@
using Dlhis.Basic.Organization.Response;
namespace Dlhis.Basic.Organization.Services;
public interface IDepartmentService : IScopeDependency
{
Task<List<DepartmentTreeResponse>> GetTreeAsync();
}

View File

@@ -0,0 +1,8 @@
using Dlhis.Basic.Organization.Response;
namespace Dlhis.Basic.Organization.Services;
public interface IWerkService : IScopeDependency
{
Task<List<WerkResponse>> GetListAsync();
}

View File

@@ -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);
}
}
}

View File

@@ -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();
}
}