452424
This commit is contained in:
@@ -17,9 +17,11 @@ public class UserController : ControllerBase
|
||||
private readonly IGameChatService _chatService;
|
||||
private readonly IGameSkillService _skillService;
|
||||
private readonly IGameTeamService _teamService;
|
||||
|
||||
public UserController(IUnitUserService userService, IUnitUserAttrService attrService,
|
||||
IUnitUserAccService accService, IGameMapService mapService, IUnitUserRelationService relationService,
|
||||
IGameGoodsService goodsService, IGameChatService chatService,IGameSkillService skillService,IGameTeamService teamService)
|
||||
IGameGoodsService goodsService, IGameChatService chatService, IGameSkillService skillService,
|
||||
IGameTeamService teamService)
|
||||
{
|
||||
_userService = userService;
|
||||
_attrService = attrService;
|
||||
@@ -87,7 +89,7 @@ public class UserController : ControllerBase
|
||||
var model = await UserModelTool.GetUserView(userId);
|
||||
return PoAction.Ok(model);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取基础属性信息
|
||||
/// </summary>
|
||||
@@ -163,7 +165,7 @@ public class UserController : ControllerBase
|
||||
bool isFriend = await _relationService.CheckIsFriend(userId, userInfo.userId);
|
||||
bool isEnemy = await _relationService.CheckUserEnemy(userId, userInfo.userId);
|
||||
var team = await _teamService.GetUserTeamInfo(userInfo.userId);
|
||||
object result = new { user, attr = new { attrInfo.lev }, acc, isOnline, onMapName, isFriend, isEnemy ,team};
|
||||
object result = new { user, attr = new { attrInfo.lev }, acc, isOnline, onMapName, isFriend, isEnemy, team };
|
||||
return PoAction.Ok(result);
|
||||
}
|
||||
|
||||
@@ -284,16 +286,134 @@ public class UserController : ControllerBase
|
||||
return PoAction.Message("操作失败,请稍后尝试!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取用户技能
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<IPoAction>GetUserSkill()
|
||||
public async Task<IPoAction> GetUserSkill()
|
||||
{
|
||||
var userId = StateHelper.userId;
|
||||
var data = await _skillService.GetUserSkill(userId);
|
||||
return PoAction.Ok(data);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取个人药品栏
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<IPoAction> GetUserDrugColumn()
|
||||
{
|
||||
string userId = StateHelper.userId;
|
||||
var data = await _attrService.GetUserDrug(userId);
|
||||
return PoAction.Ok(data.drug);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 移除药品栏药品
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<IPoAction> RemoverUserDrug(string id)
|
||||
{
|
||||
string userId = StateHelper.userId;
|
||||
var data = await _attrService.GetUserDrug(userId);
|
||||
var onDrug = data.drug.Find(it => it.id == id);
|
||||
if (onDrug == null)
|
||||
{
|
||||
return PoAction.Message("药品栏无此药品!");
|
||||
}
|
||||
|
||||
data.drug.Remove(onDrug);
|
||||
if (await _attrService.UpdateUserDrug(data))
|
||||
{
|
||||
if (onDrug.count > 0)
|
||||
{
|
||||
await _goodsService.UpdateUserGoods(userId, 1, onDrug.goodsId, onDrug.count, "药品栏移除,退回背包");
|
||||
}
|
||||
|
||||
return PoAction.Ok(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
return PoAction.Message("移除失败!");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加到药品栏
|
||||
/// </summary>
|
||||
/// <param name="goodsId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<IPoAction> AddUserDrug(int goodsId, int count)
|
||||
{
|
||||
count = count < 1 ? 1 : count;
|
||||
count = count > 999 ? 999 : count;
|
||||
string userId = StateHelper.userId;
|
||||
var myGoods = await _goodsService.GetUserGoodsInfo(userId, goodsId);
|
||||
if (myGoods == null)
|
||||
{
|
||||
return PoAction.Message("暂无该物品!");
|
||||
}
|
||||
|
||||
if (myGoods.count < count)
|
||||
{
|
||||
return PoAction.Message("物品数量不足!");
|
||||
}
|
||||
|
||||
if (myGoods.code != nameof(GoodsEnum.Code.Drug))
|
||||
{
|
||||
return PoAction.Message("该物品无法置放到药品栏!");
|
||||
}
|
||||
|
||||
bool isAdd = false;
|
||||
var myDrug = await _attrService.GetUserDrug(userId);
|
||||
var onDrug = myDrug.drug.Find(it => it.goodsId == goodsId);
|
||||
if (onDrug == null)
|
||||
{
|
||||
if (myDrug.drug.Count >= 5)
|
||||
{
|
||||
return PoAction.Message("药品栏最多添加5个药品!");
|
||||
}
|
||||
|
||||
isAdd = true;
|
||||
}
|
||||
|
||||
if (await _goodsService.UpdateUserGoods(userId, 0, goodsId, count, "放置到药品栏"))
|
||||
{
|
||||
if (isAdd)
|
||||
{
|
||||
UserDrugModel temp = new UserDrugModel();
|
||||
temp.id = StringAssist.NewGuid;
|
||||
temp.goodsId = goodsId;
|
||||
temp.name = myGoods.goodsName;
|
||||
temp.code = "Blood";
|
||||
temp.count = count;
|
||||
myDrug.drug.Add(temp);
|
||||
}
|
||||
else
|
||||
{
|
||||
myDrug.drug.Remove(onDrug);
|
||||
onDrug.count += count;
|
||||
myDrug.drug.Add(onDrug);
|
||||
}
|
||||
|
||||
if (await _attrService.UpdateUserDrug(myDrug))
|
||||
{
|
||||
return PoAction.Ok(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
return PoAction.Message("添加失败,请稍后尝试!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return PoAction.Message("添加失败,请稍后尝试!");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user