This commit is contained in:
Putoo
2026-06-01 18:49:17 +08:00
parent 8a5b6d31ca
commit eb81a1c381
50 changed files with 1367 additions and 59 deletions

View File

@@ -214,4 +214,72 @@ public class ChatController : ControllerBase
return PoAction.Message("操作失败,请稍后尝试!");
}
}
/// <summary>
/// 封禁ID
/// </summary>
/// <param name="chatId"></param>
/// <returns></returns>
[HttpGet]
public async Task<IPoAction> BlackUser(string chatId)
{
var chatInfo = await _chatService.GetChatInfo(chatId);
if (chatInfo == null)
{
return PoAction.Message("发言不存在!");
}
if (chatInfo.state != 1)
{
return PoAction.Message("发言不存在!");
}
if (chatInfo.areaId != StateHelper.areaId)
{
return PoAction.Message("发言不存在!");
}
if (chatInfo.userId == StateHelper.userId)
{
return PoAction.Message("不能封禁自己!");
}
bool IsOp = false;
string userId = StateHelper.userId;
int chatRole = await _userService.GetUserConfigInfo(userId, nameof(UserEnum.ConfigCode.ChatRole));
if ((chatInfo.code == nameof(GameChatEnum.Code.Public) || chatInfo.code == nameof(GameChatEnum.Code.Region)) &&
chatRole > 0)
{
IsOp = true;
}
else if (chatRole > 1 && chatInfo.code == nameof(GameChatEnum.Code.Dress))
{
IsOp = true;
}
if (IsOp == false)
{
return PoAction.Message("无权限!");
}
var otConfig = await _userService.GetUserConfigInfo(chatInfo.userId);
if (otConfig.chatRole < 0)
{
return PoAction.Message("Ta已被禁言,无需封禁!");
}
if (otConfig.chatRole != 0)
{
return PoAction.Message("您无权封禁!");
}
if (await _userService.UpdateUserConfigInfo(chatInfo.userId, nameof(UserEnum.ConfigCode.ChatRole), -1))
{
return PoAction.Ok(true);
}
else
{
return PoAction.Message("操作失败,请稍后尝试!");
}
}
}

View File

@@ -110,7 +110,7 @@ public class StoreController : ControllerBase
//此处需要计算负重
var needWeight = await GameTool.GetPropWeight(storeInfo.type, storeInfo.parameter);
needWeight = needWeight * parms.count;
if (await _weightService.CheakUserWeight(userId, needWeight) == false)
if (await _weightService.CheckUserWeight(userId, needWeight) == false)
{
return PoAction.Message("负重不足!");
}

View File

@@ -0,0 +1,71 @@
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 (equInfo.suitCode != "0" && !string.IsNullOrEmpty(equInfo.suitCode))
{
suit = await _equService.GetEuqSuitInfo(equInfo.suitCode);
}
user = await UserModelTool.GetUserView(ueInfo.owerId);
}
return PoAction.Ok(new { equ = equInfo, suit, equData = ueInfo,user });
}
}

View 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 });
}
}

View File

@@ -115,6 +115,12 @@ public class MessageController : ControllerBase
string userId = StateHelper.userId;
int areaId = StateHelper.areaId;
var msgRole = await _userService.GetUserConfigInfo(userId, nameof(UserEnum.ConfigCode.MsgRole));
if (msgRole != 1)
{
return PoAction.Message("消息权限已被封禁!");
}
var toUser = await _userService.GetUserInfoByUserNo(parms.no.ToString());
if (toUser == null)
{

View File

@@ -0,0 +1,203 @@
using Microsoft.AspNetCore.Mvc;
namespace Application.Web.Controllers.Pub;
/// <summary>
/// 恢复接口
/// </summary>
[Route("[controller]/[action]")]
[ApiController]
[Authorize]
public class RecoverController : ControllerBase
{
private readonly IUnitUserAttrService _attrService;
private readonly IGameMapService _mapService;
public RecoverController(IUnitUserAttrService attrService, IGameMapService mapService)
{
_attrService = attrService;
_mapService = mapService;
}
/// <summary>
/// 恢复体力
/// </summary>
/// <param name="npcId"></param>
/// <returns></returns>
[HttpGet]
public async Task<IPoAction> RecoverBlood(int npcId)
{
string userId = StateHelper.userId;
#region NPC验证
var npcInfo = await _mapService.GetNpcInfo(npcId);
if (npcInfo == null)
{
return PoAction.Message("Npc不存在!");
}
if (npcInfo.status != 1)
{
return PoAction.Message("Npc不存在!");
}
if (!npcInfo.bus.Any(it => it.code == nameof(GameEnum.NpcBusCode.RetBlood)))
{
return PoAction.Message("业务不可用!");
}
var onMap = await _mapService.GetUserOnMapId(userId);
if (npcInfo.mapId != onMap)
{
return PoAction.Message("Npc不存在!");
}
#endregion
var userAttr = await _attrService.GetUserAttrModel(userId);
if (userAttr.blood >= userAttr.upBlood)
{
return PoAction.Message("体力满满,无需恢复!");
}
bool result = await _attrService.UpdateUserBlood(userId, 2, userAttr.upBlood, true);
if (result)
{
return PoAction.Ok(true);
}
else
{
return PoAction.Message("恢复失败,请稍后尝试!");
}
}
/// <summary>
/// 恢复士气
/// </summary>
/// <param name="npcId"></param>
/// <returns></returns>
[HttpGet]
public async Task<IPoAction> RecoverMorale(int npcId)
{
string userId = StateHelper.userId;
#region NPC验证
var npcInfo = await _mapService.GetNpcInfo(npcId);
if (npcInfo == null)
{
return PoAction.Message("Npc不存在!");
}
if (npcInfo.status != 1)
{
return PoAction.Message("Npc不存在!");
}
if (!npcInfo.bus.Any(it => it.code == nameof(GameEnum.NpcBusCode.RetMorale)))
{
return PoAction.Message("业务不可用!");
}
var onMap = await _mapService.GetUserOnMapId(userId);
if (npcInfo.mapId != onMap)
{
return PoAction.Message("Npc不存在!");
}
#endregion
if (await _attrService.CheackRecoverMorale(userId))
{
return PoAction.Message("今天已恢复过士气啦!");
}
var userAttr = await _attrService.GetUserAttrModel(userId);
if (userAttr.morale >= userAttr.upMorale)
{
return PoAction.Message("士气满满,无需恢复!");
}
bool result = await _attrService.UpdateUserMorale(userId, 2, userAttr.upMorale);
if (result)
{
await _attrService.LockRecoverMorale(userId);
return PoAction.Ok(true);
}
else
{
return PoAction.Message("恢复失败,请稍后尝试!");
}
}
/// <summary>
/// 获取个人活力
/// </summary>
/// <returns></returns>
[HttpGet]
public async Task<IPoAction> GetUserVigour()
{
string userId = StateHelper.userId;
var data = await _attrService.GetUserVigourInfo(userId);
return PoAction.Ok(data);
}
/// <summary>
/// 恢复活力
/// </summary>
/// <param name="npcId"></param>
/// <returns></returns>
[HttpGet]
public async Task<IPoAction> RecoverVigour(int npcId)
{
string userId = StateHelper.userId;
#region NPC验证
var npcInfo = await _mapService.GetNpcInfo(npcId);
if (npcInfo == null)
{
return PoAction.Message("Npc不存在!");
}
if (npcInfo.status != 1)
{
return PoAction.Message("Npc不存在!");
}
if (!npcInfo.bus.Any(it => it.code == nameof(GameEnum.NpcBusCode.RetVigour)))
{
return PoAction.Message("业务不可用!");
}
var onMap = await _mapService.GetUserOnMapId(userId);
if (npcInfo.mapId != onMap)
{
return PoAction.Message("Npc不存在!");
}
#endregion
var data = await _attrService.GetUserVigourInfo(userId);
string time = TimeAssist.GetDateTimeYMDString(0);
if (data.upTime == time)
{
return PoAction.Message("今天已恢复过活力啦!");
}
if (data.vitality >= data.upVitality)
{
return PoAction.Message("活力满满,无需恢复!");
}
bool result = await _attrService.UpdateUserVigour(userId, 2, (long)data.upVitality,time);
if (result)
{
return PoAction.Ok(true);
}
else
{
return PoAction.Message("恢复失败,请稍后尝试!");
}
}
}

View File

@@ -13,11 +13,15 @@ public class SettingController : ControllerBase
{
private readonly IUnitUserService _userService;
private readonly IGameGoodsService _goodsService;
private readonly IGameEquService _equService;
private readonly IUnitUserWeight _weightService;
public SettingController(IUnitUserService userService,IGameGoodsService goodsService)
public SettingController(IUnitUserService userService,IGameGoodsService goodsService,IGameEquService equService,IUnitUserWeight weightService)
{
_userService = userService;
_goodsService = goodsService;
_equService = equService;
_weightService = weightService;
}
/// <summary>
@@ -190,4 +194,45 @@ public class SettingController : ControllerBase
return PoAction.Message("暂无法设置!");
}
}
/// <summary>
/// 刷新/重置设置
/// </summary>
/// <param name="type"></param>
/// <returns></returns>
[HttpGet]
public async Task<IPoAction> RefreshSetting(int type)
{
string userId = StateHelper.userId;
if (type == 0)//刷新负重
{
var equWeight = await _equService.GetUserEquWeightSum(userId);
var goodsWeight = await _goodsService.GetUserGoodWeightSum(userId,0);
int onWeight = equWeight + goodsWeight;//当前总占用负重
var weightLog = await _weightService.GetUserWeightLog(userId);
int maxWeight = weightLog.Sum(it => (int)it.sum);
var weightInfo = await _weightService.GetUserWeightInfo(userId);
weightInfo.onWeight = onWeight;
weightInfo.maxWeight = maxWeight;
var shipWeight = await _goodsService.GetUserGoodWeightSum(userId,1);
weightInfo.shipOnWeight = shipWeight;
if (await _weightService.UpdateUserWeight(weightInfo))
{
return PoAction.Ok(true,"负重数据已刷新成功!");
}
else
{
return PoAction.Message("负重刷新失败,请稍后尝试!");
}
}
else if (type == 1)//刷新图标
{
return PoAction.Ok(true, "图标刷新成功!");
}
else
{
return PoAction.Message("无效的操作!");
}
}
}

View File

@@ -84,6 +84,40 @@ public class UserController : ControllerBase
var model = await UserModelTool.GetUserView(userId);
return PoAction.Ok(model);
}
/// <summary>
/// 获取基础属性信息
/// </summary>
/// <param name="no"></param>
/// <returns></returns>
[HttpGet]
public async Task<IPoAction> GetUserBaseAttrInfo(string? no)
{
string userId = StateHelper.userId;
if (!string.IsNullOrEmpty(no))
{
var userInfo = await _userService.GetUserInfoByUserNo(no); //基础资料
if (userInfo == null)
{
return PoAction.Message("玩家不存在!", 102);
}
if (userInfo.userId == userId)
{
return PoAction.Message("用户本身!", 101);
}
if (userInfo.areaId != StateHelper.areaId)
{
return PoAction.Message("玩家不存在!", 102);
}
userId = userInfo.userId;
}
var model = await _attrService.GetUserAttrModel(userId);
return PoAction.Ok(model);
}
/// <summary>
/// 获取用户资料