Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
Education
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
黄奎
Education
Commits
3e12f67d
Commit
3e12f67d
authored
Jan 27, 2021
by
吴春
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
提交学生app登录以及首页接口
parent
89c96702
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
25 changed files
with
1785 additions
and
107 deletions
+1785
-107
AppStudentReidsCache.cs
Edu.Cache/App/AppStudentReidsCache.cs
+140
-0
MsgUserRedisCache.cs
Edu.Cache/App/MsgUserRedisCache.cs
+135
-0
CacheKey.cs
Edu.Cache/CacheKey.cs
+11
-0
IAppStudentInfoToken.cs
Edu.Common/API/IAppStudentInfoToken.cs
+47
-0
InterestEnum.cs
Edu.Common/Enum/App/InterestEnum.cs
+47
-0
JapanbaseInfoEnum.cs
Edu.Common/Enum/App/JapanbaseInfoEnum.cs
+37
-0
AppStudentInfo.cs
Edu.Model/CacheModel/AppStudentInfo.cs
+2
-0
RB_HomePage_Banner.cs
Edu.Model/Entity/App/RB_HomePage_Banner.cs
+70
-0
RB_HomePage_Lable.cs
Edu.Model/Entity/App/RB_HomePage_Lable.cs
+73
-0
RB_Account.cs
Edu.Model/Entity/User/RB_Account.cs
+68
-59
RB_Student.cs
Edu.Model/Entity/User/RB_Student.cs
+12
-0
AppHomePageModule.cs
Edu.Module.System/AppHomePageModule.cs
+91
-0
MsgLogModule.cs
Edu.Module.System/MsgLogModule.cs
+45
-0
AccountModule.cs
Edu.Module.User/AccountModule.cs
+41
-10
StudentModule.cs
Edu.Module.User/StudentModule.cs
+30
-0
TeacherModule.cs
Edu.Module.User/TeacherModule.cs
+14
-1
RB_HomePage_BannerRepository.cs
Edu.Repository/App/RB_HomePage_BannerRepository.cs
+36
-0
RB_HomePage_LableRepository.cs
Edu.Repository/App/RB_HomePage_LableRepository.cs
+36
-0
RB_AccountRepository.cs
Edu.Repository/User/RB_AccountRepository.cs
+4
-0
RB_TeacherRepository.cs
Edu.Repository/User/RB_TeacherRepository.cs
+21
-0
APPStudentLoginController.cs
Edu.WebApi/Controllers/APP/APPStudentLoginController.cs
+468
-37
AppIndexController.cs
Edu.WebApi/Controllers/APP/AppIndexController.cs
+87
-0
AppBaseController.cs
Edu.WebApi/Controllers/AppBaseController.cs
+89
-0
AppPublicController.cs
Edu.WebApi/Controllers/Public/AppPublicController.cs
+120
-0
APPApiTokenHelper.cs
Edu.WebApi/Helper/APPApiTokenHelper.cs
+61
-0
No files found.
Edu.Cache/App/AppStudentReidsCache.cs
0 → 100644
View file @
3e12f67d
using
Edu.CacheManager.Base
;
using
Edu.Common.Enum
;
using
Edu.Model.CacheModel
;
using
Edu.Repository.User
;
using
System
;
using
System.Linq
;
namespace
Edu.Cache.User
{
/// <summary>
/// redis缓存
/// </summary>
public
class
AppStudentReidsCache
{
/// <summary>
/// 使用redis第几号库
/// </summary>
public
static
readonly
int
REDIS_DB3
=
3
;
static
readonly
RedisHelper
redis
=
new
RedisHelper
(
REDIS_DB3
);
/// <summary>
/// 设置缓存
/// </summary>
/// <param name="model"></param>
public
static
void
UserInfoSet
(
string
cacheKey
,
AppStudentInfo
model
,
int
JwtExpirTime
)
{
try
{
TimeSpan
ts
=
GetExpirTime
(
JwtExpirTime
);
redis
.
StringSet
<
AppStudentInfo
>(
cacheKey
,
model
,
ts
);
}
catch
(
Exception
ex
)
{
Common
.
Plugin
.
LogHelper
.
Write
(
ex
,
"UserInfoSet缓存设置失败"
);
}
}
/// <summary>
/// 获取缓存时长
/// </summary>
/// <param name="JwtExpirTime"></param>
/// <returns></returns>
private
static
TimeSpan
GetExpirTime
(
int
JwtExpirTime
)
{
DateTime
dt
=
DateTime
.
Now
;
DateTime
dt2
=
DateTime
.
Now
;
TimeSpan
ts
=
dt
.
AddSeconds
(
JwtExpirTime
)
-
dt2
;
return
ts
;
}
/// <summary>
/// 判断key是否存在
/// </summary>
/// <param name="cacheKey"></param>
/// <returns></returns>
public
static
bool
Exists
(
string
cacheKey
)
{
return
redis
.
KeyExists
(
cacheKey
);
}
/// <summary>
/// 设置缓存
/// </summary>
/// <param name="cacheKey"></param>
/// <param name="Data"></param>
/// <param name="JwtExpirTime"></param>
public
static
void
Set
(
string
cacheKey
,
object
Data
,
int
JwtExpirTime
)
{
try
{
TimeSpan
ts
=
GetExpirTime
(
JwtExpirTime
);
redis
.
StringSet
(
cacheKey
,
Data
,
ts
);
}
catch
(
Exception
)
{
}
}
/// <summary>
/// 账号仓储层对象
/// </summary>
private
static
readonly
RB_AccountRepository
accountRepository
=
new
RB_AccountRepository
();
/// <summary>
/// 获取用户登录信息
/// </summary>
/// <param name="Id">账号Id</param>
/// <param name="apiRequestFromEnum">请求来源</param>
/// <returns></returns>
public
static
AppStudentInfo
GetUserLoginInfo
(
object
Id
,
ApiRequestFromEnum
apiRequestFromEnum
=
ApiRequestFromEnum
.
AppStudent
)
{
AppStudentInfo
userInfo
=
null
;
if
(
Id
!=
null
)
{
string
cacheKey
=
Cache
.
CacheKey
.
AppStudent_Login_Key
+
Id
.
ToString
();
try
{
userInfo
=
redis
.
StringGet
<
AppStudentInfo
>(
cacheKey
);
}
catch
(
Exception
ex
)
{
Common
.
Plugin
.
LogHelper
.
Write
(
ex
,
"GetUserLoginInfo"
);
}
if
(
userInfo
==
null
)
{
Int32
.
TryParse
(
Id
.
ToString
(),
out
int
NewId
);
if
(
NewId
>
0
)
{
string
token
=
""
;
var
model
=
accountRepository
.
GetAccountListExtRepository
(
new
Model
.
ViewModel
.
User
.
RB_Account_ViewModel
()
{
Id
=
NewId
})?.
FirstOrDefault
();
if
(
model
!=
null
)
{
userInfo
=
new
AppStudentInfo
{
Id
=
model
.
Id
,
Group_Id
=
model
.
Group_Id
,
School_Id
=
model
.
School_Id
,
AccountName
=
model
.
AccountName
,
GroupName
=
model
.
GroupName
,
SchoolName
=
model
.
SchoolName
,
Token
=
token
,
ApiRequestFromEnum
=
apiRequestFromEnum
};
UserInfoSet
(
Cache
.
CacheKey
.
AppStudent_Login_Key
+
Id
.
ToString
(),
userInfo
,
Common
.
Config
.
JwtExpirTime
);
}
}
}
}
else
{
userInfo
=
new
AppStudentInfo
();
}
return
userInfo
;
}
}
}
\ No newline at end of file
Edu.Cache/App/MsgUserRedisCache.cs
0 → 100644
View file @
3e12f67d
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
Edu.CacheManager.Base
;
using
Edu.Common.Enum
;
namespace
Edu.Cache.App
{
public
class
MsgUserRedisCache
{
/// <summary>
/// 使用redis第几号库
/// </summary>
public
static
readonly
int
REDIS_DB3
=
3
;
static
readonly
RedisHelper
redis
=
new
RedisHelper
(
REDIS_DB3
);
/// <summary>
/// 添加用户发送验证码时间记录
/// </summary>
/// <param name="mobileNumber">手机号码</param>
public
static
bool
AddUserSendCodeHistory
(
string
mobileNumber
)
{
string
key
=
Cache
.
CacheKey
.
MsgStudent_Login_Key
+
mobileNumber
;
List
<
DateTime
>
codeTimeList
=
redis
.
StringGet
<
List
<
DateTime
>>(
key
);
if
(
codeTimeList
==
null
)
{
codeTimeList
=
new
List
<
DateTime
>();
}
codeTimeList
.
Add
(
DateTime
.
Now
);
TimeSpan
ts
=
GetExpirTime
(
Common
.
Config
.
JwtExpirTime
);
return
redis
.
StringSet
<
List
<
DateTime
>>(
key
,
codeTimeList
,
ts
);
}
/// <summary>
/// 设置缓存
/// </summary>
/// <param name="cacheKey"></param>
/// <param name="Data"></param>
/// <param name="JwtExpirTime"></param>
public
static
void
SetSendCode
(
string
cacheKey
,
object
Data
,
int
JwtExpirTime
)
{
try
{
TimeSpan
ts
=
GetExpirTime
(
JwtExpirTime
);
redis
.
StringSet
(
cacheKey
,
Data
,
ts
);
}
catch
(
Exception
)
{
}
}
/// <summary>
/// 获取缓存时长
/// </summary>
/// <param name="JwtExpirTime"></param>
/// <returns></returns>
private
static
TimeSpan
GetExpirTime
(
int
JwtExpirTime
)
{
DateTime
dt
=
DateTime
.
Now
;
DateTime
dt2
=
DateTime
.
Now
;
TimeSpan
ts
=
dt
.
AddSeconds
(
JwtExpirTime
)
-
dt2
;
return
ts
;
}
/// <summary>
/// 验证是否可以发送验证码
/// </summary>
/// <param name="mobileNumber">手机号码</param>
/// <param name="message">返回消息</param>
public
static
bool
CheckCanSendCode
(
string
mobileNumber
,
out
string
message
)
{
message
=
""
;
//Monitor.Enter和Monitor.Exit
string
key
=
string
.
Concat
(
CacheKey
.
MsgStudent_Login_Key
,
mobileNumber
);
List
<
DateTime
>
codeTimeList
=
redis
.
StringGet
<
List
<
DateTime
>>(
key
);
if
(
codeTimeList
!=
null
)
{
//计算阿里短信业务限流
codeTimeList
=
codeTimeList
.
Where
(
t
=>
t
>=
DateTime
.
Now
.
AddDays
(-
1
)).
ToList
();
//去除一天以外的记录
TimeSpan
ts
=
GetExpirTime
(
Common
.
Config
.
JwtExpirTime
);
redis
.
StringSet
(
key
,
codeTimeList
,
ts
);
if
(
codeTimeList
.
Count
()
>=
10
)
{
message
=
"24小时内不能发送超过10条验证码"
;
return
false
;
}
if
(
codeTimeList
.
Where
(
t
=>
t
>=
DateTime
.
Now
.
AddHours
(-
1
)).
Count
()
>=
5
)
{
message
=
"1小时内不能发送超过5条验证码"
;
return
false
;
}
if
(
codeTimeList
.
Where
(
t
=>
t
>=
DateTime
.
Now
.
AddMinutes
(-
1
)).
Count
()
>=
1
)
{
message
=
"1分钟内只能发送1条验证码"
;
return
false
;
}
return
true
;
}
else
{
return
true
;
}
}
/// <summary>
/// 获取短信验证码
/// </summary>
/// <param name="Id">账号Id</param>
/// <param name="apiRequestFromEnum">请求来源</param>
/// <returns></returns>
public
static
string
GetUserCode
(
object
Id
,
ApiRequestFromEnum
apiRequestFromEnum
=
ApiRequestFromEnum
.
WebAdmin
)
{
string
code
=
string
.
Empty
;
if
(
Id
!=
null
)
{
string
cacheKey
=
Cache
.
CacheKey
.
MsgStudent_Login_Key
+
Id
.
ToString
();
try
{
code
=
redis
.
StringGet
<
string
>(
cacheKey
);
}
catch
(
Exception
ex
)
{
Common
.
Plugin
.
LogHelper
.
Write
(
ex
,
"GetUserCode"
);
}
}
return
code
;
}
}
}
Edu.Cache/CacheKey.cs
View file @
3e12f67d
...
@@ -10,5 +10,16 @@ namespace Edu.Cache
...
@@ -10,5 +10,16 @@ namespace Edu.Cache
/// 用户登录缓存Key
/// 用户登录缓存Key
/// </summary>
/// </summary>
public
static
string
User_Login_Key
=
"Edu_User_Login_"
;
public
static
string
User_Login_Key
=
"Edu_User_Login_"
;
/// <summary>
///app学生登录缓存Key
/// </summary>
public
static
string
AppStudent_Login_Key
=
"App_Student_Login_"
;
/// <summary>
/// 短信号码缓存Key
/// </summary>
public
static
string
MsgStudent_Login_Key
=
"Msg_Student_Login_"
;
}
}
}
}
Edu.Common/API/IAppStudentInfoToken.cs
0 → 100644
View file @
3e12f67d
using
Edu.Common.Enum
;
namespace
Edu.Common.API
{
/// <summary>
/// 用户Token
/// </summary>
public
interface
IAppStudentInfoToken
{
/// <summary>
/// 用户ID
/// </summary>
public
string
uid
{
get
;
set
;
}
/// <summary>
/// 请求消息来源
/// </summary>
public
ApiRequestFromEnum
requestFrom
{
get
;
set
;
}
}
/// <summary>
/// API请求token携带的用户信息
/// </summary>
public
class
AppStudentInfoToken
:
IAppStudentInfoToken
{
/// <summary>
/// 用户ID
/// </summary>
public
string
uid
{
get
;
set
;
}
/// <summary>
/// 请求消息来源
/// </summary>
public
ApiRequestFromEnum
requestFrom
{
get
;
set
;
}
/// <summary>
/// 集团id
/// </summary>
public
int
groupId
{
get
;
set
;
}
}
}
Edu.Common/Enum/App/InterestEnum.cs
0 → 100644
View file @
3e12f67d
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
using
Edu.Common.Plugin
;
namespace
Edu.Common.Enum.App
{
public
enum
InterestEnum
{
/// <summary>
/// 考试
/// </summary>
[
EnumField
(
"考试"
)]
Examination
=
0
,
/// <summary>
/// 游学
/// </summary>
[
EnumField
(
"游学"
)]
StudyTour
=
1
,
/// <summary>
/// 留学
/// </summary>
[
EnumField
(
"留学"
)]
StudyAbroad
=
2
,
/// <summary>
/// 旅游
/// </summary>
[
EnumField
(
"旅游"
)]
Travel
=
3
,
/// <summary>
/// 影视
/// </summary>
[
EnumField
(
"影视"
)]
Movies
=
4
,
/// <summary>
/// 动漫
/// </summary>
[
EnumField
(
"动漫"
)]
Comic
=
5
,
/// <summary>
/// 工作
/// </summary>
[
EnumField
(
"工作"
)]
Work
=
6
}
}
Edu.Common/Enum/App/JapanbaseInfoEnum.cs
0 → 100644
View file @
3e12f67d
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
using
Edu.Common.Plugin
;
namespace
Edu.Common.Enum.App
{
public
enum
JapanbaseInfoEnum
{
/// <summary>
/// 完全没学过
/// </summary>
[
EnumField
(
"完全没学过"
)]
NotLikely
=
1
,
/// <summary>
/// 懂得50音
/// </summary>
[
EnumField
(
"懂得50音"
)]
Pinyin
=
2
,
/// <summary>
/// 会一些单词
/// </summary>
[
EnumField
(
"会一些单词"
)]
ALittleBit
=
3
,
/// <summary>
/// 经过系统学习
/// </summary>
[
EnumField
(
"经过系统学习"
)]
System
=
4
,
/// <summary>
/// 学过一段时间
/// </summary>
[
EnumField
(
"学过一段时间"
)]
Span
=
5
}
}
Edu.Model/CacheModel/AppStudentInfo.cs
View file @
3e12f67d
...
@@ -79,5 +79,7 @@ namespace Edu.Model.CacheModel
...
@@ -79,5 +79,7 @@ namespace Edu.Model.CacheModel
/// 上传配置
/// 上传配置
/// </summary>
/// </summary>
public
object
UploadConfig
{
get
;
set
;
}
public
object
UploadConfig
{
get
;
set
;
}
public
int
ActivationStatus
{
get
;
set
;
}
}
}
}
}
\ No newline at end of file
Edu.Model/Entity/App/RB_HomePage_Banner.cs
0 → 100644
View file @
3e12f67d
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
using
Edu.Common.Enum
;
using
VT.FW.DB
;
namespace
Edu.Model.Entity.App
{
/// <summary>
/// app首页banner图片
/// </summary>
[
Serializable
]
[
DB
(
ConnectionName
=
"DefaultConnection"
)]
public
class
RB_HomePage_Banner
{
/// <summary>
/// 编号
/// </summary>
public
int
BannerId
{
get
;
set
;
}
/// <summary>
/// 排序
/// </summary>
public
int
Sort
{
get
;
set
;
}
/// <summary>
/// 图片
/// </summary>
public
string
BannerPic
{
get
;
set
;
}
/// <summary>
/// 链接
/// </summary>
public
string
BannerUrl
{
get
;
set
;
}
/// <summary>
/// 集团编号
/// </summary>
public
int
Group_Id
{
get
;
set
;
}
/// <summary>
/// 学校编号
/// </summary>
public
int
School_Id
{
get
;
set
;
}
/// <summary>
/// 创建人
/// </summary>
public
int
CreateBy
{
get
;
set
;
}
/// <summary>
/// 创建时间
/// </summary>
public
DateTime
CreateTime
{
get
;
set
;
}
/// <summary>
/// 修改人
/// </summary>
public
int
UpdateBy
{
get
;
set
;
}
/// <summary>
/// 更新时间
/// </summary>
public
DateTime
UpdateTime
{
get
;
set
;
}
/// <summary>
/// 删除状态(0-正常,1-禁用)
/// </summary>
public
DateStateEnum
Status
{
get
;
set
;
}
}
}
Edu.Model/Entity/App/RB_HomePage_Lable.cs
0 → 100644
View file @
3e12f67d
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
using
Edu.Common.Enum
;
using
VT.FW.DB
;
namespace
Edu.Model.Entity.App
{
/// <summary>
/// app首页banner图片
/// </summary>
[
Serializable
]
[
DB
(
ConnectionName
=
"DefaultConnection"
)]
public
class
RB_HomePage_Lable
{
/// <summary>
/// 编号
/// </summary>
public
int
LableId
{
get
;
set
;
}
/// <summary>
/// 排序
/// </summary>
public
int
Sort
{
get
;
set
;
}
/// <summary>
/// 图片
/// </summary>
public
string
LablePic
{
get
;
set
;
}
/// <summary>
/// 链接
/// </summary>
public
string
LableUrl
{
get
;
set
;
}
/// <summary>
/// 链接
/// </summary>
public
string
LableName
{
get
;
set
;
}
/// <summary>
/// 集团编号
/// </summary>
public
int
Group_Id
{
get
;
set
;
}
/// <summary>
/// 学校编号
/// </summary>
public
int
School_Id
{
get
;
set
;
}
/// <summary>
/// 创建人
/// </summary>
public
int
CreateBy
{
get
;
set
;
}
/// <summary>
/// 创建时间
/// </summary>
public
DateTime
CreateTime
{
get
;
set
;
}
/// <summary>
/// 修改人
/// </summary>
public
int
UpdateBy
{
get
;
set
;
}
/// <summary>
/// 更新时间
/// </summary>
public
DateTime
UpdateTime
{
get
;
set
;
}
/// <summary>
/// 删除状态(0-正常,1-禁用)
/// </summary>
public
DateStateEnum
Status
{
get
;
set
;
}
}
}
Edu.Model/Entity/User/RB_Account.cs
View file @
3e12f67d
...
@@ -82,5 +82,14 @@ namespace Edu.Model.Entity.User
...
@@ -82,5 +82,14 @@ namespace Edu.Model.Entity.User
/// </summary>
/// </summary>
public
int
DirectSupervisor
{
get
;
set
;
}
public
int
DirectSupervisor
{
get
;
set
;
}
/// <summary>
/// 微信openid
/// </summary>
public
string
OpenId
{
get
;
set
;
}
/// <summary>
/// 学生激活状态0-未激活,1-已激活
/// </summary>
public
int
ActivationStatus
{
get
;
set
;
}
}
}
}
}
Edu.Model/Entity/User/RB_Student.cs
View file @
3e12f67d
...
@@ -103,5 +103,17 @@ namespace Edu.Model.Entity.User
...
@@ -103,5 +103,17 @@ namespace Edu.Model.Entity.User
/// </summary>
/// </summary>
public
int
StuStatus
{
get
;
set
;
}
public
int
StuStatus
{
get
;
set
;
}
/// <summary>
/// 兴趣爱好
/// </summary>
public
string
Interest
{
get
;
set
;
}
/// <summary>
/// 日语基础信息
/// </summary>
public
int
JapanBaseInfo
{
get
;
set
;
}
}
}
}
}
Edu.Module.System/AppHomePageModule.cs
0 → 100644
View file @
3e12f67d
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
Edu.AOP.CustomerAttribute
;
using
Edu.Model.Entity.App
;
using
Edu.Repository.App
;
namespace
Edu.Module.System
{
public
class
AppHomePageModule
{
/// <summary>
/// 首页banner仓储层对象
/// </summary>
private
readonly
RB_HomePage_BannerRepository
homePageBannerRepository
=
new
RB_HomePage_BannerRepository
();
/// <summary>
/// 首页标签仓储层
/// </summary>
private
readonly
RB_HomePage_LableRepository
homeLableRepository
=
new
RB_HomePage_LableRepository
();
#
region
首页
banner
列表
/// <summary>
/// 获取学生app首页banner列表
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public
List
<
RB_HomePage_Banner
>
GetHomePageBannerList
(
RB_HomePage_Banner
query
)
{
return
homePageBannerRepository
.
GetHomePageBannerList
(
query
);
}
[
TransactionCallHandler
]
public
bool
SetHomePage
(
List
<
RB_HomePage_Banner
>
list
)
{
bool
flag
=
false
;
var
oldList
=
homePageBannerRepository
.
GetHomePageBannerList
(
new
RB_HomePage_Banner
{
Group_Id
=
list
.
FirstOrDefault
()?.
Group_Id
??
0
});
oldList
.
ForEach
(
x
=>
x
.
Status
=
Common
.
Enum
.
DateStateEnum
.
Delete
);
homePageBannerRepository
.
UpdateBatch
(
oldList
);
foreach
(
var
item
in
list
)
{
if
(
item
.
BannerId
==
0
)
{
flag
=
homePageBannerRepository
.
Insert
(
item
)
>
0
;
}
else
{
flag
=
homePageBannerRepository
.
Update
(
item
);
}
}
return
flag
;
}
#
endregion
#
region
首页
banner
列表
/// <summary>
/// 获取学生app首页banner列表
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public
List
<
RB_HomePage_Lable
>
GetHomePageLableList
(
RB_HomePage_Lable
query
)
{
return
homeLableRepository
.
GetHomePageLableList
(
query
);
}
[
TransactionCallHandler
]
public
bool
SetHomePageLable
(
List
<
RB_HomePage_Lable
>
list
)
{
bool
flag
=
false
;
var
oldList
=
homeLableRepository
.
GetHomePageLableList
(
new
RB_HomePage_Lable
{
Group_Id
=
list
.
FirstOrDefault
()?.
Group_Id
??
0
});
oldList
.
ForEach
(
x
=>
x
.
Status
=
Common
.
Enum
.
DateStateEnum
.
Delete
);
homeLableRepository
.
UpdateBatch
(
oldList
);
foreach
(
var
item
in
list
)
{
if
(
item
.
LableId
==
0
)
{
flag
=
homeLableRepository
.
Insert
(
item
)
>
0
;
}
else
{
flag
=
homeLableRepository
.
Update
(
item
);
}
}
return
flag
;
}
#
endregion
}
}
Edu.Module.System/MsgLogModule.cs
View file @
3e12f67d
...
@@ -288,6 +288,51 @@ namespace Edu.Module.System
...
@@ -288,6 +288,51 @@ namespace Edu.Module.System
}
}
}
}
}
}
public
void
SendCode
(
string
code
,
Common
.
Enum
.
System
.
BaseTemplateTypeEnum
BaseTemplateType
,
RB_Msg_Log
msgLogModel
)
{
//查询当前集团的短信基础配置
var
msgBaseList
=
msgBaseRepository
.
GetListRepository
(
new
RB_Msg_Base_Function_ViewModel
{
Group_Id
=
msgLogModel
.
Group_Id
});
//查询当前下面是否有模板
var
allMsgBaseTemplateList
=
msgBaseTemplateRepository
.
GetListRepository
(
new
RB_Msg_BaseTemplate_ViewModel
{
BaseTemplateType
=
BaseTemplateType
,
Group_Id
=
msgLogModel
.
Group_Id
}).
Where
(
x
=>
x
.
TemplateStaus
==
0
);
if
(
msgBaseList
!=
null
&&
msgBaseList
.
Any
()
&&
allMsgBaseTemplateList
!=
null
&&
allMsgBaseTemplateList
.
Any
())
{
RB_Msg_Base_Function_ViewModel
model
=
new
RB_Msg_Base_Function_ViewModel
();
// msgBaseList.OrderBy(x => x.ID).FirstOrDefault();
if
(
allMsgBaseTemplateList
.
Where
(
x
=>
x
.
BaseTemplateType
==
BaseTemplateType
).
GroupBy
(
x
=>
x
.
StoreType
).
Count
()
>
1
)
{
model
=
msgBaseList
.
OrderBy
(
x
=>
x
.
ID
).
FirstOrDefault
();
}
else
{
model
=
msgBaseList
.
Where
(
x
=>
x
.
StoreType
==
allMsgBaseTemplateList
.
FirstOrDefault
().
StoreType
).
FirstOrDefault
();
}
if
(
model
!=
null
&&
model
.
ID
>
0
)
{
if
(!
string
.
IsNullOrWhiteSpace
(
model
.
MsgConfigure
))
{
msgLogModel
.
StoreType
=
model
.
StoreType
;
msgLogModel
.
MsgConfigure
=
model
.
MsgConfigure
;
int
id
=
msgLogRepository
.
Insert
(
msgLogModel
);
model
.
MsgBase
=
Common
.
Plugin
.
JsonHelper
.
DeserializeObject
<
RB_Msg_Base_ViewModel
>(
model
.
MsgConfigure
);
var
msgBaseTemplateList
=
allMsgBaseTemplateList
.
Where
(
x
=>
x
.
BaseTemplateType
==
BaseTemplateType
);
if
(!
string
.
IsNullOrWhiteSpace
(
model
.
MsgBase
.
AccessKeyId
)
&&
!
string
.
IsNullOrWhiteSpace
(
model
.
MsgBase
.
AccessSecret
)
&&
!
string
.
IsNullOrWhiteSpace
(
model
.
MsgBase
.
Domain
)
&&
!
string
.
IsNullOrWhiteSpace
(
model
.
MsgBase
.
RegionId
))
{
if
(
msgBaseTemplateList
!=
null
&&
msgBaseTemplateList
.
Any
(
x
=>
x
.
TemplateStaus
==
0
))
{
var
msgBaseTemplateModel
=
msgBaseTemplateList
.
Where
(
x
=>
x
.
TemplateStaus
==
0
).
FirstOrDefault
();
if
(
Common
.
Config
.
IsSendMsg
==
1
)
{
ThirdCore
.
Message
.
SMSService
.
SendCode
(
msgLogModel
.
ReceiverPhone
,
code
,
msgBaseTemplateModel
.
TemplateId
,
msgBaseTemplateModel
.
Sign
,
model
.
MsgBase
.
Domain
,
model
.
MsgBase
.
AccessKeyId
,
model
.
MsgBase
.
AccessSecret
,
model
.
MsgBase
.
RegionId
,
id
.
ToString
());
}
}
}
}
}
}
// ThirdCore.Message.SMSService.SendMsg("13551132417", PhoneMessage, "SMS_201722097", "印象之旅", "dysmsapi.aliyuncs.com", "LTAIwE7l9dImZSa3", "j47Ajn0d0WzUCIX8Biyj3P2r8QDltI", "cn-hangzhou");
}
#
endregion
#
endregion
}
}
}
}
Edu.Module.User/AccountModule.cs
View file @
3e12f67d
...
@@ -148,7 +148,7 @@ namespace Edu.Module.User
...
@@ -148,7 +148,7 @@ namespace Edu.Module.User
[
TransactionCallHandler
]
[
TransactionCallHandler
]
public
bool
SetBatchResetPassword
(
List
<
RB_Account_ViewModel
>
list
,
string
newPwd
)
public
bool
SetBatchResetPassword
(
List
<
RB_Account_ViewModel
>
list
,
string
newPwd
)
{
{
bool
flag
=
false
;
bool
flag
=
false
;
foreach
(
var
model
in
list
)
foreach
(
var
model
in
list
)
{
{
...
@@ -166,5 +166,36 @@ namespace Edu.Module.User
...
@@ -166,5 +166,36 @@ namespace Edu.Module.User
}
}
return
flag
;
return
flag
;
}
}
/// <summary>
/// 修改密码以及更新激活状态
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
[
TransactionCallHandler
]
public
bool
SetResetPwdAndAtatus
(
RB_Account_ViewModel
model
,
string
newPwd
)
{
bool
flag
=
false
;
Dictionary
<
string
,
object
>
fileds
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_Account_ViewModel
.
Password
),
newPwd
},
{
nameof
(
RB_Account_ViewModel
.
ActivationStatus
),
model
.
ActivationStatus
}
};
if
(!
string
.
IsNullOrWhiteSpace
(
model
.
OpenId
))
{
fileds
.
Add
(
nameof
(
RB_Account_ViewModel
.
OpenId
),
model
.
OpenId
);
}
var
wheres
=
new
List
<
WhereHelper
>
{
new
WhereHelper
(
nameof
(
RB_Account_ViewModel
.
AccountId
),
model
.
AccountId
),
new
WhereHelper
(
nameof
(
RB_Account_ViewModel
.
AccountType
),
model
.
AccountType
),
new
WhereHelper
(
nameof
(
RB_Account_ViewModel
.
Group_Id
),
model
.
Group_Id
)
};
flag
=
accountRepository
.
Update
(
fileds
,
wheres
);
return
flag
;
}
}
}
}
}
\ No newline at end of file
Edu.Module.User/StudentModule.cs
View file @
3e12f67d
...
@@ -32,6 +32,8 @@ namespace Edu.Module.User
...
@@ -32,6 +32,8 @@ namespace Edu.Module.User
/// </summary>
/// </summary>
private
readonly
AccountModule
accountModule
=
new
AccountModule
();
private
readonly
AccountModule
accountModule
=
new
AccountModule
();
/// <summary>
/// <summary>
/// 获取学生列表
/// 获取学生列表
/// </summary>
/// </summary>
...
@@ -225,5 +227,33 @@ namespace Edu.Module.User
...
@@ -225,5 +227,33 @@ namespace Edu.Module.User
}
}
return
flag
;
return
flag
;
}
}
#
region
学生兴趣爱好
/// <summary>
/// 新增学生兴趣
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public
bool
SetStudentInterest
(
RB_Student_ViewModel
model
)
{
if
(
model
.
StuId
==
0
)
{
return
false
;
}
else
{
Dictionary
<
string
,
object
>
fileds
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_Student_ViewModel
.
Interest
),
model
.
Interest
.
Trim
()
},
{
nameof
(
RB_Student_ViewModel
.
JapanBaseInfo
),(
int
)
model
.
JapanBaseInfo
},
{
nameof
(
RB_Student_ViewModel
.
StuIcon
),
model
.
StuIcon
.
Trim
()
},
{
nameof
(
RB_Student_ViewModel
.
StuSex
),
model
.
StuSex
},
{
nameof
(
RB_Student_ViewModel
.
UpdateTime
),
System
.
DateTime
.
Now
}
};
return
studentRepository
.
Update
(
fileds
,
new
WhereHelper
(
nameof
(
RB_Student_ViewModel
.
StuId
),
model
.
StuId
));
}
}
#
endregion
}
}
}
}
Edu.Module.User/TeacherModule.cs
View file @
3e12f67d
...
@@ -101,7 +101,7 @@ namespace Edu.Module.User
...
@@ -101,7 +101,7 @@ namespace Edu.Module.User
}
}
if
(!
string
.
IsNullOrEmpty
(
ids
))
if
(!
string
.
IsNullOrEmpty
(
ids
))
{
{
teacherClassList
=
classRepository
.
GetTeacherClassCountRepository
(
ids
);
teacherClassList
=
classRepository
.
GetTeacherClassCountRepository
(
ids
);
}
}
foreach
(
var
item
in
list
)
foreach
(
var
item
in
list
)
{
{
...
@@ -519,5 +519,18 @@ namespace Edu.Module.User
...
@@ -519,5 +519,18 @@ namespace Edu.Module.User
}
}
return
flag
;
return
flag
;
}
}
/// <summary>
/// 根据学生id获取教师账户
/// </summary>
/// <param name="teacherIds"></param>
/// <returns></returns>
public
List
<
RB_Teacher_ViewModel
>
GetListByStudentId
(
int
Student_Id
,
int
Group_Id
)
{
return
teacherRepository
.
GetListByStudentId
(
Student_Id
,
Group_Id
);
}
}
}
}
}
Edu.Repository/App/RB_HomePage_BannerRepository.cs
0 → 100644
View file @
3e12f67d
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
Edu.Common.Enum
;
using
Edu.Model.Entity.App
;
namespace
Edu.Repository.App
{
public
class
RB_HomePage_BannerRepository
:
BaseRepository
<
RB_HomePage_Banner
>
{
/// <summary>
/// 获取学生app首页banner列表
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public
List
<
RB_HomePage_Banner
>
GetHomePageBannerList
(
RB_HomePage_Banner
query
)
{
StringBuilder
builder
=
new
StringBuilder
();
builder
.
AppendFormat
(
@" SELECT * FROM RB_HomePage_Banner WHERE 1=1 "
);
builder
.
AppendFormat
(
" AND {0}={1} "
,
nameof
(
RB_HomePage_Banner
.
Status
),
(
int
)
DateStateEnum
.
Normal
);
if
(
query
!=
null
)
{
if
(
query
.
Group_Id
>
0
)
{
builder
.
AppendFormat
(
" AND {0}={1} "
,
nameof
(
RB_HomePage_Banner
.
Group_Id
),
query
.
Group_Id
);
}
if
(
query
.
School_Id
>
0
)
{
builder
.
AppendFormat
(
" AND {0}={1} "
,
nameof
(
RB_HomePage_Banner
.
School_Id
),
query
.
School_Id
);
}
}
return
Get
<
RB_HomePage_Banner
>(
builder
.
ToString
()).
ToList
();
}
}
}
Edu.Repository/App/RB_HomePage_LableRepository.cs
0 → 100644
View file @
3e12f67d
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
Edu.Common.Enum
;
using
Edu.Model.Entity.App
;
namespace
Edu.Repository.App
{
public
class
RB_HomePage_LableRepository
:
BaseRepository
<
RB_HomePage_Lable
>
{
/// <summary>
/// 获取学生app首页Lable列表
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public
List
<
RB_HomePage_Lable
>
GetHomePageLableList
(
RB_HomePage_Lable
query
)
{
StringBuilder
builder
=
new
StringBuilder
();
builder
.
AppendFormat
(
@" SELECT * FROM RB_HomePage_Lable WHERE 1=1 "
);
builder
.
AppendFormat
(
" AND {0}={1} "
,
nameof
(
RB_HomePage_Lable
.
Status
),
(
int
)
DateStateEnum
.
Normal
);
if
(
query
!=
null
)
{
if
(
query
.
Group_Id
>
0
)
{
builder
.
AppendFormat
(
" AND {0}={1} "
,
nameof
(
RB_HomePage_Lable
.
Group_Id
),
query
.
Group_Id
);
}
if
(
query
.
School_Id
>
0
)
{
builder
.
AppendFormat
(
" AND {0}={1} "
,
nameof
(
RB_HomePage_Lable
.
School_Id
),
query
.
School_Id
);
}
}
return
Get
<
RB_HomePage_Lable
>(
builder
.
ToString
()).
ToList
();
}
}
}
Edu.Repository/User/RB_AccountRepository.cs
View file @
3e12f67d
...
@@ -130,6 +130,10 @@ WHERE 1=1
...
@@ -130,6 +130,10 @@ WHERE 1=1
{
{
where
.
AppendFormat
(
" AND A.{0}={1} "
,
nameof
(
RB_Account_ViewModel
.
AccountId
),
query
.
AccountId
);
where
.
AppendFormat
(
" AND A.{0}={1} "
,
nameof
(
RB_Account_ViewModel
.
AccountId
),
query
.
AccountId
);
}
}
if
(!
string
.
IsNullOrEmpty
(
query
.
OpenId
))
{
where
.
AppendFormat
(
" AND A.{0}='{1}' "
,
nameof
(
RB_Account_ViewModel
.
OpenId
),
query
.
OpenId
);
}
if
(!
string
.
IsNullOrEmpty
(
query
.
PostName
))
if
(!
string
.
IsNullOrEmpty
(
query
.
PostName
))
{
{
where2
.
AppendFormat
(
" AND p.{0}='{1}' "
,
nameof
(
RB_Account_ViewModel
.
PostName
),
query
.
PostName
);
where2
.
AppendFormat
(
" AND p.{0}='{1}' "
,
nameof
(
RB_Account_ViewModel
.
PostName
),
query
.
PostName
);
...
...
Edu.Repository/User/RB_TeacherRepository.cs
View file @
3e12f67d
...
@@ -171,5 +171,26 @@ WHERE 1=1
...
@@ -171,5 +171,26 @@ WHERE 1=1
builder
.
AppendFormat
(
" AND t.{0} IN({1}) "
,
nameof
(
RB_Teacher_ViewModel
.
TId
),
teacherIds
);
builder
.
AppendFormat
(
" AND t.{0} IN({1}) "
,
nameof
(
RB_Teacher_ViewModel
.
TId
),
teacherIds
);
return
Get
<
RB_Teacher_ViewModel
>(
builder
.
ToString
(),
parameters
).
ToList
();
return
Get
<
RB_Teacher_ViewModel
>(
builder
.
ToString
(),
parameters
).
ToList
();
}
}
/// <summary>
/// 根据学生id获取教师账户
/// </summary>
/// <param name="teacherIds"></param>
/// <returns></returns>
public
List
<
RB_Teacher_ViewModel
>
GetListByStudentId
(
int
Student_Id
,
int
Group_Id
)
{
var
parameters
=
new
DynamicParameters
();
StringBuilder
builder
=
new
StringBuilder
();
builder
.
AppendFormat
(
@"
SELECT * from rb_teacher as t
LEFT JOIN (SELECT ClassId,TeacherId from rb_class_plan where `Status`=0 GROUP BY ClassId,TeacherId) as cp on t.TId=cp.TeacherId
LEFT JOIN rb_class as c on cp.ClassId=c.ClassId
LEFT JOIN rb_student_orderguest as sog on sog.ClassId=c.ClassId
where t.`Status`=0 and c.`Status`= and sog.`Status`=0 "
);
builder
.
AppendFormat
(
" AND sog.Student_Id={0} "
,
Student_Id
);
builder
.
AppendFormat
(
" AND t.{0}={1} "
,
nameof
(
RB_Teacher_ViewModel
.
Group_Id
),
Group_Id
);
return
Get
<
RB_Teacher_ViewModel
>(
builder
.
ToString
(),
parameters
).
ToList
();
}
}
}
}
}
\ No newline at end of file
Edu.WebApi/Controllers/APP/APPStudentLoginController.cs
View file @
3e12f67d
This diff is collapsed.
Click to expand it.
Edu.WebApi/Controllers/APP/AppIndexController.cs
0 → 100644
View file @
3e12f67d
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Threading.Tasks
;
using
Edu.Common.API
;
using
Edu.Common.Plugin
;
using
Edu.Model.Entity.App
;
using
Edu.Model.ViewModel.User
;
using
Edu.Module.System
;
using
Edu.Module.User
;
using
Edu.WebApi.Filter
;
using
Microsoft.AspNetCore.Cors
;
using
Microsoft.AspNetCore.Http
;
using
Microsoft.AspNetCore.Mvc
;
namespace
Edu.WebApi.Controllers.APP
{
[
Route
(
"api/[controller]/[action]"
)]
[
ApiExceptionFilter
]
[
ApiController
]
[
EnableCors
(
"AllowCors"
)]
public
class
AppIndexController
:
AppBaseController
{
private
StudentModule
StudentModule
=
new
StudentModule
();
private
readonly
AppHomePageModule
appHomePageModule
=
AOP
.
AOPHelper
.
CreateAOPObject
<
AppHomePageModule
>();
#
region
首次登录后填写兴趣爱好
/// <summary>
/// 首次登录记录用户的兴趣爱好
/// </summary>
/// <returns></returns>
[
HttpPost
]
public
ApiResult
SetInterest
()
{
var
query
=
new
RB_Student_ViewModel
()
{
Interest
=
base
.
ParmJObj
.
GetStringValue
(
"Interest"
),
JapanBaseInfo
=
base
.
ParmJObj
.
GetInt
(
"ClassId"
),
StuSex
=
base
.
ParmJObj
.
GetInt
(
"StuSex"
),
StuIcon
=
base
.
ParmJObj
.
GetStringValue
(
"StuIcon"
),
Group_Id
=
base
.
AppStudentInfo
.
Group_Id
,
School_Id
=
base
.
AppStudentInfo
.
School_Id
,
StuId
=
base
.
AppStudentInfo
.
AccountId
,
};
bool
result
=
StudentModule
.
SetStudentInterest
(
query
);
if
(
result
)
{
return
ApiResult
.
Success
(
""
);
}
else
{
return
ApiResult
.
Failed
(
"兴趣爱好记录失败"
);
}
}
#
endregion
#
region
首页
banner
/
老师信息
[
HttpPost
]
public
ApiResult
GetBannerIndex
()
{
var
query
=
new
RB_HomePage_Banner
()
{
Group_Id
=
base
.
AppStudentInfo
.
Group_Id
,
};
var
list
=
appHomePageModule
.
GetHomePageBannerList
(
query
).
OrderBy
(
x
=>
x
.
Sort
);
return
ApiResult
.
Success
(
""
,
list
);
}
#
endregion
#
region
首页
lable
(
菜单
)
[
HttpPost
]
public
ApiResult
GetLableIndex
()
{
var
query
=
new
RB_HomePage_Lable
()
{
Group_Id
=
base
.
AppStudentInfo
.
Group_Id
,
};
var
list
=
appHomePageModule
.
GetHomePageLableList
(
query
).
OrderBy
(
x
=>
x
.
Sort
);
return
ApiResult
.
Success
(
""
,
list
);
}
#
endregion
}
}
Edu.WebApi/Controllers/AppBaseController.cs
0 → 100644
View file @
3e12f67d
using
Edu.Common
;
using
Edu.Common.API
;
using
Edu.Common.Plugin
;
using
Edu.WebApi.Filter
;
using
Microsoft.AspNetCore.Cors
;
using
Microsoft.AspNetCore.Mvc
;
using
Newtonsoft.Json
;
using
Newtonsoft.Json.Linq
;
using
Edu.Model.CacheModel
;
using
Edu.Cache.User
;
using
Edu.Module.System
;
namespace
Edu.WebApi.Controllers
{
[
Route
(
"api/[controller]/[action]"
)]
[
ApiExceptionFilter
]
[
ApiFilter
]
[
EnableCors
(
"AllowCors"
)]
public
class
AppBaseController
:
ControllerBase
{
/// <summary>
/// 整理前端传递的post参数
/// </summary>
/// <param name="requestMsg"></param>
/// <returns></returns>
public
RequestParm
RequestParm
{
get
{
var
requestParm
=
new
RequestParm
();
#
region
读取
post
参数
var
requestMsg
=
Request
.
HttpContext
.
Items
[
GlobalKey
.
JWT_App_Student_Key
];
if
(
requestMsg
!=
null
)
{
requestParm
=
JsonConvert
.
DeserializeObject
<
RequestParm
>(
requestMsg
.
ToString
());
if
(
Request
.
HttpContext
.
Items
[
GlobalKey
.
JWT_App_Student_Key
]
!=
null
)
{
JObject
parms
=
JObject
.
Parse
(
Request
.
HttpContext
.
Items
[
GlobalKey
.
JWT_App_Student_Key
].
ToString
());
requestParm
.
Uid
=
parms
.
GetStringValue
(
"uid"
);
}
}
#
endregion
//根据token 获取uid
return
requestParm
;
}
}
/// <summary>
/// 获取参数
/// </summary>
public
JObject
ParmJObj
{
get
{
if
(
this
.
RequestParm
!=
null
&&
this
.
RequestParm
.
Msg
!=
null
)
{
return
JObject
.
Parse
(
this
.
RequestParm
.
Msg
.
ToString
());
}
return
new
JObject
();
}
}
/// <summary>
/// 用户缓存
/// </summary>
public
AppStudentInfo
AppStudentInfo
{
get
{
var
parm
=
this
.
RequestParm
;
AppStudentInfo
appStudentInfo
=
AppStudentReidsCache
.
GetUserLoginInfo
(
parm
.
Uid
);
return
AppStudentInfo
;
}
}
/// <summary>
/// 根据Id获取用户信息
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
public
AppStudentInfo
GetAppStudentInfo
(
object
Id
)
{
AppStudentInfo
appStudentInfo
=
AppStudentReidsCache
.
GetUserLoginInfo
(
Id
);
return
AppStudentInfo
;
}
}
}
\ No newline at end of file
Edu.WebApi/Controllers/Public/AppPublicController.cs
0 → 100644
View file @
3e12f67d
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Threading.Tasks
;
using
Edu.Common.API
;
using
Edu.Common.Plugin
;
using
Edu.Model.Entity.App
;
using
Edu.Model.Entity.System
;
using
Edu.Model.ViewModel.System
;
using
Edu.Module.System
;
using
Edu.WebApi.Filter
;
using
Microsoft.AspNetCore.Cors
;
using
Microsoft.AspNetCore.Mvc
;
namespace
Edu.WebApi.Controllers.Public
{
/// <summary>
/// 系统公用接口
/// </summary>
[
Route
(
"api/[controller]/[action]"
)]
[
ApiExceptionFilter
]
[
ApiController
]
[
EnableCors
(
"AllowCors"
)]
public
class
AppPublicController
:
BaseController
{
/// <summary>
/// 短信处理类对象
/// </summary>
private
readonly
AppHomePageModule
appHomePageModule
=
AOP
.
AOPHelper
.
CreateAOPObject
<
AppHomePageModule
>();
#
region
首页轮播图
[
HttpPost
]
public
ApiResult
GetBannerIndex
()
{
var
query
=
new
RB_HomePage_Banner
()
{
Group_Id
=
base
.
UserInfo
.
Group_Id
,
};
var
list
=
appHomePageModule
.
GetHomePageBannerList
(
query
).
OrderBy
(
x
=>
x
.
Sort
);
return
ApiResult
.
Success
(
""
,
list
);
}
/// <summary>
/// 添加修改轮播图信息
/// </summary>
/// <returns></returns>
[
HttpPost
]
public
ApiResult
SetBannerIndex
()
{
var
list
=
Common
.
Plugin
.
JsonHelper
.
DeserializeObject
<
List
<
RB_HomePage_Banner
>>(
RequestParm
.
Msg
.
ToString
());
if
(
list
==
null
||
!
list
.
Any
())
{
return
ApiResult
.
Failed
(
"请传入轮播图信息"
);
}
else
if
(
list
.
Any
(
x
=>
string
.
IsNullOrWhiteSpace
(
x
.
BannerPic
)))
{
return
ApiResult
.
Failed
(
"请传入轮播图信息"
);
}
list
.
Where
(
x
=>
x
.
BannerId
==
0
).
ToList
().
ForEach
(
x
=>
x
.
CreateBy
=
base
.
UserInfo
.
Id
);
list
.
Where
(
x
=>
x
.
BannerId
==
0
).
ToList
().
ForEach
(
x
=>
x
.
CreateTime
=
System
.
DateTime
.
Now
);
list
.
ForEach
(
x
=>
x
.
UpdateTime
=
System
.
DateTime
.
Now
);
list
.
ForEach
(
x
=>
x
.
UpdateBy
=
base
.
UserInfo
.
Id
);
list
.
ForEach
(
x
=>
x
.
School_Id
=
base
.
UserInfo
.
School_Id
);
list
.
ForEach
(
x
=>
x
.
Status
=
Common
.
Enum
.
DateStateEnum
.
Normal
);
bool
flag
=
appHomePageModule
.
SetHomePage
(
list
);
return
flag
?
ApiResult
.
Success
()
:
ApiResult
.
Failed
();
}
#
endregion
#
region
首页标签
[
HttpPost
]
public
ApiResult
GetLableIndex
()
{
var
query
=
new
RB_HomePage_Lable
()
{
Group_Id
=
base
.
UserInfo
.
Group_Id
,
};
var
list
=
appHomePageModule
.
GetHomePageLableList
(
query
).
OrderBy
(
x
=>
x
.
Sort
);
return
ApiResult
.
Success
(
""
,
list
);
}
/// <summary>
/// 添加修改首页标签信息
/// </summary>
/// <returns></returns>
[
HttpPost
]
public
ApiResult
SetLableIndex
()
{
var
list
=
Common
.
Plugin
.
JsonHelper
.
DeserializeObject
<
List
<
RB_HomePage_Lable
>>(
RequestParm
.
Msg
.
ToString
());
if
(
list
==
null
||
!
list
.
Any
())
{
return
ApiResult
.
Failed
(
"请传入标签信息"
);
}
else
if
(
list
.
Any
(
x
=>
string
.
IsNullOrWhiteSpace
(
x
.
LableName
)))
{
return
ApiResult
.
Failed
(
"请输入标签名称"
);
}
list
.
Where
(
x
=>
x
.
LableId
==
0
).
ToList
().
ForEach
(
x
=>
x
.
CreateBy
=
base
.
UserInfo
.
Id
);
list
.
Where
(
x
=>
x
.
LableId
==
0
).
ToList
().
ForEach
(
x
=>
x
.
CreateTime
=
System
.
DateTime
.
Now
);
list
.
ForEach
(
x
=>
x
.
UpdateTime
=
System
.
DateTime
.
Now
);
list
.
ForEach
(
x
=>
x
.
UpdateBy
=
base
.
UserInfo
.
Id
);
list
.
ForEach
(
x
=>
x
.
School_Id
=
base
.
UserInfo
.
School_Id
);
list
.
ForEach
(
x
=>
x
.
Status
=
Common
.
Enum
.
DateStateEnum
.
Normal
);
bool
flag
=
appHomePageModule
.
SetHomePageLable
(
list
);
return
flag
?
ApiResult
.
Success
()
:
ApiResult
.
Failed
();
}
#
endregion
}
}
Edu.WebApi/Helper/APPApiTokenHelper.cs
0 → 100644
View file @
3e12f67d
using
Edu.Common.API
;
using
JWT
;
using
JWT.Algorithms
;
using
JWT.Serializers
;
using
Newtonsoft.Json.Linq
;
using
System
;
using
System.Collections.Generic
;
namespace
Edu.WebApi.Helper
{
/// <summary>
/// Token帮助类
/// </summary>
public
class
APPApiTokenHelper
{
/// <summary>
/// 生成Token
/// </summary>
/// <param name="requestFromEnum">来源</param>
/// <returns></returns>
public
static
string
CreateToken
(
string
userKey
,
IAppStudentInfoToken
userInfo
)
{
IDateTimeProvider
provider
=
new
UtcDateTimeProvider
();
var
now
=
provider
.
GetNow
().
AddMinutes
(-
1
);
var
unixEpoch
=
new
DateTime
(
1970
,
1
,
1
,
0
,
0
,
0
,
DateTimeKind
.
Utc
);
var
secondsSinceEpoch
=
Math
.
Round
((
now
-
unixEpoch
).
TotalSeconds
);
var
payload
=
new
Dictionary
<
string
,
object
>()
{
{
"iat"
,
secondsSinceEpoch
},
{
"exp"
,
secondsSinceEpoch
+
Common
.
Config
.
JwtExpirTime
},
{
userKey
,
userInfo
}
};
IJwtAlgorithm
algorithm
=
new
HMACSHA256Algorithm
();
IJsonSerializer
serializer
=
new
JsonNetSerializer
();
IBase64UrlEncoder
urlEncoder
=
new
JwtBase64UrlEncoder
();
IJwtEncoder
encoder
=
new
JwtEncoder
(
algorithm
,
serializer
,
urlEncoder
);
string
secret
=
Common
.
Config
.
JwtSecretKey
;
string
token
=
encoder
.
Encode
(
payload
,
secret
);
return
token
;
}
/// <summary>
/// 解析Token
/// </summary>
/// <param name="token"></param>
/// <returns></returns>
public
static
JObject
AnalysisToken
(
string
token
)
{
IJsonSerializer
serializer
=
new
JsonNetSerializer
();
IDateTimeProvider
provider
=
new
UtcDateTimeProvider
();
IJwtValidator
validator
=
new
JwtValidator
(
serializer
,
provider
);
IBase64UrlEncoder
urlEncoder
=
new
JwtBase64UrlEncoder
();
IJwtDecoder
decoder
=
new
JwtDecoder
(
serializer
,
validator
,
urlEncoder
);
string
secret
=
Common
.
Config
.
JwtSecretKey
;
//token为之前生成的字符串
var
json
=
decoder
.
Decode
(
token
,
secret
,
verify
:
true
);
JObject
jwtJson
=
JObject
.
Parse
(
json
);
return
jwtJson
;
}
}
}
\ No newline at end of file
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