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