using Microsoft.AspNetCore.Mvc; namespace Application.Web.Controllers.Pub; /// /// 物品接口 /// [Route("[controller]/[action]")] [ApiController] [Authorize] public class GoodsController : ControllerBase { private readonly IGameGoodsService _goodsService; public GoodsController(IGameGoodsService goodsService) { _goodsService = goodsService; } /// /// 获取物品信息 /// /// 物品ID /// [HttpGet] public async Task 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); int UseState = 0; switch (goodsInfo.code) { case "Pack": UseState = 1; break; } return PoAction.Ok(new { goods = goodsInfo, count, use = UseState }); } }