Files
Kg.SeaTime/Service/Application.Web/Controllers/Pub/EquController.cs
2026-06-09 17:51:12 +08:00

136 lines
3.6 KiB
C#

using Microsoft.AspNetCore.Mvc;
namespace Application.Web.Controllers.Pub;
/// <summary>
/// 装备接口
/// </summary>
[Route("[controller]/[action]")]
[ApiController]
[Authorize]
public class EquController : ControllerBase
{
private readonly IGameEquService _equService;
public EquController(IGameEquService equService)
{
_equService = equService;
}
/// <summary>
/// 获取装备信息
/// </summary>
/// <param name="equId"></param>
/// <param name="ueId"></param>
/// <returns></returns>
[HttpGet]
public async Task<IPoAction> GetEquInfo(int? equId, string? ueId)
{
game_equ equInfo = new game_equ();
game_equ_suit suit = new game_equ_suit();
unit_user_equ ueInfo = new unit_user_equ();
UserModel user = new UserModel();
if (equId != 0)
{
equInfo = await _equService.GetEquInfo((int)equId);
if (equInfo == null)
{
return PoAction.Message("装备不存在!");
}
if (equInfo.suitCode != "0" && !string.IsNullOrEmpty(equInfo.suitCode))
{
suit = await _equService.GetEuqSuitInfo(equInfo.suitCode);
}
}
else
{
ueInfo = await _equService.GetUserEquInfo(ueId);
if (ueInfo == null)
{
return PoAction.Message("装备不存在!");
}
equInfo = await _equService.GetEquInfo((int)ueInfo.equId);
if (equInfo == null)
{
return PoAction.Message("装备不存在!");
}
if (ueInfo.suitCode != "0" && !string.IsNullOrEmpty(ueInfo.suitCode))
{
suit = await _equService.GetEuqSuitInfo(ueInfo.suitCode);
}
user = await UserModelTool.GetUserView(ueInfo.owerId);
}
return PoAction.Ok(new { equ = equInfo, suit, equData = ueInfo,user });
}
/// <summary>
/// 获取套装详情
/// </summary>
/// <param name="suitCode"></param>
/// <returns></returns>
[HttpGet]
public async Task<IPoAction> GetEquSuitInfo(string suitCode)
{
var data = await _equService.GetEuqSuitInfo(suitCode);
if (data == null)
{
return PoAction.Message("套装不存在!");
}
return PoAction.Ok(data);
}
/// <summary>
/// 绑定操作
/// </summary>
/// <param name="ueId"></param>
/// <returns></returns>
[HttpGet]
public async Task<IPoAction> EquLock(string ueId)
{
var userId = StateHelper.userId;
var equInfo = await _equService.GetUserEquInfo(ueId);
if (equInfo == null)
{
return PoAction.Message("装备不存在!");
}
if (equInfo.userId != userId)
{
return PoAction.Message("装备不存在!");
}
if (equInfo.isAppr == 0)
{
return PoAction.Message("装备未鉴定!");
}
equInfo.isLock = equInfo.isLock == 0 ? 1 : 0;
bool result = await _equService.UpdateUserEquInfo(equInfo);
if (result)
{
string msg = equInfo.isLock == 1 ? "成功绑定装备!" : "成功解除装备绑定!";
return PoAction.Ok(true, msg);
}
else
{
return PoAction.Message("操作失败,请稍后尝试!");
}
}
/// <summary>
/// 穿/卸装备
/// </summary>
/// <param name="ueId"></param>
/// <returns></returns>
[HttpGet]
public async Task<IPoAction> DownOrUpEqu(string ueId)
{
return PoAction.Ok(true);
}
}