fixup accounting api hard decepdnecy
This commit is contained in:
parent
6477b79086
commit
f0662ee1d9
|
|
@ -1,6 +1,6 @@
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore.Internal;
|
using Microsoft.EntityFrameworkCore.Internal;
|
||||||
using NejAccountingAPI.Models;
|
using NejCommon.Models;
|
||||||
|
|
||||||
namespace AutoMapProperty;
|
namespace AutoMapProperty;
|
||||||
|
|
||||||
|
|
@ -8,13 +8,13 @@ public class AutoMapPropertyUtils
|
||||||
{
|
{
|
||||||
public static T Create<T>(IServiceProvider provider) where T : class
|
public static T Create<T>(IServiceProvider provider) where T : class
|
||||||
{
|
{
|
||||||
var appDb = provider.GetRequiredService<AppDbContext>();
|
var appDb = provider.GetRequiredService<CommonDbContext>();
|
||||||
|
|
||||||
return appDb.Create<T>();
|
return appDb.Create<T>();
|
||||||
}
|
}
|
||||||
public static T Create<T, TParent>(IServiceProvider provider, TParent parent, string name) where T : class, new() where TParent : class
|
public static T Create<T, TParent>(IServiceProvider provider, TParent parent, string name) where T : class, new() where TParent : class
|
||||||
{
|
{
|
||||||
var appDb = provider.GetRequiredService<AppDbContext>();
|
var appDb = provider.GetRequiredService<CommonDbContext>();
|
||||||
|
|
||||||
return appDb.Create<T, TParent>(parent, name);
|
return appDb.Create<T, TParent>(parent, name);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Diagnostics.HealthChecks;
|
using Microsoft.Extensions.Diagnostics.HealthChecks;
|
||||||
using NejAccountingAPI.Models;
|
using NejCommon.Models;
|
||||||
|
|
||||||
namespace NejCommon.Utils;
|
namespace NejCommon.Utils;
|
||||||
|
|
||||||
|
|
@ -31,7 +31,7 @@ public class PostgresSqlHealthCheck : IHealthCheck
|
||||||
// Try to get DbContext via DI
|
// Try to get DbContext via DI
|
||||||
using var scope = _serviceProvider.CreateScope();
|
using var scope = _serviceProvider.CreateScope();
|
||||||
var dbContext = scope.ServiceProvider
|
var dbContext = scope.ServiceProvider
|
||||||
.GetRequiredService<AppDbContext>();
|
.GetRequiredService<CommonDbContext>();
|
||||||
|
|
||||||
// Execute simple query to check connectivity
|
// Execute simple query to check connectivity
|
||||||
var canConnect = await dbContext.Database
|
var canConnect = await dbContext.Database
|
||||||
|
|
@ -64,8 +64,7 @@ public class PostgresSqlHealthCheck : IHealthCheck
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test real query to validate permissions
|
// Test real query to validate permissions
|
||||||
var recordCount = await dbContext.ApiKeys
|
//var recordCount = await dbContext.;
|
||||||
.CountAsync(cancellationToken);
|
|
||||||
|
|
||||||
return HealthCheckResult.Healthy(
|
return HealthCheckResult.Healthy(
|
||||||
"PostgreSQL connection is healthy",
|
"PostgreSQL connection is healthy",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user