summaryrefslogtreecommitdiff
path: root/src/main/resources
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/resources')
-rw-r--r--src/main/resources/application-magic-api.yml77
-rw-r--r--src/main/resources/application.yml61
-rw-r--r--src/main/resources/config/asw.properties10
-rw-r--r--src/main/resources/config/logback-spring.xml67
-rw-r--r--src/main/resources/db/migration/V1.0.01__INIT_TABLES.sql136
-rw-r--r--src/main/resources/static/banner.txt8
-rw-r--r--src/main/resources/static/magic-editor.js10
7 files changed, 369 insertions, 0 deletions
diff --git a/src/main/resources/application-magic-api.yml b/src/main/resources/application-magic-api.yml
new file mode 100644
index 0000000..64266ce
--- /dev/null
+++ b/src/main/resources/application-magic-api.yml
@@ -0,0 +1,77 @@
+magic-api:
+ web: /magic/web # UI请求的界面以及UI服务地址
+ resource: #配置存储方式
+ type: database # 配置存储在数据库中
+ tableName: magic_api_file # 数据库中的表名
+# datasource: magic #指定数据源(单数据源时无需配置,多数据源时默认使用主数据源,如果存在其他数据源中需要指定。)
+# prefix: /magic-api # key前缀
+ readonly: false # 是否是只读模式
+ prefix: / # 接口前缀,可以不配置
+ auto-import-module: db,http,log # 自动导入的模块
+ auto-import-package: java.lang.*,java.util.*,net.geedge.digitalhorizon.common.util.T #自动导包
+ allow-override: false #禁止覆盖应用接口
+ sql-column-case: camel #启用驼峰命名转换
+ editor-config: classpath:./static/magic-editor.js #编辑器配置
+ support-cross-domain: true # 跨域支持,默认开启
+# secret-key: 123456789 # 远程推送时的秘钥,未配置则不开启推送
+ push-path: /_magic-api-sync #远程推送的路径,默认为/_magic-api-sync
+ show-sql: true #配置打印SQL
+ compile-cache-size: 500 #配置编译缓存容量
+ persistence-response-body: true #是否持久化保存ResponseBody
+ date-pattern: # 配置请求参数支持的日期格式
+ - yyyy-MM-dd
+ - yyyy-MM-dd HH:mm:ss
+ - yyyyMMddHHmmss
+ - yyyyMMdd
+ response: |- #配置JSON格式,格式为magic-script中的表达式
+ {
+ code: code,
+ message: message,
+ data,
+ timestamp,
+ requestTime,
+ executeTime,
+ }
+ response-code:
+ success: 200 #执行成功的code值
+ invalid: 400 #参数验证未通过的code值
+ exception: 500 #执行出现异常的code值
+ banner: false # 打印banner
+ thread-pool-executor-size: 8 # async语句的线程池大小
+ throw-exception: false #执行出错时是否抛出异常
+ backup: #备份相关配置
+ enable: true #是否启用
+ max-history: -1 #备份保留天数,-1为永久保留
+# datasource: magic #指定数据源(单数据源时无需配置,多数据源时默认使用主数据源,如果存在其他数据源中需要指定。)
+ table-name: magic_api_backup #使用数据库存储备份时的表名
+ crud: # CRUD相关配置
+ logic-delete-column: deleted #逻辑删除列
+ logic-delete-value: 1 #逻辑删除值
+ cache: # 缓存相关配置
+ capacity: 10000 #缓存容量
+ ttl: -1 # 永不过期
+ enable: true # 启用缓存
+ page:
+ size: size # 页大小的参数名称
+ page: current # 页码的参数名称
+ default-page: 1 # 未传页码时的默认首页
+ default-size: 20 # 未传页大小时的默认页大小
+ security: # 安全配置
+ username: admin # 登录用的用户名
+ password: 123456 # 登录用的密码
+ swagger:
+ version: 1.0
+ description: Digital Horizon API 接口信息
+ title: DH API Swagger Docs
+ name: DH API 接口
+ location: /v2/api-docs/dh-api/swagger2.json
+ debug:
+ timeout: 60 # 断点超时时间,默认60s
+ task:
+ thread-name-prefix: dh-task- #线程池名字前缀
+ log: true # 打印日志
+ pool:
+ size: 8 #线程池大小,默认值为CPU核心数
+ shutdown:
+ awaitTermination: false #关闭时是否等待任务执行完毕,默认为false
+ awaitTerminationPeriod: 10s # 关闭时最多等待任务执行完毕的时间 \ No newline at end of file
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
new file mode 100644
index 0000000..1300f30
--- /dev/null
+++ b/src/main/resources/application.yml
@@ -0,0 +1,61 @@
+
+spring:
+ banner:
+ location: classpath:static/banner.txt
+ web:
+ resources:
+ static-locations: ./public/
+ cache:
+ cachecontrol:
+ no-cache: true
+# max-age: 30d
+# cache-public: true
+ profiles:
+ active: prod
+ include: magic-api
+ datasource:
+ driver-class-name: org.mariadb.jdbc.Driver
+ url: jdbc:mariadb://${database.host}:${database.port}/${database.name}?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8
+ username: ${database.user}
+ password: ENC(${database.pin})
+ flyway:
+ enabled: true # 是否开启
+ encoding: UTF-8 # 编码
+ sql-migration-prefix: V # 脚本文件的前缀,默认为V
+ sql-migration-separator: __ # 双下划线
+ baseline-on-migrate: true # 连接数据库中存在表时设置为true
+ locations: classpath:db/migration # 脚本路径
+ clean-disabled: false # flyway 的 clean 命令会删除指定 schema 下的所有 table, 生产务必禁掉。这个默认值是 false 理论上作为默认配置是不科学的
+ validate-on-migrate: true # 执行迁移时是否自动调用验证 当你的 版本不符合逻辑 比如 你先执行了 DML 而没有 对应的DDL 会抛出异常
+ placeholder-replacement: false # 不做取值替换 默认替换为 ${} ,初始化sql中有sql语句存在freemarker替换,所以禁用此项
+ servlet:
+ multipart:
+ max-file-size: 200MB
+ max-request-size: 200MB
+ enabled: true
+ main:
+ allow-circular-references: true
+
+server:
+# port: 2023
+ servlet:
+ context-path: /
+ tomcat:
+ uri-encoding: UTF-8
+ max-threads: 1000
+ min-spare-threads: 5
+ connection-timeout: 60000
+ keep-alive-timeout: 600000
+ compression:
+ enabled: true
+ mime-types: text/xml,text/plain,text/css,text/javascript,application/javascript,application/json,application/xml
+
+mybatis-plus:
+ mapper-locations: classpath:db/mapper/*Mapper.xml
+ configuration:
+ log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
+ global-config:
+ banner: false
+
+logging:
+ config: ./config/logback-spring.xml \ No newline at end of file
diff --git a/src/main/resources/config/asw.properties b/src/main/resources/config/asw.properties
new file mode 100644
index 0000000..d388294
--- /dev/null
+++ b/src/main/resources/config/asw.properties
@@ -0,0 +1,10 @@
+server.port=80
+database.port=3306
+#database.host=192.168.44.23
+#database.name=dh-test-f
+#database.user=nezha
+database.host=127.0.0.1
+database.name=asw
+database.user=user
+#database.pin=NTV/OauZb0eHc9tqzQzG0bbfmzH0VRILYhGbU2ssJ1fDr5gqJ+gd5ELnND3wZ6EB
+database.pin=TPe6maTtzzu0zD0n0H+UTqug9nnb6l+eESqvILQ1dy3e1bEVZHTXfsKjqKp3vAXQ \ No newline at end of file
diff --git a/src/main/resources/config/logback-spring.xml b/src/main/resources/config/logback-spring.xml
new file mode 100644
index 0000000..1dbdc8a
--- /dev/null
+++ b/src/main/resources/config/logback-spring.xml
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration scan="true" scanPeriod="60 seconds">
+ <include resource="org/springframework/boot/logging/logback/defaults.xml" />
+ <logger name="org.springframework.web" level="info" />
+ <logger name="org.springboot.sample" level="warn" />
+ <logger name="org.apache" level="warn" />
+ <logger name="org.springframework" level="info" />
+ <logger name="druid.sql" level="info" />
+
+ <property name="log.path" value="/var/log/dh/" />
+ <!-- 输出格式 -->
+ <property name="out.pattern" value="%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n" />
+ <!-- 活动文件的大小 -->
+ <property name="max.file.size" value="100MB"/>
+ <!-- 保留的归档文件的最大数量 -->
+ <property name="max.history" value="30"/>
+ <!-- 控制所有归档日志文件的总大小 -->
+ <property name="total.size.cap" value="10GB"/>
+
+ <!-- 2.2 level为 INFO 日志,时间滚动输出 -->
+ <appender name="LOG_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <!-- 正在记录的日志文档的路径及文档名 -->
+ <file>${log.path}/dh-web.log</file>
+ <!--日志文档输出格式 -->
+ <encoder>
+ <pattern>${out.pattern}</pattern>
+ <charset>UTF-8</charset>
+ </encoder>
+ <!-- 日志记录器的滚动策略,按日期,按大小记录 -->
+ <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
+ <fileNamePattern>${log.path}/dh-web-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
+ <maxFileSize>${max.file.size}</maxFileSize>
+ <maxHistory>${max.history}</maxHistory>
+ <totalSizeCap>${total.size.cap}</totalSizeCap>
+ </rollingPolicy>
+ </appender>
+
+ <!-- 2.1 level为 ERROR 日志,时间滚动输出 -->
+ <appender name="ERROR_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <!-- 正在记录的日志文档的路径及文档名 -->
+ <file>${log.path}/dh-web-error.log</file>
+ <!--日志文档输出格式 -->
+ <encoder>
+ <pattern>${out.pattern}</pattern>
+ <charset>UTF-8</charset>
+ </encoder>
+ <!-- 日志记录器的滚动策略,按日期,按大小记录 -->
+ <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
+ <fileNamePattern>${log.path}/dh-web-error-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
+ <maxFileSize>${max.file.size}</maxFileSize>
+ <maxHistory>${max.history}</maxHistory>
+ <totalSizeCap>${total.size.cap}</totalSizeCap>
+ </rollingPolicy>
+ <!-- 此日志文档只记录debug级别的 -->
+ <filter class="ch.qos.logback.classic.filter.LevelFilter">
+ <level>error</level>
+ <onMatch>ACCEPT</onMatch>
+ <onMismatch>DENY</onMismatch>
+ </filter>
+ </appender>
+
+ <root level="INFO">
+ <appender-ref ref="LOG_FILE" />
+ <appender-ref ref="ERROR_FILE" />
+ </root>
+
+</configuration>
diff --git a/src/main/resources/db/migration/V1.0.01__INIT_TABLES.sql b/src/main/resources/db/migration/V1.0.01__INIT_TABLES.sql
new file mode 100644
index 0000000..c46f34d
--- /dev/null
+++ b/src/main/resources/db/migration/V1.0.01__INIT_TABLES.sql
@@ -0,0 +1,136 @@
+/**
+ * 1、新增 sys_user 表
+ * 2、添加默认用户 admin/admin
+ */
+DROP TABLE IF EXISTS `sys_user`;
+CREATE TABLE `sys_user` (
+ `id` varchar(64) NOT NULL,
+ `name` varchar(255) NOT NULL,
+ `user_name` varchar(255) NOT NULL,
+ `pwd` varchar(255) NOT NULL,
+ `create_timestamp` bigint(20) NOT NULL,
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `idx_user_name` (`user_name`) USING BTREE,
+ KEY `idx_name` (`name`) USING BTREE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
+
+INSERT INTO `sys_user`(`id`, `name`, `user_name`, `pwd`, `create_timestamp`) VALUES ('admin', 'admin', 'admin', 'ad9d757e620d5d9cd8e32c3dbcf37525', UNIX_TIMESTAMP(NOW())*1000);
+
+/**
+ * 1、新增 sys_role 表
+ * 2、新增 sys_menu 表
+ * 3、新增 sys_user_role 表
+ * 4、新增 sys_role_menu 表
+ * 5、添加初始化数据
+ */
+DROP TABLE IF EXISTS `sys_role`;
+CREATE TABLE `sys_role` (
+ `id` varchar(64) NOT NULL,
+ `name` varchar(255) NOT NULL,
+ `i18n` varchar(255) NOT NULL,
+ `remark` varchar(255) NOT NULL,
+ `build_in` int(10) NOT NULL DEFAULT 0,
+ `create_timestamp` bigint(20) NOT NULL,
+ PRIMARY KEY (`id`),
+ KEY `idx_name` (`name`) USING BTREE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
+
+
+DROP TABLE IF EXISTS `sys_menu`;
+CREATE TABLE `sys_menu` (
+ `id` varchar(64) NOT NULL,
+ `name` varchar(255) NOT NULL,
+ `i18n` varchar(255) NOT NULL,
+ `pid` varchar(64) NOT NULL DEFAULT '',
+ `type` varchar(64) NOT NULL,
+ `perms` varchar(255) NOT NULL DEFAULT '',
+ `route` varchar(255) NOT NULL DEFAULT '',
+ `icon` varchar(255) NOT NULL DEFAULT '',
+ `order` int(10) NOT NULL DEFAULT 1,
+ `create_timestamp` bigint(20) NOT NULL,
+ `state` int(10) NOT NULL DEFAULT 1,
+ PRIMARY KEY (`id`),
+ KEY `idx_name` (`name`) USING BTREE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
+
+DROP TABLE IF EXISTS `sys_user_role`;
+CREATE TABLE `sys_user_role` (
+ `user_id` varchar(64) NOT NULL,
+ `role_id` varchar(64) NOT NULL,
+ PRIMARY KEY (`user_id`) USING BTREE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
+
+DROP TABLE IF EXISTS `sys_role_menu`;
+CREATE TABLE `sys_role_menu` (
+ `menu_id` varchar(64) NOT NULL,
+ `role_id` varchar(64) NOT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
+
+-- 添加内置角色
+INSERT INTO `sys_role` (`id`, `name`, `i18n`, `remark`, `build_in`, `create_timestamp`) VALUES ('admin', 'admin', 'admin', 'admin', 1, UNIX_TIMESTAMP(NOW())*1000);
+
+/**
+ * 1、新增 sys_config 表
+ */
+DROP TABLE IF EXISTS `sys_config`;
+CREATE TABLE `sys_config` (
+ `param_key` varchar(50) NOT NULL COMMENT 'key',
+ `param_value` text DEFAULT NULL,
+ `status` tinyint(4) DEFAULT 1 COMMENT '状态 0:隐藏 1:显示',
+ `remark` varchar(500) DEFAULT NULL COMMENT '备注',
+ PRIMARY KEY (`param_key`) USING BTREE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='系统配置表';
+
+/**
+ 初始化 magic api 时区配置 ,默认 Asia/Shanghai
+ */
+
+INSERT INTO `sys_config` (`param_key`, `param_value`, `status`, `remark`) VALUES ( 'timezone', 'Asia/Shanghai', 1, '时区配置');
+
+/**
+ * 新增 magic api file 表
+ */
+DROP TABLE IF EXISTS `magic_api_file`;
+
+CREATE TABLE `magic_api_file` (
+ `file_path` varchar(512) NOT NULL,
+ `file_content` mediumtext,
+ PRIMARY KEY (`file_path`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
+
+DROP TABLE IF EXISTS `magic_api_backup`;
+
+CREATE TABLE `magic_api_backup` (
+ `id` varchar(32) NOT NULL COMMENT '原对象ID',
+ `create_date` bigint(13) NOT NULL COMMENT '备份时间',
+ `tag` varchar(32) DEFAULT NULL COMMENT '标签',
+ `type` varchar(32) DEFAULT NULL COMMENT '类型',
+ `name` varchar(64) DEFAULT NULL COMMENT '原名称',
+ `content` blob COMMENT '备份内容',
+ `create_by` varchar(64) DEFAULT NULL COMMENT '操作人',
+ PRIMARY KEY (`id`,`create_date`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
+
+/**
+ * 新增 sys_file sys_file_content 表
+ */
+DROP TABLE IF EXISTS `sys_file`;
+CREATE TABLE `sys_file` (
+ `id` varchar(64) NOT NULL COMMENT '文件md5值',
+ `name` varchar(255) NOT NULL,
+ `suffix` varchar(255) NOT NULL DEFAULT '' COMMENT '文件名后缀',
+ `content_type` varchar(255) DEFAULT NULL,
+ `size` bigint(20) NOT NULL,
+ `path` varchar(512) NOT NULL COMMENT 'file:相对路径 或 db:md5',
+ `create_timestamp` bigint(20) NOT NULL,
+ `remark` varchar(255) DEFAULT NULL,
+ PRIMARY KEY (`id`),
+ KEY `idx_name` (`name`) USING BTREE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
+
+DROP TABLE IF EXISTS `sys_file_content`;
+CREATE TABLE `sys_file_content` (
+ `id` varchar(64) NOT NULL,
+ `content` longblob NOT NULL,
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; \ No newline at end of file
diff --git a/src/main/resources/static/banner.txt b/src/main/resources/static/banner.txt
new file mode 100644
index 0000000..17eb02b
--- /dev/null
+++ b/src/main/resources/static/banner.txt
@@ -0,0 +1,8 @@
+ _____ _ _ _ __ __ _
+ /\ / ____| | | | | | \ \ / / | |
+ / \ _ __ _ __| (___ | | _____| |_ ___| |__ \ \ /\ / /__ _ __| | _____
+ / /\ \ | '_ \| '_ \\___ \| |/ / _ \ __/ __| '_ \ \ \/ \/ / _ \| '__| |/ / __|
+ / ____ \| |_) | |_) |___) | < __/ || (__| | | | \ /\ / (_) | | | <\__ \
+ /_/ \_\ .__/| .__/_____/|_|\_\___|\__\___|_| |_| \/ \/ \___/|_| |_|\_\___/
+ | | | |
+ |_| |_| Powered by GeedgeNetworks \ No newline at end of file
diff --git a/src/main/resources/static/magic-editor.js b/src/main/resources/static/magic-editor.js
new file mode 100644
index 0000000..17c6152
--- /dev/null
+++ b/src/main/resources/static/magic-editor.js
@@ -0,0 +1,10 @@
+var MAGIC_EDITOR_CONFIG = {
+ title: 'digital horizon api',
+ header: {
+ skin: true, // 屏蔽皮肤按钮
+ document: true, // 屏蔽文档按钮
+ repo: false, // 屏蔽gitee和github
+ qqGroup: false // 屏蔽加入QQ群
+ }
+ // 其它配置参考本页中其它配置项
+} \ No newline at end of file