This commit is contained in:
cheche
2024-01-10 16:24:00 +08:00
58 changed files with 766 additions and 1181 deletions

View File

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

View File

@@ -1,5 +1,6 @@
using Dlhis.Basic.Organization.Response;
using Dlhis.Basic.Organization.Services;
using Dlhis.User.Api.Response;
using Kurisu.AspNetCore.MVC;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
@@ -27,7 +28,7 @@ public class WerksController : ControllerBase
/// </summary>
/// <returns></returns>
[HttpGet("list")]
public async Task<List<WerkResponse>> GetListAsync()
public async Task<List<TenantResponse>> GetListAsync()
{
return await _werkService.GetListAsync();
}
@@ -37,7 +38,7 @@ public class WerksController : ControllerBase
/// </summary>
/// <returns></returns>
[HttpGet("current")]
public async Task<WerkResponse> GetCurrentAsync()
public async Task<TenantResponse> GetCurrentAsync()
{
return await _werkService.GetCurrentAsync();
}

View File

@@ -5,7 +5,7 @@ public class DepartmentTreeResponse
/// <summary>
/// 部门号
/// </summary>
public string Code { get; set; }
public string No { get; set; }
/// <summary>
/// 部门名称

View File

@@ -0,0 +1,9 @@
namespace Dlhis.Basic.Organization.Response;
public class GainfoCurrentMealInfoResponse
{
/// <summary>
/// 余额
/// </summary>
public decimal Balance { get; set; }
}

View File

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

View File

@@ -1,23 +0,0 @@
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

@@ -16,4 +16,6 @@ public interface IGainfoService : IScopeDependency
Task DimissionAsync(GainfoDImissionRequest request);
Task OnboardingAsync(GainfoDImissionRequest request);
Task<GainfoCurrentResponse> CurrentUserInfoAsync();
}

View File

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

View File

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

View File

@@ -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>
@@ -32,9 +35,9 @@ public class GainfoService : IGainfoService
request.DepartmentNos = await GetRecursionDepartmentNosAsync(request.DepartmentNos);
var page = await _gainfoStore.Queryable(request.Status)
.WhereIF(request.DepartmentNos.Any(), gainfo => request.DepartmentNos.Contains(gainfo.DepartmentNo))
.WhereIF(request.DepartmentNos.IsPresent(), gainfo => request.DepartmentNos.Contains(gainfo.DepartmentNo))
.Select<GainfoPageResponse>()
.ToPageListAsync(request);
.ToPageListAsync(request);
return page;
}
@@ -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);
}
}
}

View File

@@ -1,35 +1,39 @@
/*using Dlhis.Basic.Organization.Response;
using Dlhis.Entity.Basic.Entity;
using Dlhis.User.Api;
using Dlhis.User.Api.Response;
using Kurisu.AspNetCore.Utils.Extensions;
using Kurisu.Core.Result;
using Kurisu.Core.User.Abstractions;
using Kurisu.SqlSugar.Services;
namespace Dlhis.Basic.Organization.Services.Implements;
public class WerkService : IWerkService
{
private readonly IDbContext _dbContext;
private readonly ICurrentUser _currentUser;
private readonly ITenantApi _tenantApi;
public WerkService(IDbContext dbContext, ICurrentUser currentUser)
public WerkService(ICurrentUser currentUser, ITenantApi tenantApi)
{
_dbContext = dbContext;
_currentUser = currentUser;
_tenantApi = tenantApi;
}
public async Task<List<WerkResponse>> GetListAsync()
public async Task<List<TenantResponse>> GetListAsync()
{
return await _dbContext.Queryable<WerkEntity>()
.Select<WerkResponse>()
.ToListAsync();
var tenantResult = await _tenantApi.GetTenantsAsync();
(tenantResult.Code == ApiStateCode.Success).ThrowIfFalse(tenantResult.Msg);
var tenants = tenantResult.Data;
return tenants;
}
public async Task<WerkResponse> GetCurrentAsync()
public async Task<TenantResponse> GetCurrentAsync()
{
var tenant = _currentUser.GetStringTenantId();
return await _dbContext.Queryable<WerkEntity>()
.Where(x => x.Code == tenant)
.Select<WerkResponse>()
.FirstAsync();
var tenantResult = await _tenantApi.GetTenantsAsync();
(tenantResult.Code == ApiStateCode.Success).ThrowIfFalse(tenantResult.Msg);
var tenants = tenantResult.Data;
return tenants.FirstOrDefault(x => x.Code == tenant);
}
}
*/