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
0c07a080
Commit
0c07a080
authored
Sep 23, 2019
by
luzhuang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bfile
parent
ab7c1398
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
65 additions
and
260 deletions
+65
-260
BChapterController.java
...soft/business/bchapter/controller/BChapterController.java
+2
-188
BChapterRepository.java
...org/rcisoft/business/bchapter/dao/BChapterRepository.java
+0
-1
BCourseController.java
...cisoft/business/bcourse/controller/BCourseController.java
+25
-29
BCourseService.java
.../org/rcisoft/business/bcourse/service/BCourseService.java
+0
-2
BCourseServiceImpl.java
...oft/business/bcourse/service/impl/BCourseServiceImpl.java
+6
-14
BFileController.java
...rg/rcisoft/business/bfile/controller/BFileController.java
+22
-23
BFile.java
src/main/java/org/rcisoft/business/bfile/entity/BFile.java
+5
-1
BFileServiceImpl.java
...rcisoft/business/bfile/service/impl/BFileServiceImpl.java
+1
-1
BLessonServiceImpl.java
...oft/business/blesson/service/impl/BLessonServiceImpl.java
+0
-1
Global.java
src/main/java/org/rcisoft/common/component/Global.java
+4
-0
No files found.
src/main/java/org/rcisoft/business/bchapter/controller/BChapterController.java
View file @
0c07a080
...
...
@@ -3,6 +3,7 @@ package org.rcisoft.business.bchapter.controller;
import
cn.hutool.core.bean.BeanUtil
;
import
com.google.common.reflect.TypeToken
;
import
com.google.gson.Gson
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiOperation
;
...
...
@@ -68,7 +69,7 @@ public class BChapterController extends PaginationController<BChapter> {
@ApiImplicitParam
(
name
=
"pid"
,
value
=
"上一级(1-50)"
,
required
=
true
,
dataType
=
"varchar"
),
@ApiImplicitParam
(
name
=
"chapterLevel"
,
value
=
"等级,1:章 2:节"
,
required
=
true
,
dataType
=
"varchar"
),
@ApiImplicitParam
(
name
=
"classHour"
,
value
=
"课时"
,
required
=
false
,
dataType
=
"varchar"
),
@ApiImplicitParam
(
name
=
"isTest"
,
value
=
"1
:实验 2:视频 3:PPT 4:pdf 5:资料 6试题
"
,
required
=
false
,
dataType
=
"varchar"
),
@ApiImplicitParam
(
name
=
"isTest"
,
value
=
"1
视频 2音频 3PPT 4pdf 5资料
"
,
required
=
false
,
dataType
=
"varchar"
),
@ApiImplicitParam
(
name
=
"lessonId"
,
value
=
"课程ID"
,
required
=
false
,
dataType
=
"varchar"
)})
@PostMapping
(
value
=
"/add"
)
public
Result
add
(
CurUser
curUser
,
@Valid
BChapter
bChapter
,
BindingResult
bindingResult
)
{
...
...
@@ -91,42 +92,6 @@ public class BChapterController extends PaginationController<BChapter> {
id
);
}
// @ApiOperation(value = "唯一查找", notes = "根据主键唯一查找任务书")
// @ApiImplicitParam(name = "id", value = "businessId", required = true, dataType = "varchar")
// @PostMapping(value = "/getMdFileById")
// public Result queryOne(String businessId) {
// String mdFile = bChapterService.selectOne(businessId).getMdFile();
// return Result.builder(new PersistModel(1),
// MessageConstant.MESSAGE_ALERT_SUCCESS,
// MessageConstant.MESSAGE_ALERT_ERROR,
// mdFile);
// }
@ApiOperation
(
value
=
"上传图片"
,
notes
=
"上传任务书所需图片"
)
@ApiImplicitParam
(
name
=
"image"
,
value
=
"图片文件"
,
required
=
true
,
dataType
=
"MultipartFile"
)
@PostMapping
(
value
=
"/uploadMdFileWithoutAuth"
)
public
Map
<
String
,
Object
>
uploadMdFile
(
MultipartFile
image
)
{
String
path
=
global
.
getMD_FILE_LOCATION
();
String
basePath
=
global
.
getBASE_UPLOAD_SERVER_LOCATION
();
boolean
type
=
false
;
if
(
"1"
.
equals
(
global
.
getIS_SERVER_LINUX
()))
{
type
=
true
;
}
Map
<
String
,
Object
>
pic
=
UploadUtil
.
picImport
(
basePath
,
path
,
image
,
type
);
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
if
(!(
boolean
)
pic
.
get
(
UploadUtil
.
IS_SUCCESSS
))
{
result
.
put
(
"success"
,
0
);
result
.
put
(
"message"
,
ResultServiceEnums
.
UPLOAD_FILE_ERROR
.
getMessage
());
result
.
put
(
"url"
,
""
);
}
else
{
result
.
put
(
"url"
,
pic
.
get
(
UploadUtil
.
URL
));
result
.
put
(
"success"
,
1
);
result
.
put
(
"message"
,
ResultServiceEnums
.
SUCCESS
.
getMessage
());
}
return
result
;
}
@ApiOperation
(
value
=
"分页查询章节"
,
notes
=
"根据条件分页查询章节"
)
@PostMapping
(
value
=
"/queryBChaptersByPagination"
)
public
Result
queryBChaptersByPagination
(
CurUser
curUser
,
@Valid
QueryChapterListDTO
param
,
BindingResult
br
)
{
...
...
@@ -138,7 +103,6 @@ public class BChapterController extends PaginationController<BChapter> {
gridModel
);
}
@ApiOperation
(
value
=
"查询章节"
,
notes
=
"根据lessonId查询章节"
)
@GetMapping
(
value
=
"/queryBChaptersWithoutAuth"
)
public
Result
queryBChapters
(
CurUser
curUser
,
@Valid
QueryChapterListDTO
param
,
BindingResult
br
)
{
...
...
@@ -150,67 +114,6 @@ public class BChapterController extends PaginationController<BChapter> {
map
);
}
@ApiOperation
(
value
=
"分数列表"
,
notes
=
"根据章节id获取分数列表"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"stuInfo"
,
value
=
"学生学号"
,
required
=
false
,
dataType
=
"varchar"
),
@ApiImplicitParam
(
name
=
"classInfo"
,
value
=
"班级编号"
,
required
=
false
,
dataType
=
"varchar"
),
@ApiImplicitParam
(
name
=
"chapterId"
,
value
=
"章节主键"
,
required
=
true
,
dataType
=
"varchar"
)})
@GetMapping
(
value
=
"/queryScoreListByChapterIdByPagination"
)
public
GridModel
queryScoreListByChapterIdByPagination
(
QueryScoreListDTO
dto
)
{
bChapterService
.
queryScoreListByChapterIdByPagination
(
getPaginationUtility
(),
dto
);
GridModel
gridModel
=
getGridModelResponse
();
return
gridModel
;
}
@ApiOperation
(
value
=
"批量打分"
,
notes
=
"批量打分"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"chapterId"
,
value
=
"章节id"
,
required
=
true
,
dataType
=
"varchar"
),
@ApiImplicitParam
(
name
=
"score"
,
value
=
"分数"
,
required
=
true
,
dataType
=
"varchar"
),
@ApiImplicitParam
(
name
=
"studentId"
,
value
=
"学生id"
,
required
=
true
,
dataType
=
"varchar"
)})
@PostMapping
(
value
=
"/markBatch"
)
public
Result
markBatch
(
String
scoreInfoList
)
{
Gson
gson
=
new
Gson
();
List
<
ScoreInfoDTO
>
list
=
new
ArrayList
<
ScoreInfoDTO
>();
try
{
list
=
gson
.
fromJson
(
scoreInfoList
,
new
TypeToken
<
List
<
ScoreInfoDTO
>>()
{
}.
getType
());
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
new
ServiceException
(
ResultServiceEnums
.
PARAMETER_ERROR
);
}
bChapterService
.
markScore
(
list
);
return
Result
.
builder
(
new
PersistModel
(
1
),
MessageConstant
.
MESSAGE_ALERT_SUCCESS
,
MessageConstant
.
MESSAGE_ALERT_ERROR
,
scoreInfoList
);
}
@ApiOperation
(
value
=
"打回重做"
,
notes
=
"打回重做"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"chapterId"
,
value
=
"章节ID"
,
required
=
true
,
dataType
=
"varchar"
),
@ApiImplicitParam
(
name
=
"studentCode"
,
value
=
"学号"
,
required
=
true
,
dataType
=
"varchar"
)})
@PostMapping
(
value
=
"/reMark"
)
public
Result
reMark
(
String
chapterId
,
String
studentCode
)
{
bChapterService
.
deleteScoerInfo
(
chapterId
,
studentCode
);
return
Result
.
builder
(
new
PersistModel
(
1
),
MessageConstant
.
MESSAGE_ALERT_SUCCESS
,
MessageConstant
.
MESSAGE_ALERT_ERROR
,
studentCode
);
}
@ApiOperation
(
value
=
"根据学生ID(token判断获取)和章节ID查询该节的学习情况"
,
notes
=
"学习情况包括:分数、实验完成状态以及各个教学手段完成状态。"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"slId"
,
value
=
"开课ID"
,
required
=
true
,
dataType
=
"varchar"
),
@ApiImplicitParam
(
name
=
"chapterId"
,
value
=
"章节ID"
,
required
=
true
,
dataType
=
"varchar"
),
})
@GetMapping
(
value
=
"/queryChapStudyState"
)
public
Result
queryChapterStudyState
(
ScoreInfoDTO
scoreInfoDTO
)
throws
Exception
{
scoreInfoDTO
=
bChapterService
.
getChapInfoById
(
scoreInfoDTO
);
return
Result
.
builder
(
new
PersistModel
(
1
),
MessageConstant
.
MESSAGE_ALERT_SUCCESS
,
MessageConstant
.
MESSAGE_ALERT_ERROR
,
scoreInfoDTO
);
}
@ApiOperation
(
value
=
"更改章节状态"
,
notes
=
"根据章节ID更改章节状态"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"businessId"
,
value
=
"businessId"
,
required
=
true
,
dataType
=
"varchar"
),
@ApiImplicitParam
(
name
=
"pid"
,
value
=
"父节点ID"
,
required
=
true
,
dataType
=
"varchar"
)})
...
...
@@ -226,7 +129,6 @@ public class BChapterController extends PaginationController<BChapter> {
@ApiOperation
(
value
=
"章节向上调顺序"
,
notes
=
"章节向上调顺序"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"businessId"
,
value
=
"businessId"
,
required
=
true
,
dataType
=
"varchar"
),
@ApiImplicitParam
(
name
=
"pid"
,
value
=
"父节点ID"
,
required
=
true
,
dataType
=
"varchar"
),
@ApiImplicitParam
(
name
=
"slId"
,
value
=
"开课ID"
,
required
=
false
,
dataType
=
"varchar"
),
@ApiImplicitParam
(
name
=
"lessonId"
,
value
=
"课程ID"
,
required
=
false
,
dataType
=
"varchar"
),
@ApiImplicitParam
(
name
=
"sort"
,
value
=
"当前顺序"
,
required
=
true
,
dataType
=
"Integer"
)})
@PostMapping
(
value
=
"/updateTopChapter"
)
...
...
@@ -241,7 +143,6 @@ public class BChapterController extends PaginationController<BChapter> {
@ApiOperation
(
value
=
"章节向下调顺序"
,
notes
=
"章节向下调顺序"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"businessId"
,
value
=
"businessId"
,
required
=
true
,
dataType
=
"varchar"
),
@ApiImplicitParam
(
name
=
"pid"
,
value
=
"父节点ID"
,
required
=
true
,
dataType
=
"varchar"
),
@ApiImplicitParam
(
name
=
"slId"
,
value
=
"开课ID"
,
required
=
false
,
dataType
=
"varchar"
),
@ApiImplicitParam
(
name
=
"lessonId"
,
value
=
"课程ID"
,
required
=
false
,
dataType
=
"varchar"
),
@ApiImplicitParam
(
name
=
"sort"
,
value
=
"当前顺序"
,
required
=
true
,
dataType
=
"Integer"
)})
@PostMapping
(
value
=
"/updateDownChapter"
)
...
...
@@ -253,91 +154,4 @@ public class BChapterController extends PaginationController<BChapter> {
bChapter
);
}
@ApiOperation
(
value
=
"根据章节ID查询任务书"
,
notes
=
"根据章节ID查询任务书"
)
@ApiImplicitParam
(
name
=
"businessId"
,
value
=
"章节ID"
,
required
=
true
,
dataType
=
"varchar"
)
@GetMapping
(
value
=
"/queryMdFileByChapterId"
)
public
Result
queryMdFileByChapterId
(
String
businessId
)
{
return
Result
.
builder
(
new
PersistModel
(
1
),
MessageConstant
.
MESSAGE_ALERT_SUCCESS
,
MessageConstant
.
MESSAGE_ALERT_ERROR
,
bChapterService
.
queryMdFileByChapterId
(
businessId
));
}
@ApiOperation
(
value
=
"查询学生章节列表"
,
notes
=
"根据学生id查询学生章节列表"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"slId"
,
value
=
"开课id"
,
required
=
true
,
dataType
=
"varchar"
),
@ApiImplicitParam
(
name
=
"lessonOrSl"
,
value
=
"课程或开课;0:开课 1:课程"
,
required
=
true
,
dataType
=
"varchar"
)})
@GetMapping
(
value
=
"/queryBChaptersByStudent"
)
public
Result
queryBChaptersByStudent
(
BChapter
param
)
{
Map
<
String
,
Object
>
map
=
new
HashedMap
();
map
.
put
(
"RoleFlag"
,
RoleFlagEnum
.
STUDENT
.
getFlag
());
map
.
put
(
"chapterList"
,
bChapterService
.
queryBChaptersByStudent
(
param
));
return
Result
.
builder
(
new
PersistModel
(
1
),
MessageConstant
.
MESSAGE_ALERT_SUCCESS
,
MessageConstant
.
MESSAGE_ALERT_ERROR
,
map
);
}
@ApiOperation
(
value
=
"打分"
,
notes
=
"根据章节ID和学号进行打分"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"chapterId"
,
value
=
"章节ID"
,
required
=
true
,
dataType
=
"varchar"
),
@ApiImplicitParam
(
name
=
"slId"
,
value
=
"开课id"
,
required
=
true
,
dataType
=
"varchar"
),
@ApiImplicitParam
(
name
=
"studentCode"
,
value
=
"学号"
,
required
=
true
,
dataType
=
"varchar"
),
@ApiImplicitParam
(
name
=
"score"
,
value
=
"分数"
,
required
=
true
,
dataType
=
"varchar"
),})
@PostMapping
(
value
=
"/Mark"
)
public
Result
Mark
(
String
chapterId
,
String
slId
,
String
studentCode
,
String
score
)
{
return
Result
.
builder
(
new
PersistModel
(
bChapterService
.
Mark
(
chapterId
,
slId
,
studentCode
,
score
)),
MessageConstant
.
MESSAGE_ALERT_SUCCESS
,
MessageConstant
.
MESSAGE_ALERT_ERROR
,
studentCode
);
}
@ApiOperation
(
value
=
"成绩评定"
,
notes
=
"成绩评定"
)
@ApiImplicitParam
(
name
=
"slId"
,
value
=
"开课id"
,
required
=
false
,
dataType
=
"varchar"
)
@GetMapping
(
value
=
"/scoreReport"
)
public
Result
scoreReport
(
String
slId
)
{
return
Result
.
builder
(
new
PersistModel
(
1
),
MessageConstant
.
MESSAGE_ALERT_SUCCESS
,
MessageConstant
.
MESSAGE_ALERT_ERROR
,
bChapterService
.
scoreReport
(
slId
));
}
@ApiOperation
(
value
=
"创建题目时从属下拉框查询"
,
notes
=
"只查询该课程的节"
)
@ApiImplicitParam
(
name
=
"slId"
,
value
=
"开课id"
,
required
=
false
,
dataType
=
"varchar"
)
@GetMapping
(
value
=
"/chapterListBySlId"
)
public
Result
chapterListBySlId
(
String
slId
)
{
return
Result
.
builder
(
new
PersistModel
(
1
),
MessageConstant
.
MESSAGE_ALERT_SUCCESS
,
MessageConstant
.
MESSAGE_ALERT_ERROR
,
bChapterService
.
chapterListBySlId
(
slId
));
}
@ApiOperation
(
value
=
"更改文件是否完成"
,
notes
=
"更改文件是否完成"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"type"
,
value
=
"完成的类型 ppt是1 pdf是2 video是3 试题是4"
,
required
=
true
,
dataType
=
"varchar"
),
@ApiImplicitParam
(
name
=
"chapterId"
,
value
=
"章节id"
,
required
=
true
,
dataType
=
"varchar"
),
@ApiImplicitParam
(
name
=
"slId"
,
value
=
"开课id"
,
required
=
true
,
dataType
=
"varchar"
),
@ApiImplicitParam
(
name
=
"studentCode"
,
value
=
"学号"
,
required
=
true
,
dataType
=
"varchar"
)})
//@PreAuthorize("hasRole('ROLE_1003')")
@PostMapping
(
value
=
"/updateToFinish"
)
public
Result
u
(
String
type
,
String
chapterId
,
String
studentCode
,
String
slId
)
{
int
data
=
bChapterService
.
updateToFinish
(
type
,
studentCode
,
chapterId
,
slId
);
return
Result
.
builder
(
new
PersistModel
(
data
),
MessageConstant
.
MESSAGE_ALERT_SUCCESS
,
MessageConstant
.
MESSAGE_ALERT_ERROR
,
studentCode
);
}
@ApiOperation
(
value
=
"修改项目任务书"
,
notes
=
"修改项目任务书"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"businessId"
,
value
=
"businessId"
,
required
=
true
,
dataType
=
"varchar"
),
@ApiImplicitParam
(
name
=
"mdFile"
,
value
=
"项目任务书内容"
,
required
=
true
,
dataType
=
"varchar"
)})
@PostMapping
(
value
=
"/updateMdFile"
)
public
Result
updateMdFile
(
String
businessId
,
String
mdFile
)
{
int
data
=
bChapterService
.
updateMdFile
(
businessId
,
mdFile
);
return
Result
.
builder
(
new
PersistModel
(
data
),
MessageConstant
.
MESSAGE_ALERT_SUCCESS
,
MessageConstant
.
MESSAGE_ALERT_ERROR
,
businessId
);
}
}
src/main/java/org/rcisoft/business/bchapter/dao/BChapterRepository.java
View file @
0c07a080
...
...
@@ -259,7 +259,6 @@ public interface BChapterRepository extends BaseMapper<BChapter> {
@Select
(
"<script>select * from b_chapter where sort > #{sort} "
+
"AND pid = #{pid} and del_flag = 0 and flag = 1 "
+
"<if test=\"slId !=null and slId !=''\">AND sl_id = #{slId} </if> "
+
"<if test=\"lessonId !=null and lessonId !=''\">AND lesson_id = #{lessonId} </if> "
+
"ORDER BY sort asc LIMIT 1</script>"
)
@ResultMap
(
value
=
"BaseResultMap"
)
...
...
src/main/java/org/rcisoft/business/bcourse/controller/BCourseController.java
View file @
0c07a080
package
org
.
rcisoft
.
business
.
bcourse
.
controller
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiOperation
;
...
...
@@ -22,6 +23,8 @@ import org.springframework.web.bind.annotation.RestController;
import
javax.servlet.http.HttpServletRequest
;
import
javax.validation.Valid
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
@RestController
...
...
@@ -31,43 +34,47 @@ public class BCourseController extends PaginationController<BCourse> {
@Autowired
private
BCourseService
bCourseServiceImpl
;
@ApiOperation
(
value
=
"查询课程分类"
,
notes
=
"查询课程分类"
)
@ApiImplicitParam
(
name
=
"cName"
,
value
=
"
课程名
模糊查询"
,
required
=
true
,
dataType
=
"varchar"
)
@ApiOperation
(
value
=
"查询课程分类"
,
notes
=
"查询课程分类"
)
@ApiImplicitParam
(
name
=
"cName"
,
value
=
"
(课程名)
模糊查询"
,
required
=
true
,
dataType
=
"varchar"
)
@PostMapping
(
value
=
"/queryCourse"
)
public
Result
queryBCourse
(
CurUser
curUser
,
@Valid
BCourse
param
,
BindingResult
br
){
public
Result
queryBCourse
(
CurUser
curUser
,
@Valid
String
cName
,
BindingResult
br
)
{
BCourse
bCourse
=
new
BCourse
();
bCourse
.
setCName
(
cName
);
Map
<
String
,
Object
>
map
=
new
HashedMap
();
map
.
put
(
"courseList"
,
bCourseServiceImpl
.
queryBCourse
(
param
));
map
.
put
(
"courseList"
,
bCourseServiceImpl
.
queryBCourse
(
bCourse
));
return
Result
.
builder
(
new
PersistModel
(
1
),
MessageConstant
.
MESSAGE_ALERT_SUCCESS
,
MessageConstant
.
MESSAGE_ALERT_ERROR
,
map
);
}
@ApiOperation
(
value
=
"根据条件分页查询"
,
notes
=
"根据条件分页查询标签"
)
@ApiImplicitParam
(
name
=
"cName"
,
value
=
"
课程名
模糊查询"
,
required
=
false
,
dataType
=
"varchar"
)
@ApiOperation
(
value
=
"根据条件分页查询"
,
notes
=
"根据条件分页查询标签"
)
@ApiImplicitParam
(
name
=
"cName"
,
value
=
"
(课程名)
模糊查询"
,
required
=
false
,
dataType
=
"varchar"
)
@GetMapping
(
value
=
"/queryBCourseByPagination"
)
public
GridModel
queryBCourseByPagination
(
CurUser
curUser
,
@Valid
BCourse
param
,
BindingResult
br
){
bCourseServiceImpl
.
queryBCourseByPagination
(
getPaginationUtility
(),
param
);
public
GridModel
queryBCourseByPagination
(
CurUser
curUser
,
@Valid
String
cName
,
BindingResult
br
)
{
BCourse
bCourse
=
new
BCourse
();
bCourse
.
setCName
(
cName
);
bCourseServiceImpl
.
queryBCourseByPagination
(
getPaginationUtility
(),
bCourse
);
GridModel
gridModel
=
getGridModelResponse
();
return
gridModel
;
}
@ApiOperation
(
value
=
"物理删除"
,
notes
=
"根据ID删除一条记录"
)
@ApiImplicitParam
(
name
=
"id"
,
value
=
"
ID
"
,
required
=
true
,
dataType
=
"varchar"
)
@ApiOperation
(
value
=
"物理删除"
,
notes
=
"根据ID删除一条记录"
)
@ApiImplicitParam
(
name
=
"id"
,
value
=
"
businessId
"
,
required
=
true
,
dataType
=
"varchar"
)
@PostMapping
(
value
=
"/remove"
)
public
Result
remove
(
CurUser
curUser
,
@Valid
String
id
,
BindingResult
br
)
{
public
Result
remove
(
CurUser
curUser
,
@Valid
String
id
,
BindingResult
br
)
{
PersistModel
data
=
bCourseServiceImpl
.
removeCourse
(
id
);
return
Result
.
builder
(
data
,
MessageConstant
.
MESSAGE_ALERT_SUCCESS
,
MessageConstant
.
MESSAGE_ALERT_ERROR
,
id
);
}
@ApiOperation
(
value
=
"更新课程名"
,
notes
=
"根据ID更新课程名"
)
@ApiOperation
(
value
=
"修改课程名"
,
notes
=
"根据ID更新课程名"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"id"
,
value
=
"businessId"
,
required
=
true
,
dataType
=
"varchar"
),
@ApiImplicitParam
(
name
=
"name"
,
value
=
"cName"
,
required
=
true
,
dataType
=
"varchar"
)})
@PostMapping
(
value
=
"/update"
)
public
Result
update
(
CurUser
curUser
,
@Valid
BCourse
bCourse
,
BindingResult
br
){
public
Result
update
(
CurUser
curUser
,
@Valid
BCourse
bCourse
,
BindingResult
br
)
{
PersistModel
data
=
bCourseServiceImpl
.
updateCourse
(
bCourse
);
return
Result
.
builder
(
data
,
MessageConstant
.
MESSAGE_ALERT_SUCCESS
,
...
...
@@ -75,11 +82,11 @@ public class BCourseController extends PaginationController<BCourse> {
bCourse
.
getBusinessId
());
}
@ApiOperation
(
value
=
"插入课程分类"
,
notes
=
"插入
课程分类"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"p
id"
,
value
=
"parentId
"
,
required
=
true
,
dataType
=
"varchar"
),
@ApiImplicitParam
(
name
=
"
name"
,
value
=
"cName
"
,
required
=
true
,
dataType
=
"varchar"
)})
@ApiOperation
(
value
=
"添加课程分类"
,
notes
=
"添加课程分类,不填parentId添加一级
课程分类"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"p
arentId"
,
value
=
"上一级
"
,
required
=
true
,
dataType
=
"varchar"
),
@ApiImplicitParam
(
name
=
"
cName"
,
value
=
"课程分类名
"
,
required
=
true
,
dataType
=
"varchar"
)})
@PostMapping
(
value
=
"/insert"
)
public
Result
insert
(
CurUser
curUser
,
@Valid
BCourse
bCourse
,
BindingResult
br
){
public
Result
insert
(
CurUser
curUser
,
@Valid
BCourse
bCourse
,
BindingResult
br
)
{
PersistModel
data
=
bCourseServiceImpl
.
insertCourse
(
bCourse
);
return
Result
.
builder
(
data
,
MessageConstant
.
MESSAGE_ALERT_SUCCESS
,
...
...
@@ -87,15 +94,4 @@ public class BCourseController extends PaginationController<BCourse> {
bCourse
.
getParentId
());
}
@ApiOperation
(
value
=
"插入课程分类"
,
notes
=
"插入一级课程分类"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"order_by"
,
value
=
"orderBy"
,
required
=
true
,
dataType
=
"varchar"
),
@ApiImplicitParam
(
name
=
"name"
,
value
=
"cName"
,
required
=
true
,
dataType
=
"varchar"
)})
@PostMapping
(
value
=
"/insertTop"
)
public
Result
insertTop
(
CurUser
curUser
,
@Valid
BCourse
bCourse
,
BindingResult
br
){
PersistModel
data
=
bCourseServiceImpl
.
insertTopCourse
(
bCourse
);
return
Result
.
builder
(
data
,
MessageConstant
.
MESSAGE_ALERT_SUCCESS
,
MessageConstant
.
MESSAGE_ALERT_ERROR
,
bCourse
.
getParentId
());
}
}
src/main/java/org/rcisoft/business/bcourse/service/BCourseService.java
View file @
0c07a080
...
...
@@ -17,8 +17,6 @@ public interface BCourseService {
PersistModel
insertCourse
(
BCourse
bCourse
);
PersistModel
insertTopCourse
(
BCourse
bCourse
);
PersistModel
removeCourse
(
String
id
);
PersistModel
updateCourse
(
BCourse
bCoursee
);
...
...
src/main/java/org/rcisoft/business/bcourse/service/impl/BCourseServiceImpl.java
View file @
0c07a080
...
...
@@ -27,7 +27,7 @@ public class BCourseServiceImpl implements BCourseService {
@Override
public
List
<
QueryCourseResDTO
>
queryBCourse
(
BCourse
model
)
{
Map
param
=
new
HashMap
<
String
,
Object
>();
if
(
model
.
getCName
()
!=
null
&&
!
""
.
equals
(
model
.
getCName
())){
if
(
model
.
getCName
()
!=
null
&&
!
""
.
equals
(
model
.
getCName
()))
{
param
.
put
(
"cName"
,
model
.
getCName
());
}
return
bCourseRepository
.
queryCourses
(
param
);
...
...
@@ -36,7 +36,7 @@ public class BCourseServiceImpl implements BCourseService {
@Override
public
List
<
QueryCourseResDTO
>
queryBCourseByPagination
(
PageUtil
pageUtil
,
BCourse
model
)
{
Map
param
=
new
HashMap
<
String
,
Object
>();
if
(
model
.
getCName
()
!=
null
&&
!
""
.
equals
(
model
.
getCName
())){
if
(
model
.
getCName
()
!=
null
&&
!
""
.
equals
(
model
.
getCName
()))
{
param
.
put
(
"cName"
,
model
.
getCName
());
}
return
bCourseRepository
.
queryCourses
(
param
);
...
...
@@ -47,19 +47,11 @@ public class BCourseServiceImpl implements BCourseService {
public
PersistModel
insertCourse
(
BCourse
bCourse
)
{
List
<
BCourse
>
list
=
bCourseRepository
.
selectOneByName
(
bCourse
.
getCName
());
if
(
list
.
size
()>
0
)
{
if
(
list
.
size
()
>
0
)
{
throw
new
ServiceException
(
ResultServiceEnums
.
NAME_IS_EXISTS
);
}
UserUtil
.
setCurrentPersistOperation
(
bCourse
);
return
new
PersistModel
(
bCourseRepository
.
insert
(
bCourse
),
MessageConstant
.
MESSAGE_ALERT_SUCCESS
)
;
}
@Override
public
PersistModel
insertTopCourse
(
BCourse
bCourse
)
{
if
(
bCourse
.
getParentId
()
==
null
||
""
.
equals
(
bCourse
.
getParentId
()))
{
bCourse
.
setParentId
(
"00000000"
);
List
<
BCourse
>
list
=
bCourseRepository
.
selectOneByName
(
bCourse
.
getCName
());
if
(
list
.
size
()>
0
){
throw
new
ServiceException
(
ResultServiceEnums
.
NAME_IS_EXISTS
);
}
UserUtil
.
setCurrentPersistOperation
(
bCourse
);
return
new
PersistModel
(
bCourseRepository
.
insert
(
bCourse
),
MessageConstant
.
MESSAGE_ALERT_SUCCESS
);
...
...
@@ -74,7 +66,7 @@ public class BCourseServiceImpl implements BCourseService {
@Override
public
PersistModel
updateCourse
(
BCourse
bCourse
)
{
List
<
BCourse
>
list
=
bCourseRepository
.
selectOneByName
(
bCourse
.
getCName
());
if
(
list
.
size
()>
0
)
{
if
(
list
.
size
()
>
0
)
{
throw
new
ServiceException
(
ResultServiceEnums
.
NAME_IS_EXISTS
);
}
UserUtil
.
setCurrentMergeOperation
(
bCourse
);
...
...
src/main/java/org/rcisoft/business/bfile/controller/BFileController.java
View file @
0c07a080
...
...
@@ -105,7 +105,6 @@ public class BFileController extends PaginationController<BFile> {
@ApiOperation
(
value
=
"上传文件"
,
notes
=
"上传文件"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"chapterId"
,
value
=
"章节ID"
,
required
=
true
,
dataType
=
"varchar"
),
@ApiImplicitParam
(
name
=
"lessonId"
,
value
=
"课程ID"
,
required
=
false
,
dataType
=
"varchar"
),
@ApiImplicitParam
(
name
=
"slId"
,
value
=
"开课ID"
,
required
=
false
,
dataType
=
"varchar"
),
@ApiImplicitParam
(
name
=
"type"
,
value
=
"'0'为视频,'1'为附件,'2'为ppt,'3'为pdf"
,
required
=
true
,
dataType
=
"varchar"
),
@ApiImplicitParam
(
name
=
"file"
,
value
=
"视频文件"
,
required
=
true
,
dataType
=
"MultipartFile"
)})
@PostMapping
(
value
=
"/uploadVideo"
)
...
...
@@ -118,28 +117,28 @@ public class BFileController extends PaginationController<BFile> {
videoUrl
);
}
@ApiOperation
(
value
=
"上传license"
,
notes
=
"上传license证书文件"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"file"
,
value
=
"license文件"
,
required
=
true
,
dataType
=
"MultipartFile"
)})
@PostMapping
(
value
=
"/uploadLicenseWithoutAuth"
)
public
Result
uploadLicense
(
HttpServletRequest
request
)
{
List
<
MultipartFile
>
list
=
((
MultipartHttpServletRequest
)
request
).
getFiles
(
"file"
);
try
{
if
(
list
.
size
()>
0
){
bFileService
.
uploadLicense
(
list
.
get
(
0
));
}
else
{
throw
new
ServiceException
(
ResultServiceEnums
.
UPLOAD_ERROR
);
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
throw
new
ServiceException
(
ResultServiceEnums
.
UPLOAD_ERROR
);
}
return
Result
.
builder
(
new
PersistModel
(
1
),
"license上传成功"
,
MessageConstant
.
MESSAGE_ALERT_ERROR
,
""
);
}
//
@ApiOperation(value="上传license", notes="上传license证书文件")
//
@ApiImplicitParams({
//
@ApiImplicitParam(name = "file", value = "license文件", required = true, dataType = "MultipartFile")})
//
@PostMapping(value = "/uploadLicenseWithoutAuth")
//
public Result uploadLicense(HttpServletRequest request) {
//
List<MultipartFile> list = ((MultipartHttpServletRequest)request).getFiles("file");
//
try {
//
if(list.size()>0){
//
bFileService.uploadLicense(list.get(0));
//
}else{
//
throw new ServiceException(ResultServiceEnums.UPLOAD_ERROR);
//
}
//
//
} catch (IOException e) {
//
e.printStackTrace();
//
throw new ServiceException(ResultServiceEnums.UPLOAD_ERROR);
//
}
//
return Result.builder(new PersistModel(1),
//
"license上传成功",
//
MessageConstant.MESSAGE_ALERT_ERROR,
//
"");
//
}
/**
...
...
src/main/java/org/rcisoft/business/bfile/entity/BFile.java
View file @
0c07a080
...
...
@@ -32,13 +32,17 @@ public class BFile extends IdEntity<BFile> {
@NotBlank
private
String
videoUrl
;
/*
'0'为视频,'1'为
附件*/
/*
0视频 1音频 2ppt 3pdf 4
附件*/
private
String
type
;
@Length
(
min
=
1
,
max
=
256
,
message
=
"长度最小为1,最大为200"
)
@NotBlank
private
String
fileUrl
;
@Length
(
min
=
1
,
max
=
256
,
message
=
"长度最小为1,最大为200"
)
@NotBlank
private
String
audioUrl
;
@Length
(
min
=
1
,
max
=
256
,
message
=
"长度最小为1,最大为200"
)
@NotBlank
private
String
pptUrl
;
...
...
src/main/java/org/rcisoft/business/bfile/service/impl/BFileServiceImpl.java
View file @
0c07a080
package
org
.
rcisoft
.
business
.
bfile
.
service
.
impl
;
import
com.itextpdf.text.pdf.PdfReader
;
import
org.apache.commons.io.FileUtils
;
import
org.rcisoft.business.bfile.dao.BFileRepository
;
import
org.rcisoft.business.bfile.entity.BFile
;
import
org.rcisoft.business.bfile.service.BFileService
;
import
org.rcisoft.business.bsl.task.SlTask
;
import
org.rcisoft.common.component.Global
;
import
org.rcisoft.core.aop.PageUtil
;
import
org.rcisoft.core.bean.RcLkConfigBean
;
import
org.rcisoft.core.constant.DelStatus
;
import
org.rcisoft.core.exception.ServiceException
;
import
org.rcisoft.core.model.PersistModel
;
import
org.rcisoft.core.result.ResultServiceEnums
;
import
org.rcisoft.core.util.FileUtil
;
import
org.rcisoft.core.util.IdGen
;
import
org.rcisoft.core.util.UserUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.io.*
;
import
java.nio.file.Files
;
import
java.nio.file.Path
;
import
java.nio.file.Paths
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
static
org
.
rcisoft
.
core
.
util
.
CutPdfUtil
.
partitionPdfFile
;
/** * Created by gaowenfneg on 2017-10-9 14:34:56. */
@Service
@Transactional
(
readOnly
=
true
,
propagation
=
Propagation
.
NOT_SUPPORTED
)
public
class
BFileServiceImpl
implements
BFileService
{
@Autowired
private
BFileRepository
bFileRepository
;
@Autowired
private
SlTask
slTask
;
@Autowired
private
Global
global
;
@Autowired
private
RcLkConfigBean
rcLkConfigBean
;
@Override
public
BFile
selectOne
(
String
businessId
){
return
bFileRepository
.
selectByPrimaryKey
(
businessId
);
}
@Override
public
List
<
BFile
>
queryBVideosByPagination
(
PageUtil
pageUtil
,
BFile
model
)
{
Map
param
=
new
HashMap
<
String
,
Object
>();
return
bFileRepository
.
queryBVideos
(
param
);
}
@Override
public
List
<
BFile
>
queryBVideos
(
BFile
model
)
{
Map
param
=
new
HashMap
<
String
,
Object
>();
return
bFileRepository
.
queryBVideos
(
param
);
}
@Override
public
PersistModel
persist
(
BFile
model
){
UserUtil
.
setCurrentPersistOperation
(
model
);
int
line
=
bFileRepository
.
insertSelective
(
model
);
return
new
PersistModel
(
line
);
}
@Override
public
PersistModel
removeBVideo
(
String
id
)
{
BFile
bFile
=
bFileRepository
.
selectByPrimaryKey
(
id
);
bFile
.
setDelFlag
(
DelStatus
.
DELETED
.
getStatus
());
UserUtil
.
setCurrentMergeOperation
(
bFile
);
int
line
=
bFileRepository
.
updateByPrimaryKeySelective
(
bFile
);
return
new
PersistModel
(
line
);
}
@Override
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
readOnly
=
false
)
public
String
uploadVideoToServer
(
List
<
MultipartFile
>
list
,
BFile
bFile
)
{
String
videoUrl
=
""
;
if
(
list
.
size
()>
0
)
{
for
(
int
i
=
0
;
i
<
list
.
size
();
++
i
)
{
MultipartFile
file
=
list
.
get
(
i
);
try
{
//查询此节是否已有视频或文件 BFile video = bFileRepository.selectInfoByChapterId(bFile.getChapterId()); if (video!=null){//此节已有视频或文件,将已有的视频或文件放置到temp目录下,然后上传新视频或文件 if(bFile.getType().equals("0")&&video.getVideoUrl()!=null&&!video.getVideoUrl().equals("")){ this.removeVideoToTemp(bFile);//复制之前视频到temp文件下 } if(bFile.getType().equals("1")&&video.getFileUrl()!=null&&!video.getFileUrl().equals("")){ this.removeVideoToTemp(bFile);//复制之前文件到temp文件下 } if(bFile.getType().equals("2")&&video.getPptUrl()!=null&&!video.getPptUrl().equals("")){ this.removeVideoToTemp(bFile);//复制之前ppt到temp文件下 } if(bFile.getType().equals("3")&&video.getPdfUrl()!=null&&!video.getPdfUrl().equals("")){ this.removeVideoToTemp(bFile);//复制之前pdf到temp文件下 } BFile newVideo = this.uploadVideo(file, bFile);//上传新文件 newVideo.setBusinessId(video.getBusinessId()); UserUtil.setCurrentMergeOperation(newVideo); bFileRepository.updateByPrimaryKeySelective(newVideo);//更新表中信息 if (bFile.getType().equals("0")){ videoUrl = newVideo.getVideoUrl(); }else if(bFile.getType().equals("1")){ videoUrl = newVideo.getFileUrl(); }else if(bFile.getType().equals("2")){ videoUrl = newVideo.getPptUrl(); }else{ videoUrl = newVideo.getPdfUrl(); } }else{ BFile newVideo = this.uploadVideo(file, bFile);//上传文件 this.persist(newVideo);//插入表信息 if (bFile.getType().equals("0")){ videoUrl = newVideo.getVideoUrl(); }else if(bFile.getType().equals("1")){ videoUrl = newVideo.getFileUrl(); }else if(bFile.getType().equals("2")){ videoUrl = newVideo.getPptUrl(); }else{ videoUrl = newVideo.getPdfUrl(); } } } catch (Exception e) { e.printStackTrace(); throw new ServiceException(ResultServiceEnums.UPLOAD_ERROR); } } } return videoUrl; } /** * 将原视频复制到temp/video文件下,并删除原视频 * @param bFile */ private void removeVideoToTemp(BFile bFile) throws Exception{ String path; String pathName; if(bFile.getLessonId()!=null&&!bFile.getLessonId().equals("")){ path = global.getLESSON_LOCATION() + File.separator + bFile.getLessonId() + File.separator; }else{ throw new ServiceException("路径错误!"); } if (bFile.getType().equals("0")){ pathName = global.getVIDEO_LOCATION();//视频路径 }else if(bFile.getType().equals("1")){ pathName = global.getFILE_LOCATION();//文件路径 }else if(bFile.getType().equals("2")){ pathName = global.getPPT_LOCATION();//ppt路径 }else{ pathName = global.getPDF_LOCATION();//pdf路径 } String tempPath = global.getBASE_UPLOAD_SERVER_LOCATION() + File.separator + global.getCOURSE_LOCATION() + File.separator + global.getTEMP_LOCATION() + File.separator + path + bFile.getChapterId(); File tempFilePath = new File(tempPath); if(tempFilePath.exists()){ FileUtils.deleteDirectory(tempFilePath); } String realFilePath = global.getBASE_UPLOAD_SERVER_LOCATION() + File.separator + global.getCOURSE_LOCATION() + File.separator + path + bFile.getChapterId() + File.separator + pathName; File directory = new File(realFilePath); if(directory.exists()){ FileUtils.moveDirectory(directory,tempFilePath); } } /** * 上传视频到video目录 * @param file * @param bFile * @return * @throws IOException */ private BFile uploadVideo(MultipartFile file, BFile bFile) throws IOException { BufferedOutputStream stream = null; String path; String pathName; if(bFile.getLessonId()!=null&&!bFile.getLessonId().equals("")){ path = global.getLESSON_LOCATION() + File.separator + bFile.getLessonId() + File.separator; }else{ throw new ServiceException("路径错误!"); } if (bFile.getType().equals("0")){ pathName = global.getVIDEO_LOCATION();//视频路径 }else if(bFile.getType().equals("1")){ pathName = global.getFILE_LOCATION();//文件路径 }else if(bFile.getType().equals("2")){ pathName = global.getPPT_LOCATION();//ppt路径 }else{ pathName = global.getPDF_LOCATION();//pdf路径 } String realPath = global.getBASE_UPLOAD_SERVER_LOCATION() + File.separator + global.getCOURSE_LOCATION() + File.separator + path + bFile.getChapterId() + File.separator + pathName + File.separator; File outFile=new File(realPath); if(!outFile.exists()){//判断保存路径是否存在,不存在新建 outFile.mkdirs(); } //上传文件 String uploadFile = file.getOriginalFilename(); //文件的真实名称 String name = uploadFile.substring(uploadFile.lastIndexOf(File.separator) + 1,uploadFile.lastIndexOf('.')); // 截取上传文件的后缀 String uploadFileSuffix = FileUtil.getFilePostfix(uploadFile); //uploadFile.substring(uploadFile.lastIndexOf('.') + 1, uploadFile.length()); // 设置文件名为乱码 String uploadFileName = IdGen.uuid(); String filename = uploadFileName + "." + uploadFileSuffix; stream = new BufferedOutputStream(new FileOutputStream(new File(realPath + filename))); byte[] bytes = file.getBytes(); stream.write(bytes,0,bytes.length); String newPath = global.getCOURSE_LOCATION() + File.separator + path + bFile.getChapterId() + File.separator + pathName + File.separator; if(uploadFileSuffix.equals("ppt")&&bFile.getType().equals("2")){//ppt转pdf String inputFile = global.getBASE_UPLOAD_SERVER_LOCATION() + File.separator + newPath+ filename; String outputFile = global.getBASE_UPLOAD_SERVER_LOCATION() + File.separator + newPath + uploadFileName + ".pdf"; slTask.officeToPdf(inputFile,outputFile); } if(uploadFileSuffix.equals("pdf")&&bFile.getType().equals("3")){//pdf切割 try { slTask.cutPdf(newPath, filename, uploadFileName); } catch (Exception e) { e.printStackTrace(); } } //上传的是文件时才存文件名,方便下载时取 if(bFile.getType().equals("1")){ bFile.setVideoName(name+ "." +uploadFileSuffix);//文件名 } if (bFile.getType().equals("0")){ bFile.setVideoUrl(newPath+ filename);//视频路径 }else if(bFile.getType().equals("1")){ bFile.setFileUrl(newPath+ filename);//文件路径 }else if(bFile.getType().equals("2")){ bFile.setPptUrl(newPath + uploadFileName + ".pdf");//ppt路径 }else{ bFile.setPdfUrl(newPath+ filename);//pdf路径 } stream.close(); return bFile; } @Override public BFile queryFileUrlByChapterId(String chapterId) { return bFileRepository.queryFileUrlByChapterId(chapterId); } @Override public void uploadLicense(MultipartFile file) { try { BufferedOutputStream stream = null; String path = global.getBASE_UPLOAD_SERVER_LOCATION() + rcLkConfigBean.getLicPath(); File oldFile = new File(path); if(oldFile.exists()){ FileUtils.forceDelete(oldFile); } File newFile = new File(path); stream = new BufferedOutputStream(new FileOutputStream(newFile)); byte[] bytes = file.getBytes(); stream.write(bytes,0,bytes.length); stream.flush(); stream.close(); } catch (Exception e) { e.printStackTrace(); throw new ServiceException(ResultServiceEnums.UPLOAD_ERROR); } return; } /** * 重新转换ppt * @param businessId * @param type 0开课 1课程 * @return */ @Override public List<String> reConversionPPT(String businessId, String type) { List<String> failPPTPath = new ArrayList<>(); try { String basePath = global.getSL_LOCATION(); if(type.equals("1")){ basePath = global.getLESSON_LOCATION(); } String path = global.getBASE_UPLOAD_SERVER_LOCATION() + File.separator + global.getCOURSE_LOCATION() + File.separator + basePath + File.separator + businessId; File file = new File(path); failPPTPath = this.changePPTToPDF(file,failPPTPath); } catch (IOException e) { e.printStackTrace(); } return failPPTPath; } private List<String> changePPTToPDF(File slFile, List<String> failPPTPath) throws IOException { for (File chapterFile : slFile.listFiles()) { String pptPath = chapterFile.getPath()+File.separator+"ppt"; File pptFile = new File(pptPath); if(pptFile.exists()){ File[] pptFiles = pptFile.listFiles(); if(pptFiles.length==1&&pptFiles[0].getName().endsWith("ppt")){ failPPTPath.add(pptFiles[0].getPath()); String inputFile = pptFiles[0].getPath(); String outputFile = pptFiles[0].getPath().substring(0,pptFiles[0].getPath().lastIndexOf(".")) + ".pdf"; slTask.officeToPdf(inputFile,outputFile); } } } return failPPTPath; } /*public String uploadFileToServer(MultipartFile file, BFile bFile) throws Exception{ String fileUrl = ""; //查询此节是否已有视频或文件 BFile f = bFileRepository.selectInfoByChapterId(bFile.getChapterId()); if (f!=null){ //复制文件到临时目录 this.removeVideoToTemp(bFile); }else{ BFile newVideo = this.uploadVideo(file, bFile);//上传文件 if (bFile.getType().equals("0")){ fileUrl = newVideo.getVideoUrl(); }else if(bFile.getType().equals("1")){ fileUrl = newVideo.getFileUrl(); }else if(bFile.getType().equals("2")){ fileUrl = newVideo.getPptUrl(); }else{ fileUrl = newVideo.getPdfUrl(); } } return fileUrl; }*/ }
\ No newline at end of file
package
org
.
rcisoft
.
business
.
bfile
.
service
.
impl
;
import
com.itextpdf.text.pdf.PdfReader
;
import
org.apache.commons.io.FileUtils
;
import
org.rcisoft.business.bfile.dao.BFileRepository
;
import
org.rcisoft.business.bfile.entity.BFile
;
import
org.rcisoft.business.bfile.service.BFileService
;
import
org.rcisoft.business.bsl.task.SlTask
;
import
org.rcisoft.common.component.Global
;
import
org.rcisoft.core.aop.PageUtil
;
import
org.rcisoft.core.bean.RcLkConfigBean
;
import
org.rcisoft.core.constant.DelStatus
;
import
org.rcisoft.core.exception.ServiceException
;
import
org.rcisoft.core.model.PersistModel
;
import
org.rcisoft.core.result.ResultServiceEnums
;
import
org.rcisoft.core.util.FileUtil
;
import
org.rcisoft.core.util.IdGen
;
import
org.rcisoft.core.util.UserUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.io.*
;
import
java.nio.file.Files
;
import
java.nio.file.Path
;
import
java.nio.file.Paths
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
static
org
.
rcisoft
.
core
.
util
.
CutPdfUtil
.
partitionPdfFile
;
/** * Created by gaowenfneg on 2017-10-9 14:34:56. */
@Service
@Transactional
(
readOnly
=
true
,
propagation
=
Propagation
.
NOT_SUPPORTED
)
public
class
BFileServiceImpl
implements
BFileService
{
@Autowired
private
BFileRepository
bFileRepository
;
@Autowired
private
SlTask
slTask
;
@Autowired
private
Global
global
;
@Autowired
private
RcLkConfigBean
rcLkConfigBean
;
@Override
public
BFile
selectOne
(
String
businessId
)
{
return
bFileRepository
.
selectByPrimaryKey
(
businessId
);
}
@Override
public
List
<
BFile
>
queryBVideosByPagination
(
PageUtil
pageUtil
,
BFile
model
)
{
Map
param
=
new
HashMap
<
String
,
Object
>();
return
bFileRepository
.
queryBVideos
(
param
);
}
@Override
public
List
<
BFile
>
queryBVideos
(
BFile
model
)
{
Map
param
=
new
HashMap
<
String
,
Object
>();
return
bFileRepository
.
queryBVideos
(
param
);
}
@Override
public
PersistModel
persist
(
BFile
model
)
{
UserUtil
.
setCurrentPersistOperation
(
model
);
int
line
=
bFileRepository
.
insertSelective
(
model
);
return
new
PersistModel
(
line
);
}
@Override
public
PersistModel
removeBVideo
(
String
id
)
{
BFile
bFile
=
bFileRepository
.
selectByPrimaryKey
(
id
);
bFile
.
setDelFlag
(
DelStatus
.
DELETED
.
getStatus
());
UserUtil
.
setCurrentMergeOperation
(
bFile
);
int
line
=
bFileRepository
.
updateByPrimaryKeySelective
(
bFile
);
return
new
PersistModel
(
line
);
}
@Override
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
readOnly
=
false
)
public
String
uploadVideoToServer
(
List
<
MultipartFile
>
list
,
BFile
bFile
)
{
String
videoUrl
=
""
;
if
(
list
.
size
()
>
0
)
{
for
(
int
i
=
0
;
i
<
list
.
size
();
++
i
)
{
MultipartFile
file
=
list
.
get
(
i
);
try
{
//查询此节是否已有视频或文件 BFile video = bFileRepository.selectInfoByChapterId(bFile.getChapterId()); if (video != null) {//此节已有视频或文件,将已有的视频或文件放置到temp目录下,然后上传新视频或文件 if (bFile.getType().equals("0") && video.getVideoUrl() != null && !video.getVideoUrl().equals("")) { this.removeVideoToTemp(bFile);//复制之前视频到temp文件下 } if (bFile.getType().equals("1") && video.getAudioUrl() != null && !video.getAudioUrl().equals("")) { this.removeVideoToTemp(bFile);//复制之前视频到temp文件下 } if (bFile.getType().equals("2") && video.getPptUrl() != null && !video.getPptUrl().equals("")) { this.removeVideoToTemp(bFile);//复制之前ppt到temp文件下 } if (bFile.getType().equals("3") && video.getPdfUrl() != null && !video.getPdfUrl().equals("")) { this.removeVideoToTemp(bFile);//复制之前pdf到temp文件下 } if (bFile.getType().equals("4") && video.getFileUrl() != null && !video.getFileUrl().equals("")) { this.removeVideoToTemp(bFile);//复制之前文件到temp文件下 } BFile newVideo = this.uploadVideo(file, bFile);//上传新文件 newVideo.setBusinessId(video.getBusinessId()); UserUtil.setCurrentMergeOperation(newVideo); bFileRepository.updateByPrimaryKeySelective(newVideo);//更新表中信息 if (bFile.getType().equals("0")) { videoUrl = newVideo.getVideoUrl(); } else if (bFile.getType().equals("1")) { videoUrl = newVideo.getAudioUrl(); } else if (bFile.getType().equals("2")) { videoUrl = newVideo.getPptUrl(); } else if (bFile.getType().equals("3")) { videoUrl = newVideo.getPdfUrl(); } else { videoUrl = newVideo.getFileUrl(); } } else { BFile newVideo = this.uploadVideo(file, bFile);//上传文件 this.persist(newVideo);//插入表信息 if (bFile.getType().equals("0")) { videoUrl = newVideo.getVideoUrl(); } else if (bFile.getType().equals("1")) { videoUrl = newVideo.getAudioUrl(); } else if (bFile.getType().equals("2")) { videoUrl = newVideo.getPptUrl(); } else if (bFile.getType().equals("3")) { videoUrl = newVideo.getPdfUrl(); } else { videoUrl = newVideo.getFileUrl(); } } } catch (Exception e) { e.printStackTrace(); throw new ServiceException(ResultServiceEnums.UPLOAD_ERROR); } } } return videoUrl; } /** * 将原视频复制到temp/video文件下,并删除原视频 * * @param bFile */ private void removeVideoToTemp(BFile bFile) throws Exception { String path; String pathName; if (bFile.getLessonId() != null && !bFile.getLessonId().equals("")) { path = global.getLESSON_LOCATION() + File.separator + bFile.getLessonId() + File.separator; } else { throw new ServiceException("路径错误!"); } if (bFile.getType().equals("0")) { pathName = global.getVIDEO_LOCATION();//视频路径 } else if (bFile.getType().equals("1")) { pathName = global.getAUDIO_LOCATION();//音频路径 } else if (bFile.getType().equals("2")) { pathName = global.getPPT_LOCATION();//ppt路径 } else if (bFile.getType().equals("3")) { pathName = global.getPDF_LOCATION();//pdf路径 } else { pathName = global.getFILE_LOCATION();//文件路径 } String tempPath = global.getBASE_UPLOAD_SERVER_LOCATION() + File.separator + global.getCOURSE_LOCATION() + File.separator + global.getTEMP_LOCATION() + File.separator + path + bFile.getChapterId(); File tempFilePath = new File(tempPath); if (tempFilePath.exists()) { FileUtils.deleteDirectory(tempFilePath); } String realFilePath = global.getBASE_UPLOAD_SERVER_LOCATION() + File.separator + global.getCOURSE_LOCATION() + File.separator + path + bFile.getChapterId() + File.separator + pathName; File directory = new File(realFilePath); if (directory.exists()) { FileUtils.moveDirectory(directory, tempFilePath); } } /** * 上传视频到video目录 * * @param file * @param bFile * @return * @throws IOException */ private BFile uploadVideo(MultipartFile file, BFile bFile) throws IOException { BufferedOutputStream stream = null; String path; String pathName; if (bFile.getLessonId() != null && !bFile.getLessonId().equals("")) { path = global.getLESSON_LOCATION() + File.separator + bFile.getLessonId() + File.separator; } else { throw new ServiceException("路径错误!"); } if (bFile.getType().equals("0")) { pathName = global.getVIDEO_LOCATION();//视频路径 } else if (bFile.getType().equals("1")) { pathName = global.getAUDIO_LOCATION();//音频路径 } else if (bFile.getType().equals("2")) { pathName = global.getPPT_LOCATION();//ppt路径 } else if (bFile.getType().equals("3")) { pathName = global.getPDF_LOCATION();//pdf路径 } else { pathName = global.getFILE_LOCATION();//文件路径 } String realPath = global.getBASE_UPLOAD_SERVER_LOCATION() + File.separator + global.getCOURSE_LOCATION() + File.separator + path + bFile.getChapterId() + File.separator + pathName + File.separator; File outFile = new File(realPath); if (!outFile.exists()) {//判断保存路径是否存在,不存在新建 outFile.mkdirs(); } //上传文件 String uploadFile = file.getOriginalFilename(); //文件的真实名称 String name = uploadFile.substring(uploadFile.lastIndexOf(File.separator) + 1, uploadFile.lastIndexOf('.')); // 截取上传文件的后缀 String uploadFileSuffix = FileUtil.getFilePostfix(uploadFile); //uploadFile.substring(uploadFile.lastIndexOf('.') + 1, uploadFile.length()); // 设置文件名为乱码 String uploadFileName = IdGen.uuid(); String filename = uploadFileName + "." + uploadFileSuffix; stream = new BufferedOutputStream(new FileOutputStream(new File(realPath + filename))); byte[] bytes = file.getBytes(); stream.write(bytes, 0, bytes.length); String newPath = global.getCOURSE_LOCATION() + File.separator + path + bFile.getChapterId() + File.separator + pathName + File.separator; if (uploadFileSuffix.equals("ppt") && bFile.getType().equals("2")) {//ppt转pdf String inputFile = global.getBASE_UPLOAD_SERVER_LOCATION() + File.separator + newPath + filename; String outputFile = global.getBASE_UPLOAD_SERVER_LOCATION() + File.separator + newPath + uploadFileName + ".pdf"; slTask.officeToPdf(inputFile, outputFile); } if (uploadFileSuffix.equals("pdf") && bFile.getType().equals("3")) {//pdf切割 try { slTask.cutPdf(newPath, filename, uploadFileName); } catch (Exception e) { e.printStackTrace(); } } //上传的是文件时才存文件名,方便下载时取 if (bFile.getType().equals("4")) { bFile.setVideoName(name + "." + uploadFileSuffix);//文件名 } if (bFile.getType().equals("0")) { bFile.setVideoUrl(newPath + filename);//视频路径 } else if (bFile.getType().equals("1")) { bFile.setAudioUrl(newPath + filename);//音频路径 } else if (bFile.getType().equals("2")) { bFile.setPptUrl(newPath + uploadFileName + ".pdf");//ppt路径 } else if (bFile.getType().equals("3")) { bFile.setPdfUrl(newPath + filename);//pdf路径 } else { bFile.setFileUrl(newPath + filename);//文件路径 } stream.close(); return bFile; } @Override public BFile queryFileUrlByChapterId(String chapterId) { return bFileRepository.queryFileUrlByChapterId(chapterId); } @Override public void uploadLicense(MultipartFile file) { try { BufferedOutputStream stream = null; String path = global.getBASE_UPLOAD_SERVER_LOCATION() + rcLkConfigBean.getLicPath(); File oldFile = new File(path); if (oldFile.exists()) { FileUtils.forceDelete(oldFile); } File newFile = new File(path); stream = new BufferedOutputStream(new FileOutputStream(newFile)); byte[] bytes = file.getBytes(); stream.write(bytes, 0, bytes.length); stream.flush(); stream.close(); } catch (Exception e) { e.printStackTrace(); throw new ServiceException(ResultServiceEnums.UPLOAD_ERROR); } return; } /** * 重新转换ppt * * @param businessId * @param type 0开课 1课程 * @return */ @Override public List<String> reConversionPPT(String businessId, String type) { List<String> failPPTPath = new ArrayList<>(); try { String basePath = global.getSL_LOCATION(); if (type.equals("1")) { basePath = global.getLESSON_LOCATION(); } String path = global.getBASE_UPLOAD_SERVER_LOCATION() + File.separator + global.getCOURSE_LOCATION() + File.separator + basePath + File.separator + businessId; File file = new File(path); failPPTPath = this.changePPTToPDF(file, failPPTPath); } catch (IOException e) { e.printStackTrace(); } return failPPTPath; } private List<String> changePPTToPDF(File slFile, List<String> failPPTPath) throws IOException { for (File chapterFile : slFile.listFiles()) { String pptPath = chapterFile.getPath() + File.separator + "ppt"; File pptFile = new File(pptPath); if (pptFile.exists()) { File[] pptFiles = pptFile.listFiles(); if (pptFiles.length == 1 && pptFiles[0].getName().endsWith("ppt")) { failPPTPath.add(pptFiles[0].getPath()); String inputFile = pptFiles[0].getPath(); String outputFile = pptFiles[0].getPath().substring(0, pptFiles[0].getPath().lastIndexOf(".")) + ".pdf"; slTask.officeToPdf(inputFile, outputFile); } } } return failPPTPath; } /*public String uploadFileToServer(MultipartFile file, BFile bFile) throws Exception{ String fileUrl = ""; //查询此节是否已有视频或文件 BFile f = bFileRepository.selectInfoByChapterId(bFile.getChapterId()); if (f!=null){ //复制文件到临时目录 this.removeVideoToTemp(bFile); }else{ BFile newVideo = this.uploadVideo(file, bFile);//上传文件 if (bFile.getType().equals("0")){ fileUrl = newVideo.getVideoUrl(); }else if(bFile.getType().equals("1")){ fileUrl = newVideo.getFileUrl(); }else if(bFile.getType().equals("2")){ fileUrl = newVideo.getPptUrl(); }else{ fileUrl = newVideo.getPdfUrl(); } } return fileUrl; }*/ }
\ No newline at end of file
...
...
src/main/java/org/rcisoft/business/blesson/service/impl/BLessonServiceImpl.java
View file @
0c07a080
...
...
@@ -8,7 +8,6 @@ import org.rcisoft.business.blesson.dao.BLessonRepository;
import
org.rcisoft.business.blesson.dto.BLessonIPublishDTO
;
import
org.rcisoft.business.blesson.dto.BLessonIPublishRspDTO
;
import
org.rcisoft.business.blesson.entity.BLesson
;
import
org.rcisoft.business.blesson.entity.BLessonDirection
;
import
org.rcisoft.business.blesson.service.BLessonService
;
import
org.rcisoft.business.blessonlabel.dao.BLessonLabelRepository
;
import
org.rcisoft.business.blessonlabel.entity.BLessonLabel
;
...
...
src/main/java/org/rcisoft/common/component/Global.java
View file @
0c07a080
...
...
@@ -65,6 +65,10 @@ public class Global {
@Value
(
"${global.path.video_location}"
)
private
String
VIDEO_LOCATION
;
/*音频路径*/
@Value
(
"${global.path.audio_location}"
)
private
String
AUDIO_LOCATION
;
/*旧视频路径*/
@Value
(
"${global.path.temp_location}"
)
private
String
TEMP_LOCATION
;
...
...
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