Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
O
online-edu-backend
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Redmine
Redmine
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
online-edu
online-edu-backend
Commits
010d4080
Commit
010d4080
authored
Jul 01, 2021
by
liuyang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加讲师角色
修改添加讲师功能 添加重置密码接口
parent
39292f18
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
117 additions
and
14 deletions
+117
-14
BizConstants.java
src/main/java/com/qkdata/biz/common/BizConstants.java
+4
-0
CourseController.java
...om/qkdata/biz/management/controller/CourseController.java
+2
-2
TeacherController.java
...m/qkdata/biz/management/controller/TeacherController.java
+1
-1
TeacherPO.java
...main/java/com/qkdata/biz/management/entity/TeacherPO.java
+4
-0
TeacherService.java
...ava/com/qkdata/biz/management/service/TeacherService.java
+47
-0
TeacherModel.java
src/main/java/com/qkdata/biz/management/vo/TeacherModel.java
+4
-0
SysLoginController.java
...ava/com/qkdata/biz/sys/controller/SysLoginController.java
+7
-7
SysUserController.java
...java/com/qkdata/biz/sys/controller/SysUserController.java
+9
-0
SysUserService.java
src/main/java/com/qkdata/biz/sys/service/SysUserService.java
+14
-4
V1.0.15__update.sql
src/main/resources/db/migration/V1.0.15__update.sql
+25
-0
No files found.
src/main/java/com/qkdata/biz/common/BizConstants.java
View file @
010d4080
...
@@ -12,6 +12,10 @@ public class BizConstants {
...
@@ -12,6 +12,10 @@ public class BizConstants {
* 运营人员
* 运营人员
*/
*/
public
static
final
String
ROLE_OPERATOR
=
"OPERATOR"
;
public
static
final
String
ROLE_OPERATOR
=
"OPERATOR"
;
/**
* 讲师
*/
public
static
final
String
ROLE_TEACHER
=
"TEACHER"
;
/**
/**
* 企业管理员
* 企业管理员
*/
*/
...
...
src/main/java/com/qkdata/biz/management/controller/CourseController.java
View file @
010d4080
...
@@ -37,7 +37,7 @@ public class CourseController {
...
@@ -37,7 +37,7 @@ public class CourseController {
@ApiOperation
(
"课程查询"
)
@ApiOperation
(
"课程查询"
)
@PostMapping
(
"/list"
)
@PostMapping
(
"/list"
)
@RequiresRoles
(
value
=
{
BizConstants
.
ROLE_ADMIN
,
BizConstants
.
ROLE_OPERATOR
},
logical
=
Logical
.
OR
)
@RequiresRoles
(
value
=
{
BizConstants
.
ROLE_ADMIN
,
BizConstants
.
ROLE_OPERATOR
,
BizConstants
.
ROLE_TEACHER
},
logical
=
Logical
.
OR
)
@SysLog
(
"课程查询"
)
@SysLog
(
"课程查询"
)
public
PageResult
<
CourseListItemModel
>
list
(
@RequestBody
QueryCourseModel
param
){
public
PageResult
<
CourseListItemModel
>
list
(
@RequestBody
QueryCourseModel
param
){
...
@@ -45,7 +45,7 @@ public class CourseController {
...
@@ -45,7 +45,7 @@ public class CourseController {
}
}
@ApiOperation
(
"获取课程详情"
)
@ApiOperation
(
"获取课程详情"
)
@GetMapping
(
"/{id}"
)
@GetMapping
(
"/{id}"
)
@RequiresRoles
(
value
=
{
BizConstants
.
ROLE_ADMIN
,
BizConstants
.
ROLE_OPERATOR
},
logical
=
Logical
.
OR
)
@RequiresRoles
(
value
=
{
BizConstants
.
ROLE_ADMIN
,
BizConstants
.
ROLE_OPERATOR
,
BizConstants
.
ROLE_TEACHER
},
logical
=
Logical
.
OR
)
@SysLog
(
"获取课程详情"
)
@SysLog
(
"获取课程详情"
)
public
Result
<
CourseDetailModel
>
courseDetail
(
@PathVariable
Long
id
){
public
Result
<
CourseDetailModel
>
courseDetail
(
@PathVariable
Long
id
){
return
Result
.
succeed
(
courseService
.
getCourseDetail
(
id
));
return
Result
.
succeed
(
courseService
.
getCourseDetail
(
id
));
...
...
src/main/java/com/qkdata/biz/management/controller/TeacherController.java
View file @
010d4080
...
@@ -58,7 +58,7 @@ public class TeacherController {
...
@@ -58,7 +58,7 @@ public class TeacherController {
@SysLog
(
value
=
"删除讲师信息"
)
@SysLog
(
value
=
"删除讲师信息"
)
@RequiresRoles
(
value
=
{
BizConstants
.
ROLE_ADMIN
,
BizConstants
.
ROLE_OPERATOR
},
logical
=
Logical
.
OR
)
@RequiresRoles
(
value
=
{
BizConstants
.
ROLE_ADMIN
,
BizConstants
.
ROLE_OPERATOR
},
logical
=
Logical
.
OR
)
public
Result
<
String
>
delete
(
@RequestBody
List
<
Long
>
ids
){
public
Result
<
String
>
delete
(
@RequestBody
List
<
Long
>
ids
){
teacherService
.
remove
ById
s
(
ids
);
teacherService
.
remove
Teacher
s
(
ids
);
return
Result
.
succeed
(
"ok"
);
return
Result
.
succeed
(
"ok"
);
}
}
@ApiOperation
(
"查询讲师信息"
)
@ApiOperation
(
"查询讲师信息"
)
...
...
src/main/java/com/qkdata/biz/management/entity/TeacherPO.java
View file @
010d4080
...
@@ -50,6 +50,10 @@ public class TeacherPO extends BasePO {
...
@@ -50,6 +50,10 @@ public class TeacherPO extends BasePO {
* 头像
* 头像
*/
*/
private
String
avatarUrl
;
private
String
avatarUrl
;
/**
* 讲师帐号
*/
private
String
account
;
/**
/**
* 删除标识
* 删除标识
...
...
src/main/java/com/qkdata/biz/management/service/TeacherService.java
View file @
010d4080
...
@@ -4,15 +4,22 @@ import cn.hutool.core.util.StrUtil;
...
@@ -4,15 +4,22 @@ import cn.hutool.core.util.StrUtil;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.google.common.collect.Lists
;
import
com.qkdata.biz.enums.AccountStatusEnum
;
import
com.qkdata.biz.management.entity.TeacherPO
;
import
com.qkdata.biz.management.entity.TeacherPO
;
import
com.qkdata.biz.management.mapper.TeacherMapper
;
import
com.qkdata.biz.management.mapper.TeacherMapper
;
import
com.qkdata.biz.management.vo.QueryTeacherModel
;
import
com.qkdata.biz.management.vo.QueryTeacherModel
;
import
com.qkdata.biz.management.vo.TeacherModel
;
import
com.qkdata.biz.management.vo.TeacherModel
;
import
com.qkdata.biz.sys.entity.SysUserPO
;
import
com.qkdata.biz.sys.service.SysUserService
;
import
com.qkdata.biz.sys.vo.SysUserModel
;
import
com.qkdata.common.base.enums.CodeEnum
;
import
com.qkdata.common.base.enums.CodeEnum
;
import
com.qkdata.common.base.exception.BusinessException
;
import
com.qkdata.common.base.exception.BusinessException
;
import
com.qkdata.common.base.model.PageResult
;
import
com.qkdata.common.base.model.PageResult
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.List
;
import
java.util.List
;
...
@@ -30,6 +37,10 @@ public class TeacherService extends ServiceImpl<TeacherMapper, TeacherPO> {
...
@@ -30,6 +37,10 @@ public class TeacherService extends ServiceImpl<TeacherMapper, TeacherPO> {
private
String
defaultNo
=
"00001"
;
private
String
defaultNo
=
"00001"
;
private
String
codePrefix
=
"TH"
;
private
String
codePrefix
=
"TH"
;
@Autowired
private
SysUserService
sysUserService
;
@Transactional
public
void
saveModel
(
TeacherModel
model
)
{
public
void
saveModel
(
TeacherModel
model
)
{
TeacherPO
po
=
new
TeacherPO
();
TeacherPO
po
=
new
TeacherPO
();
BeanUtils
.
copyProperties
(
model
,
po
);
BeanUtils
.
copyProperties
(
model
,
po
);
...
@@ -37,6 +48,26 @@ public class TeacherService extends ServiceImpl<TeacherMapper, TeacherPO> {
...
@@ -37,6 +48,26 @@ public class TeacherService extends ServiceImpl<TeacherMapper, TeacherPO> {
String
teacherCode
=
getTeacherCode
(
dbMaxCode
);
String
teacherCode
=
getTeacherCode
(
dbMaxCode
);
po
.
setCode
(
teacherCode
);
po
.
setCode
(
teacherCode
);
super
.
save
(
po
);
super
.
save
(
po
);
//添加讲师帐号
if
(
StrUtil
.
isNotBlank
(
po
.
getAccount
())){
addTeacherAccount
(
po
.
getAccount
(),
po
.
getName
());
}
}
/**
* 添加讲师帐号
* @param account
* @param name
*/
private
void
addTeacherAccount
(
String
account
,
String
name
)
{
SysUserModel
model
=
new
SysUserModel
();
model
.
setUsername
(
account
);
model
.
setPassword
(
"123456"
);
model
.
setStatus
(
AccountStatusEnum
.
ENABLE
);
model
.
setNickName
(
name
);
model
.
setRoleIdList
(
Lists
.
newArrayList
(
6L
));
sysUserService
.
saveUser
(
model
);
}
}
private
String
findMaxNo
()
{
private
String
findMaxNo
()
{
...
@@ -58,6 +89,7 @@ public class TeacherService extends ServiceImpl<TeacherMapper, TeacherPO> {
...
@@ -58,6 +89,7 @@ public class TeacherService extends ServiceImpl<TeacherMapper, TeacherPO> {
return
StrUtil
.
format
(
"{}{}"
,
codePrefix
,
defaultNo
);
return
StrUtil
.
format
(
"{}{}"
,
codePrefix
,
defaultNo
);
}
}
@Transactional
public
void
updateModel
(
TeacherModel
model
)
{
public
void
updateModel
(
TeacherModel
model
)
{
TeacherPO
po
=
getById
(
model
.
getId
());
TeacherPO
po
=
getById
(
model
.
getId
());
if
(
po
==
null
){
if
(
po
==
null
){
...
@@ -68,6 +100,10 @@ public class TeacherService extends ServiceImpl<TeacherMapper, TeacherPO> {
...
@@ -68,6 +100,10 @@ public class TeacherService extends ServiceImpl<TeacherMapper, TeacherPO> {
po
.
setIntroduce
(
model
.
getIntroduce
());
po
.
setIntroduce
(
model
.
getIntroduce
());
po
.
setOrgId
(
model
.
getOrgId
());
po
.
setOrgId
(
model
.
getOrgId
());
updateById
(
po
);
updateById
(
po
);
//添加讲师帐号
if
(
StrUtil
.
isBlank
(
po
.
getAccount
())
&&
StrUtil
.
isNotBlank
(
model
.
getAccount
())){
addTeacherAccount
(
model
.
getAccount
(),
po
.
getName
());
}
}
}
public
PageResult
<
TeacherModel
>
queryPage
(
QueryTeacherModel
param
)
{
public
PageResult
<
TeacherModel
>
queryPage
(
QueryTeacherModel
param
)
{
...
@@ -77,4 +113,14 @@ public class TeacherService extends ServiceImpl<TeacherMapper, TeacherPO> {
...
@@ -77,4 +113,14 @@ public class TeacherService extends ServiceImpl<TeacherMapper, TeacherPO> {
return
PageResult
.<
TeacherModel
>
builder
().
code
(
CodeEnum
.
SUCCESS
.
getCode
()).
count
(
page
.
getTotal
()).
data
(
list
).
build
();
return
PageResult
.<
TeacherModel
>
builder
().
code
(
CodeEnum
.
SUCCESS
.
getCode
()).
count
(
page
.
getTotal
()).
data
(
list
).
build
();
}
}
@Transactional
public
void
removeTeachers
(
List
<
Long
>
ids
)
{
for
(
Long
id
:
ids
){
TeacherPO
teacherPO
=
getById
(
id
);
removeById
(
id
);
//删除讲师帐号
sysUserService
.
removeByUsername
(
teacherPO
.
getAccount
());
}
}
}
}
\ No newline at end of file
src/main/java/com/qkdata/biz/management/vo/TeacherModel.java
View file @
010d4080
...
@@ -38,6 +38,10 @@ public class TeacherModel {
...
@@ -38,6 +38,10 @@ public class TeacherModel {
* 简介
* 简介
*/
*/
private
String
introduce
;
private
String
introduce
;
/**
* 讲师帐号
*/
private
String
account
;
/**
/**
* 课程数量
* 课程数量
*/
*/
...
...
src/main/java/com/qkdata/biz/sys/controller/SysLoginController.java
View file @
010d4080
...
@@ -28,27 +28,27 @@ public class SysLoginController {
...
@@ -28,27 +28,27 @@ public class SysLoginController {
@ApiOperation
(
"登陆"
)
@ApiOperation
(
"登陆"
)
@SysLog
(
value
=
"登陆"
,
includeParam
=
false
)
@SysLog
(
value
=
"登陆"
,
includeParam
=
false
)
@PostMapping
(
"/login"
)
@PostMapping
(
"/login"
)
public
Result
<
LoginUserInfo
>
login
(
@RequestBody
@Valid
LoginModel
loginModel
)
throws
JsonProcessingException
{
public
Result
<
LoginUserInfo
>
login
(
@RequestBody
@Valid
LoginModel
loginModel
)
throws
JsonProcessingException
{
LoginUserInfo
loginUserInfo
=
shiroService
.
login
(
loginModel
.
getUsername
(),
loginModel
.
getPassword
());
LoginUserInfo
loginUserInfo
=
shiroService
.
login
(
loginModel
.
getUsername
(),
loginModel
.
getPassword
());
hasPermission
(
loginUserInfo
);
hasPermission
(
loginUserInfo
);
return
Result
.
succeed
(
loginUserInfo
);
return
Result
.
succeed
(
loginUserInfo
);
}
}
private
void
hasPermission
(
LoginUserInfo
loginUserInfo
)
{
private
void
hasPermission
(
LoginUserInfo
loginUserInfo
)
{
List
<
SysRoleModel
>
roles
=
loginUserInfo
.
getRoles
();
List
<
SysRoleModel
>
roles
=
loginUserInfo
.
getRoles
();
if
(
CollUtil
.
isEmpty
(
roles
)){
if
(
CollUtil
.
isEmpty
(
roles
))
{
throw
new
BusinessException
(
"对不起,您没有权限"
);
throw
new
BusinessException
(
"对不起,您没有权限"
);
}
}
boolean
hasPermission
=
false
;
boolean
hasPermission
=
false
;
for
(
SysRoleModel
role
:
roles
){
for
(
SysRoleModel
role
:
roles
)
{
if
(
role
.
getCode
().
equals
(
BizConstants
.
ROLE_ADMIN
)
||
role
.
getCode
().
equals
(
BizConstants
.
ROLE_OPERATOR
)
)
{
if
(
role
.
getCode
().
equals
(
BizConstants
.
ROLE_ADMIN
)
||
role
.
getCode
().
equals
(
BizConstants
.
ROLE_OPERATOR
)
||
role
.
getCode
().
equals
(
BizConstants
.
ROLE_TEACHER
))
{
hasPermission
=
true
;
hasPermission
=
true
;
break
;
break
;
}
}
}
}
if
(!
hasPermission
){
if
(!
hasPermission
)
{
throw
new
BusinessException
(
"对不起,您没有权限"
);
throw
new
BusinessException
(
"对不起,您没有权限"
);
}
}
}
}
...
@@ -56,7 +56,7 @@ public class SysLoginController {
...
@@ -56,7 +56,7 @@ public class SysLoginController {
@ApiOperation
(
"登出"
)
@ApiOperation
(
"登出"
)
@SysLog
(
"登出"
)
@SysLog
(
"登出"
)
@GetMapping
(
"/logout"
)
@GetMapping
(
"/logout"
)
public
Result
<
String
>
logout
(){
public
Result
<
String
>
logout
()
{
SecurityUtils
.
getSubject
().
logout
();
SecurityUtils
.
getSubject
().
logout
();
return
Result
.
succeed
(
"ok"
);
return
Result
.
succeed
(
"ok"
);
}
}
...
...
src/main/java/com/qkdata/biz/sys/controller/SysUserController.java
View file @
010d4080
...
@@ -110,4 +110,13 @@ public class SysUserController {
...
@@ -110,4 +110,13 @@ public class SysUserController {
sysUserService
.
removeUsers
(
Arrays
.
asList
(
userIds
));
sysUserService
.
removeUsers
(
Arrays
.
asList
(
userIds
));
return
Result
.
succeed
(
"ok"
);
return
Result
.
succeed
(
"ok"
);
}
}
@ApiOperation
(
"重置密码"
)
@SysLog
(
"重置密码"
)
@GetMapping
(
"/resetPwd"
)
@RequiresRoles
(
value
=
{
BizConstants
.
ROLE_ADMIN
,
BizConstants
.
ROLE_OPERATOR
},
logical
=
Logical
.
OR
)
public
Result
<
String
>
resetPwd
(
@RequestParam
Long
id
){
sysUserService
.
resetPwd
(
id
);
return
Result
.
succeed
(
"ok"
);
}
}
}
src/main/java/com/qkdata/biz/sys/service/SysUserService.java
View file @
010d4080
...
@@ -9,10 +9,7 @@ import com.qkdata.biz.common.BizConstants;
...
@@ -9,10 +9,7 @@ import com.qkdata.biz.common.BizConstants;
import
com.qkdata.biz.enums.AccountStatusEnum
;
import
com.qkdata.biz.enums.AccountStatusEnum
;
import
com.qkdata.biz.enums.AccountTypeEnum
;
import
com.qkdata.biz.enums.AccountTypeEnum
;
import
com.qkdata.biz.enums.ProductTypeEnum
;
import
com.qkdata.biz.enums.ProductTypeEnum
;
import
com.qkdata.biz.management.entity.OrgSurplusPO
;
import
com.qkdata.biz.management.entity.*
;
import
com.qkdata.biz.management.entity.OrgUserReceiveRecordPO
;
import
com.qkdata.biz.management.entity.OrganizationPO
;
import
com.qkdata.biz.management.entity.UserCourseAuthPO
;
import
com.qkdata.biz.management.service.OrgSurplusService
;
import
com.qkdata.biz.management.service.OrgSurplusService
;
import
com.qkdata.biz.management.service.OrgUserReceiveRecordService
;
import
com.qkdata.biz.management.service.OrgUserReceiveRecordService
;
import
com.qkdata.biz.management.service.OrganizationService
;
import
com.qkdata.biz.management.service.OrganizationService
;
...
@@ -308,4 +305,17 @@ public class SysUserService extends BaseServiceImpl<SysUserMapper, SysUserPO> {
...
@@ -308,4 +305,17 @@ public class SysUserService extends BaseServiceImpl<SysUserMapper, SysUserPO> {
updateById
(
oldUser
);
updateById
(
oldUser
);
}
}
public
void
removeByUsername
(
String
username
)
{
remove
(
Wrappers
.<
SysUserPO
>
lambdaQuery
().
eq
(
SysUserPO:
:
getUsername
,
username
));
}
public
void
resetPwd
(
Long
id
)
{
SysUserPO
userPO
=
getById
(
id
);
if
(
userPO
==
null
){
throw
new
BusinessException
(
"请求错误,用户不存在"
);
}
userPO
.
setPassword
(
new
Sha256Hash
(
"123456"
,
userPO
.
getSalt
()).
toHex
());
updateById
(
userPO
);
}
}
}
src/main/resources/db/migration/V1.0.15__update.sql
0 → 100644
View file @
010d4080
CREATE
TABLE
`question`
(
`id`
bigint
(
20
)
NOT
NULL
AUTO_INCREMENT
,
`user_id`
bigint
(
20
)
NULL
COMMENT
'用户ID'
,
`course_id`
bigint
(
20
)
NULL
COMMENT
'课程ID'
,
`chapter_id`
bigint
(
20
)
NULL
COMMENT
'章节ID'
,
`content`
text
NULL
COMMENT
'问题内容'
,
`create_time`
datetime
(
0
)
NULL
,
`update_time`
datetime
(
0
)
NULL
,
`status`
VARCHAR
(
20
)
NULL
COMMENT
'状态:待回复、已回复、已完成'
,
PRIMARY
KEY
(
`id`
)
)
COMMENT
=
'用户问题表'
;
CREATE
TABLE
`answer`
(
`id`
bigint
(
20
)
NOT
NULL
AUTO_INCREMENT
,
`question_id`
bigint
(
20
)
NULL
COMMENT
'问题ID'
,
`user_id`
bigint
(
20
)
NULL
COMMENT
'回复人ID'
,
`type`
VARCHAR
(
20
)
NULL
COMMENT
'区分讲师回复还是用户回复'
,
`content`
text
NULL
COMMENT
'内容'
,
`create_time`
datetime
(
0
)
NULL
,
`update_time`
datetime
(
0
)
NULL
,
PRIMARY
KEY
(
`id`
)
)
COMMENT
=
'问题回答表'
;
ALTER
TABLE
`teacher`
ADD
COLUMN
`account`
varchar
(
20
)
NULL
COMMENT
'讲师帐号'
AFTER
`avatar_url`
;
INSERT
INTO
`sys_role`
VALUES
(
6
,
'TEACHER'
,
'讲师'
,
'2021-04-25 16:10:06'
,
'2021-04-25 16:10:06'
);
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