Files
Kg.SeaTime/Service/Application.Web/Controllers/Pub/GoodsController.cs
2026-06-01 18:49:17 +08:00

39 lines
984 B
C#

using Microsoft.AspNetCore.Mvc;
namespace Application.Web.Controllers.Pub;
/// <summary>
/// 物品接口
/// </summary>
[Route("[controller]/[action]")]
[ApiController]
[Authorize]
public class GoodsController : ControllerBase
{
private readonly IGameGoodsService _goodsService;
public GoodsController(IGameGoodsService goodsService)
{
_goodsService = goodsService;
}
/// <summary>
/// 获取物品信息
/// </summary>
/// <param name="goodsId">物品ID</param>
/// <returns></returns>
[HttpGet]
public async Task<IPoAction> GetGoodsInfo(int goodsId)
{
var goodsInfo = await _goodsService.GetGoodsInfo(goodsId);
if (goodsInfo == null)
{
return PoAction.Message("物品不存在!");
}
string userId = StateHelper.userId;
int count = await _goodsService.GetUserGoodsCount(userId, goodsId);
return PoAction.Ok(new { goods = goodsInfo, count });
}
}