feat 组织架构
This commit is contained in:
@@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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; }
|
||||||
|
}
|
||||||
@@ -5,4 +5,6 @@ namespace Dlhis.External.OpenApi.Services;
|
|||||||
public interface IGainfoService : IScopeDependency
|
public interface IGainfoService : IScopeDependency
|
||||||
{
|
{
|
||||||
Task<List<GainfoOpenResponse>> GetAllGainfosAsync();
|
Task<List<GainfoOpenResponse>> GetAllGainfosAsync();
|
||||||
|
|
||||||
|
Task<List<DepartmentOpenResponse>> GetDepartmentsAsync();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,4 +18,11 @@ public class GainfoService : IGainfoService
|
|||||||
var data = await _redisCache.ListRangeAsync("gainfo:shanxi");
|
var data = await _redisCache.ListRangeAsync("gainfo:shanxi");
|
||||||
return data.Select(x => x.ToString().ToObject<GainfoOpenResponse>()).ToList();
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
18
Src/Dlhis.ScheduledTask/Common/Dto/DepartmentOpenResponse.cs
Normal file
18
Src/Dlhis.ScheduledTask/Common/Dto/DepartmentOpenResponse.cs
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
using SqlSugar;
|
||||||
|
|
||||||
|
namespace Dlhis.ScheduledTask.Common.Dto;
|
||||||
|
|
||||||
|
public class DepartmentOpenResponse
|
||||||
|
{
|
||||||
|
public string No { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 上级部门号
|
||||||
|
/// </summary>
|
||||||
|
public string PNo { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 部门名称
|
||||||
|
/// </summary>
|
||||||
|
public string Name { get; set; }
|
||||||
|
}
|
||||||
@@ -62,5 +62,23 @@ public class SyncShanxiGainfoJob : BaseJob
|
|||||||
{
|
{
|
||||||
await _redisCache.ListLeftPushAsync(key, item);
|
await _redisCache.ListLeftPushAsync(key, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var departmentKey = "department:all";
|
||||||
|
await _redisCache.KeyDeleteAsync(departmentKey);
|
||||||
|
|
||||||
|
var departments = await DbContext.Queryable<DepartmentEntity>()
|
||||||
|
.Select((x) => new DepartmentOpenResponse
|
||||||
|
{
|
||||||
|
Name = x.Name,
|
||||||
|
No = x.No,
|
||||||
|
PNo = x.PNo,
|
||||||
|
})
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
foreach (var item in departments)
|
||||||
|
{
|
||||||
|
await _redisCache.ListLeftPushAsync(departmentKey, item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user