232
This commit is contained in:
@@ -35,5 +35,11 @@ namespace Application.Domain.Entity
|
||||
/// </summary>
|
||||
[SugarColumn(IsNullable = true)]
|
||||
public int? autoDrug { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 0 不限制赠送 1限制好友赠送
|
||||
/// </summary>
|
||||
[SugarColumn(IsNullable = true)]
|
||||
public int? giveRole { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -9,8 +9,10 @@ public static class GameConfig
|
||||
public const int SendChatGoodsService = 10002;//金海螺
|
||||
public const int UpLevAddWeight = 10;//升级增加负重
|
||||
public const int GameBaseVigour = 50;//初始活力
|
||||
public const int GameRelationEnemyNeedGold = 50;//添加仇人所需金元
|
||||
public const int GameRelationEnemyNeedGold = 300;//添加仇人所需金元
|
||||
public const int GameUpdateNickNeedGoods = 10001;//更新昵称所需道具
|
||||
public const int GameUpdateSexNeedGoods = 10001;//更新性别所需道具
|
||||
public const int GameUserFriendMaxCount = 50;//好友最大上限人数
|
||||
public const int GameAutoBagGoodsId = 10001;//百宝箱物品ID
|
||||
public const int GameAutoDrugGoodsId = 10001;//急救箱物品ID
|
||||
}
|
||||
@@ -13,5 +13,6 @@ public static class UserEnum
|
||||
ChatRole,
|
||||
AutoBag,
|
||||
AutoDrug,
|
||||
GiveRole,
|
||||
}
|
||||
}
|
||||
@@ -206,6 +206,7 @@ public class UnitUserService(ISqlSugarClient DbClient, IRedisCache redis) : IUni
|
||||
config.chatRole = 0;
|
||||
config.autoBag = -1;
|
||||
config.autoDrug = -1;
|
||||
config.giveRole = 0;
|
||||
db.Insertable(config).AddQueue();
|
||||
|
||||
//注册个人血量
|
||||
@@ -355,6 +356,7 @@ public class UnitUserService(ISqlSugarClient DbClient, IRedisCache redis) : IUni
|
||||
.SetColumnsIF(code == "ChatRole", it => it.chatRole == state)
|
||||
.SetColumnsIF(code == "AutoBag", it => it.autoBag == state)
|
||||
.SetColumnsIF(code == "AutoDrug", it => it.autoDrug == state)
|
||||
.SetColumnsIF(code == "GiveRole", it => it.giveRole == state)
|
||||
.Where(it => it.userId == userId).ExecuteCommandAsync() > 0;
|
||||
if (result)
|
||||
{
|
||||
|
||||
193
Service/Application.Web/Controllers/User/SettingController.cs
Normal file
193
Service/Application.Web/Controllers/User/SettingController.cs
Normal file
@@ -0,0 +1,193 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Application.Web.Controllers.User;
|
||||
|
||||
/// <summary>
|
||||
/// 设置接口
|
||||
/// </summary>
|
||||
[ApiExplorerSettings(GroupName = "User")]
|
||||
[Route("User/[controller]/[action]")]
|
||||
[ApiController]
|
||||
[Authorize]
|
||||
public class SettingController : ControllerBase
|
||||
{
|
||||
private readonly IUnitUserService _userService;
|
||||
private readonly IGameGoodsService _goodsService;
|
||||
|
||||
public SettingController(IUnitUserService userService,IGameGoodsService goodsService)
|
||||
{
|
||||
_userService = userService;
|
||||
_goodsService = goodsService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取个人配置
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<IPoAction> GetUserConfig(int type)
|
||||
{
|
||||
int result = 0;
|
||||
string userId = StateHelper.userId;
|
||||
var data = await _userService.GetUserConfigInfo(userId);
|
||||
switch (type)
|
||||
{
|
||||
case 0:
|
||||
result = (int)data.friendRole;
|
||||
break;
|
||||
case 1:
|
||||
result = (int)data.giveRole;
|
||||
break;
|
||||
case 2:
|
||||
result = (int)data.autoBag;
|
||||
break;
|
||||
case 3:
|
||||
result = (int)data.autoDrug;
|
||||
break;
|
||||
}
|
||||
|
||||
return PoAction.Ok(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置配置
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="state"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<IPoAction> UpdateUserConfig(int type, int state)
|
||||
{
|
||||
string userId = StateHelper.userId;
|
||||
if (type == 0)
|
||||
{
|
||||
int[] target = [0, 1, 2];
|
||||
if (target.Contains(state))
|
||||
{
|
||||
if (await _userService.UpdateUserConfigInfo(userId, nameof(UserEnum.ConfigCode.FriendRole), state))
|
||||
{
|
||||
return PoAction.Ok(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
return PoAction.Message("设置失败,请稍后尝试!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return PoAction.Message("无效的设置!");
|
||||
}
|
||||
}
|
||||
else if (type == 1)
|
||||
{
|
||||
int[] target = [0, 1];
|
||||
if (target.Contains(state))
|
||||
{
|
||||
if (await _userService.UpdateUserConfigInfo(userId, nameof(UserEnum.ConfigCode.GiveRole), state))
|
||||
{
|
||||
return PoAction.Ok(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
return PoAction.Message("设置失败,请稍后尝试!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return PoAction.Message("无效的设置!");
|
||||
}
|
||||
}
|
||||
else if (type == 2)
|
||||
{
|
||||
int[] target = [0, 1];
|
||||
if (target.Contains(state))
|
||||
{
|
||||
var data = await _userService.GetUserConfigInfo(userId);
|
||||
if (data.autoBag == -1)//判断物品开通
|
||||
{
|
||||
var goodsCount = await _goodsService.GetUserGoodsCount(userId, GameConfig.GameAutoBagGoodsId);
|
||||
if (goodsCount < 1)
|
||||
{
|
||||
return PoAction.Message("您暂无百宝箱,无法开启!");
|
||||
}
|
||||
|
||||
if (await _goodsService.UpdateUserGoods(userId, 0, GameConfig.GameAutoBagGoodsId, 1, "使用物品"))
|
||||
{
|
||||
if (await _userService.UpdateUserConfigInfo(userId, nameof(UserEnum.ConfigCode.AutoBag), state))
|
||||
{
|
||||
return PoAction.Ok(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
return PoAction.Message("开启失败,请稍后尝试!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return PoAction.Message("开启失败,请稍后尝试!");
|
||||
}
|
||||
}
|
||||
if (await _userService.UpdateUserConfigInfo(userId, nameof(UserEnum.ConfigCode.AutoBag), state))
|
||||
{
|
||||
return PoAction.Ok(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
return PoAction.Message("设置失败,请稍后尝试!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return PoAction.Message("无效的设置!");
|
||||
}
|
||||
}
|
||||
else if (type == 3)
|
||||
{
|
||||
int[] target = [0, 1];
|
||||
if (target.Contains(state))
|
||||
{
|
||||
var data = await _userService.GetUserConfigInfo(userId);
|
||||
if (data.autoBag == -1)//判断物品开通
|
||||
{
|
||||
var goodsCount = await _goodsService.GetUserGoodsCount(userId, GameConfig.GameAutoDrugGoodsId);
|
||||
if (goodsCount < 1)
|
||||
{
|
||||
return PoAction.Message("您暂无急救箱,无法开启!");
|
||||
}
|
||||
|
||||
if (await _goodsService.UpdateUserGoods(userId, 0, GameConfig.GameAutoDrugGoodsId, 1, "使用物品"))
|
||||
{
|
||||
if (await _userService.UpdateUserConfigInfo(userId, nameof(UserEnum.ConfigCode.AutoDrug), state))
|
||||
{
|
||||
return PoAction.Ok(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
return PoAction.Message("开启失败,请稍后尝试!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return PoAction.Message("开启失败,请稍后尝试!");
|
||||
}
|
||||
}
|
||||
if (await _userService.UpdateUserConfigInfo(userId, nameof(UserEnum.ConfigCode.AutoDrug), state))
|
||||
{
|
||||
return PoAction.Ok(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
return PoAction.Message("设置失败,请稍后尝试!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return PoAction.Message("无效的设置!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return PoAction.Message("暂无法设置!");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user