47 lines
1.1 KiB
C#
47 lines
1.1 KiB
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);
|
|
int UseState = 0;
|
|
switch (goodsInfo.code)
|
|
{
|
|
case "Pack":
|
|
UseState = 1;
|
|
break;
|
|
}
|
|
|
|
|
|
return PoAction.Ok(new { goods = goodsInfo, count, use = UseState });
|
|
}
|
|
} |