124 lines
3.9 KiB
C#
124 lines
3.9 KiB
C#
namespace Application.Web.Controllers.User;
|
|
|
|
/// <summary>
|
|
/// 用户背包信息
|
|
/// </summary>
|
|
[ApiExplorerSettings(GroupName = "User")]
|
|
[Route("User/[controller]/[action]")]
|
|
[ApiController]
|
|
[Authorize]
|
|
public class BagController : ControllerBase
|
|
{
|
|
private readonly IUnitUserWeight _weightService;
|
|
private readonly IGameGoodsService _goodsService;
|
|
private readonly IGameEquService _equService;
|
|
|
|
public BagController(IUnitUserWeight weightService, IGameGoodsService goodsService, IGameEquService equService)
|
|
{
|
|
_weightService = weightService;
|
|
_goodsService = goodsService;
|
|
_equService = equService;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取背包信息
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpGet]
|
|
public async Task<IPoAction> GetUserBagData()
|
|
{
|
|
string userId = StateHelper.userId;
|
|
int onWeight = 0;
|
|
int maxWeight = 0;
|
|
int gold = 0;
|
|
int cowry = 0;
|
|
long copper = 0;
|
|
var userWeight = await _weightService.GetUserWeightInfo(userId);
|
|
onWeight = (int)userWeight.onWeight;
|
|
maxWeight = (int)userWeight.maxWeight;
|
|
|
|
return PoAction.Ok(new { onWeight, maxWeight, cowry, gold, copper });
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取用户道具数据
|
|
/// </summary>
|
|
/// <param name="type"></param>
|
|
/// <param name="type"></param>
|
|
/// <param name="ch"></param>
|
|
/// <param name="page"></param>
|
|
/// <returns></returns>
|
|
[HttpGet]
|
|
public async Task<IPoAction> GetUserBagProp(int type, int ch, string? query, int page)
|
|
{
|
|
RefAsync<int> total = 0;
|
|
string userId = StateHelper.userId;
|
|
if (type == 0)
|
|
{
|
|
int _t = 0;
|
|
switch (ch)
|
|
{
|
|
case 1:
|
|
_t = 1;
|
|
break;
|
|
case 2:
|
|
_t = 2;
|
|
break;
|
|
case 3:
|
|
_t = 3;
|
|
break;
|
|
}
|
|
|
|
var data = await _equService.GetUserEquData(userId, _t, query, page, 10, total);
|
|
return PoAction.Ok(new { data, total.Value });
|
|
}
|
|
else if (type == 1)
|
|
{
|
|
List<string> code = new List<string>() { nameof(GoodsEnum.Code.Drug) };
|
|
var data = await _goodsService.GetUserGoodsData(userId, code, new List<string>(), query, page, 10, total);
|
|
return PoAction.Ok(new { data, total.Value });
|
|
}
|
|
else if (type == 2)
|
|
{
|
|
List<string> code = new List<string>();
|
|
List<string> noCode = new List<string>() { nameof(GoodsEnum.Code.Drug) };
|
|
switch (ch)
|
|
{
|
|
case 1:
|
|
code.Add(nameof(GoodsEnum.Code.Gem));
|
|
break;
|
|
case 2:
|
|
code.Add(nameof(GoodsEnum.Code.Palace));
|
|
break;
|
|
case 3:
|
|
code.Add(nameof(GoodsEnum.Code.Mark));
|
|
break;
|
|
case 4:
|
|
code.Add(nameof(GoodsEnum.Code.Pack));
|
|
break;
|
|
case 5:
|
|
code.Add(nameof(GoodsEnum.Code.Mak));
|
|
break;
|
|
case 6:
|
|
code.Add(nameof(GoodsEnum.Code.Paper));
|
|
break;
|
|
case 7:
|
|
code.Add(nameof(GoodsEnum.Code.Card));
|
|
break;
|
|
case 8:
|
|
code.Add(nameof(GoodsEnum.Code.Cargo));
|
|
break;
|
|
case 9:
|
|
code.Add(nameof(GoodsEnum.Code.Prop));
|
|
break;
|
|
}
|
|
|
|
var data = await _goodsService.GetUserGoodsData(userId, code, noCode, query, page, 10, total);
|
|
return PoAction.Ok(new { data, total.Value });
|
|
}
|
|
else
|
|
{
|
|
return PoAction.Ok(new { data = new List<string>(), total.Value });
|
|
}
|
|
}
|
|
} |