1233
This commit is contained in:
@@ -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("无效的操作!");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user