feat 组织架构

This commit is contained in:
2024-04-23 19:10:23 +08:00
parent cc273a4693
commit 9885c8d9ae
6 changed files with 93 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
using Dlhis.External.OpenApi.Response;
using Dlhis.External.OpenApi.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
namespace Dlhis.External.OpenApi.Controllers;
[Authorize]
[Route("api/[controller]")]
[ApiController]
public class DepartmentsController : ControllerBase
{
private readonly IGainfoService _gainfoService;
public DepartmentsController(IGainfoService gainfoService)
{
_gainfoService = gainfoService;
}
/// <summary>
/// 获取所有部门信息
/// </summary>
/// <returns></returns>
[HttpGet("all")]
public async Task<List<DepartmentOpenResponse>> GetDepartmentsAsync()
{
return await _gainfoService.GetDepartmentsAsync();
}
}

View File

@@ -0,0 +1,18 @@
using SqlSugar;
namespace Dlhis.External.OpenApi.Response;
public class DepartmentOpenResponse
{
public string No { get; set; }
/// <summary>
/// 上级部门号
/// </summary>
public string PNo { get; set; }
/// <summary>
/// 部门名称
/// </summary>
public string Name { get; set; }
}

View File

@@ -5,4 +5,6 @@ namespace Dlhis.External.OpenApi.Services;
public interface IGainfoService : IScopeDependency
{
Task<List<GainfoOpenResponse>> GetAllGainfosAsync();
Task<List<DepartmentOpenResponse>> GetDepartmentsAsync();
}

View File

@@ -18,4 +18,11 @@ public class GainfoService : IGainfoService
var data = await _redisCache.ListRangeAsync("gainfo:shanxi");
return data.Select(x => x.ToString().ToObject<GainfoOpenResponse>()).ToList();
}
public async Task<List<DepartmentOpenResponse>> GetDepartmentsAsync()
{
var departmentKey = "department:all";
var data = await _redisCache.ListRangeAsync(departmentKey);
return data.Select(x => x.ToString().ToObject<DepartmentOpenResponse>()).ToList();
}
}