1233
This commit is contained in:
39
Service/Application.Web/Controllers/Pub/GoodsController.cs
Normal file
39
Service/Application.Web/Controllers/Pub/GoodsController.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
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 });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user