Implement base controller for shared functionality; update existing controllers to inherit from BaseController and adjust user ID handling. Add JWT authentication support and modify item retrieval methods in GameDataController.

This commit is contained in:
2025-02-15 21:57:59 -03:00
parent 6d81ff1564
commit b84599b370
10 changed files with 72 additions and 31 deletions
+15 -5
View File
@@ -3,13 +3,10 @@ using PetCompanion.Repositories;
namespace PetCompanion.Controllers
{
[ApiController]
[Route("api/v1/[controller]")]
public class GameDataController : Controller
public class GameDataController : BaseController
{
private readonly GameItemsRepository gameItemsRepository;
private readonly ILogger<InventoryController> logger;
private readonly Guid userId = Guid.Parse("f5f4b3b3-3b7b-4b7b-8b7b-7b7b7b7b7b7b");
public GameDataController(
ILogger<InventoryController> logger,
@@ -19,7 +16,20 @@ namespace PetCompanion.Controllers
this.gameItemsRepository = gameItemsRepository;
}
[HttpGet("item/icon/{itemId}")]
[HttpGet("item/{itemId}")]
public IActionResult GetItemInfo(int itemId)
{
try
{
return Ok(gameItemsRepository.GetById(itemId));
}
catch (Exception ex)
{
return BadRequest(ex.Message);
}
}
[HttpGet("item/{itemId}/icon")]
public IActionResult GetItemIcon(int itemId)
{
try