Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
EduSpider
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
viitto
EduSpider
Commits
ac0ca2db
Commit
ac0ca2db
authored
Sep 26, 2022
by
吴春
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
调整权限
parent
94d5dbd2
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
143 additions
and
1 deletion
+143
-1
UserInfo.cs
EduSpider.Model/CacheModel/UserInfo.cs
+1
-0
RB_Account_Extend.cs
EduSpider.Model/Extend/RB_Account_Extend.cs
+3
-1
AccountRepository.cs
EduSpider.Repository/AccountRepository.cs
+4
-0
StuController.cs
EduSpider.WebApi/Controllers/Student/StuController.cs
+2
-0
LoginController.cs
EduSpider.WebApi/Controllers/User/LoginController.cs
+133
-0
No files found.
EduSpider.Model/CacheModel/UserInfo.cs
View file @
ac0ca2db
...
@@ -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
EduSpider.Model/Extend/RB_Account_Extend.cs
View file @
ac0ca2db
...
@@ -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
;
}
}
}
}
EduSpider.Repository/AccountRepository.cs
View file @
ac0ca2db
...
@@ -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(
...
...
EduSpider.WebApi/Controllers/Student/StuController.cs
View file @
ac0ca2db
...
@@ -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
);
}
}
}
}
}
}
EduSpider.WebApi/Controllers/User/LoginController.cs
View file @
ac0ca2db
...
@@ -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>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment