Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
cloud-aliyun
Overview
Overview
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hqzhdj
cloud-aliyun
Commits
fa5aeaee
Commit
fa5aeaee
authored
Feb 09, 2021
by
liangkaiping
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
copy
parent
521b13f0
Show whitespace changes
Inline
Side-by-side
Showing
53 changed files
with
3934 additions
and
2 deletions
+3934
-2
README.md
+2
-2
cloud-aliyun-api/pom.xml
+52
-0
cloud-aliyun-api/src/main/java/com/yizhi/aliyun/application/feign/AliMNSClient.java
+21
-0
cloud-aliyun-api/src/main/java/com/yizhi/aliyun/application/feign/AliyunClient.java
+55
-0
cloud-aliyun-api/src/main/java/com/yizhi/aliyun/application/vo/AddMediaResponseRecordVO.java
+47
-0
cloud-aliyun-api/src/main/java/com/yizhi/aliyun/application/vo/MNSVO.java
+30
-0
cloud-aliyun-api/src/main/java/com/yizhi/aliyun/application/vo/UploadParamVo.java
+46
-0
cloud-aliyun-service/pom.xml
+120
-0
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/AliyunApplication.java
+33
-0
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/SwaggerConfig.java
+50
-0
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/controller/AddMediaController.java
+46
-0
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/controller/ImageController.java
+70
-0
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/controller/MSNController.java
+33
-0
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/controller/PolicyController.java
+157
-0
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/controller/VideoController.java
+244
-0
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/controller/VideoFeignController.java
+103
-0
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/demo/AddMedia.java
+51
-0
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/demo/Main.java
+194
-0
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/demo/SimpleTranscode.java
+141
-0
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/domain/ActivityDTO.java
+133
-0
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/domain/ActivityState.java
+6
-0
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/domain/ActivityType.java
+6
-0
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/domain/FileDTO.java
+63
-0
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/domain/GetPlayInfoRequest.java
+57
-0
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/domain/GetVideoListRequest.java
+79
-0
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/domain/MediaState.java
+8
-0
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/domain/MediaWorkflowExecutionDTO.java
+102
-0
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/domain/MediaWorkflowInputDTO.java
+46
-0
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/domain/UpdateVideoInfoRequest.java
+66
-0
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/domain/UploadVideoURLStreamVo.java
+98
-0
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/domain/UploadVideoVo.java
+107
-0
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/mapper/AddMediaResponseRecordMapper.java
+9
-0
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/mapper/MNSMapper.java
+9
-0
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/mq/AssignmentTranscodingListener.java
+29
-0
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/service/AddMediaResponseRecordService.java
+8
-0
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/service/DealMediaTranscode.java
+381
-0
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/service/MNSService.java
+8
-0
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/service/UploadVideoApi.java
+46
-0
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/service/VideoInfoApi.java
+46
-0
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/service/impl/AddMediaResponseRecordServiceImpl.java
+21
-0
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/service/impl/MNSServiceImpl.java
+14
-0
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/service/impl/VideoInfoApiImpl.java
+136
-0
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/service/impl/VideoUploadImpl.java
+219
-0
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/util/AESCoder.java
+100
-0
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/util/AESUtil.java
+151
-0
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/util/PropertiesUtil.java
+70
-0
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/util/UploadVideoUtil.java
+93
-0
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/util/VideoRequestUtil.java
+188
-0
cloud-aliyun-service/src/main/resources/aliyunAccessKey.properties
+26
-0
cloud-aliyun-service/src/main/resources/bootstrap.properties
+13
-0
cloud-aliyun-service/src/main/resources/generatorConfig.xml
+39
-0
cloud-aliyun-service/src/test/java/com/yizhi/aliyun/application/CourseTest.java
+24
-0
pom.xml
+38
-0
No files found.
README.md
View file @
fa5aeaee
# cloud-aliyun
123
\ No newline at end of file
cloud-aliyun-api/pom.xml
0 → 100644
View file @
fa5aeaee
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<parent>
<artifactId>
cloud-aliyun
</artifactId>
<groupId>
com.yizhi
</groupId>
<version>
1.0-SNAPSHOT
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<groupId>
com.yizhi
</groupId>
<artifactId>
cloud-aliyun-api
</artifactId>
<version>
1.0-SNAPSHOT
</version>
<dependencies>
<dependency>
<groupId>
com.yizhi
</groupId>
<artifactId>
cloud-common-api
</artifactId>
<version>
1.0-SNAPSHOT
</version>
<scope>
provided
</scope>
</dependency>
<dependency>
<groupId>
com.yizhi
</groupId>
<artifactId>
cloud-util
</artifactId>
<version>
1.0-SNAPSHOT
</version>
<scope>
provided
</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-maven-plugin
</artifactId>
<executions>
<execution>
<goals>
<goal>
repackage
</goal>
</goals>
</execution>
</executions>
<configuration>
<skip>
true
</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
cloud-aliyun-api/src/main/java/com/yizhi/aliyun/application/feign/AliMNSClient.java
0 → 100644
View file @
fa5aeaee
package
com
.
yizhi
.
aliyun
.
application
.
feign
;
import
com.yizhi.aliyun.application.vo.MNSVO
;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
/**
* @ClassName AliMNSClient
* @Description TODO
* @Author shengchenglong
* @DATE 2019-10-18 11:47
* @Version 1.0
*/
@FeignClient
(
name
=
"aliyun"
,
contextId
=
"AliMNSClient"
)
public
interface
AliMNSClient
{
@PostMapping
(
"/insert"
)
boolean
insert
(
@RequestBody
MNSVO
record
);
}
cloud-aliyun-api/src/main/java/com/yizhi/aliyun/application/feign/AliyunClient.java
0 → 100644
View file @
fa5aeaee
/**
* FileName: AliyunClient
* Author: wenjunlong
* Date: 2018/6/6 13:36
* Description: 阿里云第三方接口调用
* History:
* <author> <time> <version> <desc>
* 作者姓名 修改时间 版本号 描述
*/
package
com
.
yizhi
.
aliyun
.
application
.
feign
;
import
com.yizhi.aliyun.application.vo.UploadParamVo
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiParam
;
import
org.springframework.cloud.client.loadbalancer.reactive.Response
;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.web.bind.annotation.*
;
/**
* 〈一句话功能简述〉<br>
* 〈阿里云第三方接口调用〉
*
* @author wenjunlong
* @create 2018/6/6
* @since 1.0.0
*/
@FeignClient
(
name
=
"aliyun"
,
contextId
=
"AliyunClient"
)
public
interface
AliyunClient
{
@ApiOperation
(
value
=
"视频上传"
,
notes
=
"视频上传"
,
response
=
Response
.
class
)
@RequestMapping
(
value
=
"/video/urlUpload"
,
method
=
RequestMethod
.
POST
)
String
upload
(
@RequestBody
UploadParamVo
uploadParamVo
);
@ApiOperation
(
value
=
"获取视频播放地址"
,
notes
=
"获取视频播放地址"
,
response
=
Response
.
class
)
@RequestMapping
(
value
=
"/video/movieurls"
,
method
=
RequestMethod
.
GET
)
String
movieurls
(
@ApiParam
(
name
=
"videoId"
,
value
=
"视频ID"
,
required
=
true
)
@RequestParam
(
"videoId"
)
String
videoId
);
@GetMapping
(
"/ali/addMedia/dealFinishedTranscoding"
)
boolean
dealFinishedTranscoding
();
/**
* 获取文件的下载路径
*
* @param sourceUrl oss的预览地址
* @return 返回为空表示后获下载地址失败
*/
@GetMapping
(
"/video/change/download"
)
String
downloadObjectHeader
(
@RequestParam
(
"sourceUrl"
)
String
sourceUrl
);
}
cloud-aliyun-api/src/main/java/com/yizhi/aliyun/application/vo/AddMediaResponseRecordVO.java
0 → 100644
View file @
fa5aeaee
package
com
.
yizhi
.
aliyun
.
application
.
vo
;
import
com.baomidou.mybatisplus.activerecord.Model
;
import
com.baomidou.mybatisplus.annotations.TableName
;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.util.Date
;
@Data
@TableName
(
"add_media_response_record"
)
public
class
AddMediaResponseRecordVO
extends
Model
<
AddMediaResponseRecordVO
>
{
private
Long
id
;
private
Long
relationId
;
private
String
mediaId
;
private
String
errCode
;
private
String
errMsg
;
private
String
createTime
;
private
String
response
;
private
Integer
hasProcessed
;
private
Date
processTime
;
private
Integer
type
;
/**
* 转码后的后缀
*/
private
String
suffixType
;
private
static
final
long
serialVersionUID
=
1L
;
@Override
protected
Serializable
pkVal
()
{
return
this
.
id
;
}
}
\ No newline at end of file
cloud-aliyun-api/src/main/java/com/yizhi/aliyun/application/vo/MNSVO.java
0 → 100644
View file @
fa5aeaee
package
com
.
yizhi
.
aliyun
.
application
.
vo
;
import
com.baomidou.mybatisplus.activerecord.Model
;
import
com.baomidou.mybatisplus.annotations.TableName
;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.util.Date
;
@Data
@TableName
(
"mns"
)
public
class
MNSVO
extends
Model
<
MNSVO
>
{
private
Long
id
;
private
String
relationId
;
private
Date
createTime
;
private
String
response
;
private
static
final
long
serialVersionUID
=
1L
;
@Override
protected
Serializable
pkVal
()
{
return
this
.
id
;
}
}
\ No newline at end of file
cloud-aliyun-api/src/main/java/com/yizhi/aliyun/application/vo/UploadParamVo.java
0 → 100644
View file @
fa5aeaee
/**
* FileName: UploadParamVo
* Author: wenjunlong
* Date: 2018/5/24 18:55
* Description: 文件上传vo
* History:
* <author> <time> <version> <desc>
* 作者姓名 修改时间 版本号 描述
*/
package
com
.
yizhi
.
aliyun
.
application
.
vo
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
/**
* 〈一句话功能简述〉<br>
* 〈文件上传vo〉
*
* @author wenjunlong
* @create 2018/5/24
* @since 1.0.0
*/
@Data
public
class
UploadParamVo
{
@ApiModelProperty
(
name
=
"fileType"
,
value
=
"上传文件类型 1为本地视频,2位网络url视频"
,
required
=
true
)
String
fileType
;
@ApiModelProperty
(
name
=
"title"
,
value
=
"视频标题"
,
required
=
true
)
String
title
;
@ApiModelProperty
(
name
=
"fileName"
,
value
=
"1.本地文件上传时,文件名称为上传文件绝对路径,如:/User/sample/文件名称.mp4 (必选) "
+
"2.网络流上传时,文件名称为源文件名,如文件名称.mp4(必选)。任何上传方式文件名必须包含扩展名"
,
required
=
true
)
String
fileName
;
@ApiModelProperty
(
name
=
"url"
,
value
=
"当文件类型为2的时候必填,网络文件url"
,
required
=
false
)
String
url
;
@ApiModelProperty
(
name
=
"description"
,
value
=
"视频描述"
,
required
=
false
)
String
description
;
@ApiModelProperty
(
name
=
"cateId"
,
value
=
"视频分类ID,数字Integer类型"
,
required
=
false
)
Integer
cateId
;
@ApiModelProperty
(
name
=
"tags"
,
value
=
"视频标签,多个用逗号分隔"
,
required
=
false
)
String
tags
;
@ApiModelProperty
(
name
=
"coverURL"
,
value
=
"封面图片(可选),网络url"
,
required
=
false
)
String
coverURL
;
@ApiModelProperty
(
name
=
"isShowWaterMark"
,
value
=
"是否使用默认水印,布尔型0/1"
,
required
=
false
)
Boolean
isShowWaterMark
;
}
cloud-aliyun-service/pom.xml
0 → 100644
View file @
fa5aeaee
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<parent>
<artifactId>
cloud-aliyun
</artifactId>
<groupId>
com.yizhi
</groupId>
<version>
1.0-SNAPSHOT
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<groupId>
com.yizhi
</groupId>
<artifactId>
cloud-aliyun-service
</artifactId>
<version>
1.0-SNAPSHOT
</version>
<dependencies>
<!-- 本地依赖-->
<dependency>
<groupId>
com.yizhi
</groupId>
<artifactId>
cloud-util
</artifactId>
<version>
1.0-SNAPSHOT
</version>
</dependency>
<dependency>
<groupId>
com.yizhi
</groupId>
<artifactId>
cloud-orm
</artifactId>
<version>
1.0-SNAPSHOT
</version>
</dependency>
<!-- 阿里云-->
<dependency>
<groupId>
com.aliyun
</groupId>
<artifactId>
aliyun-java-sdk-vod
</artifactId>
<version>
2.8.0
</version>
</dependency>
<dependency>
<groupId>
com.aliyun
</groupId>
<artifactId>
aliyun-java-sdk-core
</artifactId>
<version>
3.2.2
</version>
</dependency>
<dependency>
<groupId>
com.aliyun.oss
</groupId>
<artifactId>
aliyun-sdk-oss
</artifactId>
<version>
2.8.0
</version>
</dependency>
<dependency>
<groupId>
aliyun.java-vod.upload
</groupId>
<artifactId>
aliyun-java-vod-upload
</artifactId>
<version>
1.1.1
</version>
</dependency>
<dependency>
<groupId>
com.aliyun
</groupId>
<artifactId>
aliyun-java-sdk-mts
</artifactId>
<version>
2.5.2
</version>
</dependency>
<dependency>
<groupId>
com.aliyun.mns
</groupId>
<artifactId>
aliyun-sdk-mns
</artifactId>
<version>
1.1.7
</version>
</dependency>
<dependency>
<groupId>
com.yizhi
</groupId>
<artifactId>
cloud-aliyun-api
</artifactId>
<version>
1.0-SNAPSHOT
</version>
</dependency>
<dependency>
<groupId>
com.yizhi
</groupId>
<artifactId>
cloud-documents-api
</artifactId>
<version>
1.0-SNAPSHOT
</version>
</dependency>
<dependency>
<groupId>
com.yizhi
</groupId>
<artifactId>
cloud-assignment-api
</artifactId>
<version>
1.0-SNAPSHOT
</version>
</dependency>
<dependency>
<groupId>
com.yizhi
</groupId>
<artifactId>
cloud-job-api
</artifactId>
<version>
1.0-SNAPSHOT
</version>
</dependency>
<dependency>
<groupId>
com.yizhi
</groupId>
<artifactId>
library-api
</artifactId>
<version>
1.0-SNAPSHOT
</version>
</dependency>
<dependency>
<groupId>
com.yizhi
</groupId>
<artifactId>
cloud-forum-api
</artifactId>
<version>
1.0-SNAPSHOT
</version>
</dependency>
<dependency>
<groupId>
com.yizhi
</groupId>
<artifactId>
cloud-system-api
</artifactId>
<version>
1.0-SNAPSHOT
</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-deploy-plugin
</artifactId>
<configuration>
<skip>
true
</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/AliyunApplication.java
0 → 100644
View file @
fa5aeaee
package
com
.
yizhi
.
aliyun
.
application
;
import
org.springframework.amqp.core.Queue
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.cloud.client.discovery.EnableDiscoveryClient
;
import
org.springframework.cloud.openfeign.EnableFeignClients
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.ComponentScan
;
/**
*
* @author scotthu
*
* @date 2018年2月28日
*/
@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients
(
"com.yizhi"
)
@ComponentScan
(
"com.yizhi"
)
public
class
AliyunApplication
{
public
static
void
main
(
java
.
lang
.
String
[]
args
)
{
SpringApplication
.
run
(
AliyunApplication
.
class
,
args
);
}
@Bean
public
Queue
createassignmentMediaTranscodingQueue
()
{
return
new
Queue
(
"assignmentMediaTranscoding"
,
true
,
false
,
false
);
}
}
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/SwaggerConfig.java
0 → 100644
View file @
fa5aeaee
package
com
.
yizhi
.
aliyun
.
application
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
;
import
springfox.documentation.builders.ApiInfoBuilder
;
import
springfox.documentation.builders.PathSelectors
;
import
springfox.documentation.builders.RequestHandlerSelectors
;
import
springfox.documentation.service.ApiInfo
;
import
springfox.documentation.spi.DocumentationType
;
import
springfox.documentation.spring.web.plugins.Docket
;
import
springfox.documentation.swagger2.annotations.EnableSwagger2
;
/**
* @Author: shengchenglong
* @Date: 2018/3/6 14:30
*/
@Configuration
@EnableSwagger2
public
class
SwaggerConfig
extends
WebMvcConfigurerAdapter
{
@Bean
public
Docket
createRestApi
()
{
return
new
Docket
(
DocumentationType
.
SWAGGER_2
)
.
groupName
(
"阿里云服务"
)
.
apiInfo
(
apiInfo
())
.
select
()
.
apis
(
RequestHandlerSelectors
.
basePackage
(
"com.yizhi.application"
))
.
paths
(
PathSelectors
.
any
())
.
build
();
}
private
ApiInfo
apiInfo
()
{
return
new
ApiInfoBuilder
()
.
title
(
"阿里云服务"
)
//版本
.
version
(
"1.0"
)
.
build
();
}
@Override
public
void
addResourceHandlers
(
ResourceHandlerRegistry
registry
)
{
registry
.
addResourceHandler
(
"swagger-ui.html"
).
addResourceLocations
(
"classpath:/META-INF/resources/"
);
registry
.
addResourceHandler
(
"docs.html"
).
addResourceLocations
(
"classpath:/META-INF/resources/"
);
registry
.
addResourceHandler
(
"/webjars/**"
).
addResourceLocations
(
"classpath:/META-INF/resources/webjars/"
);
}
}
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/controller/AddMediaController.java
0 → 100644
View file @
fa5aeaee
package
com
.
yizhi
.
aliyun
.
application
.
controller
;
import
com.baomidou.mybatisplus.mapper.EntityWrapper
;
import
com.yizhi.aliyun.application.mapper.AddMediaResponseRecordMapper
;
import
com.yizhi.aliyun.application.service.DealMediaTranscode
;
import
com.yizhi.aliyun.application.vo.AddMediaResponseRecordVO
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.List
;
/**
* @ClassName AddMediaController
* @Description TODO
* @Author shengchenglong
* @DATE 2019-10-18 15:25
* @Version 1.0
*/
@RestController
@RequestMapping
(
"/ali/addMedia"
)
public
class
AddMediaController
{
@Autowired
private
DealMediaTranscode
dealMediaTranscode
;
@Autowired
private
AddMediaResponseRecordMapper
addMediaResponseRecordMapper
;
@GetMapping
(
"dealFinishedTranscoding"
)
public
boolean
dealFinishedTranscoding
()
{
AddMediaResponseRecordVO
responseRecord
=
new
AddMediaResponseRecordVO
();
responseRecord
.
setHasProcessed
(
0
);
List
<
AddMediaResponseRecordVO
>
records
=
addMediaResponseRecordMapper
.
selectList
(
new
EntityWrapper
<>(
responseRecord
));
if
(
CollectionUtils
.
isNotEmpty
(
records
))
{
try
{
records
.
forEach
(
r
->
dealMediaTranscode
.
dealFinishedTranscoding
(
r
));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
return
true
;
}
}
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/controller/ImageController.java
0 → 100644
View file @
fa5aeaee
package
com
.
yizhi
.
aliyun
.
application
.
controller
;
import
com.aliyun.oss.ClientException
;
import
com.aliyun.oss.HttpMethod
;
import
com.aliyun.oss.OSSClient
;
import
com.aliyun.oss.OSSException
;
import
com.aliyun.oss.model.GeneratePresignedUrlRequest
;
import
com.yizhi.aliyun.application.util.PropertiesUtil
;
import
com.yizhi.util.application.domain.Response
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiParam
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
java.net.URL
;
@RestController
@RequestMapping
(
value
=
"/image"
)
public
class
ImageController
{
@Autowired
PropertiesUtil
propertiesUtil
;
@ApiOperation
(
value
=
"图片自定义处理"
,
notes
=
"图片自定义处理"
,
response
=
Response
.
class
)
@RequestMapping
(
value
=
"/style"
,
method
=
RequestMethod
.
GET
)
public
Response
<
String
>
style
(
@ApiParam
(
name
=
"key"
,
value
=
"图片在oss存储路径"
,
required
=
true
)
@RequestParam
(
value
=
"key"
,
required
=
true
)
String
key
,
@ApiParam
(
name
=
"styleName"
,
value
=
"自定义样式名"
,
required
=
true
)
@RequestParam
(
value
=
"styleName"
,
required
=
true
)
String
styleName
)
{
String
endpoint
=
propertiesUtil
.
getPublicParam
().
get
(
"endpoint"
);
String
accessKeyId
=
propertiesUtil
.
getPublicParam
().
get
(
"accessKeyId"
);
String
accessKeySecret
=
propertiesUtil
.
getPublicParam
().
get
(
"accessKeySecret"
);
OSSClient
ossClient
=
new
OSSClient
(
endpoint
,
accessKeyId
,
accessKeySecret
);
String
bucketName
=
propertiesUtil
.
getPublicParam
().
get
(
"bucket"
);
try
{
// 图片处理样式
String
style
=
"style/"
+
styleName
;
// 过期时间10分钟
java
.
util
.
Date
expiration
=
new
java
.
util
.
Date
(
new
java
.
util
.
Date
().
getTime
()
+
1000
*
60
*
10
);
GeneratePresignedUrlRequest
req
=
new
GeneratePresignedUrlRequest
(
bucketName
,
key
,
HttpMethod
.
GET
);
req
.
setExpiration
(
expiration
);
req
.
setProcess
(
style
);
URL
signedUrl
=
ossClient
.
generatePresignedUrl
(
req
);
System
.
out
.
println
(
signedUrl
);
return
Response
.
ok
(
signedUrl
.
toString
());
}
catch
(
OSSException
oe
)
{
System
.
out
.
println
(
"Caught an OSSException, which means your request made it to OSS, "
+
"but was rejected with an error response for some reason."
);
System
.
out
.
println
(
"Error Message: "
+
oe
.
getErrorCode
());
System
.
out
.
println
(
"Error Code: "
+
oe
.
getErrorCode
());
System
.
out
.
println
(
"Request ID: "
+
oe
.
getRequestId
());
System
.
out
.
println
(
"Host ID: "
+
oe
.
getHostId
());
return
Response
.
fail
(
oe
.
getMessage
());
}
catch
(
ClientException
ce
)
{
System
.
out
.
println
(
"Caught an ClientException, which means the client encountered "
+
"a serious internal problem while trying to communicate with OSS, "
+
"such as not being able to access the network."
);
System
.
out
.
println
(
"Error Message: "
+
ce
.
getMessage
());
return
Response
.
fail
(
ce
.
getMessage
());
}
catch
(
Throwable
e
)
{
e
.
printStackTrace
();
return
Response
.
fail
(
e
.
getMessage
());
}
finally
{
ossClient
.
shutdown
();
}
}
}
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/controller/MSNController.java
0 → 100644
View file @
fa5aeaee
package
com
.
yizhi
.
aliyun
.
application
.
controller
;
import
com.yizhi.aliyun.application.vo.MNSVO
;
import
com.yizhi.application.orm.id.IdGenerator
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
/**
* @ClassName MSNController
* @Description TODO
* @Author shengchenglong
* @DATE 2019-10-18 11:44
* @Version 1.0
*/
@RestController
@RequestMapping
(
"/ali/mns/"
)
public
class
MSNController
{
@Autowired
private
IdGenerator
idGenerator
;
@PostMapping
(
"/insert"
)
public
boolean
insert
(
@RequestBody
MNSVO
record
)
{
if
(
record
.
getId
()
==
null
)
{
record
.
setId
(
idGenerator
.
generate
());
}
return
record
.
insert
();
}
}
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/controller/PolicyController.java
0 → 100644
View file @
fa5aeaee
package
com
.
yizhi
.
aliyun
.
application
.
controller
;
import
com.alibaba.fastjson.JSON
;
import
com.aliyun.oss.HttpMethod
;
import
com.aliyun.oss.OSSClient
;
import
com.aliyun.oss.common.utils.BinaryUtil
;
import
com.aliyun.oss.model.GeneratePresignedUrlRequest
;
import
com.aliyun.oss.model.MatchMode
;
import
com.aliyun.oss.model.PolicyConditions
;
import
com.yizhi.aliyun.application.util.AESCoder
;
import
com.yizhi.aliyun.application.util.PropertiesUtil
;
import
com.yizhi.util.application.domain.Response
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiParam
;
import
net.sf.json.JSONObject
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.net.URL
;
import
java.sql.Date
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
@RestController
@RequestMapping
(
value
=
"/upload"
)
public
class
PolicyController
{
@Value
(
"${ACTIVE}"
)
public
String
active
;
@Autowired
PropertiesUtil
propertiesUtil
;
@ApiOperation
(
value
=
"web端上传签名获得"
,
notes
=
"web端上传签名获得"
,
response
=
Response
.
class
)
@RequestMapping
(
value
=
"/policy"
,
method
=
RequestMethod
.
GET
)
public
Response
<
String
>
token
(
@RequestParam
(
name
=
"needTranscode"
,
required
=
false
)
Boolean
needTranscode
,
@RequestParam
(
name
=
"type"
,
required
=
false
,
defaultValue
=
"0"
)
Integer
type
)
{
String
endpoint
=
propertiesUtil
.
getPublicParam
().
get
(
"endpoint"
);
String
accessId
=
propertiesUtil
.
getPublicParam
().
get
(
"accessKeyId"
);
String
accessKey
=
propertiesUtil
.
getPublicParam
().
get
(
"accessKeySecret"
);
String
dir
=
propertiesUtil
.
getPublicParam
().
get
(
"ossdir"
);
String
bucket
=
null
;
if
(
needTranscode
==
null
||
!
needTranscode
)
{
bucket
=
propertiesUtil
.
getPublicParam
().
get
(
"bucket"
);
}
else
{
bucket
=
propertiesUtil
.
getPublicParam
().
get
(
"transcodeBucket"
);
switch
(
type
)
{
//作业本
case
0
:
dir
=
"exerciseBook"
;
break
;
//资料
case
1
:
dir
=
"document"
;
break
;
//案例
case
2
:
dir
=
"studentCase"
;
break
;
//论坛
case
3
:
dir
=
"forum"
;
break
;
}
}
String
host
=
"https://"
+
bucket
+
"."
+
endpoint
;
OSSClient
client
=
new
OSSClient
(
endpoint
,
accessId
,
accessKey
);
try
{
long
expireTime
=
60
*
24
;
long
expireEndTime
=
System
.
currentTimeMillis
()
+
expireTime
*
1000
;
Date
expiration
=
new
Date
(
expireEndTime
);
PolicyConditions
policyConds
=
new
PolicyConditions
();
policyConds
.
addConditionItem
(
PolicyConditions
.
COND_CONTENT_LENGTH_RANGE
,
0
,
10485760000L
);
policyConds
.
addConditionItem
(
MatchMode
.
StartWith
,
PolicyConditions
.
COND_KEY
,
dir
);
String
postPolicy
=
client
.
generatePostPolicy
(
expiration
,
policyConds
);
byte
[]
binaryData
=
postPolicy
.
getBytes
(
"utf-8"
);
String
encodedPolicy
=
BinaryUtil
.
toBase64String
(
binaryData
);
String
postSignature
=
client
.
calculatePostSignature
(
postPolicy
);
Map
<
String
,
String
>
respMap
=
new
LinkedHashMap
<
String
,
String
>();
respMap
.
put
(
"accessid"
,
accessId
);
respMap
.
put
(
"policy"
,
encodedPolicy
);
respMap
.
put
(
"signature"
,
postSignature
);
//respMap.put("expire", formatISO8601Date(expiration));
respMap
.
put
(
"dir"
,
dir
);
respMap
.
put
(
"host"
,
host
);
respMap
.
put
(
"expire"
,
String
.
valueOf
(
expireEndTime
/
1000
));
respMap
.
put
(
"active"
,
active
);
JSONObject
ja1
=
JSONObject
.
fromObject
(
respMap
);
System
.
out
.
println
(
ja1
.
toString
());
return
Response
.
ok
(
ja1
.
toString
());
}
catch
(
Exception
e
)
{
return
Response
.
fail
(
e
.
getMessage
());
}
finally
{
client
.
shutdown
();
}
}
@ApiOperation
(
value
=
"web端下载授权签名获得"
,
notes
=
"web端下载授权签名获得"
,
response
=
Response
.
class
)
@RequestMapping
(
value
=
"/download/url"
,
method
=
RequestMethod
.
GET
)
public
Response
<
String
>
download
(
@ApiParam
(
name
=
"key"
,
value
=
"文件在oss存储路径"
,
required
=
true
)
@RequestParam
(
value
=
"key"
,
required
=
true
)
String
key
)
{
String
endpoint
=
propertiesUtil
.
getPublicParam
().
get
(
"endpoint"
);
String
accessId
=
propertiesUtil
.
getPublicParam
().
get
(
"accessKeyId"
);
String
accessKey
=
propertiesUtil
.
getPublicParam
().
get
(
"accessKeySecret"
);
String
bucket
=
propertiesUtil
.
getPublicParam
().
get
(
"bucket"
);
OSSClient
Server
=
new
OSSClient
(
endpoint
,
accessId
,
accessKey
);
try
{
long
expireTime
=
30
;
long
expireEndTime
=
System
.
currentTimeMillis
()
+
expireTime
*
1000
;
Date
expiration
=
new
Date
(
expireEndTime
);
GeneratePresignedUrlRequest
request
=
new
GeneratePresignedUrlRequest
(
bucket
,
key
,
HttpMethod
.
GET
);
//设置过期时间
request
.
setExpiration
(
expiration
);
// 生成URL签名(HTTP GET请求)
URL
signedUrl
=
Server
.
generatePresignedUrl
(
request
);
return
Response
.
ok
(
signedUrl
.
toString
());
}
catch
(
Exception
e
)
{
return
Response
.
fail
(
e
.
getMessage
());
}
finally
{
Server
.
shutdown
();
}
}
@ApiOperation
(
value
=
"AES加密字符串获得"
,
notes
=
"AES加密字符串获得"
,
response
=
Response
.
class
)
@RequestMapping
(
value
=
"/getAesKey"
,
method
=
RequestMethod
.
GET
)
public
Response
<
String
>
getAesKey
()
{
Map
<
String
,
String
>
map
=
propertiesUtil
.
getPublicParam
();
String
content
=
JSON
.
toJSONString
(
map
);
String
enString
=
""
;
try
{
enString
=
AESCoder
.
Encrypt
(
content
,
AESCoder
.
KEY
);
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
e
.
getLocalizedMessage
());
}
return
Response
.
ok
(
enString
);
}
}
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/controller/VideoController.java
0 → 100644
View file @
fa5aeaee
package
com
.
yizhi
.
aliyun
.
application
.
controller
;
import
com.alibaba.fastjson.JSONObject
;
import
com.yizhi.aliyun.application.service.UploadVideoApi
;
import
com.yizhi.aliyun.application.service.VideoInfoApi
;
import
com.yizhi.aliyun.application.domain.*
;
import
com.yizhi.aliyun.application.vo.UploadParamVo
;
import
com.yizhi.util.application.domain.Response
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiParam
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.HashMap
;
import
java.util.Map
;
@RestController
@RequestMapping
(
value
=
"/video"
)
public
class
VideoController
{
@Autowired
private
UploadVideoApi
uploadVideoApi
;
@Autowired
private
VideoInfoApi
videoInfoApi
;
@ApiOperation
(
value
=
"视频上传"
,
notes
=
"视频上传"
,
response
=
Response
.
class
)
@RequestMapping
(
value
=
"/upload"
,
method
=
RequestMethod
.
POST
)
public
Response
<
String
>
upload
(
@RequestBody
UploadParamVo
uploadParamVo
// @ApiParam(name = "fileType", value = "上传文件类型 1为本地视频,2位网络url视频", required = true) @RequestParam(value = "fileType", required = true) String fileType,
// @ApiParam(name = "title", value = "视频标题", required = true) @RequestParam(value = "title", required = true) String title,
// @ApiParam(name = "fileName", value = "1.本地文件上传时,文件名称为上传文件绝对路径,如:/User/sample/文件名称.mp4 (必选) " +
// "2.网络流上传时,文件名称为源文件名,如文件名称.mp4(必选)。任何上传方式文件名必须包含扩展名", required = true) @RequestParam(value = "fileName", required = true) String fileName,
// @ApiParam(name = "url", value = "当文件类型为2的时候必填,网络文件url", required = false) @RequestParam(value = "url", required = false) String url,
// @ApiParam(name = "description", value = "视频描述", required = false) @RequestParam(value = "description", required = false) String description,
// @ApiParam(name = "cateId", value = "视频分类ID,数字Integer类型", required = false) @RequestParam(value = "cateId", required = false) Integer cateId,
// @ApiParam(name = "tags", value = "视频标签,多个用逗号分隔", required = false) @RequestParam(value = "tags", required = false) String tags,
// @ApiParam(name = "coverURL", value = "封面图片(可选),网络url", required = false) @RequestParam(value = "coverURL", required = false) String coverURL,
// @ApiParam(name = "isShowWaterMark", value = "是否使用默认水印,布尔型0/1", required = false) @RequestParam(value = "isShowWaterMark", required = false) Boolean isShowWaterMark
)
{
String
result
=
""
;
if
(
"1"
.
equals
(
uploadParamVo
.
getFileType
()))
{
UploadVideoVo
uploadVideoVo
=
new
UploadVideoVo
();
uploadVideoVo
.
setTitle
(
uploadParamVo
.
getTitle
());
uploadVideoVo
.
setFileName
(
uploadParamVo
.
getFileName
());
if
(
uploadParamVo
.
getDescription
()!=
null
)
{
uploadVideoVo
.
setDescription
(
uploadParamVo
.
getDescription
());
}
if
(
uploadParamVo
.
getCateId
()
!=
null
)
{
uploadVideoVo
.
setCateId
(
uploadParamVo
.
getCateId
());
}
if
(
uploadParamVo
.
getTags
()
!=
null
)
{
uploadVideoVo
.
setTags
(
uploadParamVo
.
getTags
());
}
if
(
uploadParamVo
.
getCoverURL
()
!=
null
)
{
uploadVideoVo
.
setCoverURL
(
uploadParamVo
.
getCoverURL
());
}
if
(
uploadParamVo
.
getIsShowWaterMark
()
!=
null
)
{
uploadVideoVo
.
setShowWaterMark
(
uploadParamVo
.
getIsShowWaterMark
());
}
result
=
uploadVideoApi
.
UploadVideoLocal
(
uploadVideoVo
);
}
else
if
(
"2"
.
equals
(
uploadParamVo
.
getFileType
()))
{
UploadVideoURLStreamVo
uploadVideoURLStreamVo
=
new
UploadVideoURLStreamVo
();
uploadVideoURLStreamVo
.
setTitle
(
uploadParamVo
.
getTitle
());
uploadVideoURLStreamVo
.
setFileName
(
uploadParamVo
.
getFileName
());
if
(
uploadParamVo
.
getUrl
()
!=
null
)
{
uploadVideoURLStreamVo
.
setURL
(
uploadParamVo
.
getUrl
());
}
else
{
return
Response
.
fail
(
"fileType为2的情况下url不能为空!"
);
}
if
(
uploadParamVo
.
getDescription
()
!=
null
)
{
uploadVideoURLStreamVo
.
setDescription
(
uploadParamVo
.
getDescription
());
}
if
(
uploadParamVo
.
getCateId
()
!=
null
)
{
uploadVideoURLStreamVo
.
setCateId
(
uploadParamVo
.
getCateId
());
}
if
(
uploadParamVo
.
getTags
()
!=
null
)
{
uploadVideoURLStreamVo
.
setTags
(
uploadParamVo
.
getTags
());
}
if
(
uploadParamVo
.
getCoverURL
()
!=
null
)
{
uploadVideoURLStreamVo
.
setCoverURL
(
uploadParamVo
.
getCoverURL
());
}
if
(
uploadParamVo
.
getIsShowWaterMark
()
!=
null
)
{
uploadVideoURLStreamVo
.
setShowWaterMark
(
uploadParamVo
.
getIsShowWaterMark
());
}
result
=
uploadVideoApi
.
uploadURLStream
(
uploadVideoURLStreamVo
);
}
return
Response
.
ok
(
result
);
}
@ApiOperation
(
value
=
"获取视频信息"
,
notes
=
"获取视频信息"
,
response
=
Response
.
class
)
@RequestMapping
(
value
=
"/info"
,
method
=
RequestMethod
.
GET
)
public
Response
<
String
>
info
(
@ApiParam
(
name
=
"videoId"
,
value
=
"视频id"
,
required
=
true
)
@RequestParam
(
"videoId"
)
String
videoId
)
{
return
Response
.
ok
(
videoInfoApi
.
getVideoInfo
(
videoId
));
}
@ApiOperation
(
value
=
"删除视频"
,
notes
=
"删除视频"
,
response
=
Response
.
class
)
@RequestMapping
(
value
=
"/delete"
,
method
=
RequestMethod
.
POST
)
public
Response
<
String
>
delete
(
@ApiParam
(
name
=
"videoIds"
,
value
=
"视频ID列表,多个用逗号分隔,最多支持10个"
,
required
=
true
)
@RequestParam
(
"videoIds"
)
String
videoIds
)
{
return
Response
.
ok
(
videoInfoApi
.
deleteVideo
(
videoIds
));
}
@ApiOperation
(
value
=
"修改视频信息"
,
notes
=
"修改视频信息"
,
response
=
Response
.
class
)
@RequestMapping
(
value
=
"/update"
,
method
=
RequestMethod
.
POST
)
public
Response
<
String
>
update
(
@ApiParam
(
name
=
"videoId"
,
value
=
"视频ID"
,
required
=
true
)
@RequestParam
(
"videoId"
)
String
videoId
,
@ApiParam
(
name
=
"title"
,
value
=
"视频标题,长度不超过128个字节,UTF8编码"
,
required
=
false
)
@RequestParam
(
value
=
"title"
,
required
=
false
)
String
title
,
@ApiParam
(
name
=
"description"
,
value
=
"视频描述,长度不超过1024个字节,UTF8编码"
,
required
=
false
)
@RequestParam
(
value
=
"description"
,
required
=
false
)
String
description
,
@ApiParam
(
name
=
"coverURL"
,
value
=
"视频封面URL地址"
,
required
=
false
)
@RequestParam
(
value
=
"coverURL"
,
required
=
false
)
String
coverURL
,
@ApiParam
(
name
=
"cateId"
,
value
=
"视频分类ID"
,
required
=
false
)
@RequestParam
(
value
=
"cateId"
,
required
=
false
)
String
cateId
,
@ApiParam
(
name
=
"tags"
,
value
=
"标签"
,
required
=
false
)
@RequestParam
(
value
=
"tags"
,
required
=
false
)
String
tags
)
{
UpdateVideoInfoRequest
updateVideoInfoRequest
=
new
UpdateVideoInfoRequest
();
updateVideoInfoRequest
.
setVideoId
(
videoId
);
if
(
title
!=
null
)
{
updateVideoInfoRequest
.
setTitle
(
title
);
}
if
(
description
!=
null
)
{
updateVideoInfoRequest
.
setDescription
(
description
);
}
if
(
coverURL
!=
null
)
{
updateVideoInfoRequest
.
setCoverURL
(
coverURL
);
}
if
(
cateId
!=
null
)
{
updateVideoInfoRequest
.
setCateId
(
cateId
);
}
if
(
tags
!=
null
)
{
updateVideoInfoRequest
.
setTags
(
tags
);
}
return
Response
.
ok
(
videoInfoApi
.
updateVideoInfo
(
updateVideoInfoRequest
));
}
@ApiOperation
(
value
=
"获取视频列表"
,
notes
=
"获取视频列表"
,
response
=
Response
.
class
)
@GetMapping
(
value
=
"/list"
)
public
Response
<
String
>
list
(
@ApiParam
(
name
=
"status"
,
value
=
"视频状态,默认获取所有视频,多个可以用逗号分隔,如:Uploading,Normal,"
+
"取值包括:Uploading(上传中),UploadSucc(上传完成),Transcoding(转码中),TranscodeFail(转码失败),Checking(审核中), "
+
"Blocked(屏蔽),Normal(正常)"
,
required
=
false
)
@RequestParam
(
value
=
"status"
,
required
=
false
)
String
status
,
@ApiParam
(
name
=
"startTime"
,
value
=
"视CreationTime(创建时间)的开始时间,为开区间(大于开始时间)。"
+
"日期格式按照ISO8601标准表示,并需要使用UTC时间。格式为:YYYY-MM-DDThh:mm:ssZ "
+
"例如,2017-01-11T12:00:00Z(为北京时间2017年1月11日20点0分0秒)"
,
required
=
false
)
@RequestParam
(
value
=
"startTime"
,
required
=
false
)
String
startTime
,
@ApiParam
(
name
=
"endTime"
,
value
=
"CreationTime的结束时间,为闭区间(小于等于结束时间)。"
+
"日期格式按照ISO8601标准表示,并需要使用UTC时间。格式为:YYYY-MM-DDThh:mm:ssZ "
+
"例如,2017-01-11T12:00:00Z(为北京时间2017年1月11日20点0分0秒)"
,
required
=
false
)
@RequestParam
(
value
=
"endTime"
,
required
=
false
)
String
endTime
,
@ApiParam
(
name
=
"cateId"
,
value
=
"视频分类ID"
,
required
=
false
)
@RequestParam
(
value
=
"cateId"
,
required
=
false
)
String
cateId
,
@ApiParam
(
name
=
"pageNo"
,
value
=
"页号,默认1"
,
required
=
false
)
@RequestParam
(
value
=
"pageNo"
,
required
=
false
)
Long
pageNo
,
@ApiParam
(
name
=
"pageSize"
,
value
=
"默认10,最大不超过100"
,
required
=
false
)
@RequestParam
(
value
=
"pageSize"
,
required
=
false
)
Long
pageSize
,
@ApiParam
(
name
=
"sortBy"
,
value
=
"结果排序,范围:CreationTime:Desc、CreationTime:Asc,默认为CreationTime:Desc(即按创建时间倒序)"
,
required
=
false
)
@RequestParam
(
value
=
"sortBy"
,
required
=
false
)
String
sortBy
)
{
GetVideoListRequest
getVideoListRequest
=
new
GetVideoListRequest
();
if
(
status
!=
null
)
{
getVideoListRequest
.
setStatus
(
status
);
}
if
(
startTime
!=
null
)
{
getVideoListRequest
.
setStartTime
(
startTime
);
}
if
(
endTime
!=
null
)
{
getVideoListRequest
.
setEndTime
(
endTime
);
}
if
(
cateId
!=
null
)
{
getVideoListRequest
.
setCateId
(
cateId
);
}
if
(
pageNo
!=
null
)
{
getVideoListRequest
.
setPageNo
(
pageNo
);
}
if
(
pageSize
!=
null
)
{
getVideoListRequest
.
setPageSize
(
pageSize
);
}
if
(
sortBy
!=
null
)
{
getVideoListRequest
.
setSortBy
(
sortBy
);
}
return
Response
.
ok
(
videoInfoApi
.
getVideoList
(
getVideoListRequest
));
}
@ApiOperation
(
value
=
"获取视频播放地址"
,
notes
=
"获取视频播放地址"
,
response
=
Response
.
class
)
@RequestMapping
(
value
=
"/play"
,
method
=
RequestMethod
.
GET
)
public
Response
<
String
>
play
(
@ApiParam
(
name
=
"videoId"
,
value
=
"视频ID"
,
required
=
true
)
@RequestParam
(
"videoId"
)
String
videoId
,
@ApiParam
(
name
=
"formats"
,
value
=
"视频流格式,多个用逗号分隔,支持格式mp4,m3u8,mp3,默认获取所有格式的流"
,
required
=
false
)
@RequestParam
(
value
=
"formats"
,
required
=
false
)
String
formats
,
@ApiParam
(
name
=
"authTimeout"
,
value
=
"播放地址过期时间,默认为3600秒,"
+
"支持设置最小值为3600秒(当指定时间小于3600秒时,设置为默认3600秒)。"
+
"只有开启了URL鉴权才会生效"
,
required
=
false
)
@RequestParam
(
value
=
"authTimeout"
,
required
=
false
)
String
authTimeout
,
@ApiParam
(
name
=
"streamType"
,
value
=
"视频流类型,多个用逗号分隔,支持类型video,audio,默认获取所有类型的流"
,
required
=
false
)
@RequestParam
(
value
=
"streamType"
,
required
=
false
)
String
streamType
,
@ApiParam
(
name
=
"definition"
,
value
=
"视频流清晰度,多个用逗号分隔,取值FD(流畅),LD(标清),"
+
"SD(高清),HD(超清),OD(原画),2K(2K),4K(4K),默认获取所有清晰度的流"
,
required
=
false
)
@RequestParam
(
value
=
"definition"
,
required
=
false
)
String
definition
)
{
GetPlayInfoRequest
getPlayInfoRequest
=
new
GetPlayInfoRequest
();
getPlayInfoRequest
.
setVideoId
(
videoId
);
if
(
formats
!=
null
)
{
getPlayInfoRequest
.
setFormats
(
formats
);
}
if
(
authTimeout
!=
null
)
{
getPlayInfoRequest
.
setAuthTimeout
(
authTimeout
);
}
if
(
streamType
!=
null
)
{
getPlayInfoRequest
.
setStreamType
(
streamType
);
}
if
(
definition
!=
null
)
{
getPlayInfoRequest
.
setDefinition
(
definition
);
}
String
result
=
videoInfoApi
.
GetPlayInfo
(
getPlayInfoRequest
);
JSONObject
jsStr
=
JSONObject
.
parseObject
(
result
);
return
Response
.
ok
(
jsStr
);
}
@ApiOperation
(
value
=
"取视频上传凭证和地址"
,
notes
=
"取视频上传凭证和地址"
,
response
=
Response
.
class
)
@RequestMapping
(
value
=
"/uploadAuth"
,
method
=
RequestMethod
.
GET
)
public
Response
<
String
>
uploadAuth
(
@ApiParam
(
name
=
"fileName"
,
value
=
"视频源文件名称"
,
required
=
true
)
@RequestParam
(
"fileName"
)
String
fileName
,
@ApiParam
(
name
=
"title"
,
value
=
"视频标题"
,
required
=
true
)
@RequestParam
(
value
=
"title"
,
required
=
true
)
String
title
,
@ApiParam
(
name
=
"cateId"
,
value
=
"分类ID"
,
required
=
false
)
@RequestParam
(
value
=
"cateId"
,
required
=
false
)
String
cateId
,
@ApiParam
(
name
=
"tags"
,
value
=
"视频标签,多个用逗号分隔"
,
required
=
false
)
@RequestParam
(
value
=
"tags"
,
required
=
false
)
String
tags
,
@ApiParam
(
name
=
"description"
,
value
=
"视频描述"
,
required
=
false
)
@RequestParam
(
value
=
"description"
,
required
=
false
)
String
description
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
map
.
put
(
"fileName"
,
fileName
);
map
.
put
(
"title"
,
title
);
if
(
cateId
!=
null
){
map
.
put
(
"cateId"
,
cateId
);}
if
(
cateId
!=
null
){
map
.
put
(
"cateId"
,
cateId
);}
if
(
tags
!=
null
){
map
.
put
(
"tags"
,
tags
);}
if
(
description
!=
null
){
map
.
put
(
"description"
,
description
);}
return
Response
.
ok
(
uploadVideoApi
.
createUploadVideo
(
map
));
}
@ApiOperation
(
value
=
"刷新视频上传凭证"
,
notes
=
"刷新视频上传凭证"
,
response
=
Response
.
class
)
@RequestMapping
(
value
=
"/refresh"
,
method
=
RequestMethod
.
GET
)
public
Response
<
String
>
refresh
(
@ApiParam
(
name
=
"videoId"
,
value
=
"视频上传凭证"
,
required
=
true
)
@RequestParam
(
"videoId"
)
String
videoId
)
{
return
Response
.
ok
(
uploadVideoApi
.
refreshUploadVideo
(
videoId
));
}
}
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/controller/VideoFeignController.java
0 → 100644
View file @
fa5aeaee
/**
* FileName: VideoFeignController
* Author: wenjunlong
* Date: 2018/6/6 13:38
* Description: 提供给其他微服务调用
* History:
* <author> <time> <version> <desc>
* 作者姓名 修改时间 版本号 描述
*/
package
com
.
yizhi
.
aliyun
.
application
.
controller
;
import
com.yizhi.aliyun.application.domain.GetPlayInfoRequest
;
import
com.yizhi.aliyun.application.domain.UploadVideoURLStreamVo
;
import
com.yizhi.aliyun.application.service.UploadVideoApi
;
import
com.yizhi.aliyun.application.service.VideoInfoApi
;
import
com.yizhi.aliyun.application.vo.UploadParamVo
;
import
com.yizhi.util.application.domain.Response
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiParam
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
java.io.UnsupportedEncodingException
;
import
java.net.MalformedURLException
;
/**
* 〈一句话功能简述〉<br>
* 〈提供给其他微服务调用〉
*
* @author wenjunlong
* @create 2018/6/6
* @since 1.0.0
*/
@RestController
@RequestMapping
(
value
=
"/video"
)
public
class
VideoFeignController
{
@Autowired
private
UploadVideoApi
uploadVideoApi
;
@Autowired
private
VideoInfoApi
videoInfoApi
;
@ApiOperation
(
value
=
"视频上传"
,
notes
=
"视频上传"
,
response
=
Response
.
class
)
@RequestMapping
(
value
=
"/urlUpload"
,
method
=
RequestMethod
.
POST
)
public
String
upload
(
@RequestBody
UploadParamVo
uploadParamVo
)
{
UploadVideoURLStreamVo
uploadVideoURLStreamVo
=
new
UploadVideoURLStreamVo
();
uploadVideoURLStreamVo
.
setTitle
(
uploadParamVo
.
getTitle
());
uploadVideoURLStreamVo
.
setFileName
(
uploadParamVo
.
getFileName
());
uploadVideoURLStreamVo
.
setURL
(
uploadParamVo
.
getUrl
());
if
(
uploadParamVo
.
getDescription
()
!=
null
)
{
uploadVideoURLStreamVo
.
setDescription
(
uploadParamVo
.
getDescription
());
}
if
(
uploadParamVo
.
getCateId
()
!=
null
)
{
uploadVideoURLStreamVo
.
setCateId
(
uploadParamVo
.
getCateId
());
}
if
(
uploadParamVo
.
getTags
()
!=
null
)
{
uploadVideoURLStreamVo
.
setTags
(
uploadParamVo
.
getTags
());
}
if
(
uploadParamVo
.
getCoverURL
()
!=
null
)
{
uploadVideoURLStreamVo
.
setCoverURL
(
uploadParamVo
.
getCoverURL
());
}
if
(
uploadParamVo
.
getIsShowWaterMark
()
!=
null
)
{
uploadVideoURLStreamVo
.
setShowWaterMark
(
uploadParamVo
.
getIsShowWaterMark
());
}
String
result
=
uploadVideoApi
.
uploadURLStream
(
uploadVideoURLStreamVo
);
return
result
;
}
@ApiOperation
(
value
=
"获取视频播放地址"
,
notes
=
"获取视频播放地址"
,
response
=
Response
.
class
)
@RequestMapping
(
value
=
"/movieurls"
,
method
=
RequestMethod
.
GET
)
public
String
movieurls
(
@ApiParam
(
name
=
"videoId"
,
value
=
"视频ID"
,
required
=
true
)
@RequestParam
(
"videoId"
)
String
videoId
)
{
GetPlayInfoRequest
getPlayInfoRequest
=
new
GetPlayInfoRequest
();
getPlayInfoRequest
.
setVideoId
(
videoId
);
String
result
=
videoInfoApi
.
GetPlayInfo
(
getPlayInfoRequest
);
return
result
;
}
/**
* 获取文件的下载路径
* @param sourceUrl oss的预览地址
* @return
*/
@GetMapping
(
"/change/download"
)
public
String
downloadObjectHeader
(
@RequestParam
(
"sourceUrl"
)
String
sourceUrl
){
try
{
return
uploadVideoApi
.
downloadObjectHeader
(
sourceUrl
);
}
catch
(
UnsupportedEncodingException
e
)
{
e
.
printStackTrace
();
}
catch
(
MalformedURLException
e
)
{
e
.
printStackTrace
();
}
return
""
;
}
}
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/demo/AddMedia.java
0 → 100644
View file @
fa5aeaee
package
com
.
yizhi
.
aliyun
.
application
.
demo
;
import
com.alibaba.fastjson.JSONObject
;
import
com.aliyun.mns.client.CloudAccount
;
import
com.aliyuncs.DefaultAcsClient
;
import
com.aliyuncs.exceptions.ClientException
;
import
com.aliyuncs.exceptions.ServerException
;
import
com.aliyuncs.mts.model.v20140618.AddMediaRequest
;
import
com.aliyuncs.mts.model.v20140618.AddMediaResponse
;
import
com.aliyuncs.profile.DefaultProfile
;
import
org.apache.commons.lang.exception.ExceptionUtils
;
public
class
AddMedia
{
//Step 1 .set region:cn-hangzhou、cn-shenzhen、cn-shanghai、cn-beijing
private
static
final
String
REGION
=
"cn-shanghai"
;
private
static
final
String
mtsEndpoint
=
"mts."
+
REGION
+
".aliyuncs.com"
;
private
static
final
String
mnsEndPoint
=
"http://1955327038947993.mns.cn-shanghai.aliyuncs.com/"
;
//Step 2.set accesskey & keySecret
private
static
String
accessKeyId
=
"LTAIeBliOjnD6v25"
;
private
static
String
accessKeySecret
=
"qd6iAV7tUvumvEiXxv9IGJbSdHcnmH"
;
private
static
DefaultAcsClient
aliyunClient
;
private
static
CloudAccount
account
;
private
static
String
mediaWorkflowQueueName
=
"hua"
;
static
{
account
=
new
CloudAccount
(
accessKeyId
,
accessKeySecret
,
mnsEndPoint
);
try
{
DefaultProfile
.
addEndpoint
(
REGION
,
REGION
,
"Mts"
,
mtsEndpoint
);
}
catch
(
ClientException
e
)
{
System
.
out
.
print
(
ExceptionUtils
.
getStackTrace
(
e
));
System
.
exit
(
1
);
}
aliyunClient
=
new
DefaultAcsClient
(
DefaultProfile
.
getProfile
(
REGION
,
accessKeyId
,
accessKeySecret
));
}
public
static
void
main
(
String
[]
args
)
throws
ClientException
{
AddMediaRequest
request
=
new
AddMediaRequest
();
request
.
setFileURL
(
"http://wmy-transcoding-origin.oss-cn-shanghai.aliyuncs.com/123456.mp4"
);
request
.
setMediaWorkflowId
(
"322c16126e934d1aadfb211a10730a74"
);
try
{
AddMediaResponse
response
=
aliyunClient
.
getAcsResponse
(
request
);
System
.
out
.
println
(
JSONObject
.
toJSONString
(
response
));
}
catch
(
ServerException
e
)
{
System
.
out
.
println
(
"Code:"
+
e
.
getErrCode
()
+
" Msg:"
+
e
.
getMessage
());
}
catch
(
ClientException
e
)
{
System
.
out
.
println
(
"Code:"
+
e
.
getErrCode
()
+
" Msg:"
+
e
.
getMessage
());
}
}
}
\ No newline at end of file
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/demo/Main.java
0 → 100644
View file @
fa5aeaee
package
com
.
yizhi
.
aliyun
.
application
.
demo
;
import
com.alibaba.fastjson.JSONObject
;
import
com.aliyun.mns.client.CloudAccount
;
import
com.aliyun.mns.client.CloudQueue
;
import
com.aliyun.mns.client.MNSClient
;
import
com.aliyun.mns.model.Message
;
import
com.aliyun.oss.OSSClient
;
import
com.aliyun.oss.model.ObjectMetadata
;
import
com.aliyuncs.DefaultAcsClient
;
import
com.aliyuncs.exceptions.ClientException
;
import
com.aliyuncs.exceptions.ServerException
;
import
com.aliyuncs.mts.model.v20140618.QueryMediaListRequest
;
import
com.aliyuncs.mts.model.v20140618.QueryMediaListResponse
;
import
com.aliyuncs.profile.DefaultProfile
;
import
com.yizhi.aliyun.application.domain.*
;
import
org.apache.commons.lang.exception.ExceptionUtils
;
import
java.io.*
;
import
java.net.URLDecoder
;
import
java.net.URLEncoder
;
import
java.util.List
;
import
java.util.UUID
;
public
class
Main
{
//步骤1.请填写你所需访问的Region:cn-hangzhou、cn-shenzhen、cn-shanghai、cn-beijing
private
static
final
String
REGION
=
"cn-shanghai"
;
private
static
final
String
ossEndPoint
=
"http://oss-"
+
REGION
+
".aliyuncs.com"
;
//步骤2.从阿里云消息服务的控制台对应区域Copy MNSEndPoint
//MNS控制台链接:https://mns.console.aliyun.com
private
static
final
String
mnsEndPoint
=
"http://1955327038947993.mns.cn-shanghai.aliyuncs.com/"
;
private
static
final
String
mtsEndpoint
=
"mts."
+
REGION
+
".aliyuncs.com"
;
private
static
String
testVideoFilePath
=
"videos/test-中文.mp4"
;
//步骤3.填写您的AK,确保此AK具有访问MTS的权限(即已经开通MTS)
private
static
String
accessKeyId
=
"LTAIeBliOjnD6v25"
;
private
static
String
accessKeySecret
=
"qd6iAV7tUvumvEiXxv9IGJbSdHcnmH"
;
//步骤4.填写您的媒体工作流输入Bbucket,务必与创建媒体工作流时设置的保持一致
private
static
String
mediaWorkflowInputBucket
=
"wmy-transcoding-origin"
;
//步骤5.填写媒体工作流处理视频完成时消息发送队列,务必与创建媒体工作流时设置的保持的一致
private
static
String
mediaWorkflowQueueName
=
"wmy-transcoding"
;
private
static
CloudAccount
account
;
private
static
CloudQueue
queue
;
private
static
DefaultAcsClient
aliyunClient
;
//调用MTS API的Client
static
{
account
=
new
CloudAccount
(
accessKeyId
,
accessKeySecret
,
mnsEndPoint
);
MNSClient
mnsClient
=
account
.
getMNSClient
();
queue
=
mnsClient
.
getQueueRef
(
mediaWorkflowQueueName
);
try
{
DefaultProfile
.
addEndpoint
(
REGION
,
REGION
,
"Mts"
,
mtsEndpoint
);
}
catch
(
ClientException
e
)
{
System
.
out
.
print
(
ExceptionUtils
.
getStackTrace
(
e
));
System
.
exit
(
1
);
}
aliyunClient
=
new
DefaultAcsClient
(
DefaultProfile
.
getProfile
(
REGION
,
accessKeyId
,
accessKeySecret
));
}
public
static
void
main
(
String
[]
args
)
throws
ClientException
{
//步骤6.上传视频到媒体工作流处理Bucket,媒体工作流将自动启动处理此视频
//进入MTS控制台:https://mts.console.aliyun.com/
//进入媒体库设置->工作流,务必确保媒体工作流处于启动状态,否则媒体工作流不会处理此视频
// AddMediaRequest request = new AddMediaRequest();
// request.setFileURL("http://wmy-transcoding-origin.oss-cn-shanghai.aliyuncs.com/mp4MultibitrateIn7c96a8ccd2c16a600139d4487fc6b222/mpg1m.mpg");
// request.setMediaWorkflowId("322c16126e934d1aadfb211a10730a74");
//步骤7.等待媒体工作流消息回调汇报转码完成,
while
(
true
)
{
List
<
Message
>
messageList
=
queue
.
batchPopMessage
(
16
,
30
);
if
(
null
==
messageList
||
messageList
.
isEmpty
())
{
try
{
Thread
.
sleep
(
20
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
continue
;
}
for
(
Message
message
:
messageList
)
{
handlingMessage
(
message
);
}
}
}
private
static
void
handlingMessage
(
Message
message
)
{
String
messageBody
=
message
.
getMessageBody
();
ActivityDTO
activityDTO
=
JSONObject
.
parseObject
(
messageBody
,
ActivityDTO
.
class
);
if
(
activityDTO
.
getType
().
equals
(
ActivityType
.
Start
.
name
()))
{
//若工作流启动消息不希望处理,则直接删除
queue
.
deleteMessage
(
message
.
getReceiptHandle
());
}
else
if
(
activityDTO
.
getType
().
equals
(
ActivityType
.
Report
.
name
()))
{
//System.out.print(JSONObject.toJSONString(activityDTO));
//获取媒体工作流执行信息
MediaWorkflowExecutionDTO
mediaWorkflowExecutionDTO
=
activityDTO
.
getMediaWorkflowExecutionDTO
();
//从媒体工作流中取活动列表
List
<
ActivityDTO
>
activityDTOS
=
mediaWorkflowExecutionDTO
.
getActivities
();
//遍历活动列表,判断转码是否成功
if
(
null
!=
activityDTOS
)
{
for
(
ActivityDTO
activity
:
activityDTOS
)
{
if
(
activity
.
getType
().
equals
(
ActivityType
.
Transcode
.
name
()))
{
if
(
activity
.
getState
().
equals
(
ActivityState
.
Success
.
name
()))
{
// System.out.println("transcode activity:" + activity.getName() + " is success!");
}
}
}
}
//获取转码输出地址(OSS地址)
QueryMediaListRequest
request
=
new
QueryMediaListRequest
();
request
.
setMediaIds
(
mediaWorkflowExecutionDTO
.
getMediaId
());
request
.
setIncludePlayList
(
true
);
try
{
QueryMediaListResponse
response
=
aliyunClient
.
getAcsResponse
(
request
);
List
<
QueryMediaListResponse
.
Media
>
list
=
response
.
getMediaList
();
QueryMediaListResponse
.
Media
media
=
list
.
get
(
0
);
if
(
media
.
getPublishState
().
equals
(
MediaState
.
Published
.
name
()))
{
List
<
QueryMediaListResponse
.
Media
.
Play
>
playList
=
media
.
getPlayList
();
if
(
null
!=
playList
)
{
for
(
QueryMediaListResponse
.
Media
.
Play
play
:
playList
)
{
//遍历转码输出地址
System
.
out
.
println
(
play
.
getFile1
().
getURL
());
}
}
}
}
catch
(
ServerException
e
)
{
System
.
out
.
print
(
ExceptionUtils
.
getStackTrace
(
e
));
System
.
exit
(
1
);
}
catch
(
ClientException
e
)
{
System
.
out
.
print
(
ExceptionUtils
.
getStackTrace
(
e
));
System
.
exit
(
1
);
}
//如果是report消息,需要从队列中删除,否则会一直在队列中
queue
.
deleteMessage
(
message
.
getReceiptHandle
());
}
}
private
static
FileDTO
uploadVideoFileToMediaWOrkflowInputBucket
(
String
mediaWorkflowInputBucket
)
{
return
uploadLocalFile
(
mediaWorkflowInputBucket
,
"demo/video/"
+
UUID
.
randomUUID
().
toString
()
+
"-中文.mp4"
,
testVideoFilePath
);
}
public
static
FileDTO
uploadLocalFile
(
String
bucket
,
String
object
,
String
filePath
)
{
OSSClient
client
=
new
OSSClient
(
ossEndPoint
,
accessKeyId
,
accessKeySecret
);
try
{
String
utf8FilePath
=
URLDecoder
.
decode
(
ClassLoader
.
getSystemClassLoader
().
getResource
(
filePath
).
getPath
(),
"utf-8"
);
File
file
=
new
File
(
utf8FilePath
);
InputStream
content
=
new
FileInputStream
(
file
);
ObjectMetadata
meta
=
new
ObjectMetadata
();
meta
.
setContentLength
(
file
.
length
());
client
.
putObject
(
bucket
,
object
,
content
,
meta
);
String
encodedObjectName
=
URLEncoder
.
encode
(
object
,
"utf-8"
);
return
new
FileDTO
(
client
.
getBucketLocation
(
bucket
),
bucket
,
encodedObjectName
);
}
catch
(
FileNotFoundException
e
)
{
throw
new
RuntimeException
(
"fail@uploadLocalFile FileInputStream"
);
}
catch
(
UnsupportedEncodingException
e
)
{
throw
new
RuntimeException
(
"fail@uploadLocalFile URLEncoder"
);
}
}
}
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/demo/SimpleTranscode.java
0 → 100644
View file @
fa5aeaee
package
com
.
yizhi
.
aliyun
.
application
.
demo
;
import
com.alibaba.fastjson.JSONObject
;
import
com.aliyuncs.DefaultAcsClient
;
import
com.aliyuncs.exceptions.ClientException
;
import
com.aliyuncs.mts.model.v20140618.QueryMediaListByURLRequest
;
import
com.aliyuncs.mts.model.v20140618.QueryMediaListByURLResponse
;
import
com.aliyuncs.profile.DefaultProfile
;
import
java.io.UnsupportedEncodingException
;
import
java.net.URLEncoder
;
public
class
SimpleTranscode
{
private
static
String
accessKeyId
=
"LTAIeBliOjnD6v25"
;
private
static
String
accessKeySecret
=
"qd6iAV7tUvumvEiXxv9IGJbSdHcnmH"
;
private
static
String
mpsRegionId
=
"cn-shanghai"
;
private
static
String
pipelineId
=
"e5545cec7d754001ac8df3eb991b2944"
;
private
static
String
templateId
=
"0ab46dbcb176406aa585eee7eace8237test"
;
private
static
String
ossLocation
=
"oss-cn-shanghai"
;
private
static
String
ossBucket
=
"wmy-transcoding-origin"
;
private
static
String
ossInputObject
=
"input.mp4"
;
private
static
String
ossOutputObject
=
"output.mp4"
;
public
static
void
main
(
String
[]
args
)
throws
UnsupportedEncodingException
{
// // 创建DefaultAcsClient实例并初始化
// DefaultProfile profile = DefaultProfile.getProfile(
// mpsRegionId, // 地域ID
// accessKeyId, // RAM账号的AccessKey ID
// accessKeySecret); // RAM账号Access Key Secret
// IAcsClient client = new DefaultAcsClient(profile);
// // 创建API请求并设置参数
// SubmitJobsRequest request = new SubmitJobsRequest();
// // Input
// JSONObject input = new JSONObject();
// input.put("Location", ossLocation);
// input.put("Bucket", ossBucket);
// try {
// input.put("Object", URLEncoder.encode(ossInputObject, "utf-8"));
// } catch (UnsupportedEncodingException e) {
// throw new RuntimeException("input URL encode failed");
// }
// request.setInput(input.toJSONString());
// // Output
// String outputOSSObject;
// try {
// outputOSSObject = URLEncoder.encode(ossOutputObject, "utf-8");
// } catch (UnsupportedEncodingException e) {
// throw new RuntimeException("output URL encode failed");
// }
// JSONObject output = new JSONObject();
// output.put("OutputObject", outputOSSObject);
// // Ouput->Container
// JSONObject container = new JSONObject();
// container.put("Format", "mp4");
// output.put("Container", container.toJSONString());
// // Ouput->Video
// JSONObject video = new JSONObject();
// video.put("Codec", "H.264");
// video.put("Bitrate", "1500");
// video.put("Width", "1280");
// video.put("Fps", "25");
// output.put("Video", video.toJSONString());
// // Ouput->Audio
// JSONObject audio = new JSONObject();
// audio.put("Codec", "AAC");
// audio.put("Bitrate", "128");
// audio.put("Channels", "2");
// audio.put("Samplerate", "44100");
// output.put("Audio", audio.toJSONString());
// // Ouput->TemplateId
// output.put("TemplateId", templateId);
// JSONArray outputs = new JSONArray();
// outputs.add(output);
// request.setOutputs(outputs.toJSONString());
// request.setOutputBucket(ossBucket);
// request.setOutputLocation(ossLocation);
// // PipelineId
// request.setPipelineId(pipelineId);
// // 发起请求并处理应答或异常
// SubmitJobsResponse response;
// try {
// response = client.getAcsResponse(request);
// System.out.println("RequestId is:" + response.getRequestId());
// if (response.getJobResultList().get(0).getSuccess()) {
// System.out.println("JobId is:" + response.getJobResultList().get(0).getJob().getJobId());
// } else {
// System.out.println("SubmitJobs Failed code:" + response.getJobResultList().get(0).getCode() +
// " message:" + response.getJobResultList().get(0).getMessage());
// }
// } catch (ServerException e) {
// e.printStackTrace();
// } catch (ClientException e) {
// e.printStackTrace();
// }
new
SimpleTranscode
().
deal
(
"http://wmy-transcoding-origin.oss-cn-shanghai.aliyuncs.com/"
,
"mp4MultibitrateIn7c96a8ccd2c16a600139d4487fc6b222/123456.mp4"
);
}
public
void
deal
(
String
inputOssHost
,
String
inputOssObject
)
throws
UnsupportedEncodingException
{
DefaultProfile
profile
=
DefaultProfile
.
getProfile
(
mpsRegionId
,
// 地域ID
accessKeyId
,
// RAM账号的AccessKey ID
accessKeySecret
);
// RAM账号Access Key Secret
DefaultAcsClient
client
=
new
DefaultAcsClient
(
profile
);
QueryMediaListByURLRequest
request
=
new
QueryMediaListByURLRequest
();
String
rfc3986Object
=
encodeByRFC3986
(
inputOssObject
);
request
.
setFileURLs
(
inputOssHost
+
rfc3986Object
);
QueryMediaListByURLResponse
response
=
null
;
try
{
response
=
client
.
getAcsResponse
(
request
);
}
catch
(
ClientException
e
)
{
e
.
printStackTrace
();
}
System
.
out
.
println
(
JSONObject
.
toJSONString
(
response
.
getMediaList
()));
}
private
String
encodeByRFC3986
(
String
object
)
throws
UnsupportedEncodingException
{
StringBuilder
builder
=
new
StringBuilder
();
String
[]
segments
=
object
.
split
(
"/"
);
for
(
int
i
=
0
;
i
<
segments
.
length
;
i
++)
{
builder
.
append
(
percentEncode
(
segments
[
i
]));
if
(
i
!=
segments
.
length
-
1
)
{
builder
.
append
(
"/"
);
}
}
return
builder
.
toString
();
}
private
static
String
percentEncode
(
String
value
)
throws
UnsupportedEncodingException
{
if
(
value
==
null
)
return
null
;
return
URLEncoder
.
encode
(
value
,
"UTF-8"
).
replace
(
"+"
,
"%20"
).
replace
(
"*"
,
"%2A"
).
replace
(
"%7E"
,
"~"
);
}
}
\ No newline at end of file
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/domain/ActivityDTO.java
0 → 100644
View file @
fa5aeaee
package
com
.
yizhi
.
aliyun
.
application
.
domain
;
import
com.alibaba.fastjson.annotation.JSONField
;
public
class
ActivityDTO
{
/**
*
*/
private
static
final
long
serialVersionUID
=
39871077951199522L
;
public
ActivityDTO
()
{
}
@JSONField
(
name
=
"RunId"
,
ordinal
=
1
)
private
String
runId
;
/**
* activity name
*/
@JSONField
(
name
=
"Name"
,
ordinal
=
2
)
private
String
name
;
@JSONField
(
name
=
"Type"
,
ordinal
=
3
)
private
String
type
;
@JSONField
(
name
=
"JobId"
,
ordinal
=
4
)
private
String
jobId
;
@JSONField
(
name
=
"State"
,
ordinal
=
5
)
private
String
state
;
@JSONField
(
name
=
"Code"
,
ordinal
=
6
)
private
String
code
;
@JSONField
(
name
=
"Message"
,
ordinal
=
7
)
private
String
msg
;
@JSONField
(
name
=
"StartTime"
,
ordinal
=
8
)
private
String
startTime
;
@JSONField
(
name
=
"EndTime"
,
ordinal
=
9
)
private
String
endTime
;
@JSONField
(
name
=
"MediaWorkflowExecution"
,
ordinal
=
10
)
private
MediaWorkflowExecutionDTO
mediaWorkflowExecutionDTO
;
public
String
getRunId
()
{
return
runId
;
}
public
String
getName
()
{
return
name
;
}
public
String
getType
()
{
return
type
;
}
public
String
getJobId
()
{
return
jobId
;
}
public
String
getState
()
{
return
state
;
}
public
String
getCode
()
{
return
code
;
}
public
String
getMsg
()
{
return
msg
;
}
public
void
setRunId
(
String
runId
)
{
this
.
runId
=
runId
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
void
setType
(
String
type
)
{
this
.
type
=
type
;
}
public
void
setJobId
(
String
jobId
)
{
this
.
jobId
=
jobId
;
}
public
void
setState
(
String
state
)
{
this
.
state
=
state
;
}
public
void
setCode
(
String
code
)
{
this
.
code
=
code
;
}
public
void
setMsg
(
String
msg
)
{
this
.
msg
=
msg
;
}
public
String
getStartTime
()
{
return
startTime
;
}
public
String
getEndTime
()
{
return
endTime
;
}
public
void
setStartTime
(
String
startTime
)
{
this
.
startTime
=
startTime
;
}
public
void
setEndTime
(
String
endTime
)
{
this
.
endTime
=
endTime
;
}
public
MediaWorkflowExecutionDTO
getMediaWorkflowExecutionDTO
()
{
return
mediaWorkflowExecutionDTO
;
}
public
void
setMediaWorkflowExecutionDTO
(
MediaWorkflowExecutionDTO
mediaWorkflowExecutionDTO
)
{
this
.
mediaWorkflowExecutionDTO
=
mediaWorkflowExecutionDTO
;
}
}
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/domain/ActivityState.java
0 → 100644
View file @
fa5aeaee
package
com
.
yizhi
.
aliyun
.
application
.
domain
;
public
enum
ActivityState
{
Initiated
,
Running
,
Success
,
Fail
,
Skipped
}
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/domain/ActivityType.java
0 → 100644
View file @
fa5aeaee
package
com
.
yizhi
.
aliyun
.
application
.
domain
;
public
enum
ActivityType
{
Start
,
Transcode
,
Snapshot
,
MediaInfo
,
Analysis
,
Report
;
}
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/domain/FileDTO.java
0 → 100644
View file @
fa5aeaee
package
com
.
yizhi
.
aliyun
.
application
.
domain
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.annotation.JSONField
;
public
class
FileDTO
{
/**
*
*/
private
static
final
long
serialVersionUID
=
6314849124435092391L
;
@JSONField
(
name
=
"Bucket"
)
private
String
bucket
;
@JSONField
(
name
=
"Location"
)
private
String
location
;
@JSONField
(
name
=
"Object"
)
private
String
object
;
public
JSONObject
toJson
()
{
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
"Bucket"
,
bucket
);
jsonObject
.
put
(
"Location"
,
location
);
jsonObject
.
put
(
"Object"
,
object
);
return
jsonObject
;
}
public
FileDTO
()
{
}
public
FileDTO
(
String
bucket
,
String
location
,
String
object
)
{
this
.
setBucket
(
bucket
);
this
.
setLocation
(
location
);
this
.
setObject
(
object
);
}
public
String
getBucket
()
{
return
bucket
;
}
public
void
setBucket
(
String
bucket
)
{
this
.
bucket
=
bucket
;
}
public
String
getLocation
()
{
return
location
;
}
public
void
setLocation
(
String
location
)
{
this
.
location
=
location
;
}
public
String
getObject
()
{
return
object
;
}
public
void
setObject
(
String
object
)
{
this
.
object
=
object
;
}
}
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/domain/GetPlayInfoRequest.java
0 → 100644
View file @
fa5aeaee
package
com
.
yizhi
.
aliyun
.
application
.
domain
;
public
class
GetPlayInfoRequest
{
public
GetPlayInfoRequest
()
{
}
private
String
action
=
"GetPlayInfo"
;
//操作接口名,系统规定参数,取值: UpdateVideoInfo
private
String
VideoId
;
//视频ID
private
String
Formats
;
//视频流格式,多个用逗号分隔,支持格式mp4,m3u8,mp3,默认获取所有格式的流
private
String
AuthTimeout
;
//播放地址过期时间,默认为3600秒,支持设置最小值为3600秒(当指定时间小于3600秒时,设置为默认3600秒)。只有开启了URL鉴权才会生效
private
String
StreamType
;
//视频流类型,多个用逗号分隔,支持类型video,audio,默认获取所有类型的流
private
String
Definition
;
//视频流清晰度,多个用逗号分隔,取值FD(流畅),LD(标清),SD(高清),HD(超清),OD(原画),2K(2K),4K(4K),默认获取所有清晰度的流
public
String
getAction
()
{
return
action
;
}
public
String
getVideoId
()
{
return
VideoId
;
}
public
void
setVideoId
(
String
videoId
)
{
VideoId
=
videoId
;
}
public
String
getFormats
()
{
return
Formats
;
}
public
void
setFormats
(
String
formats
)
{
Formats
=
formats
;
}
public
String
getAuthTimeout
()
{
return
AuthTimeout
;
}
public
void
setAuthTimeout
(
String
authTimeout
)
{
AuthTimeout
=
authTimeout
;
}
public
String
getStreamType
()
{
return
StreamType
;
}
public
void
setStreamType
(
String
streamType
)
{
StreamType
=
streamType
;
}
public
String
getDefinition
()
{
return
Definition
;
}
public
void
setDefinition
(
String
definition
)
{
Definition
=
definition
;
}
}
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/domain/GetVideoListRequest.java
0 → 100644
View file @
fa5aeaee
package
com
.
yizhi
.
aliyun
.
application
.
domain
;
/**
* 获取视频列表 请求对象
*/
public
class
GetVideoListRequest
{
public
GetVideoListRequest
()
{
}
private
String
action
=
"GetVideoList"
;
//操作接口名,系统规定参数,取值: GetVideoList
private
String
status
;
//视频状态,默认获取所有视频,多个可以用逗号分隔,如:Uploading,Normal,取值包括:Uploading(上传中),UploadSucc(上传完成),Transcoding(转码中),TranscodeFail(转码失败),Checking(审核中), Blocked(屏蔽),Normal(正常)
private
String
startTime
;
//CreationTime(创建时间)的开始时间,为开区间(大于开始时间)。日期格式按照ISO8601标准表示,并需要使用UTC时间。格式为:YYYY-MM-DDThh:mm:ssZ 例如,2017-01-11T12:00:00Z(为北京时间2017年1月11日20点0分0秒)
private
String
endTime
;
//CreationTime的结束时间,为闭区间(小于等于结束时间)。日期格式按照ISO8601标准表示,并需要使用UTC时间。格式为:YYYY-MM-DDThh:mm:ssZ 例如,2017-01-11T12:00:00Z(为北京时间2017年1月11日20点0分0秒)
private
String
cateId
;
//视频分类ID
private
Long
pageNo
;
//默认1
private
Long
pageSize
;
//默认10,最大不超过100
private
String
sortBy
;
//结果排序,范围:CreationTime:Desc、CreationTime:Asc,默认为CreationTime:Desc(即按创建时间倒序)
public
String
getAction
()
{
return
action
;
}
public
String
getStatus
()
{
return
status
;
}
public
void
setStatus
(
String
status
)
{
this
.
status
=
status
;
}
public
String
getStartTime
()
{
return
startTime
;
}
public
void
setStartTime
(
String
startTime
)
{
this
.
startTime
=
startTime
;
}
public
String
getEndTime
()
{
return
endTime
;
}
public
void
setEndTime
(
String
endTime
)
{
this
.
endTime
=
endTime
;
}
public
String
getCateId
()
{
return
cateId
;
}
public
void
setCateId
(
String
cateId
)
{
this
.
cateId
=
cateId
;
}
public
Long
getPageNo
()
{
return
pageNo
;
}
public
void
setPageNo
(
Long
pageNo
)
{
this
.
pageNo
=
pageNo
;
}
public
Long
getPageSize
()
{
return
pageSize
;
}
public
void
setPageSize
(
Long
pageSize
)
{
this
.
pageSize
=
pageSize
;
}
public
String
getSortBy
()
{
return
sortBy
;
}
public
void
setSortBy
(
String
sortBy
)
{
this
.
sortBy
=
sortBy
;
}
}
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/domain/MediaState.java
0 → 100644
View file @
fa5aeaee
package
com
.
yizhi
.
aliyun
.
application
.
domain
;
/**
* Created by zhongyizengzy on 17/8/16.
*/
public
enum
MediaState
{
UnPublish
,
Published
,
Deleted
}
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/domain/MediaWorkflowExecutionDTO.java
0 → 100644
View file @
fa5aeaee
package
com
.
yizhi
.
aliyun
.
application
.
domain
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
java.util.List
;
public
class
MediaWorkflowExecutionDTO
{
/**
*
*/
private
static
final
long
serialVersionUID
=
-
8124470267990996867L
;
@JSONField
(
name
=
"MediaWorkflowId"
,
ordinal
=
1
)
private
String
mediaWorkflowId
;
@JSONField
(
name
=
"Name"
,
ordinal
=
2
)
private
String
name
;
@JSONField
(
name
=
"RunId"
,
ordinal
=
3
)
private
String
runId
;
@JSONField
(
name
=
"MediaId"
,
ordinal
=
4
)
private
String
mediaId
;
@JSONField
(
name
=
"Input"
,
ordinal
=
5
)
private
MediaWorkflowInputDTO
input
;
@JSONField
(
name
=
"State"
,
ordinal
=
6
)
private
String
state
;
@JSONField
(
name
=
"ActivityList"
,
ordinal
=
7
)
private
List
<
ActivityDTO
>
activities
;
@JSONField
(
name
=
"CreationTime"
,
ordinal
=
8
)
private
String
creationTime
;
public
String
getName
()
{
return
name
;
}
public
String
getRunId
()
{
return
runId
;
}
public
MediaWorkflowInputDTO
getInput
()
{
return
input
;
}
public
String
getState
()
{
return
state
;
}
public
List
<
ActivityDTO
>
getActivities
()
{
return
activities
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
void
setRunId
(
String
runId
)
{
this
.
runId
=
runId
;
}
public
void
setInput
(
MediaWorkflowInputDTO
input
)
{
this
.
input
=
input
;
}
public
void
setState
(
String
state
)
{
this
.
state
=
state
;
}
public
void
setActivities
(
List
<
ActivityDTO
>
activities
)
{
this
.
activities
=
activities
;
}
public
String
getMediaId
()
{
return
mediaId
;
}
public
void
setMediaId
(
String
mediaId
)
{
this
.
mediaId
=
mediaId
;
}
public
String
getCreationTime
()
{
return
creationTime
;
}
public
void
setCreationTime
(
String
creationTime
)
{
this
.
creationTime
=
creationTime
;
}
public
String
getMediaWorkflowId
()
{
return
mediaWorkflowId
;
}
public
void
setMediaWorkflowId
(
String
mediaWorkflowId
)
{
this
.
mediaWorkflowId
=
mediaWorkflowId
;
}
}
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/domain/MediaWorkflowInputDTO.java
0 → 100644
View file @
fa5aeaee
package
com
.
yizhi
.
aliyun
.
application
.
domain
;
import
com.alibaba.fastjson.annotation.JSONField
;
public
class
MediaWorkflowInputDTO
{
/**
*
*/
private
static
final
long
serialVersionUID
=
5212690110801932598L
;
@JSONField
(
name
=
"InputFile"
)
private
FileDTO
file
;
@JSONField
(
name
=
"UserData"
)
private
String
userData
;
public
MediaWorkflowInputDTO
()
{
}
public
MediaWorkflowInputDTO
(
FileDTO
file
,
String
userData
)
{
this
.
setFile
(
file
);
this
.
setUserData
(
userData
);
}
public
FileDTO
getFile
()
{
return
file
;
}
public
void
setFile
(
FileDTO
file
)
{
this
.
file
=
file
;
}
public
String
getUserData
()
{
return
userData
;
}
public
void
setUserData
(
String
userData
)
{
this
.
userData
=
userData
;
}
}
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/domain/UpdateVideoInfoRequest.java
0 → 100644
View file @
fa5aeaee
package
com
.
yizhi
.
aliyun
.
application
.
domain
;
public
class
UpdateVideoInfoRequest
{
public
UpdateVideoInfoRequest
()
{
}
private
String
action
=
"UpdateVideoInfo"
;
//操作接口名,系统规定参数,取值: UpdateVideoInfo
private
String
VideoId
;
//视频ID
private
String
Title
;
//视频标题,长度不超过128个字节,UTF8编码
private
String
Description
;
//视频描述,长度不超过1024个字节,UTF8编码
private
String
CoverURL
;
//视频封面URL地址
private
String
CateId
;
//视频分类ID
private
String
Tags
;
//标签
public
String
getAction
()
{
return
action
;
}
public
String
getVideoId
()
{
return
VideoId
;
}
public
void
setVideoId
(
String
videoId
)
{
VideoId
=
videoId
;
}
public
String
getTitle
()
{
return
Title
;
}
public
void
setTitle
(
String
title
)
{
Title
=
title
;
}
public
String
getDescription
()
{
return
Description
;
}
public
void
setDescription
(
String
description
)
{
Description
=
description
;
}
public
String
getCoverURL
()
{
return
CoverURL
;
}
public
void
setCoverURL
(
String
coverURL
)
{
CoverURL
=
coverURL
;
}
public
String
getCateId
()
{
return
CateId
;
}
public
void
setCateId
(
String
cateId
)
{
CateId
=
cateId
;
}
public
String
getTags
()
{
return
Tags
;
}
public
void
setTags
(
String
tags
)
{
Tags
=
tags
;
}
}
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/domain/UploadVideoURLStreamVo.java
0 → 100644
View file @
fa5aeaee
package
com
.
yizhi
.
aliyun
.
application
.
domain
;
public
class
UploadVideoURLStreamVo
{
private
String
title
;
//视频标题(必选)
private
String
description
;
//视频描述(可选)
private
Integer
cateId
;
//视频分类ID(可选)
private
String
tags
;
//视频标签,多个用逗号分隔(可选)
private
String
coverURL
;
//封面图片(可选)
private
String
IP
;
private
String
fileName
;
// 网络流上传时,文件名称为源文件名,如文件名称.mp4(必选)。任何上传方式文件名必须包含扩展名
private
String
callback
;
//设置上传完成后的回调URL(可选)
private
Boolean
isShowWaterMark
;
//是否使用默认水印
private
String
URL
;
//网络文件url
public
UploadVideoURLStreamVo
()
{
}
public
String
getTitle
()
{
return
title
;
}
public
void
setTitle
(
String
title
)
{
this
.
title
=
title
;
}
public
String
getDescription
()
{
return
description
;
}
public
void
setDescription
(
String
description
)
{
this
.
description
=
description
;
}
public
Integer
getCateId
()
{
return
cateId
;
}
public
void
setCateId
(
Integer
cateId
)
{
this
.
cateId
=
cateId
;
}
public
String
getTags
()
{
return
tags
;
}
public
void
setTags
(
String
tags
)
{
this
.
tags
=
tags
;
}
public
String
getCoverURL
()
{
return
coverURL
;
}
public
void
setCoverURL
(
String
coverURL
)
{
this
.
coverURL
=
coverURL
;
}
public
String
getIP
()
{
return
IP
;
}
public
void
setIP
(
String
IP
)
{
this
.
IP
=
IP
;
}
public
String
getFileName
()
{
return
fileName
;
}
public
void
setFileName
(
String
fileName
)
{
this
.
fileName
=
fileName
;
}
public
String
getCallback
()
{
return
callback
;
}
public
void
setCallback
(
String
callback
)
{
this
.
callback
=
callback
;
}
public
Boolean
getShowWaterMark
()
{
return
isShowWaterMark
;
}
public
void
setShowWaterMark
(
Boolean
showWaterMark
)
{
isShowWaterMark
=
showWaterMark
;
}
public
String
getURL
()
{
return
URL
;
}
public
void
setURL
(
String
URL
)
{
this
.
URL
=
URL
;
}
}
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/domain/UploadVideoVo.java
0 → 100644
View file @
fa5aeaee
package
com
.
yizhi
.
aliyun
.
application
.
domain
;
public
class
UploadVideoVo
{
private
String
title
;
//视频标题(必选)
private
String
description
;
//视频描述(可选)
private
Integer
cateId
;
//视频分类ID(可选)
private
String
tags
;
//视频标签,多个用逗号分隔(可选)
private
String
coverURL
;
//封面图片(可选)
private
String
IP
;
private
String
fileName
;
//1.本地文件上传时,文件名称为上传文件绝对路径,如:/User/sample/文件名称.mp4 (必选) 2.网络流上传时,文件名称为源文件名,如文件名称.mp4(必选)。任何上传方式文件名必须包含扩展名
private
String
callback
;
//设置上传完成后的回调URL(可选)
private
Integer
taskNum
=
Integer
.
valueOf
(
1
);
//可指定分片上传时的并发线程数,默认为1,(注:该配置会占用服务器CPU资源,需根据服务器情况指定)
private
Long
partSize
=
10485760L
;
///可指定分片上传时每个分片的大小,默认为10M字节
private
Boolean
isShowWaterMark
;
//是否使用默认水印
public
UploadVideoVo
()
{
}
public
String
getTitle
()
{
return
title
;
}
public
void
setTitle
(
String
title
)
{
this
.
title
=
title
;
}
public
String
getDescription
()
{
return
description
;
}
public
void
setDescription
(
String
description
)
{
this
.
description
=
description
;
}
public
Integer
getCateId
()
{
return
cateId
;
}
public
void
setCateId
(
Integer
cateId
)
{
this
.
cateId
=
cateId
;
}
public
String
getTags
()
{
return
tags
;
}
public
void
setTags
(
String
tags
)
{
this
.
tags
=
tags
;
}
public
String
getCoverURL
()
{
return
coverURL
;
}
public
void
setCoverURL
(
String
coverURL
)
{
this
.
coverURL
=
coverURL
;
}
public
String
getIP
()
{
return
IP
;
}
public
void
setIP
(
String
IP
)
{
this
.
IP
=
IP
;
}
public
String
getFileName
()
{
return
fileName
;
}
public
void
setFileName
(
String
fileName
)
{
this
.
fileName
=
fileName
;
}
public
String
getCallback
()
{
return
callback
;
}
public
void
setCallback
(
String
callback
)
{
this
.
callback
=
callback
;
}
public
Integer
getTaskNum
()
{
return
taskNum
;
}
public
void
setTaskNum
(
Integer
taskNum
)
{
this
.
taskNum
=
taskNum
;
}
public
Long
getPartSize
()
{
return
partSize
;
}
public
void
setPartSize
(
Long
partSize
)
{
this
.
partSize
=
partSize
;
}
public
Boolean
getShowWaterMark
()
{
return
isShowWaterMark
;
}
public
void
setShowWaterMark
(
Boolean
showWaterMark
)
{
isShowWaterMark
=
showWaterMark
;
}
}
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/mapper/AddMediaResponseRecordMapper.java
0 → 100644
View file @
fa5aeaee
package
com
.
yizhi
.
aliyun
.
application
.
mapper
;
import
com.baomidou.mybatisplus.mapper.BaseMapper
;
import
com.yizhi.aliyun.application.vo.AddMediaResponseRecordVO
;
public
interface
AddMediaResponseRecordMapper
extends
BaseMapper
<
AddMediaResponseRecordVO
>
{
}
\ No newline at end of file
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/mapper/MNSMapper.java
0 → 100755
View file @
fa5aeaee
package
com
.
yizhi
.
aliyun
.
application
.
mapper
;
import
com.baomidou.mybatisplus.mapper.BaseMapper
;
import
com.yizhi.aliyun.application.vo.MNSVO
;
public
interface
MNSMapper
extends
BaseMapper
<
MNSVO
>
{
}
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/mq/AssignmentTranscodingListener.java
0 → 100644
View file @
fa5aeaee
package
com
.
yizhi
.
aliyun
.
application
.
mq
;
import
com.yizhi.aliyun.application.service.DealMediaTranscode
;
import
com.yizhi.core.application.event.EventWrapper
;
import
com.yizhi.util.application.event.AssignmentMediaTranscodingEvent
;
import
org.springframework.amqp.rabbit.annotation.RabbitHandler
;
import
org.springframework.amqp.rabbit.annotation.RabbitListener
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
@Component
@RabbitListener
(
queues
=
"assignmentMediaTranscoding"
)
public
class
AssignmentTranscodingListener
{
@Autowired
private
DealMediaTranscode
dealMediaTranscode
;
@RabbitHandler
public
void
processBizEvent
(
EventWrapper
<
AssignmentMediaTranscodingEvent
>
eventWrapper
)
{
try
{
dealMediaTranscode
.
addMedia
(
eventWrapper
.
getData
().
getFiles
()
,
eventWrapper
.
getData
().
getType
());
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
}
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/service/AddMediaResponseRecordService.java
0 → 100755
View file @
fa5aeaee
package
com
.
yizhi
.
aliyun
.
application
.
service
;
import
com.baomidou.mybatisplus.service.IService
;
import
com.yizhi.aliyun.application.vo.AddMediaResponseRecordVO
;
public
interface
AddMediaResponseRecordService
extends
IService
<
AddMediaResponseRecordVO
>
{
}
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/service/DealMediaTranscode.java
0 → 100644
View file @
fa5aeaee
package
com
.
yizhi
.
aliyun
.
application
.
service
;
import
com.alibaba.fastjson.JSONObject
;
import
com.aliyuncs.DefaultAcsClient
;
import
com.aliyuncs.exceptions.ClientException
;
import
com.aliyuncs.exceptions.ServerException
;
import
com.aliyuncs.mts.model.v20140618.AddMediaRequest
;
import
com.aliyuncs.mts.model.v20140618.AddMediaResponse
;
import
com.aliyuncs.mts.model.v20140618.QueryMediaListRequest
;
import
com.aliyuncs.mts.model.v20140618.QueryMediaListResponse
;
import
com.aliyuncs.profile.DefaultProfile
;
import
com.yizhi.aliyun.application.domain.MediaState
;
import
com.yizhi.aliyun.application.util.PropertiesUtil
;
import
com.yizhi.aliyun.application.vo.AddMediaResponseRecordVO
;
import
com.yizhi.application.orm.id.IdGenerator
;
import
com.yizhi.assignment.application.feign.AssignmentClient
;
import
com.yizhi.core.application.cache.RedisCache
;
import
com.yizhi.documents.application.feign.DocumentClient
;
import
com.yizhi.forum.application.feign.remote.RemotePostsClient
;
import
com.yizhi.library.application.feign.StudentCaseClient
;
import
com.yizhi.util.application.constant.TpActivityType
;
import
com.yizhi.util.application.event.AssignmentMediaTranscodingEvent
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang.exception.ExceptionUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
java.util.*
;
/**
* @ClassName MediaTranscodeApi
* @Description TODO
* @Author shengchenglong
* @DATE 2019-10-18 16:27
* @Version 1.0
*/
@Component
public
class
DealMediaTranscode
{
@Autowired
private
PropertiesUtil
propertiesUtil
;
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
DealMediaTranscode
.
class
);
private
String
REGION
=
null
;
private
String
mtsEndpoint
=
null
;
// private final String mnsEndPoint = "http://1955327038947993.mns.cn-shanghai.aliyuncs.com/";
//Step 2.set accesskey & keySecret
private
String
accessKeyId
=
null
;
private
String
accessKeySecret
=
null
;
private
String
workFlowId
=
null
;
// private final String mediaWorkflowQueueName = "wmy-transcoding";
private
final
String
media_hd_act_name
=
"Act-ss-mp4-hd"
;
private
final
String
media_sd_act_name
=
"Act-ss-mp4-sd"
;
private
final
String
media_ld_act_name
=
"Act-ss-mp4-ld"
;
public
static
final
List
<
String
>
media_vedio_suffix
=
new
ArrayList
<>();
public
static
final
List
<
String
>
media_music_suffix
=
new
ArrayList
<>();
// private CloudAccount account;
// private CloudQueue queue;
private
DefaultAcsClient
aliyunClient
;
@Autowired
private
IdGenerator
idGenerator
;
@Autowired
private
AssignmentClient
assignmentClient
;
@Autowired
private
DocumentClient
documentClient
;
@Autowired
private
RedisCache
redisCache
;
@Autowired
private
StudentCaseClient
studentCaseClient
;
@Autowired
private
RemotePostsClient
remotePostsClient
;
static
{
media_vedio_suffix
.
add
(
"mp4"
);
media_vedio_suffix
.
add
(
"quicktime"
);
media_vedio_suffix
.
add
(
"3gp"
);
media_vedio_suffix
.
add
(
"avi"
);
media_vedio_suffix
.
add
(
"flv"
);
media_vedio_suffix
.
add
(
"f4v"
);
media_vedio_suffix
.
add
(
"mkv"
);
media_vedio_suffix
.
add
(
"mov"
);
media_vedio_suffix
.
add
(
"mpg"
);
media_vedio_suffix
.
add
(
"rmvb"
);
media_vedio_suffix
.
add
(
"vob"
);
media_vedio_suffix
.
add
(
"wmv"
);
media_music_suffix
.
add
(
"mp3"
);
media_music_suffix
.
add
(
"ape"
);
media_music_suffix
.
add
(
"aac"
);
media_music_suffix
.
add
(
"flac"
);
media_music_suffix
.
add
(
"wav"
);
media_music_suffix
.
add
(
"wma"
);
media_music_suffix
.
add
(
"ogg"
);
media_music_suffix
.
add
(
"m4a"
);
}
private
void
beforeTranscoding
()
{
// account = new CloudAccount(accessKeyId, accessKeySecret, mnsEndPoint);
// MNSClient mnsClient = account.getMNSClient();
// queue = mnsClient.getQueueRef(mediaWorkflowQueueName);
REGION
=
propertiesUtil
.
getPublicParam
().
get
(
"REGION"
);
mtsEndpoint
=
"mts."
+
REGION
+
".aliyuncs.com"
;
accessKeyId
=
propertiesUtil
.
getPublicParam
().
get
(
"accessKeyId"
);
accessKeySecret
=
propertiesUtil
.
getPublicParam
().
get
(
"accessKeySecret"
);
workFlowId
=
propertiesUtil
.
getPublicParam
().
get
(
"workFlowId"
);
try
{
DefaultProfile
.
addEndpoint
(
REGION
,
REGION
,
"Mts"
,
mtsEndpoint
);
}
catch
(
ClientException
e
)
{
System
.
out
.
print
(
ExceptionUtils
.
getStackTrace
(
e
));
// System.exit(1);
}
aliyunClient
=
new
DefaultAcsClient
(
DefaultProfile
.
getProfile
(
REGION
,
accessKeyId
,
accessKeySecret
));
}
/**
* 添加媒体
*
* @param files
* @throws ServerException
* @throws ClientException
*/
public
void
addMedia
(
List
<
AssignmentMediaTranscodingEvent
.
FileDTO
>
files
,
Integer
type
)
{
beforeTranscoding
();
List
<
Long
>
answerFileIds
=
new
ArrayList
<>();
files
.
forEach
(
file
->
{
int
suffixIndex
=
file
.
getOrrUrl
().
lastIndexOf
(
"."
);
String
suffix
=
file
.
getOrrUrl
().
substring
(
suffixIndex
+
1
);
LOGGER
.
info
(
"媒体转码:suffix- :"
+
suffix
);
String
type_suffix
=
null
;
AddMediaResponseRecordVO
responseRecord
=
null
;
try
{
String
fileURL
=
file
.
getOrrUrl
().
replaceAll
(
"\\["
,
"【"
).
replaceAll
(
"\\]"
,
"】"
);
if
(
fileURL
!=
null
&&
!
fileURL
.
equals
(
""
))
{
if
(
fileURL
.
startsWith
(
"https"
))
{
fileURL
=
fileURL
.
replaceFirst
(
"https"
,
"http"
);
}
}
for
(
String
s
:
media_vedio_suffix
)
{
if
(
s
.
equalsIgnoreCase
(
suffix
))
{
type_suffix
=
"mp4"
;
break
;
}
}
if
(
type_suffix
==
null
)
{
for
(
String
s
:
media_music_suffix
)
{
if
(
s
.
equalsIgnoreCase
(
suffix
))
{
type_suffix
=
"mp3"
;
break
;
}
}
}
if
(
type_suffix
==
null
)
{
LOGGER
.
info
(
"-----------------------------------未支持的格式,不进行转码操作-----------------------------------"
);
return
;
}
AddMediaRequest
request
=
new
AddMediaRequest
();
request
.
setFileURL
(
fileURL
);
request
.
setMediaWorkflowId
(
workFlowId
);
AddMediaResponse
response
=
aliyunClient
.
getAcsResponse
(
request
);
responseRecord
=
new
AddMediaResponseRecordVO
();
responseRecord
.
setId
(
idGenerator
.
generate
());
responseRecord
.
setRelationId
(
file
.
getAssignmentAnswerFileId
());
responseRecord
.
setType
(
type
);
responseRecord
.
setMediaId
(
response
.
getMedia
().
getMediaId
());
responseRecord
.
setResponse
(
JSONObject
.
toJSONString
(
response
));
responseRecord
.
setHasProcessed
(
0
);
responseRecord
.
setSuffixType
(
type_suffix
);
responseRecord
.
insert
();
answerFileIds
.
add
(
file
.
getAssignmentAnswerFileId
());
}
catch
(
ServerException
e
)
{
e
.
printStackTrace
();
}
catch
(
ClientException
e
)
{
e
.
printStackTrace
();
}
});
LOGGER
.
info
(
"answerFileIds: "
+
answerFileIds
);
LOGGER
.
info
(
"type: "
+
type
);
if
(
CollectionUtils
.
isNotEmpty
(
answerFileIds
))
{
if
(
type
.
equals
(
TpActivityType
.
TYPE_ASSIGNMENT
))
{
// 通知作业微服务该附件是视频文件,等待转码
assignmentClient
.
verifyVedio
(
answerFileIds
);
//通知资料微服务该附件是视频文件,等待转码
}
else
if
(
type
.
equals
(
TpActivityType
.
TYPE_DOCUMENT
))
{
documentClient
.
verifyVedio
(
answerFileIds
);
//通知案例微服务该附件是视频/音频文件,等待转码
}
else
if
(
type
.
equals
(
TpActivityType
.
TYPE_SELECTED_CASE
))
{
studentCaseClient
.
verifyVedio
(
answerFileIds
);
//通知论坛微服务该附件是视频/音频文件,等待转码
}
else
if
(
type
.
equals
(
TpActivityType
.
TYPE_FORUM
))
{
remotePostsClient
.
verifyVideo
(
answerFileIds
);
}
}
}
// public void getTranscodingResult() {
// boolean flag = true;
// List<Message> messageList;
//
// try {
// Thread.sleep(60000);
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
//
// while (flag) {
// messageList = queue.batchPopMessage(16, 30);
// if (null == messageList || messageList.isEmpty()) {
// flag = false;
// return;
// }
// for (Message message : messageList) {
// if (redisCache.hExisted("media:transcoding", message.getMessageId())) {
// continue;
// }
// redisCache.hset("media:transcoding", message.getMessageId(), "1", 10);
// handlingMessage(message);
// }
// }
// }
//
// private void handlingMessage(Message message) {
// String messageBody = message.getMessageBody();
// ActivityDTO activityDTO = JSONObject.parseObject(messageBody, ActivityDTO.class);
// if (activityDTO.getType().equals(ActivityType.Start.name())) {
// //若工作流启动消息不希望处理,则直接删除
// queue.deleteMessage(message.getReceiptHandle());
// } else if (activityDTO.getType().equals(ActivityType.Report.name())) {
// //获取媒体工作流执行信息
// MediaWorkflowExecutionDTO mediaWorkflowExecutionDTO = activityDTO.getMediaWorkflowExecutionDTO();
// //从媒体工作流中取活动列表
// List<ActivityDTO> activityDTOS = mediaWorkflowExecutionDTO.getActivities();
// //遍历活动列表,判断转码是否成功
// if (null != activityDTOS) {
// for (ActivityDTO activity : activityDTOS) {
// if (activity.getType().equals(ActivityType.Transcode.name())) {
// if (activity.getState().equals(ActivityState.Success.name())) {
// successTranscode(mediaWorkflowExecutionDTO, message.getReceiptHandle());
// break;
// }
// }
// }
// }
// }
// }
//
// private void successTranscode(MediaWorkflowExecutionDTO mediaWorkflowExecutionDTO, String receiptHandle) {
// //获取转码输出地址(OSS地址)
// QueryMediaListRequest request = new QueryMediaListRequest();
// request.setMediaIds(mediaWorkflowExecutionDTO.getMediaId());
// request.setIncludePlayList(true);
// try {
// QueryMediaListResponse response = aliyunClient.getAcsResponse(request);
// List<QueryMediaListResponse.Media> list = response.getMediaList();
// QueryMediaListResponse.Media media = list.get(0);
// if (media.getPublishState().equals(MediaState.Published.name())) {
// List<QueryMediaListResponse.Media.Play> playList = media.getPlayList();
// if (null != playList) {
// Map<String, String> map = new HashMap<>();
//
// AddMediaResponseRecord responseRecord = new AddMediaResponseRecord();
// responseRecord.setMediaId(mediaWorkflowExecutionDTO.getMediaId());
// responseRecord = responseRecord.selectOne(new EntityWrapper(responseRecord));
//
// if (responseRecord != null) {
// map.put("id", String.valueOf(responseRecord.getRelationId()));
// for (QueryMediaListResponse.Media.Play play : playList) {
// //遍历转码输出地址
// if (play.getActivityName().equals(media_sd_act_name)) {
// map.put("sd", play.getFile1().getURL());
// } else if (play.getActivityName().equals(media_ld_act_name)) {
// map.put("ld", play.getFile1().getURL());
// } else if (play.getActivityName().equals(media_hd_act_name)) {
// map.put("hd", play.getFile1().getURL());
// }
// }
// assignmentClient.updateVedioTranscodeUrl(map);
// }
// }
// }
// } catch (ServerException e) {
// LOGGER.error(ExceptionUtils.getStackTrace(e));
// } catch (ClientException e) {
// LOGGER.error(ExceptionUtils.getStackTrace(e));
// }
//
// //如果是report消息,需要从队列中删除,否则会一直在队列中
// queue.deleteMessage(receiptHandle);
// }
/**
* 拿取媒体id查询转码后的地址,更新到相关的服务,并记录已处理
*
* @return
*/
public
boolean
dealFinishedTranscoding
(
AddMediaResponseRecordVO
record
)
{
beforeTranscoding
();
QueryMediaListRequest
request
=
new
QueryMediaListRequest
();
request
.
setMediaIds
(
record
.
getMediaId
());
request
.
setIncludePlayList
(
true
);
try
{
QueryMediaListResponse
response
=
aliyunClient
.
getAcsResponse
(
request
);
List
<
QueryMediaListResponse
.
Media
>
list
=
response
.
getMediaList
();
QueryMediaListResponse
.
Media
media
=
list
.
get
(
0
);
if
(
media
.
getPublishState
().
equals
(
MediaState
.
Published
.
name
()))
{
List
<
QueryMediaListResponse
.
Media
.
Play
>
playList
=
media
.
getPlayList
();
if
(
null
!=
playList
)
{
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"id"
,
String
.
valueOf
(
record
.
getRelationId
()));
for
(
QueryMediaListResponse
.
Media
.
Play
play
:
playList
)
{
if
(
play
.
getFormat
().
equalsIgnoreCase
(
"mp3"
)
&&
record
.
getSuffixType
().
equalsIgnoreCase
(
"mp3"
))
{
map
.
put
(
"sd"
,
play
.
getFile1
().
getURL
().
replaceAll
(
"http"
,
"https"
));
break
;
}
else
if
(
play
.
getFormat
().
equalsIgnoreCase
(
"mp4"
)
&&
record
.
getSuffixType
().
equalsIgnoreCase
(
"mp4"
))
{
map
.
put
(
"sd"
,
play
.
getFile1
().
getURL
().
replaceAll
(
"http"
,
"https"
));
break
;
}
}
//对阿里云转码后的标清地址进行非空判断
if
(
map
.
get
(
"sd"
)==
null
||
""
.
equals
(
map
.
get
(
"sd"
))){
return
false
;
}
boolean
flag
=
notifyBiz
(
record
.
getType
(),
map
);
if
(
flag
)
{
AddMediaResponseRecordVO
responseRecord
=
new
AddMediaResponseRecordVO
();
responseRecord
.
setId
(
record
.
getId
());
responseRecord
.
setHasProcessed
(
1
);
responseRecord
.
setProcessTime
(
new
Date
());
return
responseRecord
.
updateById
();
}
}
}
}
catch
(
ServerException
e
)
{
LOGGER
.
error
(
ExceptionUtils
.
getStackTrace
(
e
));
}
catch
(
ClientException
e
)
{
LOGGER
.
error
(
ExceptionUtils
.
getStackTrace
(
e
));
}
return
false
;
}
boolean
notifyBiz
(
Integer
type
,
Map
<
String
,
String
>
map
)
{
boolean
flag
=
false
;
if
(
type
==
TpActivityType
.
TYPE_ASSIGNMENT
)
{
flag
=
assignmentClient
.
updateVedioTranscodeUrl
(
map
);
}
else
if
(
type
==
TpActivityType
.
TYPE_DOCUMENT
)
{
flag
=
documentClient
.
updateVedioTranscodeUrl
(
map
);
}
else
if
(
type
.
equals
(
TpActivityType
.
TYPE_SELECTED_CASE
))
{
flag
=
studentCaseClient
.
updateTranscodeUrl
(
map
);
}
else
if
(
type
.
equals
(
TpActivityType
.
TYPE_FORUM
))
{
System
.
out
.
println
(
"论坛传参:"
+
map
.
toString
());
flag
=
remotePostsClient
.
updateVideoTranscodeUrl
(
map
);
}
return
flag
;
}
}
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/service/MNSService.java
0 → 100755
View file @
fa5aeaee
package
com
.
yizhi
.
aliyun
.
application
.
service
;
import
com.baomidou.mybatisplus.service.IService
;
import
com.yizhi.aliyun.application.vo.MNSVO
;
public
interface
MNSService
extends
IService
<
MNSVO
>
{
}
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/service/UploadVideoApi.java
0 → 100644
View file @
fa5aeaee
package
com
.
yizhi
.
aliyun
.
application
.
service
;
import
com.yizhi.aliyun.application.domain.UploadVideoURLStreamVo
;
import
com.yizhi.aliyun.application.domain.UploadVideoVo
;
import
java.io.UnsupportedEncodingException
;
import
java.net.MalformedURLException
;
import
java.util.Map
;
public
interface
UploadVideoApi
{
/**
* 上传本地文件到阿里云服务器
* @param uploadVideoVo 上传文件属性对象 具体参数注释看对象类
* @return UploadVideoBaseResponse
*/
String
UploadVideoLocal
(
UploadVideoVo
uploadVideoVo
);
/**
* 上传网络文件到阿里云服务器
* @param uploadVideoURLStreamVo 网络文件属性对象 具体参数注释看对象类
* @return UploadVideoBaseResponse
*/
String
uploadURLStream
(
UploadVideoURLStreamVo
uploadVideoURLStreamVo
);
/**
* 获取视频上传凭证和地址
* @param map 文件属性
* @return String 返回的结果
*/
String
createUploadVideo
(
Map
<
String
,
Object
>
map
);
/**
* 刷新视频上传凭证
* @param videoId 刷新凭证
* @return String 执行结果信息
*/
String
refreshUploadVideo
(
String
videoId
);
String
downloadObjectHeader
(
String
sourceUrl
)
throws
UnsupportedEncodingException
,
MalformedURLException
;
}
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/service/VideoInfoApi.java
0 → 100644
View file @
fa5aeaee
package
com
.
yizhi
.
aliyun
.
application
.
service
;
import
com.yizhi.aliyun.application.domain.GetPlayInfoRequest
;
import
com.yizhi.aliyun.application.domain.GetVideoListRequest
;
import
com.yizhi.aliyun.application.domain.UpdateVideoInfoRequest
;
public
interface
VideoInfoApi
{
/**
* 获取视频信息
* @param videoId 视频id
* @return String json结果集
*/
String
getVideoInfo
(
String
videoId
);
/**
* 修改视频信息
* @param updateVideoInfoRequest 修改视频信息对象 具体注释看类
* @return String json结果集
*/
String
updateVideoInfo
(
UpdateVideoInfoRequest
updateVideoInfoRequest
);
/**
* 删除视频
* @param VideoIds 视频id v
* @return String json结果集
*/
String
deleteVideo
(
String
VideoIds
);
/**
* 获取视频信息列表
* @param getVideoListRequest 获取视频list请求对象
* @return String json结果集
*/
String
getVideoList
(
GetVideoListRequest
getVideoListRequest
);
/**
* 获取视频播放地址
* @param getPlayInfoRequest 获取视频播放地址请求对象
* @return String json结果集
*/
String
GetPlayInfo
(
GetPlayInfoRequest
getPlayInfoRequest
);
}
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/service/impl/AddMediaResponseRecordServiceImpl.java
0 → 100644
View file @
fa5aeaee
package
com
.
yizhi
.
aliyun
.
application
.
service
.
impl
;
import
com.baomidou.mybatisplus.service.impl.ServiceImpl
;
import
com.yizhi.aliyun.application.mapper.AddMediaResponseRecordMapper
;
import
com.yizhi.aliyun.application.service.AddMediaResponseRecordService
;
import
com.yizhi.aliyun.application.vo.AddMediaResponseRecordVO
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
/**
* @ClassName AddMediaResponseRecordServiceImpl
* @Description TODO
* @Author shengchenglong
* @DATE 2019-10-18 15:23
* @Version 1.0
*/
@Service
@Transactional
public
class
AddMediaResponseRecordServiceImpl
extends
ServiceImpl
<
AddMediaResponseRecordMapper
,
AddMediaResponseRecordVO
>
implements
AddMediaResponseRecordService
{
}
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/service/impl/MNSServiceImpl.java
0 → 100644
View file @
fa5aeaee
package
com
.
yizhi
.
aliyun
.
application
.
service
.
impl
;
import
com.baomidou.mybatisplus.service.impl.ServiceImpl
;
import
com.yizhi.aliyun.application.mapper.MNSMapper
;
import
com.yizhi.aliyun.application.service.MNSService
;
import
com.yizhi.aliyun.application.vo.MNSVO
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
@Service
@Transactional
public
class
MNSServiceImpl
extends
ServiceImpl
<
MNSMapper
,
MNSVO
>
implements
MNSService
{
}
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/service/impl/VideoInfoApiImpl.java
0 → 100644
View file @
fa5aeaee
package
com
.
yizhi
.
aliyun
.
application
.
service
.
impl
;
import
com.yizhi.aliyun.application.domain.GetPlayInfoRequest
;
import
com.yizhi.aliyun.application.domain.GetVideoListRequest
;
import
com.yizhi.aliyun.application.domain.UpdateVideoInfoRequest
;
import
com.yizhi.aliyun.application.service.VideoInfoApi
;
import
com.yizhi.aliyun.application.util.PropertiesUtil
;
import
com.yizhi.aliyun.application.util.VideoRequestUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.io.IOException
;
import
java.net.URL
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
import
java.util.Scanner
;
import
static
org
.
apache
.
commons
.
lang3
.
CharEncoding
.
UTF_8
;
@Service
public
class
VideoInfoApiImpl
implements
VideoInfoApi
{
@Autowired
PropertiesUtil
propertiesUtil
;
@Override
public
String
getVideoInfo
(
String
videoId
)
{
Map
<
String
,
String
>
privateParams
=
new
LinkedHashMap
<
String
,
String
>();
privateParams
.
put
(
"VideoId"
,
videoId
);
privateParams
.
put
(
"Action"
,
"GetVideoInfo"
);
privateParams
.
put
(
"access_key_id"
,
propertiesUtil
.
getPublicParam
().
get
(
""
));
privateParams
.
put
(
"access_key_secret"
,
propertiesUtil
.
getPublicParam
().
get
(
""
));
String
url
=
VideoRequestUtil
.
getOpenAPIURL
(
privateParams
);
String
result
=
""
;
try
{
result
=
httpGet
(
url
);
}
catch
(
Exception
e
){
e
.
printStackTrace
();
}
return
result
;
}
@Override
public
String
updateVideoInfo
(
UpdateVideoInfoRequest
updateVideoInfoRequest
)
{
Map
<
String
,
String
>
privateParams
=
new
LinkedHashMap
<
String
,
String
>();
privateParams
.
put
(
"VideoId"
,
updateVideoInfoRequest
.
getVideoId
());
privateParams
.
put
(
"Action"
,
updateVideoInfoRequest
.
getAction
());
if
(
updateVideoInfoRequest
.
getTitle
()!=
null
)
{
privateParams
.
put
(
"Title"
,
updateVideoInfoRequest
.
getTitle
());
}
if
(
updateVideoInfoRequest
.
getDescription
()!=
null
)
{
privateParams
.
put
(
"Description"
,
updateVideoInfoRequest
.
getDescription
());
}
if
(
updateVideoInfoRequest
.
getCoverURL
()!=
null
)
{
privateParams
.
put
(
"CoverURL"
,
updateVideoInfoRequest
.
getCoverURL
());
}
if
(
updateVideoInfoRequest
.
getCateId
()!=
null
)
{
privateParams
.
put
(
"CateId"
,
updateVideoInfoRequest
.
getCateId
());
}
if
(
updateVideoInfoRequest
.
getTags
()!=
null
)
{
privateParams
.
put
(
"Tags"
,
updateVideoInfoRequest
.
getTags
());
}
String
url
=
VideoRequestUtil
.
getOpenAPIURL
(
privateParams
);
String
result
=
""
;
try
{
result
=
httpGet
(
url
);
}
catch
(
Exception
e
){
e
.
printStackTrace
();
}
return
result
;
}
@Override
public
String
deleteVideo
(
String
videoId
)
{
Map
<
String
,
String
>
privateParams
=
new
LinkedHashMap
<
String
,
String
>();
privateParams
.
put
(
"VideoIds"
,
videoId
);
privateParams
.
put
(
"Action"
,
"DeleteVideo"
);
String
url
=
VideoRequestUtil
.
getOpenAPIURL
(
privateParams
);
String
result
=
""
;
try
{
result
=
httpGet
(
url
);
}
catch
(
Exception
e
){
e
.
printStackTrace
();
}
return
result
;
}
@Override
public
String
getVideoList
(
GetVideoListRequest
getVideoListRequest
)
{
Map
<
String
,
String
>
privateParams
=
new
LinkedHashMap
<
String
,
String
>();
privateParams
.
put
(
"Action"
,
getVideoListRequest
.
getAction
());
if
(
getVideoListRequest
.
getStatus
()!=
null
)
{
privateParams
.
put
(
"Status"
,
getVideoListRequest
.
getStatus
());
}
if
(
getVideoListRequest
.
getStartTime
()!=
null
)
{
privateParams
.
put
(
"StartTime"
,
getVideoListRequest
.
getStartTime
());
}
if
(
getVideoListRequest
.
getEndTime
()!=
null
)
{
privateParams
.
put
(
"EndTime"
,
getVideoListRequest
.
getEndTime
());
}
if
(
getVideoListRequest
.
getCateId
()!=
null
)
{
privateParams
.
put
(
"CateId"
,
getVideoListRequest
.
getCateId
());
}
if
(
getVideoListRequest
.
getPageNo
()!=
null
)
{
privateParams
.
put
(
"PageNo"
,
getVideoListRequest
.
getPageNo
().
toString
());
}
if
(
getVideoListRequest
.
getPageSize
()!=
null
)
{
privateParams
.
put
(
"PageSize"
,
getVideoListRequest
.
getPageSize
().
toString
());
}
if
(
getVideoListRequest
.
getSortBy
()!=
null
)
{
privateParams
.
put
(
"SortBy"
,
getVideoListRequest
.
getSortBy
());
}
String
url
=
VideoRequestUtil
.
getOpenAPIURL
(
privateParams
);
String
result
=
""
;
try
{
result
=
httpGet
(
url
);
}
catch
(
Exception
e
){
e
.
printStackTrace
();
}
return
result
;
}
@Override
public
String
GetPlayInfo
(
GetPlayInfoRequest
getPlayInfoRequest
)
{
Map
<
String
,
String
>
privateParams
=
new
LinkedHashMap
<
String
,
String
>();
privateParams
.
put
(
"Action"
,
getPlayInfoRequest
.
getAction
());
privateParams
.
put
(
"VideoId"
,
getPlayInfoRequest
.
getVideoId
());
if
(
getPlayInfoRequest
.
getFormats
()!=
null
)
{
privateParams
.
put
(
"Formats"
,
getPlayInfoRequest
.
getFormats
());
}
if
(
getPlayInfoRequest
.
getAuthTimeout
()!=
null
)
{
privateParams
.
put
(
"AuthTimeout"
,
getPlayInfoRequest
.
getAuthTimeout
());
}
if
(
getPlayInfoRequest
.
getStreamType
()!=
null
)
{
privateParams
.
put
(
"StreamType"
,
getPlayInfoRequest
.
getStreamType
());
}
if
(
getPlayInfoRequest
.
getDefinition
()!=
null
)
{
privateParams
.
put
(
"Definition"
,
getPlayInfoRequest
.
getDefinition
());
}
String
url
=
VideoRequestUtil
.
getOpenAPIURL
(
privateParams
);
String
result
=
""
;
try
{
result
=
httpGet
(
url
);
}
catch
(
Exception
e
){
e
.
printStackTrace
();
}
return
result
;
}
private
static
String
httpGet
(
String
url
)
throws
IOException
{
/*
* Read and covert a inputStream to a String.
* Referred this:
* http://stackoverflow.com/questions/309424/read-convert-an-inputstream-to-a-string
*/
@SuppressWarnings
(
"resource"
)
Scanner
s
=
new
Scanner
(
new
URL
(
url
).
openStream
(),
UTF_8
).
useDelimiter
(
"\\A"
);
try
{
String
resposne
=
s
.
hasNext
()
?
s
.
next
()
:
"true"
;
return
resposne
;
}
finally
{
s
.
close
();
}
}
}
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/service/impl/VideoUploadImpl.java
0 → 100644
View file @
fa5aeaee
package
com
.
yizhi
.
aliyun
.
application
.
service
.
impl
;
import
com.alibaba.fastjson.JSON
;
import
com.aliyun.oss.OSSClient
;
import
com.aliyun.oss.model.CopyObjectRequest
;
import
com.aliyun.oss.model.ObjectMetadata
;
import
com.aliyun.vod.upload.impl.UploadVideoImpl
;
import
com.aliyun.vod.upload.req.UploadURLStreamRequest
;
import
com.aliyun.vod.upload.req.UploadVideoRequest
;
import
com.aliyun.vod.upload.resp.UploadURLStreamResponse
;
import
com.aliyun.vod.upload.resp.UploadVideoResponse
;
import
com.aliyuncs.DefaultAcsClient
;
import
com.aliyuncs.exceptions.ClientException
;
import
com.aliyuncs.exceptions.ServerException
;
import
com.aliyuncs.profile.DefaultProfile
;
import
com.aliyuncs.vod.model.v20170321.CreateUploadVideoRequest
;
import
com.aliyuncs.vod.model.v20170321.CreateUploadVideoResponse
;
import
com.aliyuncs.vod.model.v20170321.RefreshUploadVideoRequest
;
import
com.aliyuncs.vod.model.v20170321.RefreshUploadVideoResponse
;
import
com.yizhi.aliyun.application.domain.UploadVideoURLStreamVo
;
import
com.yizhi.aliyun.application.domain.UploadVideoVo
;
import
com.yizhi.aliyun.application.service.UploadVideoApi
;
import
com.yizhi.aliyun.application.util.PropertiesUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.io.UnsupportedEncodingException
;
import
java.net.MalformedURLException
;
import
java.net.URL
;
import
java.net.URLEncoder
;
import
java.nio.file.Path
;
import
java.nio.file.Paths
;
import
java.util.HashMap
;
import
java.util.Map
;
@Service
public
class
VideoUploadImpl
implements
UploadVideoApi
{
@Autowired
PropertiesUtil
propertiesUtil
;
@Override
public
String
UploadVideoLocal
(
UploadVideoVo
uploadVideoVo
)
{
Map
<
String
,
String
>
map
=
propertiesUtil
.
getPublicParam
();
String
accessKeyId
=
map
.
get
(
"accessKeyId"
);
String
accessKeySecret
=
map
.
get
(
"accessKeySecret"
);
UploadVideoRequest
request
=
new
UploadVideoRequest
(
accessKeyId
,
accessKeySecret
,
uploadVideoVo
.
getTitle
(),
uploadVideoVo
.
getFileName
());
if
(
uploadVideoVo
.
getPartSize
()!=
null
){
request
.
setPartSize
(
uploadVideoVo
.
getPartSize
());}
//可指定分片上传时每个分片的大小,默认为10M字节
if
(
uploadVideoVo
.
getTaskNum
()!=
null
){
request
.
setTaskNum
(
uploadVideoVo
.
getTaskNum
());
}
//可指定分片上传时的并发线程数,默认为1,(注:该配置会占用服务器CPU资源,需根据服务器情况指定)
if
(
uploadVideoVo
.
getShowWaterMark
()!=
null
){
request
.
setIsShowWaterMark
(
uploadVideoVo
.
getShowWaterMark
());}
//是否使用默认水印
if
(
uploadVideoVo
.
getCallback
()!=
null
){
request
.
setCallback
(
uploadVideoVo
.
getCallback
());}
//设置上传完成后的回调URL(可选)
if
(
uploadVideoVo
.
getCateId
()!=
null
){
request
.
setCateId
(
uploadVideoVo
.
getCateId
());}
//视频分类ID(可选)
if
(
uploadVideoVo
.
getTags
()!=
null
){
request
.
setTags
(
uploadVideoVo
.
getTags
());}
//视频标签,多个用逗号分隔(可选)
if
(
uploadVideoVo
.
getDescription
()!=
null
){
request
.
setDescription
(
uploadVideoVo
.
getDescription
());}
//视频描述(可选)
if
(
uploadVideoVo
.
getCoverURL
()!=
null
){
request
.
setCoverURL
(
uploadVideoVo
.
getCoverURL
());}
//封面图片(可选)
UploadVideoImpl
uploader
=
new
UploadVideoImpl
();
UploadVideoResponse
response
=
uploader
.
uploadVideo
(
request
);
String
result
=
JSON
.
toJSONString
(
response
);
return
result
;
}
@Override
public
String
uploadURLStream
(
UploadVideoURLStreamVo
uploadVideoURLStreamVo
)
{
Map
<
String
,
String
>
map
=
propertiesUtil
.
getPublicParam
();
String
accessKeyId
=
map
.
get
(
"accessKeyId"
);
String
accessKeySecret
=
map
.
get
(
"accessKeySecret"
);
UploadURLStreamRequest
request
=
new
UploadURLStreamRequest
(
accessKeyId
,
accessKeySecret
,
uploadVideoURLStreamVo
.
getTitle
(),
uploadVideoURLStreamVo
.
getFileName
(),
uploadVideoURLStreamVo
.
getURL
());
if
(
uploadVideoURLStreamVo
.
getShowWaterMark
()!=
null
){
request
.
setShowWaterMark
(
uploadVideoURLStreamVo
.
getShowWaterMark
());}
//是否使用默认水印
if
(
uploadVideoURLStreamVo
.
getCallback
()!=
null
){
request
.
setCallback
(
uploadVideoURLStreamVo
.
getCallback
());}
//设置上传完成后的回调URL(可选)
if
(
uploadVideoURLStreamVo
.
getCateId
()!=
null
){
request
.
setCateId
(
uploadVideoURLStreamVo
.
getCateId
());}
//视频分类ID(可选)
if
(
uploadVideoURLStreamVo
.
getTags
()!=
null
){
request
.
setTags
(
uploadVideoURLStreamVo
.
getTags
());}
//视频标签,多个用逗号分隔(可选)
if
(
uploadVideoURLStreamVo
.
getDescription
()!=
null
){
request
.
setDescription
(
uploadVideoURLStreamVo
.
getDescription
());}
//视频描述(可选)
if
(
uploadVideoURLStreamVo
.
getCoverURL
()!=
null
){
request
.
setCoverURL
(
uploadVideoURLStreamVo
.
getCoverURL
());}
//封面图片(可选)
UploadVideoImpl
uploader
=
new
UploadVideoImpl
();
UploadURLStreamResponse
response
=
uploader
.
uploadURLStream
(
request
);
String
result
=
JSON
.
toJSONString
(
response
);
return
result
;
}
@Override
public
String
createUploadVideo
(
Map
<
String
,
Object
>
map
)
{
String
result
=
""
;
CreateUploadVideoRequest
request
=
new
CreateUploadVideoRequest
();
CreateUploadVideoResponse
response
=
null
;
try
{
/*必选,视频源文件名称(必须带后缀, 支持 ".3gp", ".asf", ".avi", ".dat", ".dv", ".flv", ".f4v", ".gif", ".m2t", ".m3u8", ".m4v", ".mj2", ".mjpeg", ".mkv", ".mov", ".mp4", ".mpe", ".mpg", ".mpeg", ".mts", ".ogg", ".qt", ".rm", ".rmvb", ".swf", ".ts", ".vob", ".wmv", ".webm"".aac", ".ac3", ".acm", ".amr", ".ape", ".caf", ".flac", ".m4a", ".mp3", ".ra", ".wav", ".wma")*/
request
.
setFileName
(
map
.
get
(
"fileName"
).
toString
());
//必选,视频标题
request
.
setTitle
(
map
.
get
(
"title"
).
toString
());
if
(
map
.
containsKey
(
"cateId"
)){
//可选,分类ID
request
.
setCateId
((
Integer
)
map
.
get
(
"cateId"
));
}
if
(
map
.
containsKey
(
"tags"
)){
//可选,视频标签,多个用逗号分隔
request
.
setTags
(
map
.
get
(
"tags"
).
toString
());
}
if
(
map
.
containsKey
(
"description"
)){
//可选,视频描述
request
.
setDescription
(
map
.
get
(
"description"
).
toString
());
}
response
=
this
.
getAliyunClient
().
getAcsResponse
(
request
);
}
catch
(
ServerException
e
)
{
System
.
out
.
println
(
"CreateUploadVideoRequest Server Exception:"
);
e
.
printStackTrace
();
Map
<
String
,
Object
>
resultMap
=
new
HashMap
<
String
,
Object
>();
resultMap
.
put
(
"msg"
,
"CreateUploadVideoRequest Server Exception:"
);
result
=
JSON
.
toJSONString
(
resultMap
);
return
result
;
}
catch
(
ClientException
e
)
{
System
.
out
.
println
(
"CreateUploadVideoRequest Client Exception:"
);
e
.
printStackTrace
();
Map
<
String
,
Object
>
resultMap
=
new
HashMap
<
String
,
Object
>();
resultMap
.
put
(
"msg"
,
"CreateUploadVideoRequest Client Exception:"
);
result
=
JSON
.
toJSONString
(
resultMap
);
}
result
=
JSON
.
toJSONString
(
response
);
return
result
;
}
@Override
public
String
refreshUploadVideo
(
String
videoId
)
{
RefreshUploadVideoRequest
request
=
new
RefreshUploadVideoRequest
();
RefreshUploadVideoResponse
response
=
null
;
try
{
request
.
setVideoId
(
videoId
);
response
=
this
.
getAliyunClient
().
getAcsResponse
(
request
);
}
catch
(
ServerException
e
)
{
System
.
out
.
println
(
"RefreshUploadVideoRequest Server Exception:"
);
e
.
printStackTrace
();
return
"RefreshUploadVideoRequest Server Exception:"
;
}
catch
(
ClientException
e
)
{
System
.
out
.
println
(
"RefreshUploadVideoRequest Client Exception:"
);
e
.
printStackTrace
();
return
"RefreshUploadVideoRequest Client Exception:"
;
}
return
"success"
;
}
@Override
public
String
downloadObjectHeader
(
String
sourceUrl
)
throws
UnsupportedEncodingException
,
MalformedURLException
{
Map
<
String
,
String
>
map
=
propertiesUtil
.
getPublicParam
();
String
accessKeyId
=
map
.
get
(
"accessKeyId"
);
String
accessKeySecret
=
map
.
get
(
"accessKeySecret"
);
String
bucket
=
map
.
get
(
"bucket"
);
String
endpoint
=
map
.
get
(
"endpoint"
);
URL
url
=
new
URL
(
sourceUrl
);
/*System.out.println("域名(不包含http://部分)="+url.getHost());
System.out.println("域名后面的路径(**.com后面的内容)="+url.getPath());
System.out.println("?号后面的内容="+url.getQuery());
System.out.println("协议(http或者https)="+url.getProtocol());
System.out.println("端口(http=80,https=443)="+url.getDefaultPort());
System.out.println("Port(返回负1,不知道为啥)="+url.getPort());*/
String
sourceKey
=
url
.
getPath
();
Path
path
=
Paths
.
get
(
sourceKey
);
//String destinationKey = path.getFileName().toString(); // todo 需要改文件名参考main函数的处理方式
String
destinationKey
=
"/download"
+
sourceKey
;
OSSClient
ossClient
=
new
OSSClient
(
endpoint
,
accessKeyId
,
accessKeySecret
);
CopyObjectRequest
request
=
new
CopyObjectRequest
(
bucket
,
sourceKey
,
bucket
,
destinationKey
);
ObjectMetadata
meta
=
ossClient
.
getObjectMetadata
(
bucket
,
sourceKey
);
meta
.
setContentDisposition
(
"attachment; filename=\""
+
URLEncoder
.
encode
(
path
.
getFileName
().
toString
(),
"UTF-8"
)
+
"\""
);
meta
.
setContentEncoding
(
"utf-8"
);
request
.
setNewObjectMetadata
(
meta
);
//修改元信息。
ossClient
.
copyObject
(
request
);
// 关闭OSSClient。
ossClient
.
shutdown
();
return
sourceUrl
.
replace
(
sourceKey
,
destinationKey
);
}
public
static
void
main
(
String
[]
args
)
throws
MalformedURLException
{
String
urlStr
=
"https://test-wmy-transcoding-origin.oss-cn-hangzhou.aliyuncs.com/document/rc-upload-1575553047642-2.1.jpg?jj=0"
;
URL
url
=
new
URL
(
urlStr
);
String
host
=
url
.
getHost
();
// 获取主机名
System
.
out
.
println
(
"Host="
+
url
.
getHost
());
String
pathStr
=
url
.
getPath
();
System
.
out
.
println
(
"Path="
+
pathStr
);
Path
path
=
Paths
.
get
(
pathStr
);
System
.
out
.
println
(
path
.
getFileName
());
System
.
out
.
println
(
path
.
getParent
());
String
changeStr
=
path
.
getParent
()+
"/"
+
"change_"
+
path
.
getFileName
();
System
.
out
.
println
(
"Query="
+
url
.
getQuery
());
System
.
out
.
println
(
"Protocol="
+
url
.
getProtocol
());
System
.
out
.
println
(
"DefaultPort="
+
url
.
getDefaultPort
());
System
.
out
.
println
(
"Port="
+
url
.
getPort
());
System
.
out
.
println
(
urlStr
.
replace
(
pathStr
,
changeStr
));
}
private
DefaultAcsClient
getAliyunClient
(){
Map
<
String
,
String
>
map
=
propertiesUtil
.
getPublicParam
();
String
accessKeyId
=
map
.
get
(
"accessKeyId"
);
String
accessKeySecret
=
map
.
get
(
"accessKeySecret"
);
DefaultAcsClient
aliyunClient
;
aliyunClient
=
new
DefaultAcsClient
(
DefaultProfile
.
getProfile
(
"cn-shanghai"
,
accessKeyId
,
accessKeySecret
));
return
aliyunClient
;
}
}
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/util/AESCoder.java
0 → 100644
View file @
fa5aeaee
/**
* FileName: AESCoder
* Author: wenjunlong
* Date: 2018/4/28 9:52
* Description: aes加密
* History:
* <author> <time> <version> <desc>
* 作者姓名 修改时间 版本号 描述
*/
package
com
.
yizhi
.
aliyun
.
application
.
util
;
import
com.alibaba.fastjson.JSON
;
import
org.apache.commons.codec.binary.Base64
;
import
javax.crypto.Cipher
;
import
javax.crypto.spec.SecretKeySpec
;
import
java.util.Map
;
/**
* 〈一句话功能简述〉<br>
* 〈aes加密〉
*
* @author wenjunlong
* @create 2018/4/28
* @since 1.0.0
*/
public
class
AESCoder
{
public
static
final
String
KEY
=
"fulan@3923912300"
;
// 加密
public
static
String
Encrypt
(
String
sSrc
,
String
sKey
)
throws
Exception
{
if
(
sKey
==
null
)
{
System
.
out
.
print
(
"Key为空null"
);
return
null
;
}
// 判断Key是否为16位
if
(
sKey
.
length
()
!=
16
)
{
System
.
out
.
print
(
"Key长度不是16位"
);
return
null
;
}
byte
[]
raw
=
sKey
.
getBytes
(
"utf-8"
);
SecretKeySpec
skeySpec
=
new
SecretKeySpec
(
raw
,
"AES"
);
Cipher
cipher
=
Cipher
.
getInstance
(
"AES/ECB/PKCS5Padding"
);
// "算法/模式/补码方式"
cipher
.
init
(
Cipher
.
ENCRYPT_MODE
,
skeySpec
);
byte
[]
encrypted
=
cipher
.
doFinal
(
sSrc
.
getBytes
(
"utf-8"
));
return
new
Base64
().
encodeToString
(
encrypted
);
// 此处使用BASE64做转码功能,同时能起到2次加密的作用。
}
// 解密
public
static
String
Decrypt
(
String
sSrc
,
String
sKey
)
throws
Exception
{
try
{
// 判断Key是否正确
if
(
sKey
==
null
)
{
System
.
out
.
print
(
"Key为空null"
);
return
null
;
}
// 判断Key是否为16位
if
(
sKey
.
length
()
!=
16
)
{
System
.
out
.
print
(
"Key长度不是16位"
);
return
null
;
}
byte
[]
raw
=
sKey
.
getBytes
(
"utf-8"
);
SecretKeySpec
skeySpec
=
new
SecretKeySpec
(
raw
,
"AES"
);
Cipher
cipher
=
Cipher
.
getInstance
(
"AES/ECB/PKCS5Padding"
);
cipher
.
init
(
Cipher
.
DECRYPT_MODE
,
skeySpec
);
byte
[]
encrypted1
=
new
Base64
().
decode
(
sSrc
);
// 先用base64解密
try
{
byte
[]
original
=
cipher
.
doFinal
(
encrypted1
);
String
originalString
=
new
String
(
original
,
"utf-8"
);
return
originalString
;
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
e
.
toString
());
return
null
;
}
}
catch
(
Exception
ex
)
{
System
.
out
.
println
(
ex
.
toString
());
return
null
;
}
}
// public static void main(String[] args) throws Exception {
// /*
// * 此处使用AES-128-ECB加密模式,key需要为16位。
// */
// String cKey = KEY;
// // 需要加密的字串
// Map<String,String> map = PropertiesUtil.getPublicParam();
// String cSrc = JSON.toJSONString(map);
//// String cSrc = "{key:123,sex:345}";
// System.out.println(cSrc);
// // 加密
// String enString = AESCoder.Encrypt(cSrc, cKey);
// System.out.println("加密后的字串是:" + enString);
//
// // 解密
// String DeString = AESCoder.Decrypt(enString, cKey);
// System.out.println("解密后的字串是:" + DeString);
// }
}
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/util/AESUtil.java
0 → 100644
View file @
fa5aeaee
/**
* FileName: AESUtil
* Author: wenjunlong
* Date: 2018/4/27 18:51
* Description: aes 加密工具类
* History:
* <author> <time> <version> <desc>
* 作者姓名 修改时间 版本号 描述
*/
package
com
.
yizhi
.
aliyun
.
application
.
util
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
javax.crypto.Cipher
;
import
javax.crypto.KeyGenerator
;
import
javax.crypto.SecretKey
;
import
javax.crypto.spec.SecretKeySpec
;
import
java.security.SecureRandom
;
/**
* 〈一句话功能简述〉<br>
* 〈aes 加密工具类〉
*
* @author wenjunlong
* @create 2018/4/27
* @since 1.0.0
*/
public
class
AESUtil
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
AESUtil
.
class
);
private
static
final
String
defaultCharset
=
"UTF-8"
;
private
static
final
String
KEY_AES
=
"AES"
;
public
static
final
String
KEY
=
"fulan@123"
;
/**
* 加密
*
* @param data 需要加密的内容
* @param key 加密密码
* @return
*/
public
static
String
encrypt
(
String
data
,
String
key
)
{
return
doAES
(
data
,
key
,
Cipher
.
ENCRYPT_MODE
);
}
/**
* 解密
*
* @param data 待解密内容
* @param key 解密密钥
* @return
*/
public
static
String
decrypt
(
String
data
,
String
key
)
{
return
doAES
(
data
,
key
,
Cipher
.
DECRYPT_MODE
);
}
/**
* 加解密
*
* @param data 待处理数据
* @param password 密钥
* @param mode 加解密mode
* @return
*/
private
static
String
doAES
(
String
data
,
String
key
,
int
mode
)
{
try
{
if
(
StringUtils
.
isBlank
(
data
)
||
StringUtils
.
isBlank
(
key
))
{
return
null
;
}
//判断是加密还是解密
boolean
encrypt
=
mode
==
Cipher
.
ENCRYPT_MODE
;
byte
[]
content
;
//true 加密内容 false 解密内容
if
(
encrypt
)
{
content
=
data
.
getBytes
(
defaultCharset
);
}
else
{
content
=
parseHexStr2Byte
(
data
);
}
//1.构造密钥生成器,指定为AES算法,不区分大小写
KeyGenerator
kgen
=
KeyGenerator
.
getInstance
(
KEY_AES
);
//2.根据ecnodeRules规则初始化密钥生成器
//生成一个128位的随机源,根据传入的字节数组
kgen
.
init
(
128
,
new
SecureRandom
(
key
.
getBytes
()));
//3.产生原始对称密钥
SecretKey
secretKey
=
kgen
.
generateKey
();
//4.获得原始对称密钥的字节数组
byte
[]
enCodeFormat
=
secretKey
.
getEncoded
();
//5.根据字节数组生成AES密钥
SecretKeySpec
keySpec
=
new
SecretKeySpec
(
enCodeFormat
,
KEY_AES
);
//6.根据指定算法AES自成密码器
Cipher
cipher
=
Cipher
.
getInstance
(
KEY_AES
);
// 创建密码器
//7.初始化密码器,第一个参数为加密(Encrypt_mode)或者解密解密(Decrypt_mode)操作,第二个参数为使用的KEY
cipher
.
init
(
mode
,
keySpec
);
// 初始化
byte
[]
result
=
cipher
.
doFinal
(
content
);
if
(
encrypt
)
{
//将二进制转换成16进制
return
parseByte2HexStr
(
result
);
}
else
{
return
new
String
(
result
,
defaultCharset
);
}
}
catch
(
Exception
e
)
{
logger
.
error
(
"AES 密文处理异常"
,
e
);
}
return
null
;
}
/**
* 将二进制转换成16进制
*
* @param buf
* @return
*/
public
static
String
parseByte2HexStr
(
byte
buf
[])
{
StringBuilder
sb
=
new
StringBuilder
();
for
(
int
i
=
0
;
i
<
buf
.
length
;
i
++)
{
String
hex
=
Integer
.
toHexString
(
buf
[
i
]
&
0xFF
);
if
(
hex
.
length
()
==
1
)
{
hex
=
'0'
+
hex
;
}
sb
.
append
(
hex
.
toUpperCase
());
}
return
sb
.
toString
();
}
/**
* 将16进制转换为二进制
*
* @param hexStr
* @return
*/
public
static
byte
[]
parseHexStr2Byte
(
String
hexStr
)
{
if
(
hexStr
.
length
()
<
1
)
{
return
null
;
}
byte
[]
result
=
new
byte
[
hexStr
.
length
()
/
2
];
for
(
int
i
=
0
;
i
<
hexStr
.
length
()
/
2
;
i
++)
{
int
high
=
Integer
.
parseInt
(
hexStr
.
substring
(
i
*
2
,
i
*
2
+
1
),
16
);
int
low
=
Integer
.
parseInt
(
hexStr
.
substring
(
i
*
2
+
1
,
i
*
2
+
2
),
16
);
result
[
i
]
=
(
byte
)
(
high
*
16
+
low
);
}
return
result
;
}
// public static void main(String[] args) throws Exception {
// Map<String,String> map = propertiesUtil.getPublicParam();
// String content = map.toString();
// System.out.println("加密前:" + content);
// System.out.println("加密密钥和解密密钥:" + KEY);
// String encrypt = encrypt(content, KEY);
// System.out.println("加密后:" + encrypt);
// String decrypt = decrypt(encrypt, KEY);
// System.out.println("解密后:" + decrypt);
// }
}
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/util/PropertiesUtil.java
0 → 100644
View file @
fa5aeaee
package
com
.
yizhi
.
aliyun
.
application
.
util
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
import
java.util.ResourceBundle
;
@Component
public
class
PropertiesUtil
{
@Value
(
"${ACTIVE}"
)
public
String
active
;
public
Map
<
String
,
String
>
getPublicParam
(){
Map
<
String
,
String
>
map
=
new
LinkedHashMap
<
String
,
String
>();
try
{
String
accessKeyId
=
""
;
String
accessKeySecret
=
""
;
String
endpoint
=
""
;
String
bucket
=
""
;
String
ossdir
=
""
;
String
transcodeBucket
=
""
;
String
REGION
;
String
mediaVedioWorkFlowId
;
String
mediaMp3WorkFlowId
;
String
workFlowId
;
ResourceBundle
rb
=
ResourceBundle
.
getBundle
(
"aliyunAccessKey"
);
if
(
"dev"
.
equals
(
active
)||
"sit"
.
equals
(
active
)||
"uat"
.
equals
(
active
))
{
accessKeyId
=
rb
.
getString
(
"accessKeyId"
);
accessKeySecret
=
rb
.
getString
(
"accessKeySecret"
);
endpoint
=
rb
.
getString
(
"endpoint"
);
bucket
=
rb
.
getString
(
"bucket"
);
ossdir
=
rb
.
getString
(
"ossdir"
);
transcodeBucket
=
rb
.
getString
(
"transcodeBucket"
);
REGION
=
rb
.
getString
(
"REGION"
);
// mediaVedioWorkFlowId = rb.getString("mediaVedioWorkFlowId");
// mediaMp3WorkFlowId = rb.getString("mediaMp3WorkFlowId");
workFlowId
=
rb
.
getString
(
"workFlowId"
);
}
else
{
accessKeyId
=
rb
.
getString
(
"accessKeyId_prod"
);
accessKeySecret
=
rb
.
getString
(
"accessKeySecret_prod"
);
endpoint
=
rb
.
getString
(
"endpoint_prod"
);
bucket
=
rb
.
getString
(
"bucket_prod"
);
ossdir
=
rb
.
getString
(
"ossdir_prod"
);
transcodeBucket
=
rb
.
getString
(
"transcodeBucket_prod"
);
REGION
=
rb
.
getString
(
"REGION_prod"
);
// mediaVedioWorkFlowId = rb.getString("mediaVedioWorkFlowId_prod");
// mediaMp3WorkFlowId = rb.getString("mediaMp3WorkFlowId_prod");
workFlowId
=
rb
.
getString
(
"workFlowId_prod"
);
}
map
.
put
(
"accessKeyId"
,
accessKeyId
);
map
.
put
(
"accessKeySecret"
,
accessKeySecret
);
map
.
put
(
"endpoint"
,
endpoint
);
map
.
put
(
"bucket"
,
bucket
);
map
.
put
(
"ossdir"
,
ossdir
);
map
.
put
(
"transcodeBucket"
,
transcodeBucket
);
map
.
put
(
"REGION"
,
REGION
);
// map.put("mediaVedioWorkFlowId", mediaVedioWorkFlowId);
// map.put("mediaMp3WorkFlowId", mediaMp3WorkFlowId);
map
.
put
(
"workFlowId"
,
workFlowId
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
map
;
}
}
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/util/UploadVideoUtil.java
0 → 100644
View file @
fa5aeaee
package
com
.
yizhi
.
aliyun
.
application
.
util
;
import
com.aliyuncs.DefaultAcsClient
;
import
com.aliyuncs.exceptions.ClientException
;
import
com.aliyuncs.exceptions.ServerException
;
import
com.aliyuncs.profile.DefaultProfile
;
import
com.aliyuncs.vod.model.v20170321.CreateUploadVideoRequest
;
import
com.aliyuncs.vod.model.v20170321.CreateUploadVideoResponse
;
import
com.aliyuncs.vod.model.v20170321.RefreshUploadVideoRequest
;
import
com.aliyuncs.vod.model.v20170321.RefreshUploadVideoResponse
;
import
java.util.Map
;
public
class
UploadVideoUtil
{
private
static
String
accessKeyId
=
""
;
private
static
String
accessKeySecret
=
""
;
/**
* 获取视频上传凭证和地址
* @param client
* @return
*/
public
static
String
createUploadVideo
(
DefaultAcsClient
client
,
Map
<
String
,
Object
>
map
)
{
CreateUploadVideoRequest
request
=
new
CreateUploadVideoRequest
();
CreateUploadVideoResponse
response
=
null
;
try
{
/*必选,视频源文件名称(必须带后缀, 支持 ".3gp", ".asf", ".avi", ".dat", ".dv", ".flv", ".f4v", ".gif", ".m2t", ".m3u8", ".m4v", ".mj2", ".mjpeg", ".mkv", ".mov", ".mp4", ".mpe", ".mpg", ".mpeg", ".mts", ".ogg", ".qt", ".rm", ".rmvb", ".swf", ".ts", ".vob", ".wmv", ".webm"".aac", ".ac3", ".acm", ".amr", ".ape", ".caf", ".flac", ".m4a", ".mp3", ".ra", ".wav", ".wma")*/
request
.
setFileName
(
map
.
get
(
"fileName"
).
toString
());
//必选,视频标题
request
.
setTitle
(
map
.
get
(
"title"
).
toString
());
if
(
map
.
containsKey
(
"cateId"
)){
//可选,分类ID
request
.
setCateId
((
Integer
)
map
.
get
(
"cateId"
));
}
if
(
map
.
containsKey
(
"tags"
)){
//可选,视频标签,多个用逗号分隔
request
.
setTags
(
map
.
get
(
"tags"
).
toString
());
}
if
(
map
.
containsKey
(
"description"
)){
//可选,视频描述
request
.
setDescription
(
map
.
get
(
"description"
).
toString
());
}
response
=
client
.
getAcsResponse
(
request
);
}
catch
(
ServerException
e
)
{
System
.
out
.
println
(
"CreateUploadVideoRequest Server Exception:"
);
e
.
printStackTrace
();
return
null
;
}
catch
(
ClientException
e
)
{
System
.
out
.
println
(
"CreateUploadVideoRequest Client Exception:"
);
e
.
printStackTrace
();
return
null
;
}
System
.
out
.
println
(
"RequestId:"
+
response
.
getRequestId
());
System
.
out
.
println
(
"UploadAuth:"
+
response
.
getUploadAuth
());
System
.
out
.
println
(
"UploadAddress:"
+
response
.
getUploadAddress
());
return
response
.
getVideoId
();
}
/**
* 刷新视频上传凭证
* @param client
* @return
*/
public
static
void
refreshUploadVideo
(
DefaultAcsClient
client
,
String
videoId
)
{
RefreshUploadVideoRequest
request
=
new
RefreshUploadVideoRequest
();
RefreshUploadVideoResponse
response
=
null
;
try
{
request
.
setVideoId
(
videoId
);
response
=
client
.
getAcsResponse
(
request
);
}
catch
(
ServerException
e
)
{
System
.
out
.
println
(
"RefreshUploadVideoRequest Server Exception:"
);
e
.
printStackTrace
();
return
;
}
catch
(
ClientException
e
)
{
System
.
out
.
println
(
"RefreshUploadVideoRequest Client Exception:"
);
e
.
printStackTrace
();
return
;
}
System
.
out
.
println
(
"RequestId:"
+
response
.
getRequestId
());
System
.
out
.
println
(
"UploadAuth:"
+
response
.
getUploadAuth
());
}
public
static
DefaultAcsClient
getAliyunClient
(){
DefaultAcsClient
aliyunClient
;
aliyunClient
=
new
DefaultAcsClient
(
DefaultProfile
.
getProfile
(
"cn-shanghai"
,
accessKeyId
,
accessKeySecret
));
return
aliyunClient
;
}
}
cloud-aliyun-service/src/main/java/com/yizhi/aliyun/application/util/VideoRequestUtil.java
0 → 100644
View file @
fa5aeaee
package
com
.
yizhi
.
aliyun
.
application
.
util
;
import
javax.crypto.Mac
;
import
javax.crypto.spec.SecretKeySpec
;
import
java.io.UnsupportedEncodingException
;
import
java.net.URLEncoder
;
import
java.security.SignatureException
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
public
class
VideoRequestUtil
{
//STS临时授权方式访问时该参数为必选,使用主账号AK和RAM子账号AK不需要填写
private
static
String
security_token
=
""
;
//以下参数不需要修改
private
final
static
String
VOD_DOMAIN
=
"https://vod.cn-shanghai.aliyuncs.com/"
;
private
final
static
String
ISO8601_DATE_FORMAT
=
"yyyy-MM-dd'T'HH:mm:ss'Z'"
;
private
final
static
String
HTTP_METHOD
=
"GET"
;
private
final
static
String
HMAC_SHA1_ALGORITHM
=
"HmacSHA1"
;
public
static
String
getOpenAPIURL
(
Map
<
String
,
String
>
privateParams
){
//生成公共参数
Map
<
String
,
String
>
publicParams
=
generatePublicParamters
();
//生成OpenAPI地址
String
URL
=
generateOpenAPIURL
(
publicParams
,
privateParams
);
return
URL
;
}
/**
* 生成视频点播OpenAPI公共参数
* 不需要修改
* @return
*/
private
static
Map
<
String
,
String
>
generatePublicParamters
()
{
Map
<
String
,
String
>
publicParams
=
new
HashMap
<
String
,
String
>();
publicParams
.
put
(
"Format"
,
"JSON"
);
publicParams
.
put
(
"Version"
,
"2017-03-21"
);
// publicParams.put("AccessKeyId", access_key_id);
publicParams
.
put
(
"SignatureMethod"
,
"HMAC-SHA1"
);
publicParams
.
put
(
"Timestamp"
,
generateTimestamp
());
publicParams
.
put
(
"SignatureVersion"
,
"1.0"
);
publicParams
.
put
(
"SignatureNonce"
,
generateRandom
());
if
(
security_token
!=
null
&&
security_token
.
length
()
>
0
)
{
publicParams
.
put
(
"SecurityToken"
,
security_token
);
}
return
publicParams
;
}
/**
* 生成OpenAPI地址
* @param privateParams
* @return
* @throws Exception
*/
private
static
String
generateOpenAPIURL
(
Map
<
String
,
String
>
publicParams
,
Map
<
String
,
String
>
privateParams
)
{
publicParams
.
put
(
"AccessKeyId"
,
privateParams
.
get
(
"access_key_id"
));
privateParams
.
remove
(
"access_key_id"
);
return
generateURL
(
VOD_DOMAIN
,
HTTP_METHOD
,
publicParams
,
privateParams
);
}
/**
* @param domain 请求地址
* @param httpMethod HTTP请求方式GET,POST等
* @param publicParams 公共参数
* @param privateParams 接口的私有参数
* @return 最后的url
*/
private
static
String
generateURL
(
String
domain
,
String
httpMethod
,
Map
<
String
,
String
>
publicParams
,
Map
<
String
,
String
>
privateParams
)
{
List
<
String
>
allEncodeParams
=
getAllParams
(
publicParams
,
privateParams
);
String
cqsString
=
getCQS
(
allEncodeParams
);
String
stringToSign
=
httpMethod
+
"&"
+
percentEncode
(
"/"
)
+
"&"
+
percentEncode
(
cqsString
);
String
access_key_secret
=
privateParams
.
get
(
"access_key_secret"
);
String
signature
=
hmacSHA1Signature
(
access_key_secret
,
stringToSign
);
privateParams
.
remove
(
"access_key_secret"
);
return
domain
+
"?"
+
cqsString
+
"&"
+
percentEncode
(
"Signature"
)
+
"="
+
percentEncode
(
signature
);
}
private
static
List
<
String
>
getAllParams
(
Map
<
String
,
String
>
publicParams
,
Map
<
String
,
String
>
privateParams
)
{
List
<
String
>
encodeParams
=
new
ArrayList
<
String
>();
if
(
publicParams
!=
null
)
{
for
(
String
key
:
publicParams
.
keySet
())
{
String
value
=
publicParams
.
get
(
key
);
String
encodeKey
=
percentEncode
(
key
);
String
encodeVal
=
percentEncode
(
value
);
encodeParams
.
add
(
encodeKey
+
"="
+
encodeVal
);
}
}
if
(
privateParams
!=
null
)
{
for
(
String
key
:
privateParams
.
keySet
())
{
String
value
=
privateParams
.
get
(
key
);
//将参数和值都urlEncode一下。
String
encodeKey
=
percentEncode
(
key
);
String
encodeVal
=
percentEncode
(
value
);
encodeParams
.
add
(
encodeKey
+
"="
+
encodeVal
);
}
}
return
encodeParams
;
}
/**
* 参数urlEncode
*
* @param value
* @return
*/
private
static
String
percentEncode
(
String
value
)
{
try
{
String
urlEncodeOrignStr
=
URLEncoder
.
encode
(
value
,
"UTF-8"
);
String
plusReplaced
=
urlEncodeOrignStr
.
replace
(
"+"
,
"%20"
);
String
starReplaced
=
plusReplaced
.
replace
(
"*"
,
"%2A"
);
String
waveReplaced
=
starReplaced
.
replace
(
"%7E"
,
"~"
);
return
waveReplaced
;
}
catch
(
UnsupportedEncodingException
e
)
{
e
.
printStackTrace
();
}
return
value
;
}
/**
* 获取CQS 的字符串
*
* @param allParams
* @return
*/
private
static
String
getCQS
(
List
<
String
>
allParams
)
{
VideoRequestUtil
.
ParamsComparator
paramsComparator
=
new
VideoRequestUtil
.
ParamsComparator
();
Collections
.
sort
(
allParams
,
paramsComparator
);
String
cqString
=
""
;
for
(
int
i
=
0
;
i
<
allParams
.
size
();
i
++)
{
cqString
+=
allParams
.
get
(
i
);
if
(
i
!=
allParams
.
size
()
-
1
)
{
cqString
+=
"&"
;
}
}
return
cqString
;
}
private
static
class
ParamsComparator
implements
Comparator
<
String
>
{
public
int
compare
(
String
lhs
,
String
rhs
)
{
return
lhs
.
compareTo
(
rhs
);
}
}
private
static
String
hmacSHA1Signature
(
String
accessKeySecret
,
String
stringtoSign
)
{
try
{
String
key
=
accessKeySecret
+
"&"
;
try
{
SecretKeySpec
signKey
=
new
SecretKeySpec
(
key
.
getBytes
(),
HMAC_SHA1_ALGORITHM
);
Mac
mac
=
Mac
.
getInstance
(
HMAC_SHA1_ALGORITHM
);
mac
.
init
(
signKey
);
byte
[]
rawHmac
=
mac
.
doFinal
(
stringtoSign
.
getBytes
());
//按照Base64 编码规则把上面的 HMAC 值编码成字符串,即得到签名值(Signature)
return
Base64
.
getEncoder
().
encodeToString
(
rawHmac
);
// return new String(new BASE64Encoder().encode(rawHmac));
}
catch
(
Exception
e
)
{
throw
new
SignatureException
(
"Failed to generate HMAC : "
+
e
.
getMessage
());
}
}
catch
(
SignatureException
e
)
{
e
.
printStackTrace
();
}
return
""
;
}
/**
* 生成随机数
*
* @return
*/
private
static
String
generateRandom
()
{
String
signatureNonce
=
UUID
.
randomUUID
().
toString
();
return
signatureNonce
;
}
/**
* 生成当前UTC时间戳
*
* @return
*/
public
static
String
generateTimestamp
()
{
Date
date
=
new
Date
(
System
.
currentTimeMillis
());
SimpleDateFormat
df
=
new
SimpleDateFormat
(
ISO8601_DATE_FORMAT
);
df
.
setTimeZone
(
new
SimpleTimeZone
(
0
,
"GMT"
));
return
df
.
format
(
date
);
}
}
cloud-aliyun-service/src/main/resources/aliyunAccessKey.properties
0 → 100644
View file @
fa5aeaee
# 阿里云 oss access_key_id access_key_id access_key_secret
accessKeyId
=
LTAInZlfTwk5fCDJ
accessKeySecret
=
UavtbFb2vUvRxiwUMLvUEelXTQtHCB
endpoint
=
oss-cn-hangzhou.aliyuncs.com
bucket
=
fulan-test
ossdir
=
test
# 媒体解析
transcodeBucket
=
test-wmy-transcoding-origin
REGION
=
cn-hangzhou
workFlowId
=
4ab10a061d59488481def0903f44f3e8
# ������
accessKeyId_prod
=
LTAIeBliOjnD6v25
accessKeySecret_prod
=
qd6iAV7tUvumvEiXxv9IGJbSdHcnmH
endpoint_prod
=
oss-cn-shanghai.aliyuncs.com
bucket_prod
=
cloud-wmy
ossdir_prod
=
wmy
transcodeBucket_prod
=
wmy-transcoding-origin
REGION_prod
=
cn-shanghai
#mediaVedioWorkFlowId_prod = 322c16126e934d1aadfb211a10730a74
#mediaMp3WorkFlowId_prod = 322c16126e934d1aadfb211a10730a74
workFlowId_prod
=
322c16126e934d1aadfb211a10730a74
\ No newline at end of file
cloud-aliyun-service/src/main/resources/bootstrap.properties
0 → 100644
View file @
fa5aeaee
server.port
=
31234
spring.application.name
=
aliyun
ACTIVE
=
${spring.profiles.active}
spring.profiles.active
=
dev
# nacos
spring.cloud.nacos.config.shared-dataids
=
common-${spring.profiles.active}.properties
spring.cloud.nacos.config.namespace
=
${spring.profiles.active}
spring.cloud.nacos.config.prefix
=
${spring.application.name}
spring.cloud.nacos.config.file-extension
=
properties
#spring.cloud.nacos.config.server-addr=192.168.0.203:8848
spring.cloud.nacos.config.server-addr
=
192.168.1.22:3333,192.168.1.22:4444,192.168.1.22:5555
\ No newline at end of file
cloud-aliyun-service/src/main/resources/generatorConfig.xml
0 → 100644
View file @
fa5aeaee
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE generatorConfiguration PUBLIC
"-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
<generatorConfiguration>
<classPathEntry
location=
"/Users/chengchenglong/.m2/repository/mysql/mysql-connector-java/5.1.35/mysql-connector-java-5.1.35.jar"
/>
<context
id=
"tplat-bd"
defaultModelType=
"flat"
>
<plugin
type=
"org.mybatis.generator.plugins.CaseInsensitiveLikePlugin"
/>
<plugin
type=
"org.mybatis.generator.plugins.EqualsHashCodePlugin"
/>
<plugin
type=
"org.mybatis.generator.plugins.ToStringPlugin"
/>
<plugin
type=
"org.mybatis.generator.plugins.RowBoundsPlugin"
/>
<plugin
type=
"org.mybatis.generator.plugins.SerializablePlugin"
>
<property
name=
"suppressJavaInterface"
value=
"false"
/>
</plugin>
<commentGenerator>
<property
name=
"suppressAllComments"
value=
"true"
/>
</commentGenerator>
<jdbcConnection
driverClass=
"com.mysql.jdbc.Driver"
connectionURL=
"jdbc:mysql://220.248.15.46:26532/cloud_aliyun"
userId=
"devDB"
password=
"devDB@123"
/>
<!-- <jdbcConnection driverClass="com.mysql.jdbc.Driver"-->
<!-- connectionURL="jdbc:mysql://180.169.149.5:11306/cloud_aliyun"-->
<!-- userId="root" password="fulan123"/>-->
<javaModelGenerator
targetPackage=
"com.yizhi.application"
targetProject=
"/Users/chengchenglong/mybatisGenerator"
/>
<sqlMapGenerator
targetPackage=
"com.fulan.application"
targetProject=
"/Users/chengchenglong/mybatisGenerator"
/>
<javaClientGenerator
targetPackage=
"com.fulan.application"
targetProject=
"/Users/chengchenglong/mybatisGenerator"
type=
"XMLMAPPER"
/>
<table
tableName=
"add_media_response_record"
domainObjectName=
"AddMediaResponseRecord"
alias=
"tb"
enableCountByExample=
"false"
enableSelectByExample=
"false"
enableUpdateByExample=
"false"
enableDeleteByExample=
"false"
>
</table>
</context>
</generatorConfiguration>
\ No newline at end of file
cloud-aliyun-service/src/test/java/com/yizhi/aliyun/application/CourseTest.java
0 → 100644
View file @
fa5aeaee
package
com
.
yizhi
.
aliyun
.
application
;
import
com.yizhi.aliyun.application.controller.AddMediaController
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.test.context.junit4.SpringRunner
;
@RunWith
(
SpringRunner
.
class
)
@SpringBootTest
public
class
CourseTest
{
@Autowired
private
AddMediaController
addMediaController
;
@Test
public
void
test
()
{
addMediaController
.
dealFinishedTranscoding
();
}
}
pom.xml
0 → 100644
View file @
fa5aeaee
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<parent>
<groupId>
com.yizhi
</groupId>
<artifactId>
wmy-parent
</artifactId>
<version>
1.0-SNAPSHOT
</version>
<relativePath/>
</parent>
<groupId>
com.yizhi
</groupId>
<artifactId>
cloud-aliyun
</artifactId>
<version>
1.0-SNAPSHOT
</version>
<modules>
<module>
cloud-aliyun-api
</module>
<module>
cloud-aliyun-service
</module>
</modules>
<packaging>
pom
</packaging>
<repositories>
<repository>
<id>
wmy4.0
</id>
<url>
http://mvn.km365.pw/nexus/content/groups/wmy4.0-group/
</url>
<releases>
<enabled>
true
</enabled>
</releases>
<snapshots>
<enabled>
true
</enabled>
<updatePolicy>
always
</updatePolicy>
</snapshots>
</repository>
</repositories>
</project>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment