Recipe fix
This commit is contained in:
+34
-1
@@ -3,6 +3,7 @@ using Microsoft.EntityFrameworkCore;
|
||||
using DataServer.Data;
|
||||
using DataServer.Data.Entities;
|
||||
using Server.Services.Auth;
|
||||
using Server.Game.Dungeon;
|
||||
|
||||
namespace Server.Api;
|
||||
|
||||
@@ -15,11 +16,43 @@ public class AdminController : ControllerBase
|
||||
{
|
||||
private readonly GameDbContext _db;
|
||||
private readonly IAdminAuthService _adminAuth;
|
||||
private readonly CraftingHandler? _craftingHandler;
|
||||
|
||||
public AdminController(GameDbContext db, IAdminAuthService adminAuth)
|
||||
public AdminController(GameDbContext db, IAdminAuthService adminAuth, CraftingHandler? craftingHandler = null)
|
||||
{
|
||||
_db = db;
|
||||
_adminAuth = adminAuth;
|
||||
_craftingHandler = craftingHandler;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Refresh server caches (recipes, items, etc.)
|
||||
/// </summary>
|
||||
[HttpPost("cache/refresh")]
|
||||
public async Task<IActionResult> RefreshCache([FromQuery] string? type = null)
|
||||
{
|
||||
var auth = await ValidateAdminAsync(AccountRole.Admin);
|
||||
if (!auth.IsAuthorized) return Unauthorized(new { error = auth.Error });
|
||||
|
||||
var refreshed = new List<string>();
|
||||
|
||||
// Refresh recipe cache
|
||||
if (type == null || type.Equals("recipes", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
if (_craftingHandler != null)
|
||||
{
|
||||
await _craftingHandler.RefreshRecipeCacheAsync();
|
||||
refreshed.Add("recipes");
|
||||
}
|
||||
}
|
||||
|
||||
// Add more cache types here as needed (items, mobs, etc.)
|
||||
|
||||
return Ok(new {
|
||||
message = "Cache refreshed",
|
||||
refreshed,
|
||||
timestamp = DateTime.UtcNow
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user