feat 获取当前人员信息
This commit is contained in:
@@ -78,5 +78,15 @@ public class GainfosController : ControllerBase
|
||||
{
|
||||
await _gainfoService.OnboardingAsync(request);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 当前人员信息
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("current")]
|
||||
public async Task<GainfoCurrentResponse> CurrentUserInfoAsync()
|
||||
{
|
||||
return await _gainfoService.CurrentUserInfoAsync();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ public class DepartmentTreeResponse
|
||||
/// <summary>
|
||||
/// 部门号
|
||||
/// </summary>
|
||||
public string Code { get; set; }
|
||||
public string No { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 部门名称
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace Dlhis.Basic.Organization.Response;
|
||||
|
||||
public class GainfoCurrentMealInfoResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// 余额
|
||||
/// </summary>
|
||||
public decimal Balance { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
using Dlhis.Entity.Basic.Enums;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
|
||||
namespace Dlhis.Basic.Organization.Response;
|
||||
|
||||
public class GainfoCurrentResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// 用户档案号
|
||||
/// </summary>
|
||||
public string UserNo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 用户姓名
|
||||
/// </summary>
|
||||
public string UserName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 性别枚举
|
||||
/// </summary>
|
||||
public GenderEnumType Gender { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 性别描述
|
||||
/// </summary>
|
||||
public string GenderDesc => Gender.GetDescription();
|
||||
|
||||
/// <summary>
|
||||
/// 工号
|
||||
/// </summary>
|
||||
public string UserCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 部门号
|
||||
/// </summary>
|
||||
public string DepartmentNo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 部门名称
|
||||
/// </summary>
|
||||
public string DepartmentName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 出生日期/生日
|
||||
/// </summary>
|
||||
public DateTime Birthday { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 就餐信息
|
||||
/// </summary>
|
||||
public GainfoCurrentMealInfoResponse MealInfo { get; set; }
|
||||
}
|
||||
@@ -16,4 +16,6 @@ public interface IGainfoService : IScopeDependency
|
||||
Task DimissionAsync(GainfoDImissionRequest request);
|
||||
|
||||
Task OnboardingAsync(GainfoDImissionRequest request);
|
||||
|
||||
Task<GainfoCurrentResponse> CurrentUserInfoAsync();
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ public class DepartmentService : IDepartmentService
|
||||
public async Task<List<DepartmentTreeResponse>> GetTreeAsync()
|
||||
{
|
||||
var departments = await _dbContext.Queryable<DepartmentEntity>().ToListAsync();
|
||||
var tops = departments.Where(x => x.PCode.IsEmpty()).Adapt<List<DepartmentTreeResponse>>();
|
||||
var tops = departments.Where(x => x.PNo.IsEmpty()).Adapt<List<DepartmentTreeResponse>>();
|
||||
|
||||
tops.ForEach(x =>
|
||||
{
|
||||
@@ -31,7 +31,7 @@ public class DepartmentService : IDepartmentService
|
||||
|
||||
private void RecursionGetNext(DepartmentTreeResponse current, List<DepartmentEntity> departments)
|
||||
{
|
||||
var next = departments.Where(x => x.PCode == current.Code).ToList();
|
||||
var next = departments.Where(x => x.PNo == current.No).ToList();
|
||||
current.Next = next.Adapt<List<DepartmentTreeResponse>>();
|
||||
foreach (var item in next)
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@ using Dlhis.Entity.Basic.Entity;
|
||||
using Dlhis.Entity.Basic.Enums;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
using Kurisu.Core.User.Abstractions;
|
||||
using Kurisu.SqlSugar.Attributes;
|
||||
using Kurisu.SqlSugar.Extensions;
|
||||
using Kurisu.SqlSugar.Services;
|
||||
@@ -15,11 +16,13 @@ public class GainfoService : IGainfoService
|
||||
{
|
||||
private readonly IGainfoStore _gainfoStore;
|
||||
private readonly IDbContext _dbContext;
|
||||
private readonly ICurrentUser _currentUser;
|
||||
|
||||
public GainfoService(IGainfoStore gainfoStore, IDbContext dbContext)
|
||||
public GainfoService(IGainfoStore gainfoStore, IDbContext dbContext, ICurrentUser currentUser)
|
||||
{
|
||||
_gainfoStore = gainfoStore;
|
||||
_dbContext = dbContext;
|
||||
_currentUser = currentUser;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -112,6 +115,33 @@ public class GainfoService : IGainfoService
|
||||
await _gainfoStore.InsertAsync(gainfo);
|
||||
}
|
||||
|
||||
public async Task<GainfoCurrentResponse> CurrentUserInfoAsync()
|
||||
{
|
||||
var identityId = _currentUser.GetIntSubjectId();
|
||||
|
||||
var gainfo = await _gainfoStore.Queryable(GainfoStatusEnumType.Working)
|
||||
.LeftJoin<DepartmentEntity>((ga, department) => ga.DepartmentNo == department.No)
|
||||
.LeftJoin<CanteenUserEntity>((ga, department, mealUser) => ga.No == mealUser.UserNo)
|
||||
.Where((ga, department) => ga.IdentityUserId == identityId)
|
||||
.Select((ga, department, mealUser) => new GainfoCurrentResponse
|
||||
{
|
||||
UserNo = ga.No,
|
||||
Birthday = ga.Birthday,
|
||||
DepartmentNo = department.No,
|
||||
DepartmentName = department.Name,
|
||||
Gender = ga.Gender,
|
||||
UserCode = ga.Code,
|
||||
UserName = ga.Name,
|
||||
MealInfo = new GainfoCurrentMealInfoResponse
|
||||
{
|
||||
Balance = mealUser.Balance
|
||||
}
|
||||
})
|
||||
.FirstAsync();
|
||||
|
||||
return gainfo;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------help methods ------------------------------------------------
|
||||
|
||||
@@ -128,26 +158,26 @@ public class GainfoService : IGainfoService
|
||||
}
|
||||
|
||||
var departments = await _dbContext.Queryable<DepartmentEntity>().ToListAsync();
|
||||
var currentNos = departments.Where(x => departmentNos.Contains(x.Code)).ToList();
|
||||
var currentNos = departments.Where(x => departmentNos.Contains(x.No)).ToList();
|
||||
|
||||
foreach (var item in currentNos)
|
||||
{
|
||||
RecursionGetNext(item.Code, departments, departmentNos);
|
||||
RecursionGetNext(item.No, departments, departmentNos);
|
||||
}
|
||||
|
||||
return departmentNos.Distinct().ToList();
|
||||
|
||||
void RecursionGetNext(string currentCode, List<DepartmentEntity> departments, List<string> result)
|
||||
{
|
||||
var next = departments.Where(x => x.PCode == currentCode).ToList();
|
||||
var next = departments.Where(x => x.PNo == currentCode).ToList();
|
||||
foreach (var item in next)
|
||||
{
|
||||
result.Add(item.Code);
|
||||
result.Add(item.No);
|
||||
}
|
||||
|
||||
foreach (var item in next)
|
||||
{
|
||||
RecursionGetNext(item.Code, departments, result);
|
||||
RecursionGetNext(item.No, departments, result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user