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
127709bf
Commit
127709bf
authored
May 18, 2021
by
liuyang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
finished 讲师管理
parent
2dc28582
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
317 additions
and
2 deletions
+317
-2
TeacherController.java
...m/qkdata/biz/management/controller/TeacherController.java
+71
-0
TeacherPO.java
...main/java/com/qkdata/biz/management/entity/TeacherPO.java
+61
-0
TeacherMapper.java
.../java/com/qkdata/biz/management/mapper/TeacherMapper.java
+25
-0
TeacherService.java
...ava/com/qkdata/biz/management/service/TeacherService.java
+82
-0
QueryTeacherModel.java
.../java/com/qkdata/biz/management/vo/QueryTeacherModel.java
+12
-0
TeacherModel.java
src/main/java/com/qkdata/biz/management/vo/TeacherModel.java
+46
-0
RequestUtil.java
src/main/java/com/qkdata/common/util/RequestUtil.java
+2
-2
teacherMapper.xml
src/main/resources/mappers/management/teacherMapper.xml
+18
-0
No files found.
src/main/java/com/qkdata/biz/management/controller/TeacherController.java
0 → 100644
View file @
127709bf
package
com
.
qkdata
.
biz
.
management
.
controller
;
import
com.qkdata.biz.common.BizConstants
;
import
com.qkdata.biz.management.service.TeacherService
;
import
com.qkdata.biz.management.vo.QueryTeacherModel
;
import
com.qkdata.biz.management.vo.TeacherModel
;
import
com.qkdata.common.annotation.SysLog
;
import
com.qkdata.common.base.model.PageResult
;
import
com.qkdata.common.base.model.Result
;
import
io.swagger.annotations.ApiOperation
;
import
org.apache.shiro.authz.annotation.Logical
;
import
org.apache.shiro.authz.annotation.RequiresRoles
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.List
;
/**
* <p>
* 讲师 前端控制器
* </p>
*
* @author liuyang
* @since 2021-05-18
*/
@RestController
@RequestMapping
(
"/api/mgr/teacher"
)
public
class
TeacherController
{
@Autowired
private
TeacherService
teacherService
;
@ApiOperation
(
"添加讲师信息"
)
@PostMapping
(
"/save"
)
@SysLog
(
value
=
"添加讲师信息"
)
@RequiresRoles
(
value
=
{
BizConstants
.
ROLE_ADMIN
,
BizConstants
.
ROLE_OPERATOR
},
logical
=
Logical
.
OR
)
public
Result
<
String
>
save
(
@RequestBody
@Validated
TeacherModel
model
){
teacherService
.
saveModel
(
model
);
return
Result
.
succeed
(
"ok"
);
}
@ApiOperation
(
"修改讲师信息"
)
@PostMapping
(
"/update"
)
@SysLog
(
value
=
"添加讲师信息"
)
@RequiresRoles
(
value
=
{
BizConstants
.
ROLE_ADMIN
,
BizConstants
.
ROLE_OPERATOR
},
logical
=
Logical
.
OR
)
public
Result
<
String
>
update
(
@RequestBody
@Validated
TeacherModel
model
){
teacherService
.
updateModel
(
model
);
return
Result
.
succeed
(
"ok"
);
}
@ApiOperation
(
"删除讲师信息"
)
@PostMapping
(
"/delete"
)
@SysLog
(
value
=
"删除讲师信息"
)
@RequiresRoles
(
value
=
{
BizConstants
.
ROLE_ADMIN
,
BizConstants
.
ROLE_OPERATOR
},
logical
=
Logical
.
OR
)
public
Result
<
String
>
delete
(
@RequestBody
List
<
Long
>
ids
){
teacherService
.
removeByIds
(
ids
);
return
Result
.
succeed
(
"ok"
);
}
@ApiOperation
(
"查询讲师信息"
)
@PostMapping
(
"/list"
)
@RequiresRoles
(
value
=
{
BizConstants
.
ROLE_ADMIN
,
BizConstants
.
ROLE_OPERATOR
},
logical
=
Logical
.
OR
)
public
PageResult
<
TeacherModel
>
list
(
@RequestBody
QueryTeacherModel
param
){
return
teacherService
.
queryPage
(
param
);
}
}
src/main/java/com/qkdata/biz/management/entity/TeacherPO.java
0 → 100644
View file @
127709bf
package
com
.
qkdata
.
biz
.
management
.
entity
;
import
com.baomidou.mybatisplus.annotation.TableLogic
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.qkdata.common.base.entity.BasePO
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
/**
* <p>
* 讲师
* </p>
*
* @author liuyang
* @since 2021-05-18
*/
@Data
@EqualsAndHashCode
(
callSuper
=
true
)
@TableName
(
"teacher"
)
public
class
TeacherPO
extends
BasePO
{
private
static
final
long
serialVersionUID
=
1L
;
/**
* 编号
*/
private
String
code
;
/**
* 姓名
*/
private
String
name
;
/**
* 电话
*/
private
String
mobile
;
/**
* 所属机构ID
*/
private
Long
orgId
;
/**
* 简介
*/
private
String
introduce
;
/**
* 头像
*/
private
String
avatarUrl
;
/**
* 删除标识
*/
@TableLogic
private
Boolean
isDel
;
}
src/main/java/com/qkdata/biz/management/mapper/TeacherMapper.java
0 → 100644
View file @
127709bf
package
com
.
qkdata
.
biz
.
management
.
mapper
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.qkdata.biz.management.entity.TeacherPO
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.qkdata.biz.management.vo.QueryTeacherModel
;
import
com.qkdata.biz.management.vo.TeacherModel
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
/**
* <p>
* 讲师 Mapper 接口
* </p>
*
* @author liuyang
* @since 2021-05-18
*/
@Mapper
public
interface
TeacherMapper
extends
BaseMapper
<
TeacherPO
>
{
List
<
TeacherModel
>
queryPage
(
Page
page
,
@Param
(
"p"
)
QueryTeacherModel
param
);
}
src/main/java/com/qkdata/biz/management/service/TeacherService.java
0 → 100644
View file @
127709bf
package
com
.
qkdata
.
biz
.
management
.
service
;
import
cn.hutool.core.util.StrUtil
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.qkdata.biz.management.entity.TeacherPO
;
import
com.qkdata.biz.management.mapper.TeacherMapper
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.qkdata.biz.management.vo.QueryTeacherModel
;
import
com.qkdata.biz.management.vo.TeacherModel
;
import
com.qkdata.common.base.enums.CodeEnum
;
import
com.qkdata.common.base.exception.BusinessException
;
import
com.qkdata.common.base.model.PageResult
;
import
javafx.util.Builder
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
/**
* <p>
* $!{table.comment} 服务类
* </p>
*
* @author liuyang
* @since 2021-05-18
*/
@Service
public
class
TeacherService
extends
ServiceImpl
<
TeacherMapper
,
TeacherPO
>
{
private
String
defaultNo
=
"00001"
;
private
String
codePrefix
=
"TH"
;
public
void
saveModel
(
TeacherModel
model
)
{
TeacherPO
po
=
new
TeacherPO
();
BeanUtils
.
copyProperties
(
model
,
po
);
String
dbMaxCode
=
findMaxNo
();
String
teacherCode
=
getTeacherCode
(
dbMaxCode
);
po
.
setCode
(
teacherCode
);
super
.
save
(
po
);
}
private
String
findMaxNo
()
{
TeacherPO
po
=
baseMapper
.
selectOne
(
Wrappers
.<
TeacherPO
>
lambdaQuery
().
orderByDesc
(
TeacherPO:
:
getCode
).
last
(
"limit 1"
));
if
(
po
!=
null
){
return
po
.
getCode
();
}
return
""
;
}
private
String
getTeacherCode
(
String
dbMaxCode
){
if
(
StrUtil
.
isNotBlank
(
dbMaxCode
)){
String
noStr
=
StrUtil
.
sub
(
dbMaxCode
,
2
,
dbMaxCode
.
length
());
int
no
=
Integer
.
parseInt
(
noStr
);
no
++;
String
code
=
String
.
format
(
"%05d"
,
no
);
return
StrUtil
.
format
(
"{}{}"
,
codePrefix
,
code
);
}
return
StrUtil
.
format
(
"{}{}"
,
codePrefix
,
defaultNo
);
}
public
void
updateModel
(
TeacherModel
model
)
{
TeacherPO
po
=
getById
(
model
.
getId
());
if
(
po
==
null
){
throw
new
BusinessException
(
"讲师不存在"
);
}
po
.
setName
(
model
.
getName
());
po
.
setMobile
(
model
.
getMobile
());
po
.
setIntroduce
(
model
.
getIntroduce
());
po
.
setOrgId
(
model
.
getOrgId
());
updateById
(
po
);
}
public
PageResult
<
TeacherModel
>
queryPage
(
QueryTeacherModel
param
)
{
Page
page
=
new
Page
(
param
.
getPageIndex
(),
param
.
getPageSize
());
List
<
TeacherModel
>
list
=
baseMapper
.
queryPage
(
page
,
param
);
//TODO add courseCount
return
PageResult
.<
TeacherModel
>
builder
().
code
(
CodeEnum
.
SUCCESS
.
getCode
()).
count
(
page
.
getTotal
()).
data
(
list
).
build
();
}
}
\ No newline at end of file
src/main/java/com/qkdata/biz/management/vo/QueryTeacherModel.java
0 → 100644
View file @
127709bf
package
com
.
qkdata
.
biz
.
management
.
vo
;
import
com.qkdata.common.constants.Constants
;
import
lombok.Data
;
@Data
public
class
QueryTeacherModel
{
private
int
pageIndex
=
Constants
.
DEFAULT_PAGE
;
private
int
pageSize
=
Constants
.
DEFAULT_PAGE_SIZE
;
private
String
name
;
private
String
orgName
;
}
src/main/java/com/qkdata/biz/management/vo/TeacherModel.java
0 → 100644
View file @
127709bf
package
com
.
qkdata
.
biz
.
management
.
vo
;
import
lombok.Data
;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.NotNull
;
@Data
public
class
TeacherModel
{
private
Long
id
;
/**
* 编号
*/
private
String
code
;
/**
* 姓名
*/
@NotBlank
(
message
=
"讲师姓名不能为空"
)
private
String
name
;
/**
* 电话
*/
private
String
mobile
;
/**
* 所属机构ID
*/
@NotNull
(
message
=
"所属机构不能为空"
)
private
Long
orgId
;
/**
* 所属机构名称
*/
private
String
orgName
;
/**
* 简介
*/
private
String
introduce
;
/**
* 课程数量
*/
private
int
courseCount
;
}
src/main/java/com/qkdata/common/util/RequestUtil.java
View file @
127709bf
...
@@ -13,9 +13,9 @@ import java.nio.charset.StandardCharsets;
...
@@ -13,9 +13,9 @@ import java.nio.charset.StandardCharsets;
import
java.util.Map
;
import
java.util.Map
;
/**
/**
* @author
songminghui
* @author
* @date 2018-11-26 下午6:52
* @date 2018-11-26 下午6:52
* @email
songminghui@shangweiec.com
* @email
* @description
* @description
*/
*/
public
class
RequestUtil
{
public
class
RequestUtil
{
...
...
src/main/resources/mappers/management/teacherMapper.xml
0 → 100644
View file @
127709bf
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.qkdata.biz.management.mapper.TeacherMapper"
>
<select
id=
"queryPage"
resultType=
"com.qkdata.biz.management.vo.TeacherModel"
>
SELECT t.*,o.`name` orgName
FROM teacher t
INNER JOIN organization o on t.org_id = o.id
where t.is_del = 0
<if
test=
"p.name != null and p.name != ''"
>
and t.name like concat('%',#{p.name},'%')
</if>
<if
test=
"p.orgName != null and p.orgName != ''"
>
and o.`name` like concat('%',#{p.orgName},'%')
</if>
order by t.create_time desc
</select>
</mapper>
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