Commit ac0ca2db authored by 吴春's avatar 吴春

调整权限

parent 94d5dbd2
...@@ -53,5 +53,6 @@ namespace EduSpider.Model.Cache ...@@ -53,5 +53,6 @@ namespace EduSpider.Model.Cache
/// </summary> /// </summary>
public string UserMobile { get; set; } public string UserMobile { get; set; }
public string Account { get; set; }
} }
} }
\ No newline at end of file
...@@ -21,5 +21,7 @@ namespace EduSpider.Model.Extend ...@@ -21,5 +21,7 @@ namespace EduSpider.Model.Extend
/// 用户头像 /// 用户头像
/// </summary> /// </summary>
public string UserIcon { get; set; } public string UserIcon { get; set; }
}
public string Accounts { get; set; }
}
} }
...@@ -56,6 +56,10 @@ namespace EduSpider.Repository ...@@ -56,6 +56,10 @@ namespace EduSpider.Repository
{ {
where += $" and t.{nameof(rb_account_hk_Extend.Password)} ='{demodel.Password}'"; where += $" and t.{nameof(rb_account_hk_Extend.Password)} ='{demodel.Password}'";
} }
if (!string.IsNullOrEmpty(demodel.Accounts))
{
where += $" and t.{nameof(rb_account_hk_Extend.Account)} in({demodel.Accounts})";
}
string sql = $@" string sql = $@"
select * from( select * from(
......
...@@ -71,5 +71,7 @@ namespace EduSpider.WebApi.Controllers ...@@ -71,5 +71,7 @@ namespace EduSpider.WebApi.Controllers
var homeworkExamList = CourseService.GetStuWorkAndExamList(query); var homeworkExamList = CourseService.GetStuWorkAndExamList(query);
return ApiResult.Success(data: homeworkExamList); return ApiResult.Success(data: homeworkExamList);
} }
} }
} }
...@@ -15,6 +15,7 @@ using System; ...@@ -15,6 +15,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using JWT.Algorithms; using JWT.Algorithms;
using JWT.Serializers; using JWT.Serializers;
using EduSpider.Model.Cache;
namespace EduSpider.WebApi.Controllers namespace EduSpider.WebApi.Controllers
{ {
...@@ -113,6 +114,7 @@ namespace EduSpider.WebApi.Controllers ...@@ -113,6 +114,7 @@ namespace EduSpider.WebApi.Controllers
AccountId = model.AccountId, AccountId = model.AccountId,
UserMobile = model.Account, UserMobile = model.Account,
UserIcon = model.UserIcon, UserIcon = model.UserIcon,
Account = model.Account
}; };
Cache.User.UserReidsCache.UserInfoSet(Cache.CacheKey.User_Login_Key + model.UniqueId, obj, Config.JwtExpirTime); Cache.User.UserReidsCache.UserInfoSet(Cache.CacheKey.User_Login_Key + model.UniqueId, obj, Config.JwtExpirTime);
return ApiResult.Success(data: obj); return ApiResult.Success(data: obj);
...@@ -120,6 +122,43 @@ namespace EduSpider.WebApi.Controllers ...@@ -120,6 +122,43 @@ namespace EduSpider.WebApi.Controllers
} }
#endregion #endregion
[HttpPost]
[AllowAnonymous]
public ApiResult GetStudentByAccount()
{
JObject jobj = JObject.Parse(RequestParm.Msg.ToString());
string account = jobj.GetString("Account");
var model = AccountService.GetAccountList(new rb_account_hk_Extend()
{
Account = account.Trim(),
AccountType = Utility.Enum.AccountTypeEnum.Student
}).FirstOrDefault();
if (model == null || model.AccountId == 0)
{
return ApiResult.Failed("账号不存在");
}
#region 获取进阶思维小程序端token
BaseUserInfo UserInfo = new() { BaseUserId = model.UniqueId };
string token = JwtHelper.CreateToken(UserInfo, Config.JwtSecretKey, Config.JwtExpirTime);
#endregion
Model.Cache.UserInfo obj = new()
{
UniqueId = model.UniqueId,
Id = model.Id,
AccountType = model.AccountType,
AccountName = model.AccountName,
Token = token,
ApiRequestFromEnum = Utility.Enum.ApiRequestFromEnum.MiniProgram,
AccountId = model.AccountId,
UserMobile = model.Account,
UserIcon = model.UserIcon,
Account = model.Account
};
Cache.User.UserReidsCache.UserInfoSet(Cache.CacheKey.User_Login_Key + model.UniqueId, obj, Config.JwtExpirTime);
return ApiResult.Success(data: obj);
}
#region 手机号码登录 #region 手机号码登录
/// <summary> /// <summary>
/// 根据手机号码一键登录 /// 根据手机号码一键登录
...@@ -187,12 +226,86 @@ namespace EduSpider.WebApi.Controllers ...@@ -187,12 +226,86 @@ namespace EduSpider.WebApi.Controllers
AccountId = model.AccountId, AccountId = model.AccountId,
UserMobile = model.Account, UserMobile = model.Account,
UserIcon = model.UserIcon, UserIcon = model.UserIcon,
Account = model.Account
}; };
Cache.User.UserReidsCache.UserInfoSet(Cache.CacheKey.User_Login_Key + model.UniqueId, obj, Config.JwtExpirTime); Cache.User.UserReidsCache.UserInfoSet(Cache.CacheKey.User_Login_Key + model.UniqueId, obj, Config.JwtExpirTime);
return ApiResult.Success(data: obj); return ApiResult.Success(data: obj);
} }
} }
/// <summary>
/// 根据手机号码一键登录
/// </summary>
/// <returns></returns>
[HttpGet]
[HttpPost]
[AllowAnonymous]
public ApiResult LoginByAccounts()
{
JObject jobj = JObject.Parse(RequestParm.Msg.ToString());
string accounts = jobj.GetString("Accounts");
if (string.IsNullOrEmpty(accounts))
{
return ApiResult.Failed(message: "手机号码登录失败、跳转至账号登录", new { Error = -1 });
}
int AccountType = jobj.GetInt("AccountType", 2);
var models = AccountService.GetAccountList(new rb_account_hk_Extend()
{
Accounts = accounts.Trim(),
AccountType = (Utility.Enum.AccountTypeEnum)AccountType
});
if (!models.Any())
{
return ApiResult.Failed(message: "手机号码登录失败、跳转至账号登录", new { Error = -1 });
}
else
{
//if (!string.IsNullOrEmpty(model.OpenId))//UnionId是否为空,为空则绑定手机号与UnionId
//{
// if (OpenId != model.OpenId)
// {
// //return ApiResult.Failed("手机号与绑定的微信账户不一致", new { Error = 0 });
// }
//}
//else
//{
// model.UnionId = UnionId;
// model.OpenId = OpenId;
// AccountService.UpdateAccountUnionId(model);
//}
//if (model.Status == Utility.Enum.DateStateEnum.Delete)
//{
// return ApiResult.Failed(message: $"此账号【{ account }】已禁用", new { Error = 2 });
//}
var loginStus = new List<UserInfo>();
models.ForEach(model => {
#region 获取进阶思维小程序端token
BaseUserInfo UserInfo = new() { BaseUserId = model.UniqueId };
string token = JwtHelper.CreateToken(UserInfo, Config.JwtSecretKey, Config.JwtExpirTime);
#endregion
Model.Cache.UserInfo obj = new()
{
UniqueId = model.UniqueId,
Id = model.Id,
AccountType = model.AccountType,
AccountName = model.AccountName,
Token = token,
ApiRequestFromEnum = Utility.Enum.ApiRequestFromEnum.MiniProgram,
AccountId = model.AccountId,
UserMobile = model.Account,
UserIcon = model.UserIcon,
Account = model.Account
};
Cache.User.UserReidsCache.UserInfoSet(Cache.CacheKey.User_Login_Key + model.UniqueId, obj, Config.JwtExpirTime);
loginStus.Add(obj);
});
return ApiResult.Success(data: loginStus);
}
}
#region 小程序获取手机号码 #region 小程序获取手机号码
/// <summary> /// <summary>
/// 获取手机号码 /// 获取手机号码
...@@ -367,6 +480,7 @@ namespace EduSpider.WebApi.Controllers ...@@ -367,6 +480,7 @@ namespace EduSpider.WebApi.Controllers
AccountId = model.AccountId, AccountId = model.AccountId,
UserMobile = model.Account, UserMobile = model.Account,
UserIcon = model.UserIcon, UserIcon = model.UserIcon,
Account = model.Account
}; };
Cache.User.UserReidsCache.UserInfoSet(Cache.CacheKey.User_Login_Key + model.UniqueId, obj, Config.JwtExpirTime); Cache.User.UserReidsCache.UserInfoSet(Cache.CacheKey.User_Login_Key + model.UniqueId, obj, Config.JwtExpirTime);
return ApiResult.Success(data: obj); return ApiResult.Success(data: obj);
...@@ -444,6 +558,25 @@ namespace EduSpider.WebApi.Controllers ...@@ -444,6 +558,25 @@ namespace EduSpider.WebApi.Controllers
} }
#endregion #endregion
#region 根据OPENID登录
[AllowAnonymous]
public ApiResult LoginByOpenCode()
{
JObject parms = JObject.Parse(RequestParm.Msg.ToString());
string code = parms.GetString("Code");
result userinfo = WeChatHelper.GetWeChatOpenId(Config.AppID, Config.AppSecret, code);
if (!string.IsNullOrEmpty(userinfo.openid))
{
//执行登录
}
return ApiResult.Failed(message: "登录失败,请稍后重试");
}
#endregion
/// <summary> /// <summary>
/// 修改教师密码 /// 修改教师密码
/// </summary> /// </summary>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment