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
3c922ae9
Commit
3c922ae9
authored
Dec 06, 2018
by
张永
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
eeefcf41
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
133 additions
and
133 deletions
+133
-133
AliyunApiController.java
...main/java/com/egolm/film/api/web/AliyunApiController.java
+133
-133
No files found.
src/main/java/com/egolm/film/api/web/AliyunApiController.java
View file @
3c922ae9
package
com
.
egolm
.
film
.
api
.
web
;
import
java.util.HashMap
;
import
java.util.Map
;
import
javax.servlet.http.HttpServletRequest
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
com.aliyuncs.vod.model.v20170321.CreateUploadVideoResponse
;
import
com.aliyuncs.vod.model.v20170321.GetVideoPlayAuthResponse
;
import
com.aliyuncs.vod.model.v20170321.RefreshUploadVideoResponse
;
import
com.egolm.common.StringUtil
;
import
com.egolm.common.bean.Rjx
;
import
com.egolm.film.api.service.Messages
;
import
com.egolm.film.util.AliyunUtil
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiOperation
;
@Api
(
tags
={
"阿里云接口"
})
@Controller
@RequestMapping
(
"aliyun"
)
public
class
AliyunApiController
{
@Value
(
"${aliyun.sts.accessKeyId}"
)
private
String
accessKeyId
;
@Value
(
"${aliyun.sts.accessKeySecret}"
)
private
String
accessKeySecret
;
@Autowired
private
Messages
messages
;
@ResponseBody
@ApiOperation
(
"获取点播授权Auth"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
paramType
=
"query"
,
name
=
"fileName"
,
dataType
=
"String"
,
required
=
true
,
value
=
"文件名称(带后缀名)"
,
defaultValue
=
""
),
@ApiImplicitParam
(
paramType
=
"query"
,
name
=
"title"
,
dataType
=
"String"
,
required
=
true
,
value
=
"标题"
,
defaultValue
=
""
),
@ApiImplicitParam
(
paramType
=
"query"
,
name
=
"cateId"
,
dataType
=
"Long"
,
required
=
true
,
value
=
"分类ID"
,
defaultValue
=
"0"
),
@ApiImplicitParam
(
paramType
=
"query"
,
name
=
"tags"
,
dataType
=
"String"
,
required
=
false
,
value
=
"视频标签,多个用逗号分隔"
,
defaultValue
=
""
),
@ApiImplicitParam
(
paramType
=
"query"
,
name
=
"description"
,
dataType
=
"String"
,
required
=
false
,
value
=
"描述"
,
defaultValue
=
""
),
})
@RequestMapping
(
value
=
"/createUploadVideo"
,
method
=
RequestMethod
.
POST
)
public
Object
createUploadVideo
(
HttpServletRequest
request
)
{
String
fileName
=
request
.
getParameter
(
"fileName"
);
String
title
=
request
.
getParameter
(
"title"
);
String
cateId
=
request
.
getParameter
(
"cateId"
);
String
tags
=
request
.
getParameter
(
"tags"
);
String
description
=
request
.
getParameter
(
"description"
);
if
(!
StringUtil
.
isNotEmpty
(
fileName
,
title
))
{
return
Rjx
.
jsonErr
().
setMessage
(
messages
.
get
(
"err.param_null"
));
}
Map
<
String
,
Object
>
params
=
new
HashMap
<
String
,
Object
>();
params
.
put
(
"fileName"
,
fileName
);
params
.
put
(
"title"
,
title
);
params
.
put
(
"cateId"
,
cateId
);
params
.
put
(
"tags"
,
tags
);
params
.
put
(
"description"
,
description
);
AliyunUtil
aliyunUtil
=
new
AliyunUtil
(
accessKeyId
,
accessKeySecret
);
CreateUploadVideoResponse
response
=
aliyunUtil
.
createUploadVideo
(
params
);
return
Rjx
.
jsonOk
().
set
(
"RequestId"
,
response
.
getRequestId
()).
set
(
"UploadAuth"
,
response
.
getUploadAuth
())
.
set
(
"UploadAddress"
,
response
.
getUploadAddress
())
.
set
(
"VideoId"
,
response
.
getVideoId
());
}
@ResponseBody
@ApiOperation
(
"刷新点播授权"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
paramType
=
"query"
,
name
=
"videoId"
,
dataType
=
"String"
,
required
=
true
,
value
=
"点播ID"
,
defaultValue
=
""
),
})
@RequestMapping
(
value
=
"/refreshUploadVideo"
,
method
=
RequestMethod
.
GET
)
public
Object
refreshUploadVideo
(
HttpServletRequest
request
)
{
String
videoId
=
request
.
getParameter
(
"videoId"
);
if
(!
StringUtil
.
isNotEmpty
(
videoId
))
{
return
Rjx
.
jsonErr
().
setMessage
(
messages
.
get
(
"err.param_null"
));
}
AliyunUtil
aliyunUtil
=
new
AliyunUtil
(
accessKeyId
,
accessKeySecret
);
RefreshUploadVideoResponse
response
=
aliyunUtil
.
refreshUploadVideo
(
videoId
);
if
(
response
!=
null
)
{
return
Rjx
.
jsonOk
().
set
(
"RequestId"
,
response
.
getRequestId
()).
set
(
"UploadAuth"
,
response
.
getUploadAuth
()).
set
(
"UploadAddress"
,
response
.
getUploadAddress
());
}
else
{
return
Rjx
.
jsonErr
().
setMessage
(
"InvalidVideo.NotFound : The video does not exist."
);
}
}
@ResponseBody
@ApiOperation
(
"获取播放凭证"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
paramType
=
"query"
,
name
=
"videoId"
,
dataType
=
"String"
,
required
=
true
,
value
=
"点播ID"
,
defaultValue
=
""
),
})
@RequestMapping
(
value
=
"/getVideoPlayAuth"
,
method
=
RequestMethod
.
GET
)
public
Object
getVideoPlayAuth
(
HttpServletRequest
request
)
{
String
videoId
=
request
.
getParameter
(
"videoId"
);
if
(!
StringUtil
.
isNotEmpty
(
videoId
))
{
return
Rjx
.
jsonErr
().
setMessage
(
messages
.
get
(
"err.param_null"
));
}
AliyunUtil
aliyunUtil
=
new
AliyunUtil
(
accessKeyId
,
accessKeySecret
);
try
{
GetVideoPlayAuthResponse
response
=
aliyunUtil
.
getVideoPlayAuth
(
videoId
);
if
(
response
!=
null
)
{
return
Rjx
.
jsonOk
().
set
(
"playAuth"
,
response
.
getPlayAuth
()).
set
(
"videoMeta"
,
response
.
getVideoMeta
());
}
else
{
return
Rjx
.
jsonErr
().
set
Message
(
"InvalidVideo.NotFound : The video does not exist."
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
Rjx
.
jsonErr
().
setMessage
(
e
.
getMessage
());
}
}
}
package
com
.
egolm
.
film
.
api
.
web
;
import
java.util.HashMap
;
import
java.util.Map
;
import
javax.servlet.http.HttpServletRequest
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
com.aliyuncs.vod.model.v20170321.CreateUploadVideoResponse
;
import
com.aliyuncs.vod.model.v20170321.GetVideoPlayAuthResponse
;
import
com.aliyuncs.vod.model.v20170321.RefreshUploadVideoResponse
;
import
com.egolm.common.StringUtil
;
import
com.egolm.common.bean.Rjx
;
import
com.egolm.film.api.service.Messages
;
import
com.egolm.film.util.AliyunUtil
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiOperation
;
@Api
(
tags
={
"阿里云接口"
})
@Controller
@RequestMapping
(
"aliyun"
)
public
class
AliyunApiController
{
@Value
(
"${aliyun.sts.accessKeyId}"
)
private
String
accessKeyId
;
@Value
(
"${aliyun.sts.accessKeySecret}"
)
private
String
accessKeySecret
;
@Autowired
private
Messages
messages
;
@ResponseBody
@ApiOperation
(
"获取点播授权Auth"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
paramType
=
"query"
,
name
=
"fileName"
,
dataType
=
"String"
,
required
=
true
,
value
=
"文件名称(带后缀名)"
,
defaultValue
=
""
),
@ApiImplicitParam
(
paramType
=
"query"
,
name
=
"title"
,
dataType
=
"String"
,
required
=
true
,
value
=
"标题"
,
defaultValue
=
""
),
@ApiImplicitParam
(
paramType
=
"query"
,
name
=
"cateId"
,
dataType
=
"Long"
,
required
=
true
,
value
=
"分类ID"
,
defaultValue
=
"0"
),
@ApiImplicitParam
(
paramType
=
"query"
,
name
=
"tags"
,
dataType
=
"String"
,
required
=
false
,
value
=
"视频标签,多个用逗号分隔"
,
defaultValue
=
""
),
@ApiImplicitParam
(
paramType
=
"query"
,
name
=
"description"
,
dataType
=
"String"
,
required
=
false
,
value
=
"描述"
,
defaultValue
=
""
),
})
@RequestMapping
(
value
=
"/createUploadVideo"
,
method
=
RequestMethod
.
POST
)
public
Object
createUploadVideo
(
HttpServletRequest
request
)
{
String
fileName
=
request
.
getParameter
(
"fileName"
);
String
title
=
request
.
getParameter
(
"title"
);
String
cateId
=
request
.
getParameter
(
"cateId"
);
String
tags
=
request
.
getParameter
(
"tags"
);
String
description
=
request
.
getParameter
(
"description"
);
if
(!
StringUtil
.
isNotEmpty
(
fileName
,
title
))
{
return
Rjx
.
jsonErr
().
setMessage
(
messages
.
get
(
"err.param_null"
));
}
Map
<
String
,
Object
>
params
=
new
HashMap
<
String
,
Object
>();
params
.
put
(
"fileName"
,
fileName
);
params
.
put
(
"title"
,
title
);
params
.
put
(
"cateId"
,
cateId
);
params
.
put
(
"tags"
,
tags
);
params
.
put
(
"description"
,
description
);
AliyunUtil
aliyunUtil
=
new
AliyunUtil
(
accessKeyId
,
accessKeySecret
);
CreateUploadVideoResponse
response
=
aliyunUtil
.
createUploadVideo
(
params
);
return
Rjx
.
jsonOk
().
set
(
"RequestId"
,
response
.
getRequestId
()).
set
(
"UploadAuth"
,
response
.
getUploadAuth
())
.
set
(
"UploadAddress"
,
response
.
getUploadAddress
())
.
set
(
"VideoId"
,
response
.
getVideoId
());
}
@ResponseBody
@ApiOperation
(
"刷新点播授权"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
paramType
=
"query"
,
name
=
"videoId"
,
dataType
=
"String"
,
required
=
true
,
value
=
"点播ID"
,
defaultValue
=
""
),
})
@RequestMapping
(
value
=
"/refreshUploadVideo"
,
method
=
RequestMethod
.
GET
)
public
Object
refreshUploadVideo
(
HttpServletRequest
request
)
{
String
videoId
=
request
.
getParameter
(
"videoId"
);
if
(!
StringUtil
.
isNotEmpty
(
videoId
))
{
return
Rjx
.
jsonErr
().
setMessage
(
messages
.
get
(
"err.param_null"
));
}
AliyunUtil
aliyunUtil
=
new
AliyunUtil
(
accessKeyId
,
accessKeySecret
);
RefreshUploadVideoResponse
response
=
aliyunUtil
.
refreshUploadVideo
(
videoId
);
if
(
response
!=
null
)
{
return
Rjx
.
jsonOk
().
set
(
"RequestId"
,
response
.
getRequestId
()).
set
(
"UploadAuth"
,
response
.
getUploadAuth
()).
set
(
"UploadAddress"
,
response
.
getUploadAddress
());
}
else
{
return
Rjx
.
jsonErr
().
setMessage
(
"InvalidVideo.NotFound : The video does not exist."
);
}
}
@ResponseBody
@ApiOperation
(
"获取播放凭证"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
paramType
=
"query"
,
name
=
"videoId"
,
dataType
=
"String"
,
required
=
true
,
value
=
"点播ID"
,
defaultValue
=
""
),
})
@RequestMapping
(
value
=
"/getVideoPlayAuth"
,
method
=
RequestMethod
.
GET
)
public
Object
getVideoPlayAuth
(
HttpServletRequest
request
)
{
String
videoId
=
request
.
getParameter
(
"videoId"
);
if
(!
StringUtil
.
isNotEmpty
(
videoId
))
{
return
Rjx
.
jsonErr
().
setMessage
(
messages
.
get
(
"err.param_null"
));
}
AliyunUtil
aliyunUtil
=
new
AliyunUtil
(
accessKeyId
,
accessKeySecret
);
try
{
GetVideoPlayAuthResponse
response
=
aliyunUtil
.
getVideoPlayAuth
(
videoId
);
if
(
response
!=
null
)
{
return
Rjx
.
jsonOk
().
set
(
"playAuth"
,
response
.
getPlayAuth
()).
set
(
"videoMeta"
,
response
.
getVideoMeta
());
}
else
{
return
Rjx
.
jsonErr
().
set
Code
(-
1
).
setMessage
(
"InvalidVideo.NotFound : The video does not exist."
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
Rjx
.
jsonErr
().
setMessage
(
e
.
getMessage
());
}
}
}
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