111
This commit is contained in:
@@ -138,6 +138,11 @@ namespace Application.Web.Controllers.Login
|
||||
return PoAction.Message("未登录账号!");
|
||||
}
|
||||
|
||||
if (accInfo.status != 1)
|
||||
{
|
||||
return PoAction.Message("账号已冻结!");
|
||||
}
|
||||
|
||||
var areaInfo = await _areaService.GetAreaInfo(area);
|
||||
if (areaInfo == null)
|
||||
{
|
||||
@@ -172,5 +177,94 @@ namespace Application.Web.Controllers.Login
|
||||
string token = JwtHelper.CreateToken(Key, Issuer, Audience, loadData, 300);
|
||||
return PoAction.Ok(new { token = token, refToken = userInfo.token, userId = userInfo.userId });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 登录到游戏
|
||||
/// </summary>
|
||||
/// <param name="sid"></param>
|
||||
/// <param name="user"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<IPoAction> LoginGame(string sid, string user)
|
||||
{
|
||||
if (string.IsNullOrEmpty(sid))
|
||||
{
|
||||
return PoAction.Message("未登录账号!");
|
||||
}
|
||||
|
||||
var accInfo = await _accountService.GetAccInfoByToken(sid);
|
||||
if (accInfo == null)
|
||||
{
|
||||
return PoAction.Message("未登录账号!");
|
||||
}
|
||||
|
||||
if (accInfo.status != 1)
|
||||
{
|
||||
return PoAction.Message("账号已冻结!");
|
||||
}
|
||||
|
||||
var userInfo = await _userService.GetUserInfoByUserId(user);
|
||||
if (userInfo == null)
|
||||
{
|
||||
return PoAction.Message("角色不存在!");
|
||||
}
|
||||
|
||||
if (userInfo.accId != accInfo.accId)
|
||||
{
|
||||
return PoAction.Message("角色不存在!");
|
||||
}
|
||||
|
||||
if (userInfo.status == 0)
|
||||
{
|
||||
return PoAction.Message("角色已封禁!");
|
||||
}
|
||||
|
||||
Dictionary<string, object> loadData = new Dictionary<string, object>();
|
||||
loadData.Add("userId", userInfo.userId);
|
||||
loadData.Add("accId", userInfo.accId);
|
||||
|
||||
string Key = App.Configuration["JwtTokenOptions:SecurityKey"].ToString();
|
||||
string Issuer = App.Configuration["JwtTokenOptions:Issuer"].ToString();
|
||||
string Audience = App.Configuration["JwtTokenOptions:Audience"].ToString();
|
||||
string token = JwtHelper.CreateToken(Key, Issuer, Audience, loadData, 1);
|
||||
return PoAction.Ok(new
|
||||
{ regOk = userInfo.regOk, token = token, refToken = userInfo.token, userId = userInfo.userId });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 注册角色信息
|
||||
/// </summary>
|
||||
/// <param name="parms"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Authorize]
|
||||
public async Task<IPoAction> RegisterInfo([FromBody] RegisterInfoParms parms)
|
||||
{
|
||||
if (string.IsNullOrEmpty(parms.nick))
|
||||
{
|
||||
return PoAction.Message("昵称不能为空!");
|
||||
}
|
||||
|
||||
if (!RegExpAssist.RegStringLeght(parms.nick, 1, 12))
|
||||
{
|
||||
return PoAction.Message("昵称需要1-12字符之间哦!");
|
||||
}
|
||||
string sex = parms.sex == 0 ? "女" : "男";
|
||||
string userId = StateHelper.userId;
|
||||
var userInfo = await _userService.GetUserInfoByUserId(userId);
|
||||
if (userInfo.regOk == 1)
|
||||
{
|
||||
return PoAction.Ok(true);
|
||||
}
|
||||
|
||||
if (await _userService.RegisterUserInfo(userId, parms.nick, sex))
|
||||
{
|
||||
return PoAction.Ok(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
return PoAction.Message("注册失败,请稍后尝试!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -86,5 +86,26 @@ namespace Application.Web.Controllers.Pub
|
||||
data.sign = data.sign.Replace("[Br]", "<br />");
|
||||
return PoAction.Ok(data);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取用户游戏角色
|
||||
/// </summary>
|
||||
/// <param name="sid"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<IPoAction> GetMyGame(string? sid)
|
||||
{
|
||||
List<unit_user> userData = new List<unit_user>();
|
||||
if (!string.IsNullOrEmpty(sid))
|
||||
{
|
||||
var account = await _accountService.GetAccInfoByToken(sid);
|
||||
if (account != null)
|
||||
{
|
||||
userData = await _userService.GetUserDataByAccId(account.accId);
|
||||
}
|
||||
}
|
||||
return PoAction.Ok(userData);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace Application.Web;
|
||||
|
||||
public class RegisterInfoParms
|
||||
{
|
||||
public string nick { get; set; } = string.Empty;
|
||||
public int sex { get; set; }
|
||||
}
|
||||
Reference in New Issue
Block a user