commit 7ff836858689d304e95cda5fa449f4ceeea4ca71 Author: sikadi <13315935+sikadi_love@user.noreply.gitee.com> Date: Thu Nov 2 19:47:49 2023 +0800 初始化 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5ff6309 --- /dev/null +++ b/.gitignore @@ -0,0 +1,38 @@ +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### IntelliJ IDEA ### +.idea/modules.xml +.idea/jarRepositories.xml +.idea/compiler.xml +.idea/libraries/ +*.iws +*.iml +*.ipr + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..35410ca --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# 默认忽略的文件 +/shelf/ +/workspace.xml +# 基于编辑器的 HTTP 客户端请求 +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/aws.xml b/.idea/aws.xml new file mode 100644 index 0000000..b63b642 --- /dev/null +++ b/.idea/aws.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..a37ae30 --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..82dbec8 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,14 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml new file mode 100644 index 0000000..2b63946 --- /dev/null +++ b/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c37f254 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +FROM anolis-registry.cn-zhangjiakou.cr.aliyuncs.com/openanolis/openjdk:17-8.6 + + +# 暴露端口号 +EXPOSE 10011/tcp + + +# 挂载目录位置 +VOLUME /home/logs/grail-interrogation + +#构造 复制外部文件到docker 内部 +COPY /grail-patient-video-server/target/grail-patient-video-server.jar /home/app.jar + +# 工作目录 exec -it 进来就是默认这个目录 +WORKDIR /home + +# 启动java程序 +CMD ["java","-Dfile.encoding=UTF-8","-jar","/home/app.jar"] diff --git a/grail-patient-video-common/.gitignore b/grail-patient-video-common/.gitignore new file mode 100644 index 0000000..5ff6309 --- /dev/null +++ b/grail-patient-video-common/.gitignore @@ -0,0 +1,38 @@ +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### IntelliJ IDEA ### +.idea/modules.xml +.idea/jarRepositories.xml +.idea/compiler.xml +.idea/libraries/ +*.iws +*.iml +*.ipr + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/grail-patient-video-common/pom.xml b/grail-patient-video-common/pom.xml new file mode 100644 index 0000000..0060c44 --- /dev/null +++ b/grail-patient-video-common/pom.xml @@ -0,0 +1,52 @@ + + + 4.0.0 + + com.grail + grail-patient-video + 3.6.3 + + + grail-patient-video-common + + + 17 + 17 + UTF-8 + + + + com.grail + grail-common-core + + + com.grail + grail-common-redis + + + org.projectlombok + lombok + + + com.fasterxml.jackson.core + jackson-annotations + + + org.springframework.boot + spring-boot-actuator-autoconfigure + + + org.webjars.bower + jquery-jsonview + 1.2.2 + + + com.github.developframework + jsonview4-core + 4.0.0 + + + + diff --git a/grail-patient-video-common/src/main/java/com/grail/util/CommonUtil.java b/grail-patient-video-common/src/main/java/com/grail/util/CommonUtil.java new file mode 100644 index 0000000..fa0f60e --- /dev/null +++ b/grail-patient-video-common/src/main/java/com/grail/util/CommonUtil.java @@ -0,0 +1,20 @@ +package com.grail.util; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @description: TODO + * @author: SIKADI + * @date: 2023/11/1 21:26 + **/ + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class CommonUtil { + + private String UUID; + +} diff --git a/grail-patient-video-common/src/main/java/com/grail/util/QiniuUtils.java b/grail-patient-video-common/src/main/java/com/grail/util/QiniuUtils.java new file mode 100644 index 0000000..122e745 --- /dev/null +++ b/grail-patient-video-common/src/main/java/com/grail/util/QiniuUtils.java @@ -0,0 +1,128 @@ +package com.grail.util; + +/** + * @ClassName QiniuUtils + * @Author ylh + * @Date 2022/11/25 9:59 + * @Description + */ + +import com.qiniu.common.QiniuException; +import com.qiniu.http.Response; +import com.google.gson.Gson; +import com.qiniu.processing.OperationManager; +import com.qiniu.storage.BucketManager; +import com.qiniu.storage.Configuration; +import com.qiniu.storage.UploadManager; +import com.qiniu.storage.model.DefaultPutRet; +import com.qiniu.util.Auth; +import com.qiniu.util.StringMap; +import com.qiniu.util.UrlSafeBase64; + +/** + * @author zhubayi + * 七牛云工具类 + */ +public class QiniuUtils { + private static String accessKey = "KvDlBLKAEbikaDuHVFbtyRJtRR4bqGJJLWHCX7H7"; + private static String secretKey = "rU94egKJlKuU_8seffV3es6rLpzi7r-YKsgj90mO"; + private static String bucket = "duxin-ylh"; + //上传文件 + public static void upload2Qiniu(String filePath,String fileName){ + //构造一个带指定Zone对象的配置类 + Configuration cfg = new Configuration(); + UploadManager uploadManager = new UploadManager(cfg); + Auth auth = Auth.create(accessKey, secretKey); + String upToken = auth.uploadToken(bucket); + try { + Response response = uploadManager.put(filePath, fileName, upToken); + //解析上传成功的结果 + DefaultPutRet putRet = + new Gson().fromJson(response.bodyString(), DefaultPutRet.class); + } catch (QiniuException ex) { + Response r = ex.response; + try { + System.err.println(r.bodyString()); + } catch (QiniuException ex2) { + //ignore + } + } + } + //上传文件 + public static String upload2Qiniu(byte[] bytes, String fileName){ + //构造一个带指定Zone对象的配置类 + Configuration cfg = new Configuration(); + //...其他参数参考类注释 + UploadManager uploadManager = new UploadManager(cfg); + //默认不指定key的情况下,以文件内容的hash值作为文件名 + String key = fileName; + Auth auth = Auth.create(accessKey, secretKey); + String upToken = auth.uploadToken(bucket); + try { + Response response = uploadManager.put(bytes, key, upToken); + //解析上传成功的结果 + DefaultPutRet putRet = + new Gson().fromJson(response.bodyString(), DefaultPutRet.class); +// System.out.println(putRet.key); +// System.out.println(putRet.hash); + return putRet.key; + } catch (QiniuException ex) { + Response r = ex.response; + System.err.println(r.toString()); + try { + System.err.println(r.bodyString()); + } catch (QiniuException ex2) { + //ignore + } + } + return null; + } + + //删除文件 + public static void deleteFileFromQiniu(String fileName){ + //构造一个带指定Zone对象的配置类 + Configuration cfg = new Configuration(); + String key = fileName; + Auth auth = Auth.create(accessKey, secretKey); + BucketManager bucketManager = new BucketManager(auth, cfg); + try { + bucketManager.delete(bucket, key); + } catch (QiniuException ex) { + //如果遇到异常,说明删除失败 + System.err.println(ex.code()); + System.err.println(ex.response.toString()); + } + } + + public static String transcoding(String name,String UUID) { + + Auth auth = Auth.create(accessKey, secretKey); + +// String key = "ce104c91-7f82-493a-9ea6-71afae7e76c44.mp4"; + //存储空间中视频的文件名称 + String newName= UUID; +// String newKey = "H264_type.mp4"; //转码后,另存的文件名称 + String pipeline = "default.sys"; //处理队列 + + Configuration cfg = new Configuration(); + + String saveAs = UrlSafeBase64.encodeToString(bucket + ":" + newName); //saveas接口 参数 + String fops = "avthumb/mp4/vcodec/libx264|saveas/" + saveAs; //处理命令 avthumb 和 saveas 通过管道符 | 进行连接 + OperationManager operationMgr= new OperationManager(auth,cfg); + + try { + //执行转码和另存 操作 + String persistentId = operationMgr.pfop(bucket, name, fops, new StringMap().put("persistentPipeline", pipeline)); + System.out.println(persistentId); + } catch (QiniuException e) { + String errorCode = String.valueOf(e.response.statusCode); + System.out.println(errorCode); + e.printStackTrace(); + } + return newName; + } + + +} + + diff --git a/grail-patient-video-remote/.gitignore b/grail-patient-video-remote/.gitignore new file mode 100644 index 0000000..5ff6309 --- /dev/null +++ b/grail-patient-video-remote/.gitignore @@ -0,0 +1,38 @@ +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### IntelliJ IDEA ### +.idea/modules.xml +.idea/jarRepositories.xml +.idea/compiler.xml +.idea/libraries/ +*.iws +*.iml +*.ipr + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/grail-patient-video-remote/pom.xml b/grail-patient-video-remote/pom.xml new file mode 100644 index 0000000..08ad7d2 --- /dev/null +++ b/grail-patient-video-remote/pom.xml @@ -0,0 +1,28 @@ + + + 4.0.0 + + com.grail + grail-patient-video + 3.6.3 + + + grail-patient-video-remote + + + 17 + 17 + UTF-8 + + + + + com.grail + grail-patient-video-common + 3.6.3 + + + + diff --git a/grail-patient-video-remote/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/grail-patient-video-remote/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 0000000..139597f --- /dev/null +++ b/grail-patient-video-remote/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1,2 @@ + + diff --git a/grail-patient-video-server/.gitignore b/grail-patient-video-server/.gitignore new file mode 100644 index 0000000..5ff6309 --- /dev/null +++ b/grail-patient-video-server/.gitignore @@ -0,0 +1,38 @@ +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### IntelliJ IDEA ### +.idea/modules.xml +.idea/jarRepositories.xml +.idea/compiler.xml +.idea/libraries/ +*.iws +*.iml +*.ipr + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/grail-patient-video-server/pom.xml b/grail-patient-video-server/pom.xml new file mode 100644 index 0000000..87b60c4 --- /dev/null +++ b/grail-patient-video-server/pom.xml @@ -0,0 +1,132 @@ + + + + com.grail + grail-patient-video + 3.6.3 + + + 3.6.3 + 4.0.0 + + + 17 + 17 + UTF-8 + + grail-patient-video-server + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-config + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-sentinel + + + + + org.springframework.boot + spring-boot-starter-actuator + + + + + io.springfox + springfox-swagger-ui + ${swagger.fox.version} + + + + + mysql + mysql-connector-java + + + + + com.grail + grail-common-datasource + + + + + com.grail + grail-common-datascope + + + + + com.grail + grail-common-log + + + + + com.grail + grail-common-swagger + + + + + com.grail + grail-patient-video-common + 3.6.3 + + + + com.grail + grail-patient-video-remote + 3.6.3 + + + + com.squareup.okhttp3 + okhttp + 3.14.2 + compile + + + com.google.code.gson + gson + 2.8.5 + compile + + + com.qiniu + happy-dns-java + 0.1.6 + test + + + + + ${project.artifactId} + + + org.springframework.boot + spring-boot-maven-plugin + + + + repackage + + + + + + + diff --git a/grail-patient-video-server/src/main/java/com/grail/video/GrailVideoApplication.java b/grail-patient-video-server/src/main/java/com/grail/video/GrailVideoApplication.java new file mode 100644 index 0000000..b1802d1 --- /dev/null +++ b/grail-patient-video-server/src/main/java/com/grail/video/GrailVideoApplication.java @@ -0,0 +1,23 @@ +package com.grail.video; + +import com.grail.common.security.annotation.EnableCustomConfig; +import com.grail.common.security.annotation.EnableRyFeignClients; +import com.grail.common.swagger.annotation.EnableCustomSwagger2; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * @description: TODO + * @author: SIKADI + * @date: 2023/11/1 9:30 + **/ +@EnableCustomConfig +@EnableCustomSwagger2 +@EnableRyFeignClients +@SpringBootApplication +public class GrailVideoApplication { + public static void main(String[] args) { + SpringApplication.run(GrailVideoApplication.class); + } + +} diff --git a/grail-patient-video-server/src/main/java/com/grail/video/controller/Controller.java b/grail-patient-video-server/src/main/java/com/grail/video/controller/Controller.java new file mode 100644 index 0000000..1b3e707 --- /dev/null +++ b/grail-patient-video-server/src/main/java/com/grail/video/controller/Controller.java @@ -0,0 +1,94 @@ +package com.grail.video.controller; + +import com.google.gson.Gson; +import com.grail.common.core.config.QiNiuConfig; +import com.grail.common.core.domain.R; +import com.grail.common.core.utils.QiNiuUpload; +import com.grail.common.core.utils.QiNiuUtil; +import com.grail.util.QiniuUtils; +import com.qiniu.common.QiniuException; +import com.qiniu.http.Response; +import com.qiniu.storage.Configuration; +import com.qiniu.storage.Region; +import com.qiniu.storage.UploadManager; +import com.qiniu.storage.model.DefaultPutRet; +import com.qiniu.storage.persistent.FileRecorder; +import com.qiniu.util.Auth; +import lombok.extern.log4j.Log4j2; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.multipart.MultipartFile; + +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.UUID; + +/** + * @description: TODO + * @author: SIKADI + * @date: 2023/11/2 0:11 + **/ +@RestController +@RequestMapping("/video") +@Log4j2 +public class Controller { + + + /** + * 上传视频 + * @author: ZhuoXin + * @date: 2023/11/2 11:01 + * @param: [file] + * @return: java.lang.String + **/ + @PostMapping("/video") + public R video(@RequestParam("file")MultipartFile file) throws UnsupportedEncodingException { + String b = new QiNiuUpload().uploadVideo(file); + String b1 = "http://s30y1cerv.hd-bkt.clouddn.com/is" + b + "att.mp4"; + return R.ok(b1); + + } + + @PostMapping("/upload") + public R handleFileUpload(@RequestParam("file") MultipartFile file) { + + String localFilePath = file.getOriginalFilename(); + String key = UUID.randomUUID().toString().replaceAll("-", "").substring(1, 15); + Configuration cfg = new Configuration(Region.region0()); + Auth auth = Auth.create(QiNiuConfig.getInstance().getAccessKey(), QiNiuConfig.getInstance().getSecretKey()); + String upToken = auth.uploadToken(QiNiuConfig.getInstance().getBucket()); + String localTempDir = Paths.get(System.getenv("java.io.tmpdir"), QiNiuConfig.getInstance().getBucket()).toString(); + try { + //设置断点续传文件进度保存目录 + FileRecorder fileRecorder = new FileRecorder(localTempDir); + UploadManager uploadManager = new UploadManager(cfg, fileRecorder); + try { + Response response = uploadManager.put(localFilePath, key, upToken); + //解析上传成功的结果 + DefaultPutRet putRet = new Gson().fromJson(response.bodyString(), DefaultPutRet.class); + System.out.println(putRet.key); + System.out.println(putRet.hash); + } catch (QiniuException ex) { + ex.printStackTrace(); + if (ex.response != null) { + System.err.println(ex.response); + try { + String body = ex.response.toString(); + System.err.println(body); + log.info("实现:{}",body); + } catch (Exception ignored) { + } + } + } + } catch (IOException ex) { + ex.printStackTrace(); + } + return R.ok(); + } + +} diff --git a/grail-patient-video-server/src/main/resources/banner.txt b/grail-patient-video-server/src/main/resources/banner.txt new file mode 100644 index 0000000..0dd5eee --- /dev/null +++ b/grail-patient-video-server/src/main/resources/banner.txt @@ -0,0 +1,2 @@ +Spring Boot Version: ${spring-boot.version} +Spring Application Name: ${spring.application.name} diff --git a/grail-patient-video-server/src/main/resources/bootstrap.yml b/grail-patient-video-server/src/main/resources/bootstrap.yml new file mode 100644 index 0000000..4a308b5 --- /dev/null +++ b/grail-patient-video-server/src/main/resources/bootstrap.yml @@ -0,0 +1,33 @@ +# Tomcat +server: + port: 10011 + +# Spring +spring: + application: + # 应用名称 + name: grail-video + profiles: + # 环境配置 + active: dev + cloud: + nacos: + discovery: + # 服务注册地址 + server-addr: 10.100.1.3:8848 + config: + # 配置中心地址 + server-addr: 10.100.1.3:8848 + # 配置文件格式 + file-extension: yml + # 共享配置 + shared-configs: + - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} + rabbitmq: + host: 10.100.1.5 + + +mybatis: + configuration: + map-underscore-to-camel-case: true + diff --git a/grail-patient-video-server/src/main/resources/logback.xml b/grail-patient-video-server/src/main/resources/logback.xml new file mode 100644 index 0000000..384a0b9 --- /dev/null +++ b/grail-patient-video-server/src/main/resources/logback.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + ${log.pattern} + + + + + + ${log.path}/info.log + + + + ${log.path}/info.%d{yyyy-MM-dd}.log + + 60 + + + ${log.pattern} + + + + INFO + + ACCEPT + + DENY + + + + + ${log.path}/error.log + + + + ${log.path}/error.%d{yyyy-MM-dd}.log + + 60 + + + ${log.pattern} + + + + ERROR + + ACCEPT + + DENY + + + + + + + + + + + + + + + + + + diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..1c97063 --- /dev/null +++ b/pom.xml @@ -0,0 +1,30 @@ + + + + com.grail + grail-patient + 3.6.3 + + + 3.6.3 + 4.0.0 + + grail-patient-video-common + grail-patient-video-remote + grail-patient-video-server + + + + + 17 + 17 + UTF-8 + + + + grail-patient-video + pom + +