46 changed files with 2317 additions and 0 deletions
@ -0,0 +1,29 @@ |
|||
# Created by .ignore support plugin (hsz.mobi) |
|||
### Java template |
|||
# Compiled class file |
|||
*.class |
|||
|
|||
# Log file |
|||
*.log |
|||
|
|||
# BlueJ files |
|||
*.ctxt |
|||
|
|||
# Mobile Tools for Java (J2ME) |
|||
.mtj.tmp/ |
|||
|
|||
# Package Files # |
|||
*.jar |
|||
*.war |
|||
*.nar |
|||
*.ear |
|||
*.zip |
|||
*.tar.gz |
|||
*.rar |
|||
|
|||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml |
|||
hs_err_pid* |
|||
.idea/ |
|||
*.iml |
|||
**/target/ |
|||
|
@ -0,0 +1,12 @@ |
|||
[submodule "epdc-cloud-client-yushan"] |
|||
path = epdc-cloud-client-yushan |
|||
url = http://121.42.41.42:7070/r/epdc-cloud-client-yushan.git |
|||
[submodule "epdc-cloud-commons-yushan"] |
|||
path = epdc-cloud-commons-yushan |
|||
url = http://121.42.41.42:7070/r/epdc-cloud-commons-yushan.git |
|||
[submodule "epdc-cloud-gateway-yushan"] |
|||
path = epdc-cloud-gateway-yushan |
|||
url = http://121.42.41.42:7070/r/epdc-cloud-gateway-yushan.git |
|||
[submodule "epdc-cloud-parent-yushan"] |
|||
path = epdc-cloud-parent-yushan |
|||
url = http://121.42.41.42:7070/r/epdc-cloud-parent-yushan.git |
@ -0,0 +1,22 @@ |
|||
-- 文件上传 |
|||
CREATE TABLE sys_oss ( |
|||
id bigint NOT NULL COMMENT 'id', |
|||
url varchar(200) COMMENT 'URL地址', |
|||
creator bigint COMMENT '创建者', |
|||
create_date datetime COMMENT '创建时间', |
|||
PRIMARY KEY (id), |
|||
key idx_create_date (create_date) |
|||
) ENGINE=InnoDB DEFAULT CHARACTER SET utf8 COMMENT='文件上传'; |
|||
|
|||
INSERT INTO sys_menu(id, pid, url, type, icon, permissions, sort, del_flag, creator, create_date, updater, update_date) VALUES (1067246875800000060, 1067246875800000019, 'oss/oss', 0, 'icon-upload', '', 4, 0, 1067246875800000001, now(), 1067246875800000001, now()); |
|||
|
|||
INSERT INTO sys_language(table_name, table_id, field_name, field_value, language) VALUES ('sys_menu', 1067246875800000060, 'name', 'File Upload', 'en-US'); |
|||
INSERT INTO sys_language(table_name, table_id, field_name, field_value, language) VALUES ('sys_menu', 1067246875800000060, 'name', '文件上传', 'zh-CN'); |
|||
INSERT INTO sys_language(table_name, table_id, field_name, field_value, language) VALUES ('sys_menu', 1067246875800000060, 'name', '文件上傳', 'zh-TW'); |
|||
|
|||
INSERT INTO sys_resource(id, resource_code, resource_name, resource_url, resource_method, menu_flag, auth_level, creator, create_date, updater, update_date) VALUES (1067246875800000163, 1067246875800000060, '文件上传', '/oss/file', 'POST', 1, 0, 1067246875800000001, now(), 1067246875800000001, now()); |
|||
INSERT INTO sys_resource(id, resource_code, resource_name, resource_url, resource_method, menu_flag, auth_level, creator, create_date, updater, update_date) VALUES (1067246875800000164, 1067246875800000060, '文件上传', '/oss/file', 'DELETE', 1, 0, 1067246875800000001, now(), 1067246875800000001, now()); |
|||
INSERT INTO sys_resource(id, resource_code, resource_name, resource_url, resource_method, menu_flag, auth_level, creator, create_date, updater, update_date) VALUES (1067246875800000165, 1067246875800000060, '文件上传', '/oss/file/page', 'GET', 1, 0, 1067246875800000001, now(), 1067246875800000001, now()); |
|||
INSERT INTO sys_resource(id, resource_code, resource_name, resource_url, resource_method, menu_flag, auth_level, creator, create_date, updater, update_date) VALUES (1067246875800000166, 1067246875800000060, '文件上传', '/oss/file/info', 'GET', 1, 0, 1067246875800000001, now(), 1067246875800000001, now()); |
|||
|
|||
INSERT INTO sys_params(id, param_code, param_value, param_type, remark, del_flag, creator, create_date, updater, update_date) VALUES (1067246875800000167, 'CLOUD_STORAGE_CONFIG_KEY', '{"type":1,"qiniuDomain":"http://pgzjvphhb.bkt.clouddn.com","qiniuPrefix":"upload","qiniuAccessKey":"NrgMfABZxWLo5B-YYSjoE8-AZ1EISdi1Z3ubLOeZ","qiniuSecretKey":"uIwJHevMRWU0VLxFvgy0tAcOdGqasdtVlJkdy6vV","qiniuBucketName":"renren-oss","aliyunDomain":"","aliyunPrefix":"","aliyunEndPoint":"","aliyunAccessKeyId":"","aliyunAccessKeySecret":"","aliyunBucketName":"","qcloudDomain":"","qcloudPrefix":"","qcloudSecretId":"","qcloudSecretKey":"","qcloudBucketName":""}', '0', '云存储配置信息', 0, 1067246875800000001, now(), 1067246875800000001, now()); |
@ -0,0 +1,27 @@ |
|||
CREATE TABLE sys_oss ( |
|||
id NUMBER(20, 0) NOT NULL, |
|||
url varchar2(200), |
|||
creator NUMBER(20, 0), |
|||
create_date date, |
|||
PRIMARY KEY (id) |
|||
); |
|||
CREATE INDEX idx_sys_oss_create_date on sys_oss(create_date); |
|||
|
|||
COMMENT ON TABLE sys_oss IS '文件上传'; |
|||
COMMENT ON COLUMN sys_oss.id IS 'id'; |
|||
COMMENT ON COLUMN sys_oss.url IS 'URL地址'; |
|||
COMMENT ON COLUMN sys_mail_log.creator IS '创建者'; |
|||
COMMENT ON COLUMN sys_mail_log.create_date IS '创建时间'; |
|||
|
|||
INSERT INTO sys_menu(id, pid, url, type, icon, permissions, sort, del_flag, creator, create_date, updater, update_date) VALUES (1067246875800000060, 1067246875800000019, 'oss/oss', 0, 'icon-upload', '', 4, 0, 1067246875800000001, CURRENT_DATE, 1067246875800000001, CURRENT_DATE); |
|||
|
|||
INSERT INTO sys_language(table_name, table_id, field_name, field_value, language) VALUES ('sys_menu', 1067246875800000060, 'name', 'File Upload', 'en-US'); |
|||
INSERT INTO sys_language(table_name, table_id, field_name, field_value, language) VALUES ('sys_menu', 1067246875800000060, 'name', '文件上传', 'zh-CN'); |
|||
INSERT INTO sys_language(table_name, table_id, field_name, field_value, language) VALUES ('sys_menu', 1067246875800000060, 'name', '文件上傳', 'zh-TW'); |
|||
|
|||
INSERT INTO sys_resource(id, resource_code, resource_name, resource_url, resource_method, menu_flag, auth_level, creator, create_date, updater, update_date) VALUES (1067246875800000163, 1067246875800000060, '文件上传', '/oss/file', 'POST', 1, 0, 1067246875800000001, CURRENT_DATE, 1067246875800000001, CURRENT_DATE); |
|||
INSERT INTO sys_resource(id, resource_code, resource_name, resource_url, resource_method, menu_flag, auth_level, creator, create_date, updater, update_date) VALUES (1067246875800000164, 1067246875800000060, '文件上传', '/oss/file', 'DELETE', 1, 0, 1067246875800000001, CURRENT_DATE, 1067246875800000001, CURRENT_DATE); |
|||
INSERT INTO sys_resource(id, resource_code, resource_name, resource_url, resource_method, menu_flag, auth_level, creator, create_date, updater, update_date) VALUES (1067246875800000165, 1067246875800000060, '文件上传', '/oss/file/page', 'GET', 1, 0, 1067246875800000001, CURRENT_DATE, 1067246875800000001, CURRENT_DATE); |
|||
INSERT INTO sys_resource(id, resource_code, resource_name, resource_url, resource_method, menu_flag, auth_level, creator, create_date, updater, update_date) VALUES (1067246875800000166, 1067246875800000060, '文件上传', '/oss/file/info', 'GET', 1, 0, 1067246875800000001, CURRENT_DATE, 1067246875800000001, CURRENT_DATE); |
|||
|
|||
INSERT INTO sys_params(id, param_code, param_value, param_type, remark, del_flag, creator, create_date, updater, update_date) VALUES (1067246875800000167, 'CLOUD_STORAGE_CONFIG_KEY', '{"type":1,"qiniuDomain":"http://pgzjvphhb.bkt.clouddn.com","qiniuPrefix":"upload","qiniuAccessKey":"NrgMfABZxWLo5B-YYSjoE8-AZ1EISdi1Z3ubLOeZ","qiniuSecretKey":"uIwJHevMRWU0VLxFvgy0tAcOdGqasdtVlJkdy6vV","qiniuBucketName":"renren-oss","aliyunDomain":"","aliyunPrefix":"","aliyunEndPoint":"","aliyunAccessKeyId":"","aliyunAccessKeySecret":"","aliyunBucketName":"","qcloudDomain":"","qcloudPrefix":"","qcloudSecretId":"","qcloudSecretKey":"","qcloudBucketName":""}', '0', '云存储配置信息', 0, 1067246875800000001, CURRENT_DATE, 1067246875800000001, CURRENT_DATE); |
@ -0,0 +1,28 @@ |
|||
CREATE TABLE sys_oss ( |
|||
id int8 NOT NULL, |
|||
url varchar(200), |
|||
creator int8, |
|||
create_date timestamp, |
|||
PRIMARY KEY (id) |
|||
); |
|||
CREATE INDEX idx_sys_oss_create_date on sys_oss(create_date); |
|||
|
|||
COMMENT ON TABLE sys_oss IS '文件上传'; |
|||
COMMENT ON COLUMN sys_oss.id IS 'id'; |
|||
COMMENT ON COLUMN sys_oss.url IS 'URL地址'; |
|||
COMMENT ON COLUMN sys_mail_log.creator IS '创建者'; |
|||
COMMENT ON COLUMN sys_mail_log.create_date IS '创建时间'; |
|||
|
|||
|
|||
INSERT INTO sys_menu(id, pid, url, type, icon, permissions, sort, del_flag, creator, create_date, updater, update_date) VALUES (1067246875800000060, 1067246875800000019, 'oss/oss', 0, 'icon-upload', '', 4, 0, 1067246875800000001, CURRENT_DATE, 1067246875800000001, CURRENT_DATE); |
|||
|
|||
INSERT INTO sys_language(table_name, table_id, field_name, field_value, language) VALUES ('sys_menu', 1067246875800000060, 'name', 'File Upload', 'en-US'); |
|||
INSERT INTO sys_language(table_name, table_id, field_name, field_value, language) VALUES ('sys_menu', 1067246875800000060, 'name', '文件上传', 'zh-CN'); |
|||
INSERT INTO sys_language(table_name, table_id, field_name, field_value, language) VALUES ('sys_menu', 1067246875800000060, 'name', '文件上傳', 'zh-TW'); |
|||
|
|||
INSERT INTO sys_resource(id, resource_code, resource_name, resource_url, resource_method, menu_flag, auth_level, creator, create_date, updater, update_date) VALUES (1067246875800000163, 1067246875800000060, '文件上传', '/oss/file', 'POST', 1, 0, 1067246875800000001, CURRENT_DATE, 1067246875800000001, CURRENT_DATE); |
|||
INSERT INTO sys_resource(id, resource_code, resource_name, resource_url, resource_method, menu_flag, auth_level, creator, create_date, updater, update_date) VALUES (1067246875800000164, 1067246875800000060, '文件上传', '/oss/file', 'DELETE', 1, 0, 1067246875800000001, CURRENT_DATE, 1067246875800000001, CURRENT_DATE); |
|||
INSERT INTO sys_resource(id, resource_code, resource_name, resource_url, resource_method, menu_flag, auth_level, creator, create_date, updater, update_date) VALUES (1067246875800000165, 1067246875800000060, '文件上传', '/oss/file/page', 'GET', 1, 0, 1067246875800000001, CURRENT_DATE, 1067246875800000001, CURRENT_DATE); |
|||
INSERT INTO sys_resource(id, resource_code, resource_name, resource_url, resource_method, menu_flag, auth_level, creator, create_date, updater, update_date) VALUES (1067246875800000166, 1067246875800000060, '文件上传', '/oss/file/info', 'GET', 1, 0, 1067246875800000001, CURRENT_DATE, 1067246875800000001, CURRENT_DATE); |
|||
|
|||
INSERT INTO sys_params(id, param_code, param_value, param_type, remark, del_flag, creator, create_date, updater, update_date) VALUES (1067246875800000167, 'CLOUD_STORAGE_CONFIG_KEY', '{"type":1,"qiniuDomain":"http://pgzjvphhb.bkt.clouddn.com","qiniuPrefix":"upload","qiniuAccessKey":"NrgMfABZxWLo5B-YYSjoE8-AZ1EISdi1Z3ubLOeZ","qiniuSecretKey":"uIwJHevMRWU0VLxFvgy0tAcOdGqasdtVlJkdy6vV","qiniuBucketName":"renren-oss","aliyunDomain":"","aliyunPrefix":"","aliyunEndPoint":"","aliyunAccessKeyId":"","aliyunAccessKeySecret":"","aliyunBucketName":"","qcloudDomain":"","qcloudPrefix":"","qcloudSecretId":"","qcloudSecretKey":"","qcloudBucketName":""}', '0', '云存储配置信息', 0, 1067246875800000001, CURRENT_DATE, 1067246875800000001, CURRENT_DATE); |
@ -0,0 +1,22 @@ |
|||
CREATE TABLE sys_oss ( |
|||
id bigint NOT NULL, |
|||
url varchar(200), |
|||
creator bigint, |
|||
create_date datetime, |
|||
PRIMARY KEY (id) |
|||
); |
|||
CREATE INDEX idx_sys_oss_create_date on sys_oss(create_date); |
|||
|
|||
|
|||
INSERT INTO sys_menu(id, pid, url, type, icon, permissions, sort, del_flag, creator, create_date, updater, update_date) VALUES (1067246875800000060, 1067246875800000019, 'oss/oss', 0, 'icon-upload', '', 4, 0, 1067246875800000001, getdate(), 1067246875800000001, getdate()); |
|||
|
|||
INSERT INTO sys_language(table_name, table_id, field_name, field_value, language) VALUES ('sys_menu', 1067246875800000060, 'name', 'File Upload', 'en-US'); |
|||
INSERT INTO sys_language(table_name, table_id, field_name, field_value, language) VALUES ('sys_menu', 1067246875800000060, 'name', '文件上传', 'zh-CN'); |
|||
INSERT INTO sys_language(table_name, table_id, field_name, field_value, language) VALUES ('sys_menu', 1067246875800000060, 'name', '文件上傳', 'zh-TW'); |
|||
|
|||
INSERT INTO sys_resource(id, resource_code, resource_name, resource_url, resource_method, menu_flag, auth_level, creator, create_date, updater, update_date) VALUES (1067246875800000163, 1067246875800000060, '文件上传', '/oss/file', 'POST', 1, 0, 1067246875800000001, getdate(), 1067246875800000001, getdate()); |
|||
INSERT INTO sys_resource(id, resource_code, resource_name, resource_url, resource_method, menu_flag, auth_level, creator, create_date, updater, update_date) VALUES (1067246875800000164, 1067246875800000060, '文件上传', '/oss/file', 'DELETE', 1, 0, 1067246875800000001, getdate(), 1067246875800000001, getdate()); |
|||
INSERT INTO sys_resource(id, resource_code, resource_name, resource_url, resource_method, menu_flag, auth_level, creator, create_date, updater, update_date) VALUES (1067246875800000165, 1067246875800000060, '文件上传', '/oss/file/page', 'GET', 1, 0, 1067246875800000001, getdate(), 1067246875800000001, getdate()); |
|||
INSERT INTO sys_resource(id, resource_code, resource_name, resource_url, resource_method, menu_flag, auth_level, creator, create_date, updater, update_date) VALUES (1067246875800000166, 1067246875800000060, '文件上传', '/oss/file/info', 'GET', 1, 0, 1067246875800000001, getdate(), 1067246875800000001, getdate()); |
|||
|
|||
INSERT INTO sys_params(id, param_code, param_value, param_type, remark, del_flag, creator, create_date, updater, update_date) VALUES (1067246875800000167, 'CLOUD_STORAGE_CONFIG_KEY', '{"type":1,"qiniuDomain":"http://pgzjvphhb.bkt.clouddn.com","qiniuPrefix":"upload","qiniuAccessKey":"NrgMfABZxWLo5B-YYSjoE8-AZ1EISdi1Z3ubLOeZ","qiniuSecretKey":"uIwJHevMRWU0VLxFvgy0tAcOdGqasdtVlJkdy6vV","qiniuBucketName":"renren-oss","aliyunDomain":"","aliyunPrefix":"","aliyunEndPoint":"","aliyunAccessKeyId":"","aliyunAccessKeySecret":"","aliyunBucketName":"","qcloudDomain":"","qcloudPrefix":"","qcloudSecretId":"","qcloudSecretKey":"","qcloudBucketName":""}', '0', '云存储配置信息', 0, 1067246875800000001, getdate(), 1067246875800000001, getdate()); |
@ -0,0 +1,20 @@ |
|||
# 基础镜像 |
|||
FROM openjdk:8u242-jdk-buster |
|||
# 作者 |
|||
MAINTAINER rongchao@elink-cn.com |
|||
# 对应pom.xml文件中的dockerfile-maven-plugin插件JAR_FILE的值 |
|||
ARG JAR_FILE |
|||
# 对应pom.xml文件中的dockerfile-maven-plugin插件JAR_NAME的值 |
|||
ARG JAR_NAME |
|||
# 对应pom.xml文件中的dockerfile-maven-plugin插件SERVER_PORT的值 |
|||
ARG SERVER_PORT |
|||
# 复制打包完成后的jar文件到/opt目录下 |
|||
ENV JAR_PATH /mnt/epdc/${JAR_NAME}.jar |
|||
ADD ${JAR_FILE} $JAR_PATH |
|||
# /data设为环境变量 |
|||
ENV DATAPATH /data |
|||
# 挂载/data目录到主机 |
|||
VOLUME $DATAPATH |
|||
# 启动容器时执行 |
|||
ENTRYPOINT java -jar -Xmx1024m $JAR_PATH |
|||
EXPOSE ${SERVER_PORT} |
@ -0,0 +1,278 @@ |
|||
<?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.esua.epdc.yushan</groupId> |
|||
<artifactId>epdc-cloud-parent-yushan</artifactId> |
|||
<version>1.0.0</version> |
|||
<relativePath>../epdc-cloud-parent-yushan</relativePath> |
|||
</parent> |
|||
|
|||
<artifactId>epdc-cloud-oss</artifactId> |
|||
<packaging>jar</packaging> |
|||
<description>榆山党群e事通微服务对象存储服务</description> |
|||
|
|||
<properties> |
|||
<qiniu.version>[7.2.0, 7.2.99]</qiniu.version> |
|||
<aliyun.oss.version>3.5.0</aliyun.oss.version> |
|||
<aliyun.core.version>3.2.2</aliyun.core.version> |
|||
<qcloud.cos.version>5.4.4</qcloud.cos.version> |
|||
<fastdfs.version>1.26.2</fastdfs.version> |
|||
</properties> |
|||
|
|||
<dependencies> |
|||
<dependency> |
|||
<groupId>org.springframework.boot</groupId> |
|||
<artifactId>spring-boot-starter-web</artifactId> |
|||
</dependency> |
|||
|
|||
<dependency> |
|||
<groupId>org.springframework</groupId> |
|||
<artifactId>spring-context-support</artifactId> |
|||
</dependency> |
|||
|
|||
<dependency> |
|||
<groupId>com.alibaba.cloud</groupId> |
|||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId> |
|||
</dependency> |
|||
|
|||
<dependency> |
|||
<groupId>com.qiniu</groupId> |
|||
<artifactId>qiniu-java-sdk</artifactId> |
|||
<version>${qiniu.version}</version> |
|||
</dependency> |
|||
|
|||
<dependency> |
|||
<groupId>com.aliyun.oss</groupId> |
|||
<artifactId>aliyun-sdk-oss</artifactId> |
|||
<version>${aliyun.oss.version}</version> |
|||
</dependency> |
|||
|
|||
<dependency> |
|||
<groupId>com.qcloud</groupId> |
|||
<artifactId>cos_api</artifactId> |
|||
<version>${qcloud.cos.version}</version> |
|||
<exclusions> |
|||
<exclusion> |
|||
<groupId>org.slf4j</groupId> |
|||
<artifactId>slf4j-log4j12</artifactId> |
|||
</exclusion> |
|||
</exclusions> |
|||
</dependency> |
|||
|
|||
<dependency> |
|||
<groupId>com.aliyun</groupId> |
|||
<artifactId>aliyun-java-sdk-core</artifactId> |
|||
<version>${aliyun.core.version}</version> |
|||
</dependency> |
|||
|
|||
<dependency> |
|||
<groupId>com.github.tobato</groupId> |
|||
<artifactId>fastdfs-client</artifactId> |
|||
<version>${fastdfs.version}</version> |
|||
<exclusions> |
|||
<exclusion> |
|||
<groupId>commons-io</groupId> |
|||
<artifactId>commons-io</artifactId> |
|||
</exclusion> |
|||
</exclusions> |
|||
</dependency> |
|||
|
|||
<dependency> |
|||
<groupId>com.google.code.gson</groupId> |
|||
<artifactId>gson</artifactId> |
|||
<version>2.8.5</version> |
|||
</dependency> |
|||
|
|||
<dependency> |
|||
<groupId>com.alibaba.cloud</groupId> |
|||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId> |
|||
</dependency> |
|||
|
|||
<!-- client start --> |
|||
<dependency> |
|||
<groupId>com.esua.epdc.yushan</groupId> |
|||
<artifactId>epdc-cloud-oss-client</artifactId> |
|||
<version>${epdc-cloud-client.version}</version> |
|||
</dependency> |
|||
|
|||
<dependency> |
|||
<groupId>com.esua.epdc.yushan</groupId> |
|||
<artifactId>epdc-cloud-admin-client</artifactId> |
|||
<version>${epdc-cloud-client.version}</version> |
|||
</dependency> |
|||
<!-- client end --> |
|||
|
|||
<!-- commons start --> |
|||
<dependency> |
|||
<groupId>com.esua.epdc.yushan</groupId> |
|||
<artifactId>epdc-commons-tools</artifactId> |
|||
<version>${epdc-cloud-commons.version}</version> |
|||
</dependency> |
|||
|
|||
<dependency> |
|||
<groupId>com.esua.epdc.yushan</groupId> |
|||
<artifactId>epdc-commons-mybatis</artifactId> |
|||
<version>${epdc-cloud-commons.version}</version> |
|||
</dependency> |
|||
<!-- commons end --> |
|||
</dependencies> |
|||
|
|||
<build> |
|||
<finalName>${project.artifactId}</finalName> |
|||
<plugins> |
|||
<plugin> |
|||
<groupId>org.springframework.boot</groupId> |
|||
<artifactId>spring-boot-maven-plugin</artifactId> |
|||
</plugin> |
|||
<plugin> |
|||
<groupId>org.apache.maven.plugins</groupId> |
|||
<artifactId>maven-surefire-plugin</artifactId> |
|||
<configuration> |
|||
<skipTests>true</skipTests> |
|||
</configuration> |
|||
</plugin> |
|||
<plugin> |
|||
<groupId>org.apache.maven.plugins</groupId> |
|||
<artifactId>maven-deploy-plugin</artifactId> |
|||
<configuration> |
|||
<skip>true</skip> |
|||
</configuration> |
|||
</plugin> |
|||
<plugin> |
|||
<groupId>com.spotify</groupId> |
|||
<artifactId>dockerfile-maven-plugin</artifactId> |
|||
</plugin> |
|||
</plugins> |
|||
|
|||
<sourceDirectory>${project.basedir}/src/main/java</sourceDirectory> |
|||
|
|||
<resources> |
|||
<resource> |
|||
<filtering>true</filtering> |
|||
<directory>${basedir}/src/main/resources</directory> |
|||
<includes> |
|||
<include>**/application*.yml</include> |
|||
<include>**/*.properties</include> |
|||
<include>logback-spring.xml</include> |
|||
<include>registry.conf</include> |
|||
</includes> |
|||
</resource> |
|||
<resource> |
|||
<directory>${basedir}/src/main/resources</directory> |
|||
<excludes> |
|||
<exclude>**/application*.yml</exclude> |
|||
<exclude>**/*.properties</exclude> |
|||
<exclude>logback-spring.xml</exclude> |
|||
<exclude>registry.conf</exclude> |
|||
</excludes> |
|||
</resource> |
|||
</resources> |
|||
</build> |
|||
|
|||
<profiles> |
|||
<profile> |
|||
<id>dev</id> |
|||
<activation> |
|||
<activeByDefault>true</activeByDefault> |
|||
</activation> |
|||
<properties> |
|||
<spring.profiles.active>dev</spring.profiles.active> |
|||
<docker.tag>dev</docker.tag> |
|||
|
|||
<server.port>9065</server.port> |
|||
|
|||
<spring.redis.index>2</spring.redis.index> |
|||
<spring.redis.host>47.104.224.45</spring.redis.host> |
|||
<spring.redis.port>6379</spring.redis.port> |
|||
<spring.redis.password>elink@888</spring.redis.password> |
|||
|
|||
<spring.datasource.druid.url> |
|||
<![CDATA[jdbc:mysql://47.104.224.45:3308/esua_epdc_admin?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai]]> |
|||
</spring.datasource.druid.url> |
|||
<spring.datasource.druid.username>epdc</spring.datasource.druid.username> |
|||
<spring.datasource.druid.password>elink833066</spring.datasource.druid.password> |
|||
|
|||
<nacos.register-enabled>false</nacos.register-enabled> |
|||
<nacos.server-addr>47.104.224.45:8848</nacos.server-addr> |
|||
<nacos.ip></nacos.ip> |
|||
<nacos.namespace>6a3577b4-7b79-43f6-aebb-9c3f31263f6a</nacos.namespace> |
|||
<fastdfs.server-addr></fastdfs.server-addr> |
|||
</properties> |
|||
<!--<properties> |
|||
<server.port>9065</server.port> |
|||
<nacos.server-addr>47.104.224.45:8848</nacos.server-addr> |
|||
<nacos.config.namespace>513d6635-3cfe-401f-b8b6-a04417288f47</nacos.config.namespace> |
|||
<nacos.config.group>EPDC_CONFIG_GROUP</nacos.config.group> |
|||
<nacos.config.bootstrap.log.enable>true</nacos.config.bootstrap.log.enable> |
|||
</properties>--> |
|||
</profile> |
|||
|
|||
<profile> |
|||
<id>test</id> |
|||
<properties> |
|||
<spring.profiles.active>test</spring.profiles.active> |
|||
<docker.tag>test</docker.tag> |
|||
|
|||
<server.port>10012</server.port> |
|||
|
|||
<spring.redis.index>2</spring.redis.index> |
|||
<spring.redis.host>114.215.125.123</spring.redis.host> |
|||
<spring.redis.port>9603</spring.redis.port> |
|||
<spring.redis.password>epdc!redis@master1405</spring.redis.password> |
|||
|
|||
<spring.datasource.druid.url> |
|||
<![CDATA[jdbc:mysql://47.104.224.45:3308/esua_epdc_admin?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai]]> |
|||
</spring.datasource.druid.url> |
|||
<spring.datasource.druid.username>epdc</spring.datasource.druid.username> |
|||
<spring.datasource.druid.password>elink833066</spring.datasource.druid.password> |
|||
|
|||
<nacos.register-enabled>true</nacos.register-enabled> |
|||
<nacos.server-addr>47.104.224.45:8848</nacos.server-addr> |
|||
<nacos.ip>47.104.85.99</nacos.ip> |
|||
<nacos.namespace>6a3577b4-7b79-43f6-aebb-9c3f31263f6a</nacos.namespace> |
|||
|
|||
<!-- fastDFS 文件服务器 --> |
|||
<fastdfs.server-addr></fastdfs.server-addr> |
|||
</properties> |
|||
<!--<properties> |
|||
<server.port>9065</server.port> |
|||
<nacos.server-addr>47.104.224.45:8848</nacos.server-addr> |
|||
<nacos.config.namespace>6a3577b4-7b79-43f6-aebb-9c3f31263f6a</nacos.config.namespace> |
|||
<nacos.config.group>EPDC_CONFIG_GROUP</nacos.config.group> |
|||
<nacos.config.bootstrap.log.enable>true</nacos.config.bootstrap.log.enable> |
|||
</properties>--> |
|||
</profile> |
|||
|
|||
<profile> |
|||
<id>prod</id> |
|||
<properties> |
|||
<spring.profiles.active>prod</spring.profiles.active> |
|||
<docker.tag>prod</docker.tag> |
|||
|
|||
<server.port>9065</server.port> |
|||
<!-- redis配置 --> |
|||
<spring.redis.index>0</spring.redis.index> |
|||
<spring.redis.host>172.16.0.54</spring.redis.host> |
|||
<spring.redis.port>6379</spring.redis.port> |
|||
<spring.redis.password>Elink833066</spring.redis.password> |
|||
|
|||
<spring.datasource.druid.url> |
|||
<![CDATA[jdbc:mysql://172.16.0.52:3306/esua_epdc_admin?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai]]> |
|||
</spring.datasource.druid.url> |
|||
<spring.datasource.druid.username>epdc</spring.datasource.druid.username> |
|||
<spring.datasource.druid.password>Elink@833066</spring.datasource.druid.password> |
|||
<!-- nacos --> |
|||
<nacos.register-enabled>true</nacos.register-enabled> |
|||
<nacos.server-addr>172.16.0.52:8848</nacos.server-addr> |
|||
<nacos.ip></nacos.ip> |
|||
<nacos.namespace></nacos.namespace> |
|||
|
|||
<!-- fastDFS 文件服务器 --> |
|||
<fastdfs.server-addr>172.16.0.51:22122</fastdfs.server-addr> |
|||
</properties> |
|||
</profile> |
|||
</profiles> |
|||
</project> |
@ -0,0 +1,31 @@ |
|||
/** |
|||
* Copyright (c) 2018 人人开源 All rights reserved. |
|||
* |
|||
* https://www.renren.io
|
|||
* |
|||
* 版权所有,侵权必究! |
|||
*/ |
|||
|
|||
package com.elink.esua.epdc; |
|||
|
|||
import org.springframework.boot.SpringApplication; |
|||
import org.springframework.boot.autoconfigure.SpringBootApplication; |
|||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient; |
|||
import org.springframework.cloud.openfeign.EnableFeignClients; |
|||
|
|||
/** |
|||
* OSS模块 |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since 1.1.0 |
|||
*/ |
|||
@SpringBootApplication |
|||
@EnableDiscoveryClient |
|||
@EnableFeignClients |
|||
public class OssApplication { |
|||
|
|||
public static void main(String[] args) { |
|||
SpringApplication.run(OssApplication.class, args); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,79 @@ |
|||
/** |
|||
* Copyright (c) 2018 人人开源 All rights reserved. |
|||
* |
|||
* https://www.renren.io
|
|||
* |
|||
* 版权所有,侵权必究! |
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.cloud; |
|||
|
|||
import com.elink.esua.epdc.commons.tools.utils.DateUtils; |
|||
import com.elink.esua.epdc.commons.tools.utils.DateUtils; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
|
|||
import java.io.InputStream; |
|||
import java.util.Date; |
|||
import java.util.UUID; |
|||
|
|||
/** |
|||
* 云存储(支持七牛、阿里云、腾讯云、又拍云) |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
*/ |
|||
public abstract class AbstractCloudStorageService { |
|||
/** 云存储配置信息 */ |
|||
CloudStorageConfig config; |
|||
|
|||
/** |
|||
* 文件路径 |
|||
* @param prefix 前缀 |
|||
* @param suffix 后缀 |
|||
* @return 返回上传路径 |
|||
*/ |
|||
public String getPath(String prefix, String suffix) { |
|||
//生成uuid
|
|||
String uuid = UUID.randomUUID().toString().replaceAll("-", ""); |
|||
//文件路径
|
|||
String path = DateUtils.format(new Date(), "yyyyMMdd") + "/" + uuid; |
|||
|
|||
if(StringUtils.isNotBlank(prefix)){ |
|||
path = prefix + "/" + path; |
|||
} |
|||
|
|||
return path + "." + suffix; |
|||
} |
|||
|
|||
/** |
|||
* 文件上传 |
|||
* @param data 文件字节数组 |
|||
* @param path 文件路径,包含文件名 |
|||
* @return 返回http地址 |
|||
*/ |
|||
public abstract String upload(byte[] data, String path); |
|||
|
|||
/** |
|||
* 文件上传 |
|||
* @param data 文件字节数组 |
|||
* @param suffix 后缀 |
|||
* @return 返回http地址 |
|||
*/ |
|||
public abstract String uploadSuffix(byte[] data, String suffix); |
|||
|
|||
/** |
|||
* 文件上传 |
|||
* @param inputStream 字节流 |
|||
* @param path 文件路径,包含文件名 |
|||
* @return 返回http地址 |
|||
*/ |
|||
public abstract String upload(InputStream inputStream, String path); |
|||
|
|||
/** |
|||
* 文件上传 |
|||
* @param inputStream 字节流 |
|||
* @param suffix 后缀 |
|||
* @return 返回http地址 |
|||
*/ |
|||
public abstract String uploadSuffix(InputStream inputStream, String suffix); |
|||
|
|||
} |
@ -0,0 +1,103 @@ |
|||
/** |
|||
* Copyright (c) 2018 人人开源 All rights reserved. |
|||
* <p> |
|||
* https://www.renren.io
|
|||
* <p> |
|||
* 版权所有,侵权必究! |
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.cloud; |
|||
|
|||
import com.aliyun.oss.OSS; |
|||
import com.aliyun.oss.OSSClient; |
|||
import com.aliyun.oss.OSSClientBuilder; |
|||
import com.aliyun.oss.model.OSSObject; |
|||
import com.elink.esua.epdc.commons.tools.exception.RenException; |
|||
import com.elink.esua.epdc.exception.ModuleErrorCode; |
|||
|
|||
import javax.servlet.http.HttpServletResponse; |
|||
import java.io.*; |
|||
import java.net.URLEncoder; |
|||
|
|||
/** |
|||
* 阿里云存储 |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
*/ |
|||
public class AliyunCloudStorageService extends AbstractCloudStorageService { |
|||
|
|||
public AliyunCloudStorageService(CloudStorageConfig config) { |
|||
this.config = config; |
|||
} |
|||
|
|||
@Override |
|||
public String upload(byte[] data, String path) { |
|||
return upload(new ByteArrayInputStream(data), path); |
|||
} |
|||
|
|||
@Override |
|||
public String upload(InputStream inputStream, String path) { |
|||
OSSClient client = new OSSClient(config.getAliyunEndPoint(), config.getAliyunAccessKeyId(), |
|||
config.getAliyunAccessKeySecret()); |
|||
try { |
|||
client.putObject(config.getAliyunBucketName(), path, inputStream); |
|||
client.shutdown(); |
|||
} catch (Exception e) { |
|||
throw new RenException(ModuleErrorCode.OSS_UPLOAD_FILE_ERROR, e, ""); |
|||
} |
|||
|
|||
return config.getAliyunDomain() + "/" + path; |
|||
} |
|||
|
|||
@Override |
|||
public String uploadSuffix(byte[] data, String suffix) { |
|||
return upload(data, getPath(config.getAliyunPrefix(), suffix)); |
|||
} |
|||
|
|||
@Override |
|||
public String uploadSuffix(InputStream inputStream, String suffix) { |
|||
return upload(inputStream, getPath(config.getAliyunPrefix(), suffix)); |
|||
} |
|||
|
|||
/** |
|||
* 下载阿里云oss服务器上的文件 |
|||
* |
|||
* @param url 完整的访问连击 |
|||
* @param response |
|||
* @return void |
|||
* @author work@yujt.net.cn |
|||
* @date 2019/10/24 14:43 |
|||
*/ |
|||
public void download(String url, HttpServletResponse response) throws IOException { |
|||
|
|||
OSS ossClient = new OSSClientBuilder().build(config.getAliyunEndPoint(), config.getAliyunAccessKeyId(), config.getAliyunAccessKeySecret()); |
|||
|
|||
String objectName = url.replace(config.getAliyunDomain().concat("/"), ""); |
|||
String filename = objectName.substring(objectName.lastIndexOf("/") + 1); |
|||
// 调用ossClient.getObject返回一个OSSObject实例,该实例包含文件内容及文件元信息。
|
|||
OSSObject ossObject = ossClient.getObject(config.getAliyunBucketName(), objectName); |
|||
// 调用ossObject.getObjectContent获取文件输入流,可读取此输入流获取其内容。
|
|||
InputStream content = ossObject.getObjectContent(); |
|||
if (null != content) { |
|||
response.setCharacterEncoding("UTF-8"); |
|||
response.setHeader("Pragma", "No-Cache"); |
|||
response.setHeader("Cache-Control", "No-Cache"); |
|||
response.setDateHeader("Expires", 0); |
|||
response.setContentType("application/msexcel; charset=UTF-8"); |
|||
// 设定输出文件头
|
|||
response.setHeader("Content-disposition", "attachment; filename=" + URLEncoder.encode(filename, "UTF-8")); |
|||
|
|||
OutputStream toClient = new BufferedOutputStream(response.getOutputStream()); |
|||
byte[] buf = new byte[1024]; |
|||
|
|||
int L; |
|||
while ((L = content.read(buf)) != -1) { |
|||
toClient.write(buf, 0, L); |
|||
} |
|||
content.close(); |
|||
toClient.flush(); |
|||
toClient.close(); |
|||
ossClient.shutdown(); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,132 @@ |
|||
/** |
|||
* Copyright (c) 2018 人人开源 All rights reserved. |
|||
* |
|||
* https://www.renren.io
|
|||
* |
|||
* 版权所有,侵权必究! |
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.cloud; |
|||
|
|||
import com.elink.esua.epdc.commons.tools.validator.group.AliyunGroup; |
|||
import com.elink.esua.epdc.commons.tools.validator.group.QcloudGroup; |
|||
import com.elink.esua.epdc.commons.tools.validator.group.QiniuGroup; |
|||
import com.elink.esua.epdc.validator.group.FastDFSGroup; |
|||
import com.elink.esua.epdc.validator.group.LocalGroup; |
|||
import com.elink.esua.epdc.commons.tools.validator.group.AliyunGroup; |
|||
import com.elink.esua.epdc.commons.tools.validator.group.QcloudGroup; |
|||
import com.elink.esua.epdc.commons.tools.validator.group.QiniuGroup; |
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
import org.hibernate.validator.constraints.Range; |
|||
import org.hibernate.validator.constraints.URL; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
import javax.validation.constraints.NotNull; |
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* 云存储配置信息 |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
*/ |
|||
@Data |
|||
@ApiModel(value = "云存储配置信息") |
|||
public class CloudStorageConfig implements Serializable { |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
@ApiModelProperty(value = "类型 1:七牛 2:阿里云 3:腾讯云 4:FastDFS 5:本地上传") |
|||
@Range(min=1, max=5, message = "{oss.type.range}") |
|||
private Integer type; |
|||
|
|||
@ApiModelProperty(value = "七牛绑定的域名") |
|||
@NotBlank(message="{qiniu.domain.require}", groups = QiniuGroup.class) |
|||
@URL(message = "{qiniu.domain.url}", groups = QiniuGroup.class) |
|||
private String qiniuDomain; |
|||
|
|||
@ApiModelProperty(value = "七牛路径前缀") |
|||
private String qiniuPrefix; |
|||
|
|||
@ApiModelProperty(value = "七牛ACCESS_KEY") |
|||
@NotBlank(message="{qiniu.accesskey.require}", groups = QiniuGroup.class) |
|||
private String qiniuAccessKey; |
|||
|
|||
@ApiModelProperty(value = "七牛SECRET_KEY") |
|||
@NotBlank(message="{qiniu.secretkey.require}", groups = QiniuGroup.class) |
|||
private String qiniuSecretKey; |
|||
|
|||
@ApiModelProperty(value = "七牛存储空间名") |
|||
@NotBlank(message="{qiniu.bucketname.require}", groups = QiniuGroup.class) |
|||
private String qiniuBucketName; |
|||
|
|||
@ApiModelProperty(value = "阿里云绑定的域名") |
|||
@NotBlank(message="{aliyun.domain.require}", groups = AliyunGroup.class) |
|||
@URL(message = "{aliyun.domain.url}", groups = AliyunGroup.class) |
|||
private String aliyunDomain; |
|||
|
|||
@ApiModelProperty(value = "阿里云路径前缀") |
|||
private String aliyunPrefix; |
|||
|
|||
@ApiModelProperty(value = "阿里云EndPoint") |
|||
@NotBlank(message="{aliyun.endPoint.require}", groups = AliyunGroup.class) |
|||
private String aliyunEndPoint; |
|||
|
|||
@ApiModelProperty(value = "阿里云AccessKeyId") |
|||
@NotBlank(message="{aliyun.accesskeyid.require}", groups = AliyunGroup.class) |
|||
private String aliyunAccessKeyId; |
|||
|
|||
@ApiModelProperty(value = "阿里云AccessKeySecret") |
|||
@NotBlank(message="{aliyun.accesskeysecret.require}", groups = AliyunGroup.class) |
|||
private String aliyunAccessKeySecret; |
|||
|
|||
@ApiModelProperty(value = "阿里云BucketName") |
|||
@NotBlank(message="{aliyun.bucketname.require}", groups = AliyunGroup.class) |
|||
private String aliyunBucketName; |
|||
|
|||
@ApiModelProperty(value = "腾讯云绑定的域名") |
|||
@NotBlank(message="{qcloud.domain.require}", groups = QcloudGroup.class) |
|||
@URL(message = "{qcloud.domain.url}", groups = QcloudGroup.class) |
|||
private String qcloudDomain; |
|||
|
|||
@ApiModelProperty(value = "腾讯云路径前缀") |
|||
private String qcloudPrefix; |
|||
|
|||
@ApiModelProperty(value = "腾讯云AppId") |
|||
@NotNull(message="{qcloud.appid.require}", groups = QcloudGroup.class) |
|||
private Integer qcloudAppId; |
|||
|
|||
@ApiModelProperty(value = "腾讯云SecretId") |
|||
@NotBlank(message="{qcloud.secretId.require}", groups = QcloudGroup.class) |
|||
private String qcloudSecretId; |
|||
|
|||
@ApiModelProperty(value = "腾讯云SecretKey") |
|||
@NotBlank(message="{qcloud.secretkey.require}", groups = QcloudGroup.class) |
|||
private String qcloudSecretKey; |
|||
|
|||
@ApiModelProperty(value = "腾讯云BucketName") |
|||
@NotBlank(message="{qcloud.bucketname.require}", groups = QcloudGroup.class) |
|||
private String qcloudBucketName; |
|||
|
|||
@ApiModelProperty(value = "腾讯云COS所属地区") |
|||
@NotBlank(message="{qcloud.region.require}", groups = QcloudGroup.class) |
|||
private String qcloudRegion; |
|||
|
|||
@ApiModelProperty(value = "FastDFS绑定的域名") |
|||
@NotBlank(message="{fastdfs.domain.require}", groups = FastDFSGroup.class) |
|||
@URL(message = "{fastdfs.domain.url}", groups = FastDFSGroup.class) |
|||
private String fastdfsDomain; |
|||
|
|||
@ApiModelProperty(value = "本地上传绑定的域名") |
|||
@NotBlank(message="{local.domain.require}", groups = LocalGroup.class) |
|||
@URL(message = "{local.domain.url}", groups = LocalGroup.class) |
|||
private String localDomain; |
|||
|
|||
@ApiModelProperty(value = "本地上传路径前缀") |
|||
private String localPrefix; |
|||
|
|||
@ApiModelProperty(value = "本地上传存储目录") |
|||
@NotBlank(message="{local.path.url}", groups = LocalGroup.class) |
|||
private String localPath; |
|||
|
|||
} |
@ -0,0 +1,62 @@ |
|||
/** |
|||
* Copyright (c) 2018 人人开源 All rights reserved. |
|||
* <p> |
|||
* https://www.renren.io
|
|||
* <p> |
|||
* 版权所有,侵权必究! |
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.cloud; |
|||
|
|||
import com.elink.esua.epdc.commons.tools.exception.RenException; |
|||
import com.elink.esua.epdc.commons.tools.utils.SpringContextUtils; |
|||
import com.elink.esua.epdc.exception.ModuleErrorCode; |
|||
import com.github.tobato.fastdfs.domain.StorePath; |
|||
import com.github.tobato.fastdfs.service.DefaultGenerateStorageClient; |
|||
|
|||
import java.io.ByteArrayInputStream; |
|||
import java.io.InputStream; |
|||
|
|||
/** |
|||
* FastDFS |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
*/ |
|||
public class FastDFSCloudStorageService extends AbstractCloudStorageService { |
|||
private static DefaultGenerateStorageClient defaultGenerateStorageClient; |
|||
|
|||
static { |
|||
defaultGenerateStorageClient = (DefaultGenerateStorageClient) SpringContextUtils.getBean("defaultGenerateStorageClient"); |
|||
} |
|||
|
|||
public FastDFSCloudStorageService(CloudStorageConfig config) { |
|||
this.config = config; |
|||
} |
|||
|
|||
@Override |
|||
public String upload(byte[] data, String path) { |
|||
return upload(new ByteArrayInputStream(data), path); |
|||
} |
|||
|
|||
@Override |
|||
public String upload(InputStream inputStream, String suffix) { |
|||
StorePath storePath; |
|||
try { |
|||
storePath = defaultGenerateStorageClient.uploadFile("epdcFile", inputStream, inputStream.available(), suffix); |
|||
} catch (Exception ex) { |
|||
throw new RenException(ModuleErrorCode.OSS_UPLOAD_FILE_ERROR, ex, ex.getMessage()); |
|||
} |
|||
|
|||
return config.getFastdfsDomain() + "/" + storePath.getPath(); |
|||
} |
|||
|
|||
@Override |
|||
public String uploadSuffix(byte[] data, String suffix) { |
|||
return upload(data, suffix); |
|||
} |
|||
|
|||
@Override |
|||
public String uploadSuffix(InputStream inputStream, String suffix) { |
|||
return upload(inputStream, suffix); |
|||
} |
|||
} |
@ -0,0 +1,27 @@ |
|||
/** |
|||
* Copyright (c) 2018 人人开源 All rights reserved. |
|||
* |
|||
* https://www.renren.io
|
|||
* |
|||
* 版权所有,侵权必究! |
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.cloud; |
|||
|
|||
import com.github.tobato.fastdfs.FdfsClientConfig; |
|||
import org.springframework.context.annotation.Configuration; |
|||
import org.springframework.context.annotation.EnableMBeanExport; |
|||
import org.springframework.context.annotation.Import; |
|||
import org.springframework.jmx.support.RegistrationPolicy; |
|||
|
|||
/** |
|||
* 导入FastDFS-Client组件 |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
*/ |
|||
@Configuration |
|||
@Import(FdfsClientConfig.class) |
|||
@EnableMBeanExport(registration = RegistrationPolicy.IGNORE_EXISTING) |
|||
public class FastDFSImport { |
|||
|
|||
} |
@ -0,0 +1,56 @@ |
|||
/** |
|||
* Copyright (c) 2018 人人开源 All rights reserved. |
|||
* |
|||
* https://www.renren.io
|
|||
* |
|||
* 版权所有,侵权必究! |
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.cloud; |
|||
|
|||
import com.elink.esua.epdc.commons.tools.exception.RenException; |
|||
import com.elink.esua.epdc.exception.ModuleErrorCode; |
|||
import org.apache.commons.io.FileUtils; |
|||
|
|||
import java.io.ByteArrayInputStream; |
|||
import java.io.File; |
|||
import java.io.IOException; |
|||
import java.io.InputStream; |
|||
|
|||
/** |
|||
* 本地上传 |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
*/ |
|||
public class LocalCloudStorageService extends AbstractCloudStorageService { |
|||
|
|||
public LocalCloudStorageService(CloudStorageConfig config){ |
|||
this.config = config; |
|||
} |
|||
|
|||
@Override |
|||
public String upload(byte[] data, String path) { |
|||
return upload(new ByteArrayInputStream(data), path); |
|||
} |
|||
|
|||
@Override |
|||
public String upload(InputStream inputStream, String path) { |
|||
File file = new File(config.getLocalPath() + File.separator + path); |
|||
try { |
|||
FileUtils.copyToFile(inputStream, file); |
|||
} catch (IOException e) { |
|||
throw new RenException(ModuleErrorCode.OSS_UPLOAD_FILE_ERROR, e, ""); |
|||
} |
|||
return config.getLocalDomain() + "/" + path; |
|||
} |
|||
|
|||
@Override |
|||
public String uploadSuffix(byte[] data, String suffix) { |
|||
return upload(data, getPath(config.getLocalPrefix(), suffix)); |
|||
} |
|||
|
|||
@Override |
|||
public String uploadSuffix(InputStream inputStream, String suffix) { |
|||
return upload(inputStream, getPath(config.getLocalPrefix(), suffix)); |
|||
} |
|||
} |
@ -0,0 +1,50 @@ |
|||
/** |
|||
* Copyright (c) 2018 人人开源 All rights reserved. |
|||
* |
|||
* https://www.renren.io
|
|||
* |
|||
* 版权所有,侵权必究! |
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.cloud; |
|||
|
|||
import com.elink.esua.epdc.commons.tools.utils.SpringContextUtils; |
|||
import com.elink.esua.epdc.remote.ParamsRemoteService; |
|||
import com.elink.esua.epdc.utils.ModuleConstant; |
|||
import com.elink.esua.epdc.commons.tools.utils.SpringContextUtils; |
|||
import com.elink.esua.epdc.enums.OssTypeEnum; |
|||
import com.elink.esua.epdc.remote.ParamsRemoteService; |
|||
import com.elink.esua.epdc.utils.ModuleConstant; |
|||
|
|||
/** |
|||
* 文件上传Factory |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
*/ |
|||
public final class OssFactory { |
|||
private static ParamsRemoteService paramsRemoteService; |
|||
|
|||
static { |
|||
OssFactory.paramsRemoteService = SpringContextUtils.getBean(ParamsRemoteService.class); |
|||
} |
|||
|
|||
public static AbstractCloudStorageService build(){ |
|||
//获取云存储配置信息
|
|||
CloudStorageConfig config = paramsRemoteService.getValueObject(ModuleConstant.CLOUD_STORAGE_CONFIG_KEY, CloudStorageConfig.class); |
|||
|
|||
if(config.getType() == OssTypeEnum.QINIU.value()){ |
|||
return new QiniuCloudStorageService(config); |
|||
}else if(config.getType() == OssTypeEnum.ALIYUN.value()){ |
|||
return new AliyunCloudStorageService(config); |
|||
}else if(config.getType() == OssTypeEnum.QCLOUD.value()){ |
|||
return new QcloudCloudStorageService(config); |
|||
}else if(config.getType() == OssTypeEnum.FASTDFS.value()){ |
|||
return new FastDFSCloudStorageService(config); |
|||
}else if(config.getType() == OssTypeEnum.LOCAL.value()){ |
|||
return new LocalCloudStorageService(config); |
|||
} |
|||
|
|||
return null; |
|||
} |
|||
|
|||
} |
@ -0,0 +1,88 @@ |
|||
/** |
|||
* Copyright (c) 2018 人人开源 All rights reserved. |
|||
* |
|||
* https://www.renren.io
|
|||
* |
|||
* 版权所有,侵权必究! |
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.cloud; |
|||
|
|||
import com.elink.esua.epdc.commons.tools.exception.RenException; |
|||
import com.elink.esua.epdc.exception.ModuleErrorCode; |
|||
import com.qcloud.cos.COSClient; |
|||
import com.qcloud.cos.ClientConfig; |
|||
import com.qcloud.cos.auth.BasicCOSCredentials; |
|||
import com.qcloud.cos.auth.COSCredentials; |
|||
import com.qcloud.cos.model.ObjectMetadata; |
|||
import com.qcloud.cos.model.PutObjectRequest; |
|||
import com.qcloud.cos.model.PutObjectResult; |
|||
import com.qcloud.cos.region.Region; |
|||
import com.elink.esua.epdc.commons.tools.exception.RenException; |
|||
import com.elink.esua.epdc.exception.ModuleErrorCode; |
|||
|
|||
import java.io.ByteArrayInputStream; |
|||
import java.io.IOException; |
|||
import java.io.InputStream; |
|||
|
|||
/** |
|||
* 腾讯云存储 |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
*/ |
|||
public class QcloudCloudStorageService extends AbstractCloudStorageService { |
|||
private COSCredentials credentials; |
|||
private ClientConfig clientConfig; |
|||
|
|||
public QcloudCloudStorageService(CloudStorageConfig config){ |
|||
this.config = config; |
|||
|
|||
//初始化
|
|||
init(); |
|||
} |
|||
|
|||
private void init(){ |
|||
//1、初始化用户身份信息(secretId, secretKey)
|
|||
credentials = new BasicCOSCredentials(config.getQcloudSecretId(), config.getQcloudSecretKey()); |
|||
|
|||
//2、设置bucket的区域, COS地域的简称请参照 https://cloud.tencent.com/document/product/436/6224
|
|||
clientConfig = new ClientConfig(new Region(config.getQcloudRegion())); |
|||
} |
|||
|
|||
@Override |
|||
public String upload(byte[] data, String path) { |
|||
return upload(new ByteArrayInputStream(data), path); |
|||
} |
|||
|
|||
@Override |
|||
public String upload(InputStream inputStream, String path) { |
|||
try { |
|||
COSClient client = new COSClient(credentials, clientConfig); |
|||
|
|||
ObjectMetadata metadata = new ObjectMetadata(); |
|||
metadata.setContentLength(inputStream.available()); |
|||
String bucketName = config.getQcloudBucketName() +"-"+ config.getQcloudAppId(); |
|||
PutObjectRequest request = new PutObjectRequest(bucketName, path, inputStream, metadata); |
|||
PutObjectResult result = client.putObject(request); |
|||
|
|||
client.shutdown(); |
|||
if(result.getETag() == null){ |
|||
throw new RenException(ModuleErrorCode.OSS_UPLOAD_FILE_ERROR, ""); |
|||
} |
|||
} catch (IOException e) { |
|||
throw new RenException(ModuleErrorCode.OSS_UPLOAD_FILE_ERROR, e, ""); |
|||
} |
|||
|
|||
return config.getQcloudDomain() + "/" + path; |
|||
} |
|||
|
|||
@Override |
|||
public String uploadSuffix(byte[] data, String suffix) { |
|||
return upload(data, getPath(config.getQcloudPrefix(), suffix)); |
|||
} |
|||
|
|||
@Override |
|||
public String uploadSuffix(InputStream inputStream, String suffix) { |
|||
return upload(inputStream, getPath(config.getQcloudPrefix(), suffix)); |
|||
} |
|||
} |
@ -0,0 +1,82 @@ |
|||
/** |
|||
* Copyright (c) 2018 人人开源 All rights reserved. |
|||
* |
|||
* https://www.renren.io
|
|||
* |
|||
* 版权所有,侵权必究! |
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.cloud; |
|||
|
|||
import com.elink.esua.epdc.commons.tools.exception.RenException; |
|||
import com.elink.esua.epdc.exception.ModuleErrorCode; |
|||
import com.qiniu.common.Zone; |
|||
import com.qiniu.http.Response; |
|||
import com.qiniu.storage.Configuration; |
|||
import com.qiniu.storage.UploadManager; |
|||
import com.qiniu.util.Auth; |
|||
|
|||
import com.elink.esua.epdc.commons.tools.exception.RenException; |
|||
import com.elink.esua.epdc.exception.ModuleErrorCode; |
|||
import org.apache.commons.io.IOUtils; |
|||
|
|||
import java.io.IOException; |
|||
import java.io.InputStream; |
|||
|
|||
/** |
|||
* 七牛云存储 |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
*/ |
|||
public class QiniuCloudStorageService extends AbstractCloudStorageService { |
|||
private UploadManager uploadManager; |
|||
private String token; |
|||
|
|||
public QiniuCloudStorageService(CloudStorageConfig config){ |
|||
this.config = config; |
|||
|
|||
//初始化
|
|||
init(); |
|||
} |
|||
|
|||
private void init(){ |
|||
uploadManager = new UploadManager(new Configuration(Zone.autoZone())); |
|||
token = Auth.create(config.getQiniuAccessKey(), config.getQiniuSecretKey()). |
|||
uploadToken(config.getQiniuBucketName()); |
|||
|
|||
} |
|||
|
|||
@Override |
|||
public String upload(byte[] data, String path) { |
|||
try { |
|||
Response res = uploadManager.put(data, path, token); |
|||
if (!res.isOK()) { |
|||
throw new RenException(ModuleErrorCode.OSS_UPLOAD_FILE_ERROR, res.toString()); |
|||
} |
|||
} catch (Exception e) { |
|||
throw new RenException(ModuleErrorCode.OSS_UPLOAD_FILE_ERROR, e, ""); |
|||
} |
|||
|
|||
return config.getQiniuDomain() + "/" + path; |
|||
} |
|||
|
|||
@Override |
|||
public String upload(InputStream inputStream, String path) { |
|||
try { |
|||
byte[] data = IOUtils.toByteArray(inputStream); |
|||
return this.upload(data, path); |
|||
} catch (IOException e) { |
|||
throw new RenException(ModuleErrorCode.OSS_UPLOAD_FILE_ERROR, e, ""); |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
public String uploadSuffix(byte[] data, String suffix) { |
|||
return upload(data, getPath(config.getQiniuPrefix(), suffix)); |
|||
} |
|||
|
|||
@Override |
|||
public String uploadSuffix(InputStream inputStream, String suffix) { |
|||
return upload(inputStream, getPath(config.getQiniuPrefix(), suffix)); |
|||
} |
|||
} |
@ -0,0 +1,27 @@ |
|||
/** |
|||
* Copyright (c) 2018 人人开源 All rights reserved. |
|||
* |
|||
* https://www.renren.io
|
|||
* |
|||
* 版权所有,侵权必究! |
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.config; |
|||
|
|||
import com.elink.esua.epdc.commons.tools.config.ModuleConfig; |
|||
import com.elink.esua.epdc.commons.tools.config.ModuleConfig; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
/** |
|||
* 模块配置信息 |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since 1.0.0 |
|||
*/ |
|||
@Service |
|||
public class ModuleConfigImpl implements ModuleConfig { |
|||
@Override |
|||
public String getName() { |
|||
return "oss"; |
|||
} |
|||
} |
@ -0,0 +1,69 @@ |
|||
/** |
|||
* Copyright (c) 2018 人人开源 All rights reserved. |
|||
* |
|||
* https://www.renren.io
|
|||
* |
|||
* 版权所有,侵权必究! |
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.config; |
|||
|
|||
import com.elink.esua.epdc.commons.tools.constant.Constant; |
|||
import com.elink.esua.epdc.commons.tools.constant.Constant; |
|||
import io.swagger.annotations.ApiOperation; |
|||
import org.springframework.context.annotation.Bean; |
|||
import org.springframework.context.annotation.Configuration; |
|||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; |
|||
import springfox.documentation.builders.ApiInfoBuilder; |
|||
import springfox.documentation.builders.PathSelectors; |
|||
import springfox.documentation.builders.RequestHandlerSelectors; |
|||
import springfox.documentation.service.ApiInfo; |
|||
import springfox.documentation.service.ApiKey; |
|||
import springfox.documentation.spi.DocumentationType; |
|||
import springfox.documentation.spring.web.plugins.Docket; |
|||
import springfox.documentation.swagger2.annotations.EnableSwagger2; |
|||
|
|||
import java.util.List; |
|||
|
|||
import static com.google.common.collect.Lists.newArrayList; |
|||
|
|||
/** |
|||
* Swagger配置 |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since 1.0.0 |
|||
*/ |
|||
@Configuration |
|||
@EnableSwagger2 |
|||
public class SwaggerConfig implements WebMvcConfigurer { |
|||
|
|||
@Bean |
|||
public Docket createRestApi() { |
|||
return new Docket(DocumentationType.SWAGGER_2) |
|||
.apiInfo(apiInfo()) |
|||
.select() |
|||
//加了ApiOperation注解的类,才生成接口文档
|
|||
.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) |
|||
.paths(PathSelectors.any()) |
|||
.build() |
|||
.directModelSubstitute(java.util.Date.class, String.class) |
|||
.securitySchemes(security()); |
|||
|
|||
} |
|||
|
|||
private ApiInfo apiInfo() { |
|||
return new ApiInfoBuilder() |
|||
.title("人人开源") |
|||
.description("OSS接口文档") |
|||
.termsOfServiceUrl("https://www.renren.io") |
|||
.version("1.1.0") |
|||
.build(); |
|||
} |
|||
|
|||
private List<ApiKey> security() { |
|||
return newArrayList( |
|||
new ApiKey(Constant.TOKEN_HEADER, Constant.TOKEN_HEADER, "header") |
|||
); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,257 @@ |
|||
/** |
|||
* Copyright (c) 2018 人人开源 All rights reserved. |
|||
* <p> |
|||
* https://www.renren.io
|
|||
* <p> |
|||
* 版权所有,侵权必究! |
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.controller; |
|||
|
|||
import com.elink.esua.epdc.UploadImgAllDTO; |
|||
import com.elink.esua.epdc.cloud.AbstractCloudStorageService; |
|||
import com.elink.esua.epdc.cloud.AliyunCloudStorageService; |
|||
import com.elink.esua.epdc.cloud.CloudStorageConfig; |
|||
import com.elink.esua.epdc.cloud.OssFactory; |
|||
import com.elink.esua.epdc.commons.tools.annotation.LogOperation; |
|||
import com.elink.esua.epdc.commons.tools.constant.NumConstant; |
|||
import com.elink.esua.epdc.commons.tools.page.PageData; |
|||
import com.elink.esua.epdc.commons.tools.utils.CompressImgUtils; |
|||
import com.elink.esua.epdc.commons.tools.utils.Result; |
|||
import com.elink.esua.epdc.commons.tools.validator.ValidatorUtils; |
|||
import com.elink.esua.epdc.commons.tools.validator.group.AliyunGroup; |
|||
import com.elink.esua.epdc.commons.tools.validator.group.QcloudGroup; |
|||
import com.elink.esua.epdc.commons.tools.validator.group.QiniuGroup; |
|||
import com.elink.esua.epdc.dto.UploadDTO; |
|||
import com.elink.esua.epdc.dto.UploadFormDTO; |
|||
import com.elink.esua.epdc.dto.UploadToOssDTO; |
|||
import com.elink.esua.epdc.entity.OssEntity; |
|||
import com.elink.esua.epdc.enums.OssTypeEnum; |
|||
import com.elink.esua.epdc.exception.ModuleErrorCode; |
|||
import com.elink.esua.epdc.remote.ParamsRemoteService; |
|||
import com.elink.esua.epdc.service.OssService; |
|||
import com.elink.esua.epdc.utils.ModuleConstant; |
|||
import com.google.gson.Gson; |
|||
import io.swagger.annotations.Api; |
|||
import io.swagger.annotations.ApiOperation; |
|||
import org.apache.commons.io.FilenameUtils; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.*; |
|||
import org.springframework.web.multipart.MultipartFile; |
|||
import springfox.documentation.annotations.ApiIgnore; |
|||
import sun.misc.BASE64Decoder; |
|||
|
|||
import javax.servlet.http.HttpServletResponse; |
|||
import java.util.Arrays; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 文件上传 |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("file") |
|||
@Api(tags = "文件上传") |
|||
public class OssController { |
|||
|
|||
@Autowired |
|||
private OssService ossService; |
|||
|
|||
@Autowired |
|||
private ParamsRemoteService paramsRemoteService; |
|||
|
|||
private final static String KEY = ModuleConstant.CLOUD_STORAGE_CONFIG_KEY; |
|||
|
|||
@GetMapping("page") |
|||
@ApiOperation(value = "分页") |
|||
public Result<PageData<OssEntity>> page(@ApiIgnore @RequestParam Map<String, Object> params) { |
|||
PageData<OssEntity> page = ossService.page(params); |
|||
|
|||
return new Result<PageData<OssEntity>>().ok(page); |
|||
} |
|||
|
|||
@GetMapping("info") |
|||
@ApiOperation(value = "云存储配置信息") |
|||
public Result<CloudStorageConfig> info() { |
|||
CloudStorageConfig config = paramsRemoteService.getValueObject(KEY, CloudStorageConfig.class); |
|||
|
|||
return new Result<CloudStorageConfig>().ok(config); |
|||
} |
|||
|
|||
@PostMapping |
|||
@ApiOperation(value = "保存云存储配置信息") |
|||
@LogOperation("保存云存储配置信息") |
|||
public Result saveConfig(@RequestBody CloudStorageConfig config) { |
|||
//校验类型
|
|||
ValidatorUtils.validateEntity(config); |
|||
|
|||
if (config.getType() == OssTypeEnum.QINIU.value()) { |
|||
//校验七牛数据
|
|||
ValidatorUtils.validateEntity(config, QiniuGroup.class); |
|||
} else if (config.getType() == OssTypeEnum.ALIYUN.value()) { |
|||
//校验阿里云数据
|
|||
ValidatorUtils.validateEntity(config, AliyunGroup.class); |
|||
} else if (config.getType() == OssTypeEnum.QCLOUD.value()) { |
|||
//校验腾讯云数据
|
|||
ValidatorUtils.validateEntity(config, QcloudGroup.class); |
|||
} |
|||
|
|||
paramsRemoteService.updateValueByCode(KEY, new Gson().toJson(config)); |
|||
|
|||
return new Result(); |
|||
} |
|||
|
|||
@PostMapping("upload") |
|||
@ApiOperation(value = "上传文件") |
|||
public Result<UploadDTO> upload(@RequestParam("file") MultipartFile file) throws Exception { |
|||
if (file.isEmpty()) { |
|||
return new Result<UploadDTO>().error(ModuleErrorCode.UPLOAD_FILE_EMPTY); |
|||
} |
|||
|
|||
//上传文件
|
|||
String extension = FilenameUtils.getExtension(file.getOriginalFilename()); |
|||
String url = OssFactory.build().uploadSuffix(file.getBytes(), extension); |
|||
return ossService.afterUpload(url, file.getSize()); |
|||
} |
|||
|
|||
/** |
|||
* 下载阿里云oss服务器上的文件 |
|||
* |
|||
* @param fileUrl 完整的访问链接 |
|||
* @param response 浏览器返回 |
|||
* @return void |
|||
* @author work@yujt.net.cn |
|||
* @date 2019/10/24 14:43 |
|||
*/ |
|||
@GetMapping("download") |
|||
public void download(String fileUrl, HttpServletResponse response) throws Exception { |
|||
AbstractCloudStorageService build = OssFactory.build(); |
|||
if (build instanceof AliyunCloudStorageService) { |
|||
AliyunCloudStorageService aliyunCloudStorageService = (AliyunCloudStorageService) build; |
|||
aliyunCloudStorageService.download(fileUrl, response); |
|||
} else { |
|||
ossService.download(fileUrl, response); |
|||
} |
|||
} |
|||
|
|||
|
|||
@DeleteMapping |
|||
@ApiOperation(value = "删除") |
|||
@LogOperation("删除") |
|||
public Result delete(@RequestBody Long[] ids) { |
|||
ossService.deleteBatchIds(Arrays.asList(ids)); |
|||
|
|||
return new Result(); |
|||
} |
|||
|
|||
@PostMapping("uploadBase64") |
|||
@ApiOperation(value = "上传文件") |
|||
public Result<String> uploadFile(@RequestBody UploadFormDTO formDTO) throws Exception { |
|||
if (null == formDTO || StringUtils.isEmpty(formDTO.getBase64String())) { |
|||
return new Result<String>().error(ModuleErrorCode.UPLOAD_FILE_EMPTY); |
|||
} |
|||
String[] base64ImgArr = formDTO.getBase64String().split(","); |
|||
String suffixTmp = base64ImgArr[0]; |
|||
String suffix = suffixTmp.substring(11, suffixTmp.indexOf(";")); |
|||
byte[] bytes = new BASE64Decoder().decodeBuffer(base64ImgArr[1]); |
|||
// 图片压缩
|
|||
byte[] imgBytes = CompressImgUtils.commpressPicCycle(bytes, 110, 0.9); |
|||
String url = OssFactory.build().uploadSuffix(imgBytes, suffix); |
|||
return new Result<String>().ok(url); |
|||
} |
|||
|
|||
@PostMapping("uploadFile") |
|||
public Result<String> uploadFile(@RequestBody UploadToOssDTO dto) throws Exception { |
|||
byte[] fileByte = dto.getFileByte(); |
|||
if (null == fileByte || fileByte.length == NumConstant.ZERO) { |
|||
return new Result().error(ModuleErrorCode.UPLOAD_FILE_EMPTY); |
|||
} |
|||
// 图片压缩
|
|||
byte[] imgBytes = CompressImgUtils.commpressPicCycle(fileByte, 110, 0.9); |
|||
//上传文件
|
|||
String extension = FilenameUtils.getExtension(dto.getFileName()); |
|||
String url = OssFactory.build().uploadSuffix(imgBytes, extension); |
|||
|
|||
return new Result().ok(url); |
|||
} |
|||
|
|||
/** |
|||
* @param avatarUrl |
|||
* @return java.lang.String |
|||
* @Author yinzuomei |
|||
* @Description 上传微信头像 |
|||
* @Date 2019/12/19 18:48 |
|||
**/ |
|||
@GetMapping("saveWeChatFaceImg") |
|||
public Result<UploadDTO> saveWeChatFaceImg(@RequestParam(value = "avatarUrl") String avatarUrl) { |
|||
return ossService.saveWeChatFaceImg(avatarUrl); |
|||
} |
|||
|
|||
/** |
|||
* 压缩图片并上传 |
|||
* |
|||
* @param imgUrlList 完整的访问链接 |
|||
* @return void |
|||
* @author yinzuomei |
|||
* @date 2020/02/27 |
|||
*/ |
|||
@PostMapping("compressImg") |
|||
public Result<List<String>> compressImg(@RequestBody List<String> imgUrlList) { |
|||
return ossService.compressImg(imgUrlList); |
|||
} |
|||
|
|||
/** |
|||
* 图片上传并压缩缩略图 |
|||
* |
|||
* @return void |
|||
* @author lpf |
|||
* @date 2020/03/27 |
|||
*/ |
|||
@PostMapping("uploadImg") |
|||
@ApiOperation(value = "上传图片") |
|||
public Result<UploadImgAllDTO> uploadImg(@RequestParam("file") MultipartFile file) throws Exception { |
|||
if (file.isEmpty()) { |
|||
return new Result<UploadImgAllDTO>().error(ModuleErrorCode.UPLOAD_FILE_EMPTY); |
|||
} |
|||
|
|||
|
|||
//上传图片
|
|||
String extension = FilenameUtils.getExtension(file.getOriginalFilename()); |
|||
String url = OssFactory.build().uploadSuffix(file.getBytes(), extension); |
|||
ossService.afterUpload(url, file.getSize()); |
|||
//上传缩略图
|
|||
byte[] afterJyBytes = CompressImgUtils.commpressPicCycle(file.getBytes(), 1024, 0.5); |
|||
String thumbnailUrl = OssFactory.build().uploadSuffix(afterJyBytes, "jpg"); |
|||
ossService.afterUpload(thumbnailUrl, afterJyBytes.length); |
|||
UploadImgAllDTO uploadAll = new UploadImgAllDTO(); |
|||
uploadAll.setImgUrl(url); |
|||
uploadAll.setThumbnail(thumbnailUrl); |
|||
uploadAll.setFileName(file.getOriginalFilename()); |
|||
return new Result<UploadImgAllDTO>().ok(uploadAll); |
|||
} |
|||
/** |
|||
* 文件上传 |
|||
* |
|||
* @return void |
|||
* @author lpf |
|||
* @date 2020/04/02 |
|||
*/ |
|||
@PostMapping("uploadAllFile") |
|||
@ApiOperation(value = "上传文件") |
|||
public Result<UploadImgAllDTO> uploadAllFile(@RequestParam("file") MultipartFile file) throws Exception { |
|||
if (file.isEmpty()) { |
|||
return new Result<UploadImgAllDTO>().error(ModuleErrorCode.UPLOAD_FILE_EMPTY); |
|||
} |
|||
//上传文件
|
|||
String extension = FilenameUtils.getExtension(file.getOriginalFilename()); |
|||
String url = OssFactory.build().uploadSuffix(file.getBytes(), extension); |
|||
ossService.afterUpload(url, file.getSize()); |
|||
UploadImgAllDTO uploadAll = new UploadImgAllDTO(); |
|||
uploadAll.setImgUrl(url); |
|||
uploadAll.setFileName(file.getOriginalFilename()); |
|||
return new Result<UploadImgAllDTO>().ok(uploadAll); |
|||
} |
|||
} |
@ -0,0 +1,25 @@ |
|||
/** |
|||
* Copyright (c) 2018 人人开源 All rights reserved. |
|||
* |
|||
* https://www.renren.io
|
|||
* |
|||
* 版权所有,侵权必究! |
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.dao; |
|||
|
|||
import com.elink.esua.epdc.commons.mybatis.dao.BaseDao; |
|||
import com.elink.esua.epdc.entity.OssEntity; |
|||
import com.elink.esua.epdc.commons.mybatis.dao.BaseDao; |
|||
import com.elink.esua.epdc.entity.OssEntity; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
|
|||
/** |
|||
* 文件上传 |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
*/ |
|||
@Mapper |
|||
public interface OssDao extends BaseDao<OssEntity> { |
|||
|
|||
} |
@ -0,0 +1,33 @@ |
|||
/** |
|||
* Copyright (c) 2018 人人开源 All rights reserved. |
|||
* |
|||
* https://www.renren.io
|
|||
* |
|||
* 版权所有,侵权必究! |
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.entity; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import com.elink.esua.epdc.commons.mybatis.entity.BaseEntity; |
|||
import com.elink.esua.epdc.commons.mybatis.entity.BaseEntity; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
|
|||
/** |
|||
* 文件上传 |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
*/ |
|||
@Data |
|||
@EqualsAndHashCode(callSuper=false) |
|||
@TableName("sys_oss") |
|||
public class OssEntity extends BaseEntity { |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* URL地址 |
|||
*/ |
|||
private String url; |
|||
|
|||
} |
@ -0,0 +1,27 @@ |
|||
/** |
|||
* Copyright (c) 2018 人人开源 All rights reserved. |
|||
* |
|||
* https://www.renren.io
|
|||
* |
|||
* 版权所有,侵权必究! |
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.exception; |
|||
|
|||
import com.elink.esua.epdc.commons.tools.exception.ErrorCode; |
|||
import com.elink.esua.epdc.commons.tools.exception.ErrorCode; |
|||
|
|||
/** |
|||
* 模块错误编码,由9位数字组成,前6位为模块编码,后3位为业务编码 |
|||
* <p> |
|||
* 如:100001(100001代表模块,001代表业务代码) |
|||
* </p> |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since 1.0.0 |
|||
*/ |
|||
public interface ModuleErrorCode extends ErrorCode { |
|||
|
|||
int OSS_UPLOAD_FILE_ERROR = 100001001; |
|||
int UPLOAD_FILE_EMPTY = 100001002; |
|||
} |
@ -0,0 +1,70 @@ |
|||
/** |
|||
* Copyright (c) 2018 人人开源 All rights reserved. |
|||
* <p> |
|||
* https://www.renren.io
|
|||
* <p> |
|||
* 版权所有,侵权必究! |
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.service; |
|||
|
|||
import com.elink.esua.epdc.commons.mybatis.service.BaseService; |
|||
import com.elink.esua.epdc.commons.tools.page.PageData; |
|||
import com.elink.esua.epdc.commons.tools.utils.Result; |
|||
import com.elink.esua.epdc.dto.UploadDTO; |
|||
import com.elink.esua.epdc.entity.OssEntity; |
|||
|
|||
import javax.servlet.http.HttpServletResponse; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 文件上传 |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
*/ |
|||
public interface OssService extends BaseService<OssEntity> { |
|||
|
|||
PageData<OssEntity> page(Map<String, Object> params); |
|||
|
|||
/** |
|||
* 文件上传后操作 |
|||
* |
|||
* @param url 文件地址 |
|||
* @param size 文件大小 |
|||
* @return com.elink.esua.epdc.commons.tools.utils.Result<com.elink.esua.epdc.dto.UploadDTO> |
|||
* @author work@yujt.net.cn |
|||
* @date 2019/9/19 10:09 |
|||
*/ |
|||
Result<UploadDTO> afterUpload(String url, long size); |
|||
|
|||
/** |
|||
* 根据url下载图片到浏览器 |
|||
* |
|||
* @param fileUrl |
|||
* @param response |
|||
* @return void |
|||
* @author work@yujt.net.cn |
|||
* @date 2019/12/10 17:23 |
|||
*/ |
|||
void download(String fileUrl, HttpServletResponse response); |
|||
|
|||
/** |
|||
* @param fileUrl |
|||
* @return com.elink.esua.epdc.commons.tools.utils.Result<com.elink.esua.epdc.dto.UploadDTO> |
|||
* @Author yinzuomei |
|||
* @Description 上传微信头像 |
|||
* @Date 2019/12/19 18:55 |
|||
**/ |
|||
Result<UploadDTO> saveWeChatFaceImg(String fileUrl); |
|||
|
|||
/** |
|||
* 压缩图片并上传 |
|||
* |
|||
* @param imgUrlList 完整的访问链接 |
|||
* @return void |
|||
* @author yinzuomei |
|||
* @date 2020/02/27 |
|||
*/ |
|||
Result<List<String>> compressImg(List<String> imgUrlList); |
|||
} |
@ -0,0 +1,152 @@ |
|||
/** |
|||
* Copyright (c) 2018 人人开源 All rights reserved. |
|||
* <p> |
|||
* https://www.renren.io
|
|||
* <p> |
|||
* 版权所有,侵权必究! |
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.service.impl; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.elink.esua.epdc.cloud.OssFactory; |
|||
import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl; |
|||
import com.elink.esua.epdc.commons.tools.constant.Constant; |
|||
import com.elink.esua.epdc.commons.tools.constant.NumConstant; |
|||
import com.elink.esua.epdc.commons.tools.page.PageData; |
|||
import com.elink.esua.epdc.commons.tools.utils.CompressImgUtils; |
|||
import com.elink.esua.epdc.commons.tools.utils.Result; |
|||
import com.elink.esua.epdc.dao.OssDao; |
|||
import com.elink.esua.epdc.dto.UploadDTO; |
|||
import com.elink.esua.epdc.entity.OssEntity; |
|||
import com.elink.esua.epdc.service.OssService; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import javax.servlet.http.HttpServletResponse; |
|||
import java.io.*; |
|||
import java.net.MalformedURLException; |
|||
import java.net.URL; |
|||
import java.net.URLEncoder; |
|||
import java.util.ArrayList; |
|||
import java.util.Date; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
@Service |
|||
public class OssServiceImpl extends BaseServiceImpl<OssDao, OssEntity> implements OssService { |
|||
|
|||
@Override |
|||
public PageData<OssEntity> page(Map<String, Object> params) { |
|||
IPage<OssEntity> page = baseDao.selectPage( |
|||
getPage(params, Constant.CREATE_DATE, false), |
|||
new QueryWrapper<>() |
|||
); |
|||
return getPageData(page, OssEntity.class); |
|||
} |
|||
|
|||
@Override |
|||
public Result<UploadDTO> afterUpload(String url, long size) { |
|||
//保存文件信息
|
|||
OssEntity ossEntity = new OssEntity(); |
|||
ossEntity.setUrl(url); |
|||
ossEntity.setCreateDate(new Date()); |
|||
this.insert(ossEntity); |
|||
|
|||
//文件信息
|
|||
UploadDTO dto = new UploadDTO(); |
|||
dto.setUrl(url); |
|||
dto.setSize(size); |
|||
|
|||
return new Result<UploadDTO>().ok(dto); |
|||
} |
|||
|
|||
@Override |
|||
public void download(String fileUrl, HttpServletResponse response) { |
|||
URL url; |
|||
try { |
|||
url = new URL(fileUrl); |
|||
|
|||
DataInputStream dataInputStream = new DataInputStream(url.openStream()); |
|||
if (null != dataInputStream) { |
|||
|
|||
String filename = fileUrl.substring(fileUrl.lastIndexOf("/") + 1); |
|||
// 设定输出文件头
|
|||
response.setHeader("Content-disposition", "attachment; filename=" + URLEncoder.encode(filename, "UTF-8")); |
|||
|
|||
response.setCharacterEncoding("UTF-8"); |
|||
response.setHeader("Pragma", "No-Cache"); |
|||
response.setHeader("Cache-Control", "No-Cache"); |
|||
response.setDateHeader("Expires", 0); |
|||
response.setContentType("application/msexcel; charset=UTF-8"); |
|||
|
|||
byte[] buf = new byte[1024]; |
|||
int L; |
|||
|
|||
OutputStream toClient = new BufferedOutputStream(response.getOutputStream()); |
|||
while ((L = dataInputStream.read(buf)) != NumConstant.ONE_NEG) { |
|||
toClient.write(buf, NumConstant.ZERO, L); |
|||
} |
|||
dataInputStream.close(); |
|||
toClient.flush(); |
|||
toClient.close(); |
|||
} |
|||
} catch (MalformedURLException e) { |
|||
e.printStackTrace(); |
|||
} catch (UnsupportedEncodingException e) { |
|||
e.printStackTrace(); |
|||
} catch (IOException e) { |
|||
e.printStackTrace(); |
|||
} |
|||
|
|||
} |
|||
|
|||
/** |
|||
* @param avatarUrl |
|||
* @return java.lang.String |
|||
* @Author yinzuomei |
|||
* @Description 上传微信头像 |
|||
* @Date 2019/12/19 18:49 |
|||
**/ |
|||
@Override |
|||
public Result<UploadDTO> saveWeChatFaceImg(String avatarUrl) { |
|||
if (StringUtils.isBlank(avatarUrl)) { |
|||
return new Result<UploadDTO>().error("avatarUrl不能为空"); |
|||
} |
|||
try { |
|||
//实例化url
|
|||
URL url = new URL(avatarUrl); |
|||
//载入图片到输入流
|
|||
DataInputStream dataInputStream = new DataInputStream(url.openStream()); |
|||
int size = dataInputStream.available(); |
|||
//上传文件
|
|||
String fileUrl = OssFactory.build().uploadSuffix(dataInputStream, "jpg"); |
|||
return this.afterUpload(fileUrl, size); |
|||
} catch (MalformedURLException e) { |
|||
e.printStackTrace(); |
|||
} catch (IOException e) { |
|||
e.printStackTrace(); |
|||
} |
|||
return new Result<UploadDTO>().error("上传微信头像异常"); |
|||
} |
|||
|
|||
|
|||
@Override |
|||
public Result<List<String>> compressImg(List<String> imgUrlList) { |
|||
List<String> resultList = new ArrayList<>(); |
|||
if (null == imgUrlList || 0 == imgUrlList.size()) { |
|||
return new Result<List<String>>().error("imgUrlList不能为空"); |
|||
} |
|||
for (int i = 0; i < imgUrlList.size(); i++) { |
|||
String imgUrl = imgUrlList.get(i); |
|||
byte[] data = CompressImgUtils.compressImg(imgUrl); |
|||
//上传文件
|
|||
String fileUrl = OssFactory.build().uploadSuffix(data, "jpg"); |
|||
this.afterUpload(fileUrl, data.length); |
|||
resultList.add(fileUrl); |
|||
} |
|||
return new Result<List<String>>().ok(resultList); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,25 @@ |
|||
/** |
|||
* Copyright (c) 2018 人人开源 All rights reserved. |
|||
* |
|||
* https://www.renren.io
|
|||
* |
|||
* 版权所有,侵权必究! |
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.utils; |
|||
|
|||
import com.elink.esua.epdc.commons.tools.constant.Constant; |
|||
import com.elink.esua.epdc.commons.tools.constant.Constant; |
|||
|
|||
/** |
|||
* 模块常量 |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since 1.1.0 |
|||
*/ |
|||
public interface ModuleConstant extends Constant { |
|||
/** |
|||
* 云存储配置KEY |
|||
*/ |
|||
String CLOUD_STORAGE_CONFIG_KEY = "CLOUD_STORAGE_CONFIG_KEY"; |
|||
} |
@ -0,0 +1,17 @@ |
|||
/** |
|||
* Copyright (c) 2018 人人开源 All rights reserved. |
|||
* |
|||
* https://www.renren.io
|
|||
* |
|||
* 版权所有,侵权必究! |
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.validator.group; |
|||
|
|||
/** |
|||
* FastDFS |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
*/ |
|||
public interface FastDFSGroup { |
|||
} |
@ -0,0 +1,17 @@ |
|||
/** |
|||
* Copyright (c) 2018 人人开源 All rights reserved. |
|||
* |
|||
* https://www.renren.io
|
|||
* |
|||
* 版权所有,侵权必究! |
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.validator.group; |
|||
|
|||
/** |
|||
* 本地上传 |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
*/ |
|||
public interface LocalGroup { |
|||
} |
@ -0,0 +1,101 @@ |
|||
#server: |
|||
# port: @server.port@ |
|||
# servlet: |
|||
# context-path: /oss |
|||
# |
|||
#nacos: |
|||
# config: |
|||
# server-addr: @nacos.server-addr@ |
|||
# type: YAML |
|||
# namespace: @nacos.config.namespace@ |
|||
# group: @nacos.config.group@ |
|||
# dataId: epdc-oss-server |
|||
# bootstrap: |
|||
# enable: true |
|||
# log: |
|||
# enable: @nacos.config.bootstrap.log.enable@ |
|||
# |
|||
#spring: |
|||
# application: |
|||
# name: epdc-oss-server |
|||
server: |
|||
port: @server.port@ |
|||
servlet: |
|||
context-path: /oss |
|||
|
|||
spring: |
|||
application: |
|||
name: epdc-oss-server |
|||
# 环境 dev|test|prod |
|||
profiles: |
|||
active: @spring.profiles.active@ |
|||
messages: |
|||
encoding: UTF-8 |
|||
basename: i18n/messages,i18n/messages_common |
|||
jackson: |
|||
time-zone: GMT+8 |
|||
date-format: yyyy-MM-dd HH:mm:ss |
|||
servlet: |
|||
multipart: |
|||
max-file-size: 1024MB |
|||
max-request-size: 1024MB |
|||
enabled: true |
|||
redis: |
|||
database: @spring.redis.index@ |
|||
host: @spring.redis.host@ |
|||
timeout: 30s |
|||
port: @spring.redis.port@ |
|||
password: @spring.redis.password@ |
|||
cloud: |
|||
nacos: |
|||
discovery: |
|||
server-addr: @nacos.server-addr@ |
|||
register-enabled: @nacos.register-enabled@ |
|||
ip: @nacos.ip@ |
|||
namespace: @nacos.namespace@ |
|||
alibaba: |
|||
seata: |
|||
tx-service-group: epdc-oss-server-fescar-service-group |
|||
datasource: |
|||
druid: |
|||
driver-class-name: com.mysql.jdbc.Driver |
|||
url: @spring.datasource.druid.url@ |
|||
username: @spring.datasource.druid.username@ |
|||
password: @spring.datasource.druid.password@ |
|||
|
|||
fdfs: |
|||
so-timeout: 600000 |
|||
connect-timeout: 6000 |
|||
tracker-list: #TrackerList参数,支持多个 |
|||
- @fastdfs.server-addr@ |
|||
|
|||
management: |
|||
endpoints: |
|||
web: |
|||
exposure: |
|||
include: "*" |
|||
endpoint: |
|||
health: |
|||
show-details: ALWAYS |
|||
|
|||
|
|||
mybatis-plus: |
|||
mapper-locations: classpath:/mapper/**/*.xml |
|||
#实体扫描,多个package用逗号或者分号分隔 |
|||
typeAliasesPackage: io.renren.entity;com.elink.esua.epdc.entity |
|||
global-config: |
|||
#数据库相关配置 |
|||
db-config: |
|||
#主键类型 AUTO:"数据库ID自增", INPUT:"用户输入ID", ID_WORKER:"全局唯一ID (数字类型唯一ID)", UUID:"全局唯一ID UUID"; |
|||
id-type: ID_WORKER |
|||
#字段策略 IGNORED:"忽略判断",NOT_NULL:"非 NULL 判断"),NOT_EMPTY:"非空判断" |
|||
field-strategy: NOT_NULL |
|||
#驼峰下划线转换 |
|||
column-underline: true |
|||
banner: false |
|||
#原生配置 |
|||
configuration: |
|||
map-underscore-to-camel-case: true |
|||
cache-enabled: false |
|||
call-setters-on-nulls: true |
|||
jdbc-type-for-null: 'null' |
@ -0,0 +1,3 @@ |
|||
#Default |
|||
100001001=\u4E0A\u4F20\u6587\u4EF6\u5931\u8D25{0} |
|||
100001002=\u8BF7\u4E0A\u4F20\u6587\u4EF6 |
@ -0,0 +1,3 @@ |
|||
#English |
|||
100001001=Failed to upload file {0} |
|||
100001002=Please upload a file |
@ -0,0 +1,3 @@ |
|||
#\u7B80\u4F53\u4E2D\u6587 |
|||
100001001=\u4E0A\u4F20\u6587\u4EF6\u5931\u8D25{0} |
|||
100001002=\u8BF7\u4E0A\u4F20\u6587\u4EF6 |
@ -0,0 +1,3 @@ |
|||
#\u7E41\u4F53\u4E2D\u6587 |
|||
100001001=\u4E0A\u50B3\u6587\u4EF6\u5931\u6557{0} |
|||
100001002=\u8ACB\u4E0A\u50B3\u6587\u4EF6 |
@ -0,0 +1,31 @@ |
|||
#Default |
|||
oss.type.range=\u7C7B\u578B\u53D6\u503C\u8303\u56F41~5 |
|||
|
|||
aliyun.accesskeyid.require=\u963F\u91CC\u4E91AccessKeyId\u4E0D\u80FD\u4E3A\u7A7A |
|||
aliyun.accesskeysecret.require=\u963F\u91CC\u4E91AccessKeySecret\u4E0D\u80FD\u4E3A\u7A7A |
|||
aliyun.domain.require=\u963F\u91CC\u4E91\u7ED1\u5B9A\u7684\u57DF\u540D\u4E0D\u80FD\u4E3A\u7A7A |
|||
aliyun.domain.url=\u963F\u91CC\u4E91\u7ED1\u5B9A\u7684\u57DF\u540D\u683C\u5F0F\u4E0D\u6B63\u786E |
|||
aliyun.endPoint.require=\u963F\u91CC\u4E91EndPoint\u4E0D\u80FD\u4E3A\u7A7A |
|||
aliyun.bucketname.require=\u963F\u91CC\u4E91BucketName\u4E0D\u80FD\u4E3A\u7A7A |
|||
|
|||
qcloud.appid.require=\u817E\u8BAF\u4E91AppId\u4E0D\u80FD\u4E3A\u7A7A |
|||
qcloud.appkey.require=\u817E\u8BAF\u4E91AppKey\u4E0D\u80FD\u4E3A\u7A7A |
|||
qcloud.secretId.require=\u817E\u8BAF\u4E91SecretId\u4E0D\u80FD\u4E3A\u7A7A |
|||
qcloud.secretkey.require=\u817E\u8BAF\u4E91SecretKey\u4E0D\u80FD\u4E3A\u7A7A |
|||
qcloud.domain.require=\u817E\u8BAF\u4E91\u7ED1\u5B9A\u7684\u57DF\u540D\u4E0D\u80FD\u4E3A\u7A7A |
|||
qcloud.domain.url=\u817E\u8BAF\u4E91\u7ED1\u5B9A\u7684\u57DF\u540D\u683C\u5F0F\u4E0D\u6B63\u786E |
|||
qcloud.bucketname.require=\u817E\u8BAF\u4E91BucketName\u4E0D\u80FD\u4E3A\u7A7A |
|||
qcloud.region.require=\u6240\u5C5E\u5730\u533A\u4E0D\u80FD\u4E3A\u7A7A |
|||
|
|||
qiniu.domain.require=\u4E03\u725B\u7ED1\u5B9A\u7684\u57DF\u540D\u4E0D\u80FD\u4E3A\u7A7A |
|||
qiniu.domain.url=\u4E03\u725B\u7ED1\u5B9A\u7684\u57DF\u540D\u683C\u5F0F\u4E0D\u6B63\u786E |
|||
qiniu.accesskey.require=\u4E03\u725BAccessKey\u4E0D\u80FD\u4E3A\u7A7A |
|||
qiniu.secretkey.require=\u4E03\u725BSecretKey\u4E0D\u80FD\u4E3A\u7A7A |
|||
qiniu.bucketname.require=\u4E03\u725B\u7A7A\u95F4\u540D\u4E0D\u80FD\u4E3A\u7A7A |
|||
|
|||
fastdfs.domain.require=FastDFS\u7ED1\u5B9A\u7684\u57DF\u540D\u4E0D\u80FD\u4E3A\u7A7A |
|||
fastdfs.domain.url=FastDFS\u7ED1\u5B9A\u7684\u57DF\u540D\u683C\u5F0F\u4E0D\u6B63\u786E |
|||
|
|||
local.domain.require=\u672C\u5730\u4E0A\u4F20\u7ED1\u5B9A\u7684\u57DF\u540D\u4E0D\u80FD\u4E3A\u7A7A |
|||
local.domain.url=\u672C\u5730\u4E0A\u4F20\u7ED1\u5B9A\u7684\u57DF\u540D\u683C\u5F0F\u4E0D\u6B63\u786E |
|||
local.path.url=\u5B58\u50A8\u76EE\u5F55\u4E0D\u80FD\u4E3A\u7A7A |
@ -0,0 +1,31 @@ |
|||
#English |
|||
oss.type.range=Type ranges from 1 to 5 |
|||
|
|||
aliyun.accesskeyid.require=Aliyun AccessKeyId cannot be empty |
|||
aliyun.accesskeysecret.require=Aliyun AccessKeySecret cannot be empty |
|||
aliyun.domain.require=Aliyun bound domain name cannot be empty |
|||
aliyun.domain.url=Aliyun binding domain name format is incorrect |
|||
aliyun.endPoint.require=The aliyun EndPoint cannot be empty |
|||
aliyun.bucketname.require=Aliyun BucketName cannot be empty |
|||
|
|||
qcloud.appid.require=Tencent cloud AppId cannot be empty |
|||
qcloud.appkey.require=Tencent cloud AppKey cannot be empty |
|||
qcloud.secretId.require=Tencent cloud SecretId cannot be empty |
|||
qcloud.secretkey.require=Tencent cloud SecretKey cannot be empty |
|||
qcloud.domain.require=Tencent cloud bound domain name cannot be empty |
|||
qcloud.domain.url=Tencent cloud binding domain name format is incorrect |
|||
qcloud.bucketname.require=Tencent cloud BucketName cannot be empty |
|||
qcloud.region.require=The region cannot be empty |
|||
|
|||
qiniu.domain.require=Bound domain name cannot be empty |
|||
qiniu.domain.url=Binding domain name format is incorrect |
|||
qiniu.accesskey.require=The AccessKey cannot be empty |
|||
qiniu.secretkey.require=The SecretKey of seven cows cannot be empty |
|||
qiniu.bucketname.require=Space names cannot be empty |
|||
|
|||
fastdfs.domain.require=FastDFS bound domain name cannot be empty |
|||
fastdfs.domain.url=FastDFS bound domain name format is incorrect |
|||
|
|||
local.domain.require=Local upload bound domain name cannot be empty |
|||
local.domain.url=The domain name bound for local upload is not formatted correctly |
|||
local.path.url=The storage directory cannot be empty |
@ -0,0 +1,31 @@ |
|||
#\u7B80\u4F53\u4E2D\u6587 |
|||
oss.type.range=\u7C7B\u578B\u53D6\u503C\u8303\u56F41~5 |
|||
|
|||
aliyun.accesskeyid.require=\u963F\u91CC\u4E91AccessKeyId\u4E0D\u80FD\u4E3A\u7A7A |
|||
aliyun.accesskeysecret.require=\u963F\u91CC\u4E91AccessKeySecret\u4E0D\u80FD\u4E3A\u7A7A |
|||
aliyun.domain.require=\u963F\u91CC\u4E91\u7ED1\u5B9A\u7684\u57DF\u540D\u4E0D\u80FD\u4E3A\u7A7A |
|||
aliyun.domain.url=\u963F\u91CC\u4E91\u7ED1\u5B9A\u7684\u57DF\u540D\u683C\u5F0F\u4E0D\u6B63\u786E |
|||
aliyun.endPoint.require=\u963F\u91CC\u4E91EndPoint\u4E0D\u80FD\u4E3A\u7A7A |
|||
aliyun.bucketname.require=\u963F\u91CC\u4E91BucketName\u4E0D\u80FD\u4E3A\u7A7A |
|||
|
|||
qcloud.appid.require=\u817E\u8BAF\u4E91AppId\u4E0D\u80FD\u4E3A\u7A7A |
|||
qcloud.appkey.require=\u817E\u8BAF\u4E91AppKey\u4E0D\u80FD\u4E3A\u7A7A |
|||
qcloud.secretId.require=\u817E\u8BAF\u4E91SecretId\u4E0D\u80FD\u4E3A\u7A7A |
|||
qcloud.secretkey.require=\u817E\u8BAF\u4E91SecretKey\u4E0D\u80FD\u4E3A\u7A7A |
|||
qcloud.domain.require=\u817E\u8BAF\u4E91\u7ED1\u5B9A\u7684\u57DF\u540D\u4E0D\u80FD\u4E3A\u7A7A |
|||
qcloud.domain.url=\u817E\u8BAF\u4E91\u7ED1\u5B9A\u7684\u57DF\u540D\u683C\u5F0F\u4E0D\u6B63\u786E |
|||
qcloud.bucketname.require=\u817E\u8BAF\u4E91BucketName\u4E0D\u80FD\u4E3A\u7A7A |
|||
qcloud.region.require=\u6240\u5C5E\u5730\u533A\u4E0D\u80FD\u4E3A\u7A7A |
|||
|
|||
qiniu.domain.require=\u4E03\u725B\u7ED1\u5B9A\u7684\u57DF\u540D\u4E0D\u80FD\u4E3A\u7A7A |
|||
qiniu.domain.url=\u4E03\u725B\u7ED1\u5B9A\u7684\u57DF\u540D\u683C\u5F0F\u4E0D\u6B63\u786E |
|||
qiniu.accesskey.require=\u4E03\u725BAccessKey\u4E0D\u80FD\u4E3A\u7A7A |
|||
qiniu.secretkey.require=\u4E03\u725BSecretKey\u4E0D\u80FD\u4E3A\u7A7A |
|||
qiniu.bucketname.require=\u4E03\u725B\u7A7A\u95F4\u540D\u4E0D\u80FD\u4E3A\u7A7A |
|||
|
|||
fastdfs.domain.require=FastDFS\u7ED1\u5B9A\u7684\u57DF\u540D\u4E0D\u80FD\u4E3A\u7A7A |
|||
fastdfs.domain.url=FastDFS\u7ED1\u5B9A\u7684\u57DF\u540D\u683C\u5F0F\u4E0D\u6B63\u786E |
|||
|
|||
local.domain.require=\u672C\u5730\u4E0A\u4F20\u7ED1\u5B9A\u7684\u57DF\u540D\u4E0D\u80FD\u4E3A\u7A7A |
|||
local.domain.url=\u672C\u5730\u4E0A\u4F20\u7ED1\u5B9A\u7684\u57DF\u540D\u683C\u5F0F\u4E0D\u6B63\u786E |
|||
local.path.url=\u5B58\u50A8\u76EE\u5F55\u4E0D\u80FD\u4E3A\u7A7A |
@ -0,0 +1,31 @@ |
|||
#\u7E41\u4F53\u4E2D\u6587 |
|||
oss.type.range=\u985E\u578B\u53D6\u503C\u7BC4\u570D1~5 |
|||
|
|||
aliyun.accesskeyid.require=\u963F\u91CC\u96F2AccessKeyId\u4E0D\u80FD\u70BA\u7A7A |
|||
aliyun.accesskeysecret.require=\u963F\u91CC\u96F2AccessKeySecret\u4E0D\u80FD\u70BA\u7A7A |
|||
aliyun.domain.require=\u963F\u91CC\u96F2\u7D81\u5B9A\u7684\u57DF\u540D\u4E0D\u80FD\u70BA\u7A7A |
|||
aliyun.domain.url=\u963F\u91CC\u96F2\u7D81\u5B9A\u7684\u57DF\u540D\u683C\u5F0F\u4E0D\u6B63\u78BA |
|||
aliyun.endPoint.require=\u963F\u91CC\u96F2EndPoint\u4E0D\u80FD\u70BA\u7A7A |
|||
aliyun.bucketname.require=\u963F\u91CC\u96F2BucketName\u4E0D\u80FD\u70BA\u7A7A |
|||
|
|||
qcloud.appid.require=\u9A30\u8A0A\u96F2AppId\u4E0D\u80FD\u70BA\u7A7A |
|||
qcloud.appkey.require=\u9A30\u8A0A\u96F2AppKey\u4E0D\u80FD\u70BA\u7A7A |
|||
qcloud.secretId.require=\u9A30\u8A0A\u96F2SecretId\u4E0D\u80FD\u70BA\u7A7A |
|||
qcloud.secretkey.require=\u9A30\u8A0A\u96F2SecretKey\u4E0D\u80FD\u70BA\u7A7A |
|||
qcloud.domain.require=\u9A30\u8A0A\u96F2\u7D81\u5B9A\u7684\u57DF\u540D\u4E0D\u80FD\u70BA\u7A7A |
|||
qcloud.domain.url=\u9A30\u8A0A\u96F2\u7D81\u5B9A\u7684\u57DF\u540D\u683C\u5F0F\u4E0D\u6B63\u78BA |
|||
qcloud.bucketname.require=\u9A30\u8A0A\u96F2BucketName\u4E0D\u80FD\u70BA\u7A7A |
|||
qcloud.region.require=\u6240\u5C6C\u5730\u5340\u4E0D\u80FD\u70BA\u7A7A |
|||
|
|||
qiniu.domain.require=\u4E03\u725B\u7D81\u5B9A\u7684\u57DF\u540D\u4E0D\u80FD\u70BA\u7A7A |
|||
qiniu.domain.url=\u4E03\u725B\u7D81\u5B9A\u7684\u57DF\u540D\u683C\u5F0F\u4E0D\u6B63\u78BA |
|||
qiniu.accesskey.require=\u4E03\u725BAccessKey\u4E0D\u80FD\u70BA\u7A7A |
|||
qiniu.secretkey.require=\u4E03\u725BSecretKey\u4E0D\u80FD\u70BA\u7A7A |
|||
qiniu.bucketname.require=\u4E03\u725B\u7A7A\u9593\u540D\u4E0D\u80FD\u70BA\u7A7A |
|||
|
|||
fastdfs.domain.require=FastDFS\u7D81\u5B9A\u7684\u57DF\u540D\u4E0D\u80FD\u70BA\u7A7A |
|||
fastdfs.domain.url=FastDFS\u7D81\u5B9A\u7684\u57DF\u540D\u683C\u5F0F\u4E0D\u6B63\u78BA |
|||
|
|||
local.domain.require=\u672C\u5730\u4E0A\u50B3\u7D81\u5B9A\u7684\u57DF\u540D\u4E0D\u80FD\u70BA\u7A7A |
|||
local.domain.url=\u672C\u5730\u4E0A\u50B3\u7D81\u5B9A\u7684\u57DF\u540D\u683C\u5F0F\u4E0D\u6B63\u78BA |
|||
local.path.url=\u5B58\u5132\u76EE\u9304\u4E0D\u80FD\u70BA\u7A7A |
@ -0,0 +1,159 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<configuration> |
|||
<include resource="org/springframework/boot/logging/logback/base.xml"/> |
|||
|
|||
<property name="log.path" value="logs/oss"/> |
|||
|
|||
<!-- 彩色日志格式 --> |
|||
<property name="CONSOLE_LOG_PATTERN" |
|||
value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/> |
|||
|
|||
<!--1. 输出到控制台--> |
|||
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender"> |
|||
<!--此日志appender是为开发使用,只配置最底级别,控制台输出的日志级别是大于或等于此级别的日志信息--> |
|||
<filter class="ch.qos.logback.classic.filter.ThresholdFilter"> |
|||
<level>debug</level> |
|||
</filter> |
|||
<encoder> |
|||
<Pattern>${CONSOLE_LOG_PATTERN}</Pattern> |
|||
<!-- 设置字符集 --> |
|||
<charset>UTF-8</charset> |
|||
</encoder> |
|||
</appender> |
|||
|
|||
<!--2. 输出到文档--> |
|||
<!-- 2.1 level为 DEBUG 日志,时间滚动输出 --> |
|||
<appender name="DEBUG_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
|||
<!-- 正在记录的日志文档的路径及文档名 --> |
|||
<file>${log.path}/debug.log</file> |
|||
<!--日志文档输出格式--> |
|||
<encoder> |
|||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern> |
|||
<charset>UTF-8</charset> <!-- 设置字符集 --> |
|||
</encoder> |
|||
<!-- 日志记录器的滚动策略,按日期,按大小记录 --> |
|||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> |
|||
<!-- 日志归档 --> |
|||
<fileNamePattern>${log.path}/debug-%d{yyyy-MM-dd}.%i.log</fileNamePattern> |
|||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> |
|||
<maxFileSize>100MB</maxFileSize> |
|||
</timeBasedFileNamingAndTriggeringPolicy> |
|||
<!--日志文档保留天数--> |
|||
<maxHistory>15</maxHistory> |
|||
</rollingPolicy> |
|||
<!-- 此日志文档只记录debug级别的 --> |
|||
<filter class="ch.qos.logback.classic.filter.LevelFilter"> |
|||
<level>debug</level> |
|||
<onMatch>ACCEPT</onMatch> |
|||
<onMismatch>DENY</onMismatch> |
|||
</filter> |
|||
</appender> |
|||
|
|||
<!-- 2.2 level为 INFO 日志,时间滚动输出 --> |
|||
<appender name="INFO_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
|||
<!-- 正在记录的日志文档的路径及文档名 --> |
|||
<file>${log.path}/info.log</file> |
|||
<!--日志文档输出格式--> |
|||
<encoder> |
|||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern> |
|||
<charset>UTF-8</charset> |
|||
</encoder> |
|||
<!-- 日志记录器的滚动策略,按日期,按大小记录 --> |
|||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> |
|||
<!-- 每天日志归档路径以及格式 --> |
|||
<fileNamePattern>${log.path}/info-%d{yyyy-MM-dd}.%i.log</fileNamePattern> |
|||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> |
|||
<maxFileSize>100MB</maxFileSize> |
|||
</timeBasedFileNamingAndTriggeringPolicy> |
|||
<!--日志文档保留天数--> |
|||
<maxHistory>15</maxHistory> |
|||
</rollingPolicy> |
|||
<!-- 此日志文档只记录info级别的 --> |
|||
<filter class="ch.qos.logback.classic.filter.LevelFilter"> |
|||
<level>info</level> |
|||
<onMatch>ACCEPT</onMatch> |
|||
<onMismatch>DENY</onMismatch> |
|||
</filter> |
|||
</appender> |
|||
|
|||
<!-- 2.3 level为 WARN 日志,时间滚动输出 --> |
|||
<appender name="WARN_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
|||
<!-- 正在记录的日志文档的路径及文档名 --> |
|||
<file>${log.path}/warn.log</file> |
|||
<!--日志文档输出格式--> |
|||
<encoder> |
|||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern> |
|||
<charset>UTF-8</charset> <!-- 此处设置字符集 --> |
|||
</encoder> |
|||
<!-- 日志记录器的滚动策略,按日期,按大小记录 --> |
|||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> |
|||
<fileNamePattern>${log.path}/warn-%d{yyyy-MM-dd}.%i.log</fileNamePattern> |
|||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> |
|||
<maxFileSize>100MB</maxFileSize> |
|||
</timeBasedFileNamingAndTriggeringPolicy> |
|||
<!--日志文档保留天数--> |
|||
<maxHistory>15</maxHistory> |
|||
</rollingPolicy> |
|||
<!-- 此日志文档只记录warn级别的 --> |
|||
<filter class="ch.qos.logback.classic.filter.LevelFilter"> |
|||
<level>warn</level> |
|||
<onMatch>ACCEPT</onMatch> |
|||
<onMismatch>DENY</onMismatch> |
|||
</filter> |
|||
</appender> |
|||
|
|||
<!-- 2.4 level为 ERROR 日志,时间滚动输出 --> |
|||
<appender name="ERROR_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
|||
<!-- 正在记录的日志文档的路径及文档名 --> |
|||
<file>${log.path}/error.log</file> |
|||
<!--日志文档输出格式--> |
|||
<encoder> |
|||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern> |
|||
<charset>UTF-8</charset> <!-- 此处设置字符集 --> |
|||
</encoder> |
|||
<!-- 日志记录器的滚动策略,按日期,按大小记录 --> |
|||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> |
|||
<fileNamePattern>${log.path}/error-%d{yyyy-MM-dd}.%i.log</fileNamePattern> |
|||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> |
|||
<maxFileSize>100MB</maxFileSize> |
|||
</timeBasedFileNamingAndTriggeringPolicy> |
|||
<!--日志文档保留天数--> |
|||
<maxHistory>15</maxHistory> |
|||
</rollingPolicy> |
|||
<!-- 此日志文档只记录ERROR级别的 --> |
|||
<filter class="ch.qos.logback.classic.filter.LevelFilter"> |
|||
<level>ERROR</level> |
|||
<onMatch>ACCEPT</onMatch> |
|||
<onMismatch>DENY</onMismatch> |
|||
</filter> |
|||
</appender> |
|||
|
|||
<!-- 开发、测试环境 --> |
|||
<springProfile name="dev,test"> |
|||
<logger name="org.springframework.web" level="INFO"/> |
|||
<logger name="org.springboot.sample" level="INFO"/> |
|||
<logger name="com.elink.esua.epdc" level="INFO"/> |
|||
<logger name="com.elink.esua.epdc.dao" level="DEBUG"/> |
|||
<root level="INFO"> |
|||
<appender-ref ref="DEBUG_FILE"/> |
|||
<appender-ref ref="INFO_FILE"/> |
|||
<appender-ref ref="WARN_FILE"/> |
|||
<appender-ref ref="ERROR_FILE"/> |
|||
</root> |
|||
</springProfile> |
|||
|
|||
<!-- 生产环境 --> |
|||
<springProfile name="prod"> |
|||
<logger name="org.springframework.web" level="INFO"/> |
|||
<logger name="org.springboot.sample" level="INFO"/> |
|||
<logger name="com.elink.esua.epdc" level="INFO"/> |
|||
<root level="INFO"> |
|||
<appender-ref ref="CONSOLE"/> |
|||
<appender-ref ref="DEBUG_FILE"/> |
|||
<appender-ref ref="INFO_FILE"/> |
|||
<appender-ref ref="WARN_FILE"/> |
|||
<appender-ref ref="ERROR_FILE"/> |
|||
</root> |
|||
</springProfile> |
|||
|
|||
</configuration> |
@ -0,0 +1,7 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
|
|||
<mapper namespace="com.elink.esua.epdc.dao.OssDao"> |
|||
|
|||
|
|||
</mapper> |
@ -0,0 +1,21 @@ |
|||
registry { |
|||
# file 、nacos 、eureka、redis、zk、consul、etcd3、sofa |
|||
type = "nacos" |
|||
|
|||
nacos { |
|||
serverAddr = "@nacos.server-addr@" |
|||
namespace = "@nacos.namespace@" |
|||
cluster = "default" |
|||
} |
|||
} |
|||
|
|||
config { |
|||
# file、nacos 、apollo、zk、consul、etcd3 |
|||
type = "nacos" |
|||
|
|||
nacos { |
|||
serverAddr = "@nacos.server-addr@" |
|||
namespace = "@nacos.namespace@" |
|||
cluster = "default" |
|||
} |
|||
} |
@ -0,0 +1,22 @@ |
|||
<?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> |
|||
|
|||
<groupId>com.esua.epdc.yushan</groupId> |
|||
<artifactId>epdc-cloud-oss-yushan</artifactId> |
|||
<version>1.0.0</version> |
|||
|
|||
<packaging>pom</packaging> |
|||
<description>榆山党群e事通互帮互助模块</description> |
|||
|
|||
<modules> |
|||
<module>epdc-cloud-oss</module> |
|||
<module>epdc-cloud-client-yushan</module> |
|||
<module>epdc-cloud-commons-yushan</module> |
|||
<module>epdc-cloud-gateway-yushan</module> |
|||
<module>epdc-cloud-parent-yushan</module> |
|||
</modules> |
|||
|
|||
</project> |
Loading…
Reference in new issue