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
0517b07e
Commit
0517b07e
authored
Oct 11, 2021
by
liuyang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
课程支持url
parent
d854f06f
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
156 additions
and
85 deletions
+156
-85
VideoTypeEnum.java
src/main/java/com/qkdata/biz/enums/VideoTypeEnum.java
+6
-0
ResourcePO.java
...ain/java/com/qkdata/biz/management/entity/ResourcePO.java
+5
-0
CourseService.java
...java/com/qkdata/biz/management/service/CourseService.java
+132
-85
CourseChaperModel.java
.../java/com/qkdata/biz/management/vo/CourseChaperModel.java
+5
-0
SaveCourseChaperModel.java
...a/com/qkdata/biz/management/vo/SaveCourseChaperModel.java
+3
-0
V1.0.3__update.sql
src/main/resources/db/migration/V1.0.3__update.sql
+5
-0
No files found.
src/main/java/com/qkdata/biz/enums/VideoTypeEnum.java
0 → 100644
View file @
0517b07e
package
com
.
qkdata
.
biz
.
enums
;
public
enum
VideoTypeEnum
{
URL
,
ALI
;
}
src/main/java/com/qkdata/biz/management/entity/ResourcePO.java
View file @
0517b07e
package
com
.
qkdata
.
biz
.
management
.
entity
;
package
com
.
qkdata
.
biz
.
management
.
entity
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.qkdata.biz.enums.VideoTypeEnum
;
import
com.qkdata.common.base.entity.BasePO
;
import
com.qkdata.common.base.entity.BasePO
;
import
lombok.Data
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.EqualsAndHashCode
;
...
@@ -44,6 +45,10 @@ public class ResourcePO extends BasePO {
...
@@ -44,6 +45,10 @@ public class ResourcePO extends BasePO {
* 视频时长
* 视频时长
*/
*/
private
Float
videoDuration
;
private
Float
videoDuration
;
/**
* 视频类型
*/
private
VideoTypeEnum
videoType
;
}
}
src/main/java/com/qkdata/biz/management/service/CourseService.java
View file @
0517b07e
...
@@ -13,10 +13,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
...
@@ -13,10 +13,7 @@ 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.google.common.collect.Lists
;
import
com.qkdata.aliyun.service.AliyunService
;
import
com.qkdata.aliyun.service.AliyunService
;
import
com.qkdata.biz.enums.CourseAllowEnum
;
import
com.qkdata.biz.enums.*
;
import
com.qkdata.biz.enums.CourseChargeModelEnum
;
import
com.qkdata.biz.enums.CourseModelEnum
;
import
com.qkdata.biz.enums.CourseStatusEnum
;
import
com.qkdata.biz.management.entity.*
;
import
com.qkdata.biz.management.entity.*
;
import
com.qkdata.biz.management.mapper.*
;
import
com.qkdata.biz.management.mapper.*
;
import
com.qkdata.biz.management.vo.*
;
import
com.qkdata.biz.management.vo.*
;
...
@@ -80,6 +77,7 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
...
@@ -80,6 +77,7 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
/**
/**
* 后台-分页查询课程列表
* 后台-分页查询课程列表
*
* @param param
* @param param
* @return
* @return
*/
*/
...
@@ -99,6 +97,7 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
...
@@ -99,6 +97,7 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
/**
/**
* 获取课程详情
* 获取课程详情
*
* @param id
* @param id
* @return
* @return
*/
*/
...
@@ -121,12 +120,13 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
...
@@ -121,12 +120,13 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
/**
/**
* 添加该课程是否已被用户收藏
* 添加该课程是否已被用户收藏
*
* @param model
* @param model
*/
*/
private
void
setFavorite
(
CourseDetailModel
model
)
{
private
void
setFavorite
(
CourseDetailModel
model
)
{
if
(
UserContext
.
getUser
()
!=
null
){
if
(
UserContext
.
getUser
()
!=
null
)
{
UserFavoritesPO
po
=
userFavoritesService
.
findByUserIdAndCourseId
(
UserContext
.
getUserId
(),
model
.
getId
());
UserFavoritesPO
po
=
userFavoritesService
.
findByUserIdAndCourseId
(
UserContext
.
getUserId
(),
model
.
getId
());
if
(
po
!=
null
){
if
(
po
!=
null
)
{
model
.
setFavorite
(
true
);
model
.
setFavorite
(
true
);
}
}
}
}
...
@@ -135,10 +135,11 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
...
@@ -135,10 +135,11 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
/**
/**
* 添加课程授权的企业
* 添加课程授权的企业
*
* @param model
* @param model
*/
*/
private
void
addOrgInfo
(
CourseDetailModel
model
)
{
private
void
addOrgInfo
(
CourseDetailModel
model
)
{
if
(
model
.
getAllow
()
==
CourseAllowEnum
.
SPECIFY
){
if
(
model
.
getAllow
()
==
CourseAllowEnum
.
SPECIFY
)
{
List
<
CourseAllowEnterpriseModel
>
allowOrgList
=
baseMapper
.
selectOrgListByCourseId
(
model
.
getId
());
List
<
CourseAllowEnterpriseModel
>
allowOrgList
=
baseMapper
.
selectOrgListByCourseId
(
model
.
getId
());
model
.
setAllowOrgList
(
allowOrgList
);
model
.
setAllowOrgList
(
allowOrgList
);
}
}
...
@@ -146,6 +147,7 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
...
@@ -146,6 +147,7 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
/**
/**
* 添加课程上传的附件
* 添加课程上传的附件
*
* @param model
* @param model
*/
*/
private
void
addAttachmentInfo
(
CourseDetailModel
model
)
{
private
void
addAttachmentInfo
(
CourseDetailModel
model
)
{
...
@@ -155,6 +157,7 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
...
@@ -155,6 +157,7 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
/**
/**
* 添加课程的章节列表
* 添加课程的章节列表
*
* @param model
* @param model
*/
*/
private
void
addChaperInfo
(
CourseDetailModel
model
)
{
private
void
addChaperInfo
(
CourseDetailModel
model
)
{
...
@@ -164,6 +167,7 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
...
@@ -164,6 +167,7 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
/**
/**
* 添加课程的标签
* 添加课程的标签
*
* @param model
* @param model
*/
*/
private
void
addTags
(
CourseDetailModel
model
)
{
private
void
addTags
(
CourseDetailModel
model
)
{
...
@@ -173,6 +177,7 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
...
@@ -173,6 +177,7 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
/**
/**
* 添加课程所属系列
* 添加课程所属系列
*
* @param model
* @param model
*/
*/
private
void
addSeriesInfo
(
CourseDetailModel
model
)
{
private
void
addSeriesInfo
(
CourseDetailModel
model
)
{
...
@@ -184,6 +189,7 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
...
@@ -184,6 +189,7 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
/**
/**
* 添加课程所属教师信息
* 添加课程所属教师信息
*
* @param model
* @param model
*/
*/
private
void
addTeacherInfo
(
CourseDetailModel
model
)
{
private
void
addTeacherInfo
(
CourseDetailModel
model
)
{
...
@@ -197,6 +203,7 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
...
@@ -197,6 +203,7 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
/**
/**
* 后台-修改章节名称
* 后台-修改章节名称
*
* @param model
* @param model
*/
*/
public
void
modifyChaperName
(
ModifyChaperNameModel
model
)
{
public
void
modifyChaperName
(
ModifyChaperNameModel
model
)
{
...
@@ -210,6 +217,7 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
...
@@ -210,6 +217,7 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
/**
/**
* 后台-删除章节
* 后台-删除章节
*
* @param chaperId
* @param chaperId
*/
*/
@Transactional
@Transactional
...
@@ -219,14 +227,14 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
...
@@ -219,14 +227,14 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
chapterMapper
.
deleteById
(
chaperId
);
chapterMapper
.
deleteById
(
chaperId
);
//删除资源
//删除资源
ResourcePO
resourcePO
=
resourceService
.
getById
(
po
.
getResourceId
());
ResourcePO
resourcePO
=
resourceService
.
getById
(
po
.
getResourceId
());
if
(
resourcePO
!=
null
){
if
(
resourcePO
!=
null
)
{
resourceService
.
removeById
(
po
.
getResourceId
());
resourceService
.
removeById
(
po
.
getResourceId
());
}
}
if
(
StrUtil
.
isNotBlank
(
resourcePO
.
getVideoId
())){
if
(
StrUtil
.
isNotBlank
(
resourcePO
.
getVideoId
()))
{
try
{
try
{
aliyunService
.
removeVideo
(
resourcePO
.
getVideoId
());
aliyunService
.
removeVideo
(
resourcePO
.
getVideoId
());
}
catch
(
ClientException
e
)
{
}
catch
(
ClientException
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
log
.
error
(
e
.
getMessage
(),
e
);
}
}
}
}
...
@@ -237,6 +245,7 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
...
@@ -237,6 +245,7 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
/**
/**
* 修改课程状态
* 修改课程状态
*
* @param model
* @param model
*/
*/
public
void
modifyStatus
(
ModifyCourseStatusModel
model
)
{
public
void
modifyStatus
(
ModifyCourseStatusModel
model
)
{
...
@@ -244,15 +253,17 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
...
@@ -244,15 +253,17 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
}
}
public
List
<
CourseChaperModel
>
chaperList
(
Long
courseId
)
{
public
List
<
CourseChaperModel
>
chaperList
(
Long
courseId
)
{
return
chaperList
(
courseId
,
true
);
return
chaperList
(
courseId
,
true
);
}
}
/**
/**
* 获取课程章节列表
* 获取课程章节列表
*
* @param courseId
* @param courseId
* @param needCoverUrl
* @param needCoverUrl
* @return
* @return
*/
*/
public
List
<
CourseChaperModel
>
chaperList
(
Long
courseId
,
boolean
needCoverUrl
)
{
public
List
<
CourseChaperModel
>
chaperList
(
Long
courseId
,
boolean
needCoverUrl
)
{
List
<
CourseChaperModel
>
list
=
Lists
.
newArrayList
();
List
<
CourseChaperModel
>
list
=
Lists
.
newArrayList
();
List
<
CourseChapterPO
>
poList
=
chapterMapper
.
selectList
(
Wrappers
.<
CourseChapterPO
>
lambdaQuery
().
eq
(
CourseChapterPO:
:
getCourseId
,
courseId
).
orderByAsc
(
CourseChapterPO:
:
getSortNo
));
List
<
CourseChapterPO
>
poList
=
chapterMapper
.
selectList
(
Wrappers
.<
CourseChapterPO
>
lambdaQuery
().
eq
(
CourseChapterPO:
:
getCourseId
,
courseId
).
orderByAsc
(
CourseChapterPO:
:
getSortNo
));
if
(
CollUtil
.
isNotEmpty
(
poList
))
{
if
(
CollUtil
.
isNotEmpty
(
poList
))
{
...
@@ -263,7 +274,7 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
...
@@ -263,7 +274,7 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
model
.
setCourseId
(
po
.
getCourseId
());
model
.
setCourseId
(
po
.
getCourseId
());
model
.
setSortNo
(
po
.
getSortNo
());
model
.
setSortNo
(
po
.
getSortNo
());
Long
resourceId
=
po
.
getResourceId
();
Long
resourceId
=
po
.
getResourceId
();
setVideoInfo
(
resourceId
,
model
,
needCoverUrl
);
setVideoInfo
(
resourceId
,
model
,
needCoverUrl
);
list
.
add
(
model
);
list
.
add
(
model
);
}
}
}
}
...
@@ -272,23 +283,29 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
...
@@ -272,23 +283,29 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
/**
/**
* 设置章节对应视频的信息
* 设置章节对应视频的信息
*
* @param resourceId
* @param resourceId
* @param model
* @param model
*/
*/
private
void
setVideoInfo
(
Long
resourceId
,
CourseChaperModel
model
,
boolean
needCoverUrl
)
{
private
void
setVideoInfo
(
Long
resourceId
,
CourseChaperModel
model
,
boolean
needCoverUrl
)
{
ResourcePO
resourcePO
=
resourceService
.
getById
(
resourceId
);
ResourcePO
resourcePO
=
resourceService
.
getById
(
resourceId
);
if
(
resourcePO
!=
null
)
{
if
(
resourcePO
!=
null
)
{
if
(
resourcePO
.
getVideoType
()
==
VideoTypeEnum
.
URL
){
model
.
setVideoType
(
resourcePO
.
getVideoType
());
model
.
setVideoUrl
(
resourcePO
.
getUrl
());
}
else
{
String
videoId
=
resourcePO
.
getVideoId
();
String
videoId
=
resourcePO
.
getVideoId
();
model
.
setResourceId
(
resourceId
);
model
.
setResourceId
(
resourceId
);
model
.
setDuration
(
resourcePO
.
getVideoDuration
());
model
.
setDuration
(
resourcePO
.
getVideoDuration
());
model
.
setSize
(
resourcePO
.
getSize
());
model
.
setSize
(
resourcePO
.
getSize
());
model
.
setVideoType
(
resourcePO
.
getVideoType
());
if
(
needCoverUrl
)
{
if
(
needCoverUrl
)
{
try
{
try
{
GetVideoInfoResponse
response
=
aliyunService
.
getVideoInfo
(
videoId
);
GetVideoInfoResponse
response
=
aliyunService
.
getVideoInfo
(
videoId
);
GetVideoInfoResponse
.
Video
videoInfo
=
response
.
getVideo
();
GetVideoInfoResponse
.
Video
videoInfo
=
response
.
getVideo
();
if
(
videoInfo
!=
null
)
{
if
(
videoInfo
!=
null
)
{
if
(
StrUtil
.
isNotBlank
(
videoInfo
.
getCoverURL
()))
{
if
(
StrUtil
.
isNotBlank
(
videoInfo
.
getCoverURL
()))
{
model
.
setCoverUrl
(
videoInfo
.
getCoverURL
());
model
.
setCoverUrl
(
videoInfo
.
getCoverURL
());
}
}
...
@@ -298,6 +315,7 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
...
@@ -298,6 +315,7 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
log
.
error
(
e
.
getMessage
(),
e
);
log
.
error
(
e
.
getMessage
(),
e
);
}
}
}
}
}
}
}
}
}
...
@@ -305,6 +323,7 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
...
@@ -305,6 +323,7 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
/**
/**
* 后台-分页查询课程系列表表
* 后台-分页查询课程系列表表
*
* @param model
* @param model
* @return
* @return
*/
*/
...
@@ -316,6 +335,7 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
...
@@ -316,6 +335,7 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
/**
/**
* 后台-保存课程系列
* 后台-保存课程系列
*
* @param po
* @param po
* @return
* @return
*/
*/
...
@@ -326,6 +346,7 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
...
@@ -326,6 +346,7 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
/**
/**
* 后台-新增或修改课程信息
* 后台-新增或修改课程信息
*
* @param model
* @param model
*/
*/
@Transactional
@Transactional
...
@@ -334,21 +355,22 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
...
@@ -334,21 +355,22 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
saveCourseChaper
(
id
,
model
.
getChaperList
());
saveCourseChaper
(
id
,
model
.
getChaperList
());
saveCourseAttachment
(
id
,
model
.
getAttachmenIds
());
saveCourseAttachment
(
id
,
model
.
getAttachmenIds
());
saveOrUpdateCourseTags
(
id
,
model
.
getTagIds
());
saveOrUpdateCourseTags
(
id
,
model
.
getTagIds
());
if
(
model
.
getAllow
()
==
CourseAllowEnum
.
SPECIFY
){
if
(
model
.
getAllow
()
==
CourseAllowEnum
.
SPECIFY
)
{
saveOrUpdateOrg
(
id
,
model
.
getAllowOrgIds
());
saveOrUpdateOrg
(
id
,
model
.
getAllowOrgIds
());
}
}
}
}
/**
/**
* 新增或修改课程授权的企业信息
* 新增或修改课程授权的企业信息
*
* @param courseId
* @param courseId
* @param allowOrgIds
* @param allowOrgIds
*/
*/
private
void
saveOrUpdateOrg
(
Long
courseId
,
List
<
Long
>
allowOrgIds
)
{
private
void
saveOrUpdateOrg
(
Long
courseId
,
List
<
Long
>
allowOrgIds
)
{
if
(
CollUtil
.
isNotEmpty
(
allowOrgIds
)){
if
(
CollUtil
.
isNotEmpty
(
allowOrgIds
))
{
allowOrgCourseMapper
.
deleteByCourseId
(
courseId
);
allowOrgCourseMapper
.
deleteByCourseId
(
courseId
);
for
(
Long
orgId
:
allowOrgIds
){
for
(
Long
orgId
:
allowOrgIds
)
{
AllowOrgCoursePO
po
=
new
AllowOrgCoursePO
();
AllowOrgCoursePO
po
=
new
AllowOrgCoursePO
();
po
.
setCourseId
(
courseId
);
po
.
setCourseId
(
courseId
);
po
.
setOrgId
(
orgId
);
po
.
setOrgId
(
orgId
);
...
@@ -359,13 +381,14 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
...
@@ -359,13 +381,14 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
/**
/**
* 新增或修改课程所属标签
* 新增或修改课程所属标签
*
* @param courseId
* @param courseId
* @param tagIds
* @param tagIds
*/
*/
private
void
saveOrUpdateCourseTags
(
Long
courseId
,
List
<
Long
>
tagIds
)
{
private
void
saveOrUpdateCourseTags
(
Long
courseId
,
List
<
Long
>
tagIds
)
{
if
(
CollUtil
.
isNotEmpty
(
tagIds
)){
if
(
CollUtil
.
isNotEmpty
(
tagIds
))
{
tagRelMapper
.
deleteByCourseId
(
courseId
);
tagRelMapper
.
deleteByCourseId
(
courseId
);
for
(
Long
tagId
:
tagIds
){
for
(
Long
tagId
:
tagIds
)
{
CourseTagRelPO
po
=
new
CourseTagRelPO
();
CourseTagRelPO
po
=
new
CourseTagRelPO
();
po
.
setCourseId
(
courseId
);
po
.
setCourseId
(
courseId
);
po
.
setTagId
(
tagId
);
po
.
setTagId
(
tagId
);
...
@@ -376,13 +399,14 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
...
@@ -376,13 +399,14 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
/**
/**
* 新增或修改课程上传的附件
* 新增或修改课程上传的附件
*
* @param courseId
* @param courseId
* @param attachmenIds
* @param attachmenIds
*/
*/
private
void
saveCourseAttachment
(
Long
courseId
,
List
<
Long
>
attachmenIds
)
{
private
void
saveCourseAttachment
(
Long
courseId
,
List
<
Long
>
attachmenIds
)
{
if
(
CollUtil
.
isNotEmpty
(
attachmenIds
)){
if
(
CollUtil
.
isNotEmpty
(
attachmenIds
))
{
attachmentMapper
.
deleteByCourseId
(
courseId
);
attachmentMapper
.
deleteByCourseId
(
courseId
);
for
(
Long
attachmentId
:
attachmenIds
){
for
(
Long
attachmentId
:
attachmenIds
)
{
CourseAttachmentPO
po
=
new
CourseAttachmentPO
();
CourseAttachmentPO
po
=
new
CourseAttachmentPO
();
po
.
setCourseId
(
courseId
);
po
.
setCourseId
(
courseId
);
po
.
setResourceId
(
attachmentId
);
po
.
setResourceId
(
attachmentId
);
...
@@ -393,26 +417,35 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
...
@@ -393,26 +417,35 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
/**
/**
* 新增课程的章节列表
* 新增课程的章节列表
*
* @param courseId
* @param courseId
* @param chaperList
* @param chaperList
*/
*/
private
void
saveCourseChaper
(
Long
courseId
,
List
<
SaveCourseChaperModel
>
chaperList
)
{
private
void
saveCourseChaper
(
Long
courseId
,
List
<
SaveCourseChaperModel
>
chaperList
)
{
if
(
CollUtil
.
isNotEmpty
(
chaperList
)){
if
(
CollUtil
.
isNotEmpty
(
chaperList
))
{
for
(
SaveCourseChaperModel
chaperModel
:
chaperList
){
for
(
SaveCourseChaperModel
chaperModel
:
chaperList
)
{
Long
chaperId
=
chaperModel
.
getId
();
Long
chaperId
=
chaperModel
.
getId
();
if
(
chaperId
==
null
){
if
(
chaperId
==
null
)
{
//只做章节新增保存
//只做章节新增保存
ResourcePO
resourcePO
=
new
ResourcePO
();
ResourcePO
resourcePO
=
new
ResourcePO
();
resourcePO
.
setName
(
chaperModel
.
getName
());
resourcePO
.
setName
(
chaperModel
.
getName
());
if
(
chaperModel
.
getVideoType
()
==
VideoTypeEnum
.
ALI
){
resourcePO
.
setVideoType
(
chaperModel
.
getVideoType
());
resourcePO
.
setVideoId
(
chaperModel
.
getVideoId
());
resourcePO
.
setVideoId
(
chaperModel
.
getVideoId
());
try
{
try
{
GetVideoInfoResponse
videoInfoResponse
=
aliyunService
.
getVideoInfo
(
chaperModel
.
getVideoId
());
GetVideoInfoResponse
videoInfoResponse
=
aliyunService
.
getVideoInfo
(
chaperModel
.
getVideoId
());
resourcePO
.
setSize
(
videoInfoResponse
.
getVideo
().
getSize
());
resourcePO
.
setSize
(
videoInfoResponse
.
getVideo
().
getSize
());
resourcePO
.
setVideoDuration
(
videoInfoResponse
.
getVideo
().
getDuration
());
resourcePO
.
setVideoDuration
(
videoInfoResponse
.
getVideo
().
getDuration
());
}
catch
(
ClientException
e
)
{
}
catch
(
ClientException
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
log
.
error
(
e
.
getMessage
(),
e
);
}
}
}
else
{
resourcePO
.
setVideoType
(
chaperModel
.
getVideoType
());
resourcePO
.
setUrl
(
chaperModel
.
getVideoUrl
());
}
resourceService
.
save
(
resourcePO
);
resourceService
.
save
(
resourcePO
);
CourseChapterPO
chapterPO
=
new
CourseChapterPO
();
CourseChapterPO
chapterPO
=
new
CourseChapterPO
();
chapterPO
.
setCourseId
(
courseId
);
chapterPO
.
setCourseId
(
courseId
);
chapterPO
.
setSortNo
(
chaperModel
.
getSortNo
());
chapterPO
.
setSortNo
(
chaperModel
.
getSortNo
());
...
@@ -420,12 +453,15 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
...
@@ -420,12 +453,15 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
chapterPO
.
setResourceId
(
resourcePO
.
getId
());
chapterPO
.
setResourceId
(
resourcePO
.
getId
());
chapterMapper
.
insert
(
chapterPO
);
chapterMapper
.
insert
(
chapterPO
);
}
}
}
}
}
}
}
}
/**
/**
* 新增或修改课程的基础信息
* 新增或修改课程的基础信息
*
* @param model
* @param model
* @return
* @return
*/
*/
...
@@ -448,12 +484,12 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
...
@@ -448,12 +484,12 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
po
.
setModel
(
CourseModelEnum
.
VOD
);
po
.
setModel
(
CourseModelEnum
.
VOD
);
po
.
setSeriesId
(
model
.
getSeriesId
());
po
.
setSeriesId
(
model
.
getSeriesId
());
po
.
setAllow
(
model
.
getAllow
());
po
.
setAllow
(
model
.
getAllow
());
if
(
po
.
getAllow
()
==
CourseAllowEnum
.
USER_TAG
){
if
(
po
.
getAllow
()
==
CourseAllowEnum
.
USER_TAG
)
{
if
(
Strings
.
isBlank
(
model
.
getUserTagIds
())){
if
(
Strings
.
isBlank
(
model
.
getUserTagIds
()))
{
throw
new
BusinessException
(
"请选择用户标签"
);
throw
new
BusinessException
(
"请选择用户标签"
);
}
}
po
.
setUserTagIds
(
model
.
getUserTagIds
());
po
.
setUserTagIds
(
model
.
getUserTagIds
());
}
else
{
}
else
{
po
.
setUserTagIds
(
""
);
po
.
setUserTagIds
(
""
);
}
}
saveOrUpdate
(
po
);
saveOrUpdate
(
po
);
...
@@ -462,6 +498,7 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
...
@@ -462,6 +498,7 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
/**
/**
* 获取视频信息
* 获取视频信息
*
* @return
* @return
* @throws ClientException
* @throws ClientException
*/
*/
...
@@ -477,32 +514,34 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
...
@@ -477,32 +514,34 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
/**
/**
* 用户端-搜索课程
* 用户端-搜索课程
*
* @param model
* @param model
* @return
* @return
*/
*/
public
PageResult
<
SearchCourseResultModel
>
search
(
SearchCourseConditionModel
model
,
AuthorizedUser
user
)
{
public
PageResult
<
SearchCourseResultModel
>
search
(
SearchCourseConditionModel
model
,
AuthorizedUser
user
)
{
Page
page
=
new
Page
(
model
.
getPageIndex
(),
model
.
getPageSize
());
Page
page
=
new
Page
(
model
.
getPageIndex
(),
model
.
getPageSize
());
List
<
Long
>
userTagIds
=
null
;
List
<
Long
>
userTagIds
=
null
;
if
(
user
!=
null
){
if
(
user
!=
null
)
{
List
<
UserTagPO
>
userTagList
=
userTagService
.
findTagsByUserId
(
user
.
getUserId
());
List
<
UserTagPO
>
userTagList
=
userTagService
.
findTagsByUserId
(
user
.
getUserId
());
userTagIds
=
userTagList
.
stream
().
map
(
BasePO:
:
getId
).
collect
(
Collectors
.
toList
());
userTagIds
=
userTagList
.
stream
().
map
(
BasePO:
:
getId
).
collect
(
Collectors
.
toList
());
}
}
List
<
SearchCourseResultModel
>
list
=
baseMapper
.
searchPageList
(
page
,
model
,
userTagIds
);
List
<
SearchCourseResultModel
>
list
=
baseMapper
.
searchPageList
(
page
,
model
,
userTagIds
);
addTagAndDuration
(
list
);
addTagAndDuration
(
list
);
return
PageResult
.<
SearchCourseResultModel
>
builder
().
code
(
CodeEnum
.
SUCCESS
.
getCode
()).
count
(
page
.
getTotal
()).
data
(
list
).
build
();
return
PageResult
.<
SearchCourseResultModel
>
builder
().
code
(
CodeEnum
.
SUCCESS
.
getCode
()).
count
(
page
.
getTotal
()).
data
(
list
).
build
();
}
}
/**
/**
* 设置课程所属标签和第一个章节视频时长
* 设置课程所属标签和第一个章节视频时长
*
* @param list
* @param list
*/
*/
public
void
addTagAndDuration
(
List
<
SearchCourseResultModel
>
list
){
public
void
addTagAndDuration
(
List
<
SearchCourseResultModel
>
list
)
{
for
(
SearchCourseResultModel
m
:
list
){
for
(
SearchCourseResultModel
m
:
list
)
{
List
<
CourseTagsModel
>
tags
=
tagRelMapper
.
selectModelList
(
m
.
getCourseId
());
List
<
CourseTagsModel
>
tags
=
tagRelMapper
.
selectModelList
(
m
.
getCourseId
());
m
.
setTags
(
tags
);
m
.
setTags
(
tags
);
List
<
CourseChaperModel
>
chaperList
=
chaperList
(
m
.
getCourseId
());
List
<
CourseChaperModel
>
chaperList
=
chaperList
(
m
.
getCourseId
());
if
(
CollUtil
.
isNotEmpty
(
chaperList
)){
if
(
CollUtil
.
isNotEmpty
(
chaperList
))
{
m
.
setDuration
(
chaperList
.
get
(
0
).
getDuration
());
m
.
setDuration
(
chaperList
.
get
(
0
).
getDuration
());
}
}
}
}
...
@@ -510,12 +549,13 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
...
@@ -510,12 +549,13 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
/**
/**
* 获取课程授权企业的ID集合
* 获取课程授权企业的ID集合
*
* @param courseId
* @param courseId
* @return
* @return
*/
*/
public
List
<
Long
>
getAllowEnterpriseList
(
Long
courseId
)
{
public
List
<
Long
>
getAllowEnterpriseList
(
Long
courseId
)
{
List
<
AllowOrgCoursePO
>
enterpriseIdList
=
allowOrgCourseMapper
.
selectList
(
Wrappers
.<
AllowOrgCoursePO
>
lambdaQuery
().
eq
(
AllowOrgCoursePO:
:
getCourseId
,
courseId
));
List
<
AllowOrgCoursePO
>
enterpriseIdList
=
allowOrgCourseMapper
.
selectList
(
Wrappers
.<
AllowOrgCoursePO
>
lambdaQuery
().
eq
(
AllowOrgCoursePO:
:
getCourseId
,
courseId
));
if
(
CollUtil
.
isNotEmpty
(
enterpriseIdList
)){
if
(
CollUtil
.
isNotEmpty
(
enterpriseIdList
))
{
return
enterpriseIdList
.
stream
().
map
(
AllowOrgCoursePO:
:
getOrgId
).
collect
(
Collectors
.
toList
());
return
enterpriseIdList
.
stream
().
map
(
AllowOrgCoursePO:
:
getOrgId
).
collect
(
Collectors
.
toList
());
}
}
return
Lists
.
newArrayList
();
return
Lists
.
newArrayList
();
...
@@ -523,29 +563,30 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
...
@@ -523,29 +563,30 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
/**
/**
* 验证当前登陆用户是否有该课程权限
* 验证当前登陆用户是否有该课程权限
*
* @param courseId
* @param courseId
*/
*/
public
void
checkPerm
(
Long
courseId
)
{
public
void
checkPerm
(
Long
courseId
)
{
boolean
hasPerm
=
false
;
boolean
hasPerm
=
false
;
CoursePO
coursePO
=
getById
(
courseId
);
CoursePO
coursePO
=
getById
(
courseId
);
if
(
coursePO
==
null
){
if
(
coursePO
==
null
)
{
throw
new
BusinessException
(
"请求错误,该课程不存在"
);
throw
new
BusinessException
(
"请求错误,该课程不存在"
);
}
}
if
(
coursePO
.
getStatus
()
==
CourseStatusEnum
.
DOWN
){
if
(
coursePO
.
getStatus
()
==
CourseStatusEnum
.
DOWN
)
{
throw
new
BusinessException
(
"该课程已下架"
);
throw
new
BusinessException
(
"该课程已下架"
);
}
}
if
(
coursePO
.
getAllow
()
==
CourseAllowEnum
.
SPECIFY
){
if
(
coursePO
.
getAllow
()
==
CourseAllowEnum
.
SPECIFY
)
{
SysUserPO
sysUserPO
=
UserContext
.
getUser
();
SysUserPO
sysUserPO
=
UserContext
.
getUser
();
if
(
sysUserPO
==
null
){
if
(
sysUserPO
==
null
)
{
throw
new
BusinessException
(
"请登陆后查看"
);
throw
new
BusinessException
(
"请登陆后查看"
);
}
}
List
<
Long
>
allowOrgIds
=
getAllowEnterpriseList
(
courseId
);
List
<
Long
>
allowOrgIds
=
getAllowEnterpriseList
(
courseId
);
if
(
CollUtil
.
isNotEmpty
(
allowOrgIds
)){
if
(
CollUtil
.
isNotEmpty
(
allowOrgIds
))
{
String
username
=
UserContext
.
getUser
().
getUsername
();
String
username
=
UserContext
.
getUser
().
getUsername
();
FullUserInfo
userInfo
=
sysUserService
.
findFullUserInfo
(
username
);
FullUserInfo
userInfo
=
sysUserService
.
findFullUserInfo
(
username
);
if
(
userInfo
.
getEnterpriseId
()
!=
null
){
if
(
userInfo
.
getEnterpriseId
()
!=
null
)
{
for
(
Long
orgId
:
allowOrgIds
){
for
(
Long
orgId
:
allowOrgIds
)
{
if
(
orgId
.
longValue
()
==
userInfo
.
getEnterpriseId
().
longValue
()){
if
(
orgId
.
longValue
()
==
userInfo
.
getEnterpriseId
().
longValue
())
{
hasPerm
=
true
;
hasPerm
=
true
;
break
;
break
;
}
}
...
@@ -553,20 +594,20 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
...
@@ -553,20 +594,20 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
}
}
}
}
}
else
{
}
else
{
hasPerm
=
true
;
hasPerm
=
true
;
}
}
if
(!
hasPerm
){
if
(!
hasPerm
)
{
throw
new
BusinessException
(
"对不起,您没权限查看该课程"
);
throw
new
BusinessException
(
"对不起,您没权限查看该课程"
);
}
}
}
}
public
GetVideoPlayAuthResponse
getVideoPlayAuth
(
Long
courseId
,
Long
chaperId
)
{
public
GetVideoPlayAuthResponse
getVideoPlayAuth
(
Long
courseId
,
Long
chaperId
)
{
CourseChapterPO
po
=
chapterMapper
.
selectById
(
chaperId
);
CourseChapterPO
po
=
chapterMapper
.
selectById
(
chaperId
);
if
(
po
!=
null
){
if
(
po
!=
null
)
{
ResourcePO
resourcePO
=
resourceService
.
getById
(
po
.
getResourceId
());
ResourcePO
resourcePO
=
resourceService
.
getById
(
po
.
getResourceId
());
if
(
resourcePO
!=
null
&&
StrUtil
.
isNotBlank
(
resourcePO
.
getVideoId
())){
if
(
resourcePO
!=
null
&&
StrUtil
.
isNotBlank
(
resourcePO
.
getVideoId
()))
{
try
{
try
{
GetVideoPlayAuthResponse
response
=
aliyunService
.
getVideoPlayAuth
(
resourcePO
.
getVideoId
());
GetVideoPlayAuthResponse
response
=
aliyunService
.
getVideoPlayAuth
(
resourcePO
.
getVideoId
());
return
response
;
return
response
;
...
@@ -577,20 +618,23 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
...
@@ -577,20 +618,23 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
}
}
return
null
;
return
null
;
}
}
private
List
<
CoursePO
>
findListByTags
(
List
<
Long
>
tagIds
){
private
List
<
CoursePO
>
findListByTags
(
List
<
Long
>
tagIds
)
{
return
baseMapper
.
findListByTags
(
tagIds
);
return
baseMapper
.
findListByTags
(
tagIds
);
}
}
/**
/**
* 根据课程标签关联推荐课程列表
* 根据课程标签关联推荐课程列表
* 默认推荐4个课程
* 默认推荐4个课程
* 优先推荐相同标签下的其它课程
* 优先推荐相同标签下的其它课程
* 如果相同标签下没有其它课程,则随机推荐其它课程
* 如果相同标签下没有其它课程,则随机推荐其它课程
* 注意过滤指定企业可见范围的课程
* 注意过滤指定企业可见范围的课程
*
* @return
* @return
*/
*/
public
List
<
SearchCourseResultModel
>
relationRecommend
(
Long
courseId
)
{
public
List
<
SearchCourseResultModel
>
relationRecommend
(
Long
courseId
)
{
CoursePO
coursePO
=
getById
(
courseId
);
CoursePO
coursePO
=
getById
(
courseId
);
if
(
coursePO
!=
null
){
if
(
coursePO
!=
null
)
{
throw
new
BusinessException
(
"请求错误,课程不存在"
);
throw
new
BusinessException
(
"请求错误,课程不存在"
);
}
}
List
<
SearchCourseResultModel
>
resultList
=
Lists
.
newArrayList
();
List
<
SearchCourseResultModel
>
resultList
=
Lists
.
newArrayList
();
...
@@ -598,10 +642,10 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
...
@@ -598,10 +642,10 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
List
<
Long
>
tagIds
=
courseTagsModelList
.
stream
().
map
(
CourseTagsModel:
:
getTagId
).
collect
(
Collectors
.
toList
());
List
<
Long
>
tagIds
=
courseTagsModelList
.
stream
().
map
(
CourseTagsModel:
:
getTagId
).
collect
(
Collectors
.
toList
());
List
<
CoursePO
>
courseList
=
findListByTags
(
tagIds
);
List
<
CoursePO
>
courseList
=
findListByTags
(
tagIds
);
int
index
=
0
;
int
index
=
0
;
for
(
CoursePO
course
:
courseList
){
for
(
CoursePO
course
:
courseList
)
{
if
(
index
==
3
){
if
(
index
==
3
)
{
break
;
break
;
}
else
{
}
else
{
SearchCourseResultModel
model
=
new
SearchCourseResultModel
();
SearchCourseResultModel
model
=
new
SearchCourseResultModel
();
model
.
setCourseId
(
course
.
getId
());
model
.
setCourseId
(
course
.
getId
());
model
.
setCourseName
(
course
.
getName
());
model
.
setCourseName
(
course
.
getName
());
...
@@ -611,15 +655,15 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
...
@@ -611,15 +655,15 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
}
}
}
}
if
(
resultList
.
size
()
<
4
){
if
(
resultList
.
size
()
<
4
)
{
int
diff
=
4
-
resultList
.
size
();
int
diff
=
4
-
resultList
.
size
();
List
<
Long
>
ids
=
resultList
.
stream
().
map
(
SearchCourseResultModel:
:
getCourseId
).
collect
(
Collectors
.
toList
());
List
<
Long
>
ids
=
resultList
.
stream
().
map
(
SearchCourseResultModel:
:
getCourseId
).
collect
(
Collectors
.
toList
());
courseList
=
list
(
Wrappers
.<
CoursePO
>
lambdaQuery
()
courseList
=
list
(
Wrappers
.<
CoursePO
>
lambdaQuery
()
.
notIn
(
CoursePO:
:
getId
,
ids
)
.
notIn
(
CoursePO:
:
getId
,
ids
)
.
eq
(
CoursePO:
:
getStatus
,
CourseStatusEnum
.
UP
)
.
eq
(
CoursePO:
:
getStatus
,
CourseStatusEnum
.
UP
)
.
eq
(
CoursePO:
:
getAllow
,
CourseAllowEnum
.
ALL
)
.
eq
(
CoursePO:
:
getAllow
,
CourseAllowEnum
.
ALL
)
.
last
(
"limit "
+
diff
));
.
last
(
"limit "
+
diff
));
for
(
CoursePO
course
:
courseList
){
for
(
CoursePO
course
:
courseList
)
{
SearchCourseResultModel
model
=
new
SearchCourseResultModel
();
SearchCourseResultModel
model
=
new
SearchCourseResultModel
();
model
.
setCourseId
(
course
.
getId
());
model
.
setCourseId
(
course
.
getId
());
model
.
setCourseName
(
course
.
getName
());
model
.
setCourseName
(
course
.
getName
());
...
@@ -627,14 +671,14 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
...
@@ -627,14 +671,14 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
resultList
.
add
(
model
);
resultList
.
add
(
model
);
}
}
}
}
for
(
SearchCourseResultModel
model
:
resultList
){
for
(
SearchCourseResultModel
model
:
resultList
)
{
List
<
CourseTagsModel
>
tagList
=
tagService
.
findListByCourseId
(
model
.
getCourseId
());
List
<
CourseTagsModel
>
tagList
=
tagService
.
findListByCourseId
(
model
.
getCourseId
());
model
.
setTags
(
tagList
);
model
.
setTags
(
tagList
);
List
<
CourseChaperModel
>
chaperList
=
chaperList
(
model
.
getCourseId
());
List
<
CourseChaperModel
>
chaperList
=
chaperList
(
model
.
getCourseId
());
if
(
CollUtil
.
isNotEmpty
(
chaperList
)){
if
(
CollUtil
.
isNotEmpty
(
chaperList
))
{
CourseChaperModel
chaperModel
=
chaperList
.
get
(
0
);
CourseChaperModel
chaperModel
=
chaperList
.
get
(
0
);
ResourcePO
resourcePO
=
resourceService
.
getById
(
chaperModel
.
getResourceId
());
ResourcePO
resourcePO
=
resourceService
.
getById
(
chaperModel
.
getResourceId
());
if
(
resourcePO
!=
null
){
if
(
resourcePO
!=
null
)
{
model
.
setDuration
(
resourcePO
.
getVideoDuration
());
model
.
setDuration
(
resourcePO
.
getVideoDuration
());
}
}
...
@@ -645,22 +689,22 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
...
@@ -645,22 +689,22 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
}
}
public
PageResult
<
SearchCourseResultModel
>
mainPageRecommendList
(
SearchCourseConditionModel
model
,
AuthorizedUser
user
)
{
public
PageResult
<
SearchCourseResultModel
>
mainPageRecommendList
(
SearchCourseConditionModel
model
,
AuthorizedUser
user
)
{
Page
page
=
new
Page
(
model
.
getPageIndex
(),
model
.
getPageSize
());
Page
page
=
new
Page
(
model
.
getPageIndex
(),
model
.
getPageSize
());
List
<
Long
>
userTagIds
=
null
;
List
<
Long
>
userTagIds
=
null
;
if
(
user
!=
null
){
if
(
user
!=
null
)
{
List
<
UserTagPO
>
userTagList
=
userTagService
.
findTagsByUserId
(
user
.
getUserId
());
List
<
UserTagPO
>
userTagList
=
userTagService
.
findTagsByUserId
(
user
.
getUserId
());
userTagIds
=
userTagList
.
stream
().
map
(
BasePO:
:
getId
).
collect
(
Collectors
.
toList
());
userTagIds
=
userTagList
.
stream
().
map
(
BasePO:
:
getId
).
collect
(
Collectors
.
toList
());
}
}
List
<
SearchCourseResultModel
>
list
=
baseMapper
.
recommendList
(
page
,
model
,
userTagIds
);
List
<
SearchCourseResultModel
>
list
=
baseMapper
.
recommendList
(
page
,
model
,
userTagIds
);
for
(
SearchCourseResultModel
recommend
:
list
){
for
(
SearchCourseResultModel
recommend
:
list
)
{
List
<
CourseTagsModel
>
tagList
=
tagService
.
findListByCourseId
(
recommend
.
getCourseId
());
List
<
CourseTagsModel
>
tagList
=
tagService
.
findListByCourseId
(
recommend
.
getCourseId
());
recommend
.
setTags
(
tagList
);
recommend
.
setTags
(
tagList
);
List
<
CourseChaperModel
>
chaperList
=
chaperList
(
recommend
.
getCourseId
(),
false
);
List
<
CourseChaperModel
>
chaperList
=
chaperList
(
recommend
.
getCourseId
(),
false
);
if
(
CollUtil
.
isNotEmpty
(
chaperList
)){
if
(
CollUtil
.
isNotEmpty
(
chaperList
))
{
CourseChaperModel
chaperModel
=
chaperList
.
get
(
0
);
CourseChaperModel
chaperModel
=
chaperList
.
get
(
0
);
ResourcePO
resourcePO
=
resourceService
.
getById
(
chaperModel
.
getResourceId
());
ResourcePO
resourcePO
=
resourceService
.
getById
(
chaperModel
.
getResourceId
());
if
(
resourcePO
!=
null
){
if
(
resourcePO
!=
null
)
{
recommend
.
setDuration
(
resourcePO
.
getVideoDuration
());
recommend
.
setDuration
(
resourcePO
.
getVideoDuration
());
}
}
...
@@ -671,15 +715,16 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
...
@@ -671,15 +715,16 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
/**
/**
* 查询已购、过期课程分页列表
* 查询已购、过期课程分页列表
*
* @param model
* @param model
* @return
* @return
*/
*/
public
PageResult
<
BuyCourseListItem
>
queryBuyCourseList
(
QueryBuyCourseListModel
model
)
{
public
PageResult
<
BuyCourseListItem
>
queryBuyCourseList
(
QueryBuyCourseListModel
model
)
{
Page
page
=
new
Page
(
model
.
getPageIndex
(),
model
.
getPageSize
());
Page
page
=
new
Page
(
model
.
getPageIndex
(),
model
.
getPageSize
());
List
<
BuyCourseListItem
>
list
=
baseMapper
.
queryBuyCourseList
(
page
,
model
);
List
<
BuyCourseListItem
>
list
=
baseMapper
.
queryBuyCourseList
(
page
,
model
);
for
(
BuyCourseListItem
item
:
list
){
for
(
BuyCourseListItem
item
:
list
)
{
//计算剩余有效期
//计算剩余有效期
Duration
duration
=
Duration
.
between
(
model
.
getQueryTime
(),
item
.
getEndTime
());
Duration
duration
=
Duration
.
between
(
model
.
getQueryTime
(),
item
.
getEndTime
());
String
validPeriod
=
DateUtil
.
formatBetween
(
duration
.
toMillis
(),
BetweenFormater
.
Level
.
HOUR
);
String
validPeriod
=
DateUtil
.
formatBetween
(
duration
.
toMillis
(),
BetweenFormater
.
Level
.
HOUR
);
item
.
setValidPeriod
(
validPeriod
);
item
.
setValidPeriod
(
validPeriod
);
}
}
...
@@ -688,20 +733,21 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
...
@@ -688,20 +733,21 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
/**
/**
* 查询企业课程列表
* 查询企业课程列表
*
* @param model
* @param model
* @return
* @return
*/
*/
public
PageResult
<
SearchCourseResultModel
>
queryPageListByEnterprise
(
QueryMyEnterpriseCourseModel
model
)
{
public
PageResult
<
SearchCourseResultModel
>
queryPageListByEnterprise
(
QueryMyEnterpriseCourseModel
model
)
{
Page
page
=
new
Page
(
model
.
getPageIndex
(),
model
.
getPageSize
());
Page
page
=
new
Page
(
model
.
getPageIndex
(),
model
.
getPageSize
());
List
<
SearchCourseResultModel
>
list
=
baseMapper
.
queryPageListByEnterprise
(
page
,
model
);
List
<
SearchCourseResultModel
>
list
=
baseMapper
.
queryPageListByEnterprise
(
page
,
model
);
for
(
SearchCourseResultModel
courseModel
:
list
){
for
(
SearchCourseResultModel
courseModel
:
list
)
{
List
<
CourseTagsModel
>
tagList
=
tagService
.
findListByCourseId
(
courseModel
.
getCourseId
());
List
<
CourseTagsModel
>
tagList
=
tagService
.
findListByCourseId
(
courseModel
.
getCourseId
());
courseModel
.
setTags
(
tagList
);
courseModel
.
setTags
(
tagList
);
List
<
CourseChaperModel
>
chaperList
=
chaperList
(
courseModel
.
getCourseId
());
List
<
CourseChaperModel
>
chaperList
=
chaperList
(
courseModel
.
getCourseId
());
if
(
CollUtil
.
isNotEmpty
(
chaperList
)){
if
(
CollUtil
.
isNotEmpty
(
chaperList
))
{
CourseChaperModel
chaperModel
=
chaperList
.
get
(
0
);
CourseChaperModel
chaperModel
=
chaperList
.
get
(
0
);
ResourcePO
resourcePO
=
resourceService
.
getById
(
chaperModel
.
getResourceId
());
ResourcePO
resourcePO
=
resourceService
.
getById
(
chaperModel
.
getResourceId
());
if
(
resourcePO
!=
null
){
if
(
resourcePO
!=
null
)
{
courseModel
.
setDuration
(
resourcePO
.
getVideoDuration
());
courseModel
.
setDuration
(
resourcePO
.
getVideoDuration
());
}
}
...
@@ -711,6 +757,6 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
...
@@ -711,6 +757,6 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
}
}
public
int
countByTeacher
(
Long
teacherId
)
{
public
int
countByTeacher
(
Long
teacherId
)
{
return
count
(
Wrappers
.<
CoursePO
>
lambdaQuery
().
eq
(
CoursePO:
:
getTeacherId
,
teacherId
));
return
count
(
Wrappers
.<
CoursePO
>
lambdaQuery
().
eq
(
CoursePO:
:
getTeacherId
,
teacherId
));
}
}
}
}
\ No newline at end of file
src/main/java/com/qkdata/biz/management/vo/CourseChaperModel.java
View file @
0517b07e
package
com
.
qkdata
.
biz
.
management
.
vo
;
package
com
.
qkdata
.
biz
.
management
.
vo
;
import
com.qkdata.biz.enums.VideoTypeEnum
;
import
lombok.Data
;
import
lombok.Data
;
@Data
@Data
...
@@ -37,4 +38,8 @@ public class CourseChaperModel {
...
@@ -37,4 +38,8 @@ public class CourseChaperModel {
* 视频时长
* 视频时长
*/
*/
private
Float
duration
;
private
Float
duration
;
/**
* 视频类型
*/
private
VideoTypeEnum
videoType
;
}
}
src/main/java/com/qkdata/biz/management/vo/SaveCourseChaperModel.java
View file @
0517b07e
package
com
.
qkdata
.
biz
.
management
.
vo
;
package
com
.
qkdata
.
biz
.
management
.
vo
;
import
com.qkdata.biz.enums.VideoTypeEnum
;
import
lombok.Data
;
import
lombok.Data
;
@Data
@Data
...
@@ -8,4 +9,6 @@ public class SaveCourseChaperModel {
...
@@ -8,4 +9,6 @@ public class SaveCourseChaperModel {
private
String
name
;
private
String
name
;
private
Integer
sortNo
=
0
;
private
Integer
sortNo
=
0
;
private
String
videoId
;
private
String
videoId
;
private
VideoTypeEnum
videoType
;
private
String
videoUrl
;
}
}
src/main/resources/db/migration/V1.0.3__update.sql
0 → 100644
View file @
0517b07e
ALTER
TABLE
`resource`
ADD
COLUMN
`video_type`
varchar
(
10
)
NULL
COMMENT
'视频类型'
AFTER
`update_time`
;
UPDATE
resource
SET
video_type
=
'ALI'
WHERE
video_id
is
NOT
NULL
;
\ 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