feat middleHealthz
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
public class BusinessPlaceShiftTinyResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// 无用字段,暂时不删除 //todo
|
||||
/// 无用字段,暂时不删除
|
||||
/// </summary>
|
||||
public string CustomCode { get; set; }
|
||||
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
using Dlhis.Basic.Common.SysData.Request;
|
||||
using Dlhis.Basic.Common.SysData.Services;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Dlhis.Basic.Common.SysData.Controller;
|
||||
|
||||
[Authorize]
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class MiddlesController : ControllerBase
|
||||
{
|
||||
private readonly IHealthCheckService _healthCheckService;
|
||||
|
||||
public MiddlesController(IHealthCheckService healthCheckService)
|
||||
{
|
||||
_healthCheckService = healthCheckService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 健康检查
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
[HttpPost("healthz")]
|
||||
public async Task CheckAsync(MiddleHealthCheckRequest request)
|
||||
{
|
||||
await _healthCheckService.CheckAsync(request.Factories);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Dlhis.Basic.Common.SysData.Request;
|
||||
|
||||
public class HealthCheckRequest
|
||||
{
|
||||
[MinLength(1)]
|
||||
public List<string> Factories { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace Dlhis.Basic.Common.SysData.Request;
|
||||
|
||||
public class MiddleHealthCheckRequest
|
||||
{
|
||||
public List<string> Factories { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace Dlhis.Basic.Common.SysData.Services;
|
||||
|
||||
public interface IHealthCheckService : IScopeDependency
|
||||
{
|
||||
Task CheckAsync(List<string> factories);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace Dlhis.Basic.Common.SysData.Services.Implements;
|
||||
|
||||
public class HealthCheckService : IHealthCheckService
|
||||
{
|
||||
public async Task CheckAsync(List<string> factories)
|
||||
{
|
||||
//todo 状态显示
|
||||
await Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
using System.Reflection;
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
using Dlhis.Entity.Canteen.Entities;
|
||||
using Dlhis.Entity.Canteen.Enums;
|
||||
using Kurisu.AspNetCore;
|
||||
using Kurisu.AspNetCore.DataAccess.Entity;
|
||||
using Kurisu.AspNetCore.DataAccess.SqlSugar.Services;
|
||||
@@ -34,17 +36,34 @@ public class SysDataService : ISysDataService
|
||||
switch (tableName)
|
||||
{
|
||||
case "Gainfo":
|
||||
//sql = $"select * from Gainfo where factory = '{factory}'";
|
||||
return await _dbContext.Queryable<GainfoEntity>().Where(x => x.Factory == factory).Select(x => (object)x).ToListAsync();
|
||||
case "GainfoMeal":
|
||||
{
|
||||
var factories = await GetWalletFactoriesAsync(factory);
|
||||
|
||||
var codes = await _dbContext.Queryable<GainfoEntity>().Where(x => x.Factory == factory).Select(x => x.Code).ToListAsync();
|
||||
// return await _dbContext.Queryable<BalanceRecordEntity>()
|
||||
// .Where(x => codes.Contains(x.UserCode) && factories.Contains(x.TenantId))
|
||||
// .Where(x => x.Source != BalanceRecordSourceEnumType.EMealVoucher)
|
||||
// .GroupBy(x => x.UserCode)
|
||||
// .Select(x => new
|
||||
// {
|
||||
// x.UserCode,
|
||||
// Balance = SqlFunc.AggregateSum(x.Amount)
|
||||
// })
|
||||
// .ToListAsync();
|
||||
return null;
|
||||
//todo 余额
|
||||
///return await _dbContext.Queryable<GainfoMealEntity>().Where(x => codes.Contains(x.UserCode)).Select(x => (object)x).ToListAsync();
|
||||
}
|
||||
default:
|
||||
return await _dbContext.Client.SqlQueryable<object>(sql).ToListAsync();
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<List<string>> GetWalletFactoriesAsync(string factory)
|
||||
{
|
||||
var wallets = await _dbContext.Queryable<WalletEntity>().ToListAsync();
|
||||
var code = wallets.First(x => x.Factory == factory).Code;
|
||||
|
||||
return wallets.Where(x => x.Code == code).Select(x => x.Factory).ToList();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user