Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
S
sentinel
Project
Project
Details
Activity
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
曲欣亮
sentinel
Commits
9980adc1
Commit
9980adc1
authored
Feb 22, 2019
by
Quxl
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
http://key@gitlab.egolm.com/hanxu/siff-film-api.git
parents
f7874a82
50016f92
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
729 additions
and
254 deletions
+729
-254
OtherUploadService.java
...n/java/com/egolm/film/api/service/OtherUploadService.java
+28
-0
FilmServiceImpl.java
...java/com/egolm/film/api/service/impl/FilmServiceImpl.java
+15
-4
OtherUploadServiceImpl.java
...m/egolm/film/api/service/impl/OtherUploadServiceImpl.java
+90
-0
AdminFirstController.java
...va/com/egolm/film/api/web/admin/AdminFirstController.java
+266
-250
FilmUploadController.java
...va/com/egolm/film/api/web/admin/FilmUploadController.java
+174
-0
Fc_film_upload.java
src/main/java/com/egolm/film/bean/Fc_film_upload.java
+148
-0
FilmContrants.java
src/main/java/com/egolm/film/util/FilmContrants.java
+8
-0
No files found.
src/main/java/com/egolm/film/api/service/OtherUploadService.java
0 → 100644
View file @
9980adc1
package
com
.
egolm
.
film
.
api
.
service
;
import
java.util.List
;
import
java.util.Map
;
import
com.egolm.common.jdbc.Page
;
import
com.egolm.film.bean.Fc_film_upload
;
public
interface
OtherUploadService
{
public
void
batchSave
(
List
<
Fc_film_upload
>
fc_film_upload
);
public
void
save
(
Fc_film_upload
fc_film_upload
);
public
int
checkExists
(
Integer
film_id
,
Integer
number
);
public
List
<
Map
<
String
,
Object
>>
getWaitUploadList
(
Page
page
);
public
void
updateBegin
(
Integer
film_id
,
Integer
number
,
String
videoId
,
String
taskName
);
public
void
updateProgress
(
String
videoId
,
String
progress
);
public
void
updateSuccess
(
String
videoId
);
public
void
updateFail
(
String
videoId
,
String
errorMessage
);
public
void
updateFail
(
Integer
film_id
,
Integer
number
,
String
errorMessage
);
}
src/main/java/com/egolm/film/api/service/impl/FilmServiceImpl.java
View file @
9980adc1
...
@@ -35,6 +35,7 @@ import com.egolm.film.bean.model.Fc_member_film_base_model;
...
@@ -35,6 +35,7 @@ import com.egolm.film.bean.model.Fc_member_film_base_model;
import
com.egolm.film.config.WebMvcConfig
;
import
com.egolm.film.config.WebMvcConfig
;
import
com.egolm.film.config.XException
;
import
com.egolm.film.config.XException
;
import
com.egolm.film.config.XRException
;
import
com.egolm.film.config.XRException
;
import
com.egolm.film.util.FilmContrants
;
import
com.egolm.film.util.SqlWhere
;
import
com.egolm.film.util.SqlWhere
;
...
@@ -635,15 +636,25 @@ public class FilmServiceImpl implements FilmService {
...
@@ -635,15 +636,25 @@ public class FilmServiceImpl implements FilmService {
@Override
@Override
public
void
updateFilmUploadState
(
String
[]
film_id
,
String
[]
number
)
{
public
void
updateFilmUploadState
(
String
[]
film_id
,
String
[]
number
)
{
if
(
film_id
.
length
==
number
.
length
)
{
if
(
film_id
.
length
==
number
.
length
)
{
List
<
Object
[]>
objs
=
new
ArrayList
<
Object
[]>();
List
<
Object
[]>
uploadObjs
=
new
ArrayList
<
Object
[]>();
List
<
Object
[]>
filmObjs
=
new
ArrayList
<
Object
[]>();
for
(
int
i
=
0
;
i
<
film_id
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
film_id
.
length
;
i
++)
{
objs
.
add
(
new
Object
[]{
uploadObjs
.
add
(
new
Object
[]{
FilmContrants
.
UPLOAD_STATUS_INIT
,
film_id
[
i
],
film_id
[
i
],
number
[
i
]});
number
[
i
]});
filmObjs
.
add
(
new
Object
[]{
FilmContrants
.
UPLOAD_STATUS_INIT
,
film_id
[
i
]});
}
}
String
sql
=
"update fc_film_upload set upload_state = 0 ,upload__error_message= '',upload_progress='0%' where film_id = ? and number = ? "
;
String
updateSql
=
"update fc_film_upload set upload_state = ? ,upload__error_message= '',upload_progress='0%' where film_id = ? and number = ? "
;
jdbcTemplate
.
batchUpdate
(
sql
,
objs
);
jdbcTemplate
.
batchUpdate
(
updateSql
,
uploadObjs
);
String
filmSql
=
"update fc_member_film set upload_state = ? where film_no = ? "
;
jdbcTemplate
.
batchUpdate
(
filmSql
,
filmObjs
);
}
}
}
}
}
}
src/main/java/com/egolm/film/api/service/impl/OtherUploadServiceImpl.java
0 → 100644
View file @
9980adc1
package
com
.
egolm
.
film
.
api
.
service
.
impl
;
import
java.util.List
;
import
java.util.Map
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
com.egolm.common.StringUtil
;
import
com.egolm.common.jdbc.JdbcTemplate
;
import
com.egolm.common.jdbc.Page
;
import
com.egolm.film.api.service.OtherUploadService
;
import
com.egolm.film.bean.Fc_film_upload
;
import
com.egolm.film.util.FilmContrants
;
@Service
public
class
OtherUploadServiceImpl
implements
OtherUploadService
{
@Autowired
private
JdbcTemplate
jdbcTemplate
;
public
void
save
(
Fc_film_upload
fc_film_upload
)
{
jdbcTemplate
.
saveOrUpdate
(
fc_film_upload
);
}
public
void
batchSave
(
List
<
Fc_film_upload
>
fc_film_upload
)
{
jdbcTemplate
.
batchSave
(
fc_film_upload
);
}
public
int
checkExists
(
Integer
film_id
,
Integer
number
)
{
String
sql
=
"SELECT count(1) from fc_film_upload where film_id = ? and number = ?"
;
return
jdbcTemplate
.
queryForInt
(
sql
,
film_id
,
number
);
}
//开始上传
public
void
updateBegin
(
Integer
film_id
,
Integer
number
,
String
videoId
,
String
taskName
)
{
if
(
StringUtil
.
isNotEmpty
(
taskName
))
{
String
sql
=
"update fc_film_upload set id = ? ,upload_state = ? ,upload_progress = '0%' ,taskName=? where film_id = ? and number = ? "
;
jdbcTemplate
.
executeUpdate
(
sql
,
videoId
,
FilmContrants
.
UPLOAD_STATUS_ING
,
taskName
,
film_id
,
number
);
}
else
{
String
sql
=
"update fc_film_upload set id = ? ,upload_state = ? ,upload_progress = '0%' where film_id = ? and number = ? "
;
jdbcTemplate
.
executeUpdate
(
sql
,
videoId
,
FilmContrants
.
UPLOAD_STATUS_ING
,
film_id
,
number
);
}
String
filmSql
=
"update fc_member_film set upload_id =?, upload_state = ? where film_no = ? "
;
jdbcTemplate
.
executeUpdate
(
filmSql
,
videoId
,
FilmContrants
.
UPLOAD_STATUS_ING
,
film_id
);
}
//修改进度
public
void
updateProgress
(
String
videoId
,
String
progress
)
{
String
sql
=
"update fc_film_upload set upload_progress = ? where id = ? "
;
jdbcTemplate
.
executeUpdate
(
sql
,
progress
,
videoId
);
}
//上传成功
public
void
updateSuccess
(
String
videoId
)
{
String
sql
=
"update fc_film_upload set upload_time = now() ,file_local_path = '' ,upload_state = ? where id = ? "
;
jdbcTemplate
.
executeUpdate
(
sql
,
FilmContrants
.
UPLOAD_STATUS_COMPLETED
,
videoId
);
String
filmSql
=
"update fc_member_film set upload_state = ? ,upload_time =now() where upload_id = ? "
;
jdbcTemplate
.
executeUpdate
(
filmSql
,
FilmContrants
.
UPLOAD_STATUS_COMPLETED
,
videoId
);
}
//上传失败
public
void
updateFail
(
String
videoId
,
String
errorMessage
)
{
String
sql
=
"update fc_film_upload set upload__error_message =? ,upload_state = ? where id = ? "
;
jdbcTemplate
.
executeUpdate
(
sql
,
errorMessage
,
FilmContrants
.
UPLOAD_STATUS_FILE
,
videoId
);
String
filmSql
=
"update fc_member_film set upload_state = ? where upload_id = ? "
;
jdbcTemplate
.
executeUpdate
(
filmSql
,
FilmContrants
.
UPLOAD_STATUS_FILE
,
videoId
);
}
public
void
updateFail
(
Integer
film_id
,
Integer
number
,
String
errorMessage
)
{
String
sql
=
"update fc_film_upload set upload__error_message =? ,upload_state = ? where film_id = ? and number = ? "
;
jdbcTemplate
.
executeUpdate
(
sql
,
errorMessage
,
FilmContrants
.
UPLOAD_STATUS_FILE
,
film_id
,
number
);
}
/**
* 获取待上传的视频 一次1条
* @Title: getList
* @Description: TODO(这里用一句话描述这个方法的作用)
* @param: @return
* @return: List<Map<String,Object>>
* @throws
*/
public
List
<
Map
<
String
,
Object
>>
getWaitUploadList
(
Page
page
){
String
sql
=
"SELECT * from fc_film_upload where upload_state = 0"
;
return
jdbcTemplate
.
limit
(
sql
,
page
);
}
}
src/main/java/com/egolm/film/api/web/admin/AdminFirstController.java
View file @
9980adc1
This diff is collapsed.
Click to expand it.
src/main/java/com/egolm/film/api/web/admin/FilmUploadController.java
0 → 100644
View file @
9980adc1
package
com
.
egolm
.
film
.
api
.
web
.
admin
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
com.egolm.common.bean.Rjx
;
import
com.egolm.common.jdbc.Page
;
import
com.egolm.film.api.service.OtherUploadService
;
import
com.egolm.film.bean.Fc_film_upload
;
import
com.egolm.film.util.FilmContrants
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiOperation
;
/**
*
* @ClassName: FilmUploadController
* @Description:上传服务调用接口
* @author: zhang.yong
* @date: 2019年2月21日 下午5:09:33
*
*/
@Api
(
tags
={
"后台视频上传单独服务"
})
@Controller
@RequestMapping
(
"other/upload"
)
public
class
FilmUploadController
{
@Autowired
private
OtherUploadService
otherUploadService
;
@ResponseBody
@Transactional
@PostMapping
(
"save"
)
@ApiOperation
(
"保存上传数据"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
paramType
=
"query"
,
dataType
=
"int"
,
required
=
true
,
name
=
"film_id"
,
value
=
"申报影片ID"
),
@ApiImplicitParam
(
paramType
=
"query"
,
dataType
=
"int"
,
required
=
true
,
name
=
"number"
,
value
=
"影片分类扩展分类"
),
@ApiImplicitParam
(
paramType
=
"query"
,
dataType
=
"String"
,
required
=
true
,
name
=
"unit_name"
,
value
=
"剧集名"
),
@ApiImplicitParam
(
paramType
=
"query"
,
dataType
=
"String"
,
required
=
true
,
name
=
"file_name"
,
value
=
"文件名"
),
@ApiImplicitParam
(
paramType
=
"query"
,
dataType
=
"String"
,
required
=
true
,
name
=
"file_local_path"
,
value
=
"后台服务上传路径"
),
})
public
Object
save
(
Integer
film_id
,
Integer
number
,
String
unit_name
,
String
file_name
,
String
file_local_path
)
{
try
{
Fc_film_upload
fc_film_upload
=
new
Fc_film_upload
();
fc_film_upload
.
setFilm_id
(
film_id
);
fc_film_upload
.
setNumber
(
number
);
fc_film_upload
.
setUnit_name
(
unit_name
);
fc_film_upload
.
setFile_name
(
file_name
);
fc_film_upload
.
setFile_local_path
(
file_local_path
);
fc_film_upload
.
setUpload_state
(
FilmContrants
.
UPLOAD_STATUS_INIT
);
fc_film_upload
.
setCreate_time
(
new
Date
());
otherUploadService
.
save
(
fc_film_upload
);
return
Rjx
.
jsonOk
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
Rjx
.
jsonErr
().
setMessage
(
"数据保存失败"
);
}
@ResponseBody
@Transactional
@PostMapping
(
"checkExists"
)
@ApiOperation
(
"检查数据是否存在"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
paramType
=
"query"
,
dataType
=
"int"
,
required
=
true
,
name
=
"film_id"
,
value
=
"影片ID"
),
@ApiImplicitParam
(
paramType
=
"query"
,
dataType
=
"int"
,
required
=
true
,
name
=
"number"
,
value
=
"集数"
),
})
public
Object
checkExists
(
Integer
film_id
,
Integer
number
)
{
int
result
=
otherUploadService
.
checkExists
(
film_id
,
number
);
if
(
result
==
0
)
{
return
Rjx
.
jsonOk
();
}
else
{
return
Rjx
.
jsonErr
().
setMessage
(
"记录已存在"
);
}
}
@ResponseBody
@Transactional
@PostMapping
(
"getWaitUploadList"
)
@ApiOperation
(
"获取待上传的数据"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
paramType
=
"query"
,
dataType
=
"long"
,
required
=
true
,
name
=
"index"
,
value
=
"分页编号"
),
@ApiImplicitParam
(
paramType
=
"query"
,
dataType
=
"long"
,
required
=
true
,
name
=
"limit"
,
value
=
"分页大小"
),
})
public
Object
getWaitUploadList
(
Long
index
,
Long
limit
){
index
=
index
==
null
?
1
:
index
;
limit
=
limit
==
null
?
1
:
limit
;
Page
page
=
new
Page
(
index
,
limit
);
List
<
Map
<
String
,
Object
>>
list
=
otherUploadService
.
getWaitUploadList
(
page
);
return
Rjx
.
jsonOk
().
setData
(
list
).
setPage
(
page
);
}
@ResponseBody
@Transactional
@PostMapping
(
"updateBegin"
)
@ApiOperation
(
"修改为开始上传"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
paramType
=
"query"
,
dataType
=
"long"
,
required
=
true
,
name
=
"film_id"
,
value
=
"分页编号"
),
@ApiImplicitParam
(
paramType
=
"query"
,
dataType
=
"long"
,
required
=
true
,
name
=
"number"
,
value
=
"分页大小"
),
@ApiImplicitParam
(
paramType
=
"query"
,
dataType
=
"String"
,
required
=
false
,
name
=
"videoId"
,
value
=
"阿里视频ID"
),
@ApiImplicitParam
(
paramType
=
"query"
,
dataType
=
"String"
,
required
=
false
,
name
=
"taskName"
,
value
=
"任务名称"
),
})
public
Object
updateBegin
(
Integer
film_id
,
Integer
number
,
String
videoId
,
String
taskName
){
otherUploadService
.
updateBegin
(
film_id
,
number
,
videoId
,
taskName
);
return
Rjx
.
jsonOk
();
}
@ResponseBody
@Transactional
@PostMapping
(
"updateProgress"
)
@ApiOperation
(
"更新上传进度"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
paramType
=
"query"
,
dataType
=
"String"
,
required
=
false
,
name
=
"videoId"
,
value
=
"阿里视频ID"
),
@ApiImplicitParam
(
paramType
=
"query"
,
dataType
=
"String"
,
required
=
false
,
name
=
"progress"
,
value
=
"上传进度"
),
})
public
Object
updateProgress
(
String
videoId
,
String
progress
){
otherUploadService
.
updateProgress
(
videoId
,
progress
);
return
Rjx
.
jsonOk
();
}
@ResponseBody
@Transactional
@PostMapping
(
"updateSuccess"
)
@ApiOperation
(
"更新上传完成"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
paramType
=
"query"
,
dataType
=
"String"
,
required
=
false
,
name
=
"videoId"
,
value
=
"阿里视频ID"
),
})
public
Object
updateSuccess
(
String
videoId
){
otherUploadService
.
updateSuccess
(
videoId
);
return
Rjx
.
jsonOk
();
}
@ResponseBody
@Transactional
@PostMapping
(
"updateFailByVideoId"
)
@ApiOperation
(
"更新为上传失败"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
paramType
=
"query"
,
dataType
=
"String"
,
required
=
true
,
name
=
"videoId"
,
value
=
"阿里视频ID"
),
@ApiImplicitParam
(
paramType
=
"query"
,
dataType
=
"String"
,
required
=
false
,
name
=
"errorMessage"
,
value
=
"失败原因"
),
})
public
Object
updateFailByVideoId
(
String
videoId
,
String
errorMessage
){
otherUploadService
.
updateFail
(
videoId
,
errorMessage
);
return
Rjx
.
jsonOk
();
}
@ResponseBody
@Transactional
@PostMapping
(
"updateFailByFilmId"
)
@ApiOperation
(
"更新为上传失败"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
paramType
=
"query"
,
dataType
=
"int"
,
required
=
true
,
name
=
"film_id"
,
value
=
"影片ID"
),
@ApiImplicitParam
(
paramType
=
"query"
,
dataType
=
"int"
,
required
=
false
,
name
=
"number"
,
value
=
"集数"
),
@ApiImplicitParam
(
paramType
=
"query"
,
dataType
=
"String"
,
required
=
false
,
name
=
"errorMessage"
,
value
=
"失败原因"
),
})
public
Object
updateFailByFilmId
(
Integer
film_id
,
Integer
number
,
String
errorMessage
){
otherUploadService
.
updateFail
(
film_id
,
number
,
errorMessage
);
return
Rjx
.
jsonOk
();
}
}
src/main/java/com/egolm/film/bean/Fc_film_upload.java
0 → 100644
View file @
9980adc1
package
com
.
egolm
.
film
.
bean
;
import
javax.persistence.Entity
;
import
javax.persistence.Column
;
import
java.util.Date
;
@Entity
(
name
=
"fc_film_upload"
)
public
class
Fc_film_upload
implements
java
.
io
.
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
@Column
(
columnDefinition
=
"varchar(255) COMMENT '阿里云视频ID'"
)
private
String
id
;
@Column
(
columnDefinition
=
"int(11) COMMENT '影片ID'"
)
private
Integer
film_id
;
@Column
(
columnDefinition
=
"int(11) COMMENT '集数'"
)
private
Integer
number
;
@Column
(
columnDefinition
=
"int(11) COMMENT '上传状态 0未上传, 1上传中, 2已上传'"
)
private
Integer
upload_state
;
@Column
(
columnDefinition
=
"varchar(255) COMMENT '剧集名'"
)
private
String
unit_name
;
@Column
(
columnDefinition
=
"varchar(255) COMMENT '文件名'"
)
private
String
file_name
;
@Column
(
columnDefinition
=
"datetime COMMENT '开始上传时间'"
)
private
Date
create_time
;
@Column
(
columnDefinition
=
"datetime COMMENT '完成上传时间'"
)
private
Date
upload_time
;
@Column
(
columnDefinition
=
"varchar(36) COMMENT '上传进度'"
)
private
String
upload_progress
;
@Column
(
columnDefinition
=
"varchar(255) COMMENT '后台服务上传路径'"
)
private
String
file_local_path
;
@Column
(
columnDefinition
=
"varchar(255) COMMENT '后台服务上传失败原因'"
)
private
String
upload__error_message
;
@Column
(
columnDefinition
=
"varchar(255) COMMENT '分配的任务名称'"
)
private
String
taskName
;
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
}
public
String
getId
()
{
return
id
;
}
public
void
setFilm_id
(
Integer
film_id
)
{
this
.
film_id
=
film_id
;
}
public
Integer
getFilm_id
()
{
return
film_id
;
}
public
void
setNumber
(
Integer
number
)
{
this
.
number
=
number
;
}
public
Integer
getNumber
()
{
return
number
;
}
public
void
setUpload_state
(
Integer
upload_state
)
{
this
.
upload_state
=
upload_state
;
}
public
Integer
getUpload_state
()
{
return
upload_state
;
}
public
void
setUnit_name
(
String
unit_name
)
{
this
.
unit_name
=
unit_name
;
}
public
String
getUnit_name
()
{
return
unit_name
;
}
public
void
setFile_name
(
String
file_name
)
{
this
.
file_name
=
file_name
;
}
public
String
getFile_name
()
{
return
file_name
;
}
public
void
setCreate_time
(
Date
create_time
)
{
this
.
create_time
=
create_time
;
}
public
Date
getCreate_time
()
{
return
create_time
;
}
public
void
setUpload_time
(
Date
upload_time
)
{
this
.
upload_time
=
upload_time
;
}
public
Date
getUpload_time
()
{
return
upload_time
;
}
public
void
setUpload_progress
(
String
upload_progress
)
{
this
.
upload_progress
=
upload_progress
;
}
public
String
getUpload_progress
()
{
return
upload_progress
;
}
public
void
setFile_local_path
(
String
file_local_path
)
{
this
.
file_local_path
=
file_local_path
;
}
public
String
getFile_local_path
()
{
return
file_local_path
;
}
public
void
setUpload__error_message
(
String
upload__error_message
)
{
this
.
upload__error_message
=
upload__error_message
;
}
public
String
getUpload__error_message
()
{
return
upload__error_message
;
}
public
void
setTaskName
(
String
taskName
)
{
this
.
taskName
=
taskName
;
}
public
String
getTaskName
()
{
return
taskName
;
}
}
src/main/java/com/egolm/film/util/FilmContrants.java
0 → 100644
View file @
9980adc1
package
com
.
egolm
.
film
.
util
;
public
class
FilmContrants
{
public
static
int
UPLOAD_STATUS_INIT
=
0
;
//待上传
public
static
int
UPLOAD_STATUS_ING
=
1
;
//上传中
public
static
int
UPLOAD_STATUS_COMPLETED
=
2
;
//上传完成
public
static
int
UPLOAD_STATUS_FILE
=
3
;
//上传失败
}
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