From 834f283f8ba5401c4b5c1484b43f5b79bab0a4e8 Mon Sep 17 00:00:00 2001 From: FatttSnake Date: Tue, 3 Sep 2024 16:51:24 +0800 Subject: [PATCH 1/5] Build(pom): Optimize structure --- pom.xml | 356 +++++++++++++++++++++++++++++++++----------------------- 1 file changed, 212 insertions(+), 144 deletions(-) diff --git a/pom.xml b/pom.xml index 0f4ae0e..d50f75d 100644 --- a/pom.xml +++ b/pom.xml @@ -8,78 +8,140 @@ 3.2.1 - top.fatweb + + top.fatweb.oxygen api 0.0.1-SNAPSHOT + oxygen-api - oxygen-api - - - - sonatype-oss-snapshots - sonatype-oss-snapshots - https://s01.oss.sonatype.org/content/repositories/snapshots - - false - - - true - - - - - - - dev - - true - - env - dev - - - - - com.github.xiaoymin - knife4j-openapi3-jakarta-spring-boot-starter - 4.4.0 - - - - - prod - - - env - prod - - - - - com.github.xiaoymin - knife4j-openapi3-jakarta-spring-boot-starter - - - com.github.xiaoymin - knife4j-openapi3-ui - - - org.webjars - swagger-ui - - - - - - + API of Oxygen Toolbox + https://github.com/FatttSnake/oxygen-api 17 1.9.21 ${maven.build.timestamp} yyyy-MM-dd'T'HH:mm:ss + 3.0.3 + 2.3 + 3.5.7 + 4.3.1 9.22.3 + 4.4.0 + 1.1.0 + 6.4.9 + 3.5.3 + 4.4.0 + + + FatWeb + https://fatweb.top + + + + + GNU General Public License v3.0 or later + https://www.gnu.org/licenses/gpl-3.0-standalone.html + repo + + + + + + fatttsnake + FatttSnake + fatttsnake@gmail.com + + + + + ${project.name}-${project.version} + ${project.basedir}/src/main/kotlin + ${project.basedir}/src/test/kotlin + + + org.springframework.boot + spring-boot-maven-plugin + + + org.jetbrains.kotlin + kotlin-maven-plugin + + + compile + compile + + compile + + + + src/main/kotlin + target/generated-sources/annotations + + + + + test-compile + test-compile + + test-compile + + + + src/main/kotlin + target/generated-sources/annotations + + + + + + + -Xjsr305=strict + + + spring + + + + + org.jetbrains.kotlin + kotlin-maven-allopen + ${kotlin.version} + + + + + maven-surefire-plugin + 2.22.2 + + + maven-failsafe-plugin + 3.1.2 + + + org.jetbrains.dokka + dokka-maven-plugin + 1.9.10 + + + pre-site + + dokka + + + + attach-javadocJar + package + + javadocJar + + + + + + + org.springframework.boot @@ -111,20 +173,10 @@ runtime true - - org.springframework.boot - spring-boot-starter-test - test - - - org.springframework.security - spring-security-test - test - com.github.lianjiatech retrofit-spring-boot-starter - 3.0.3 + ${retrofit.version} @@ -147,7 +199,7 @@ org.apache.velocity velocity-engine-core - 2.3 + ${velocity.version} com.mysql @@ -157,17 +209,16 @@ com.baomidou mybatis-plus-spring-boot3-starter - 3.5.7 + ${mybatis-plus.version} org.xerial sqlite-jdbc - 3.44.1.0 com.baomidou dynamic-datasource-spring-boot3-starter - 4.3.1 + ${dynamic-datasource.version} org.flywaydb @@ -178,94 +229,111 @@ org.springframework.boot spring-boot-starter-data-redis - - com.baomidou - mybatis-plus-spring-boot3-starter-test - 3.5.7 - test - com.auth0 java-jwt - 4.4.0 + ${jwt.version} top.fatweb avatar-generator - 1.1.0 + ${avatar-generator.version} com.github.oshi oshi-core - 6.4.9 + ${oshi.version} commons-codec commons-codec - 1.16.1 com.google.zxing core - 3.5.3 + ${zxing.version} + + + + + org.springframework.boot + spring-boot-starter-test + test + + + org.springframework.security + spring-security-test + test + + + com.baomidou + mybatis-plus-spring-boot3-starter-test + ${mybatis-plus.version} + test - - ${project.basedir}/src/main/kotlin - ${project.basedir}/src/test/kotlin - - - org.springframework.boot - spring-boot-maven-plugin - - - org.jetbrains.kotlin - kotlin-maven-plugin - - - compile - process-sources - - compile - - - - src/main/kotlin - target/generated-sources/annotations - - - - - - - -Xjsr305=strict - - - spring - - - - - org.jetbrains.kotlin - kotlin-maven-allopen - ${kotlin.version} - - - - - org.jetbrains.dokka - dokka-maven-plugin - 1.9.10 - - - pre-site - - dokka - - - - - - + + + dev + + true + + env + dev + + + + + com.github.xiaoymin + knife4j-openapi3-jakarta-spring-boot-starter + ${knife4j.version} + + + + + release + + + env + release + + + + + com.github.xiaoymin + knife4j-openapi3-jakarta-spring-boot-starter + ${knife4j.version} + + + com.github.xiaoymin + knife4j-openapi3-ui + + + org.webjars + swagger-ui + + + + + + + + org.apache.maven.plugins + maven-gpg-plugin + 3.1.0 + + + sign-artifact + verify + + sign + + + + + + + + From 909a169373c3cdb417c76563c33e7938554c60a6 Mon Sep 17 00:00:00 2001 From: FatttSnake Date: Wed, 4 Sep 2024 17:34:42 +0800 Subject: [PATCH 2/5] Docs(README): Add README.md and README_zh.md --- README.md | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++ README_zh.md | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++ doc/logo.svg | 1 + 3 files changed, 161 insertions(+) create mode 100644 README.md create mode 100644 README_zh.md create mode 100644 doc/logo.svg diff --git a/README.md b/README.md new file mode 100644 index 0000000..e979450 --- /dev/null +++ b/README.md @@ -0,0 +1,80 @@ +
+

+ Logo +
+ API of Oxygen Toolbox +

+
+ +--- + +
+ + Build + + + Release + + + LICENSE + +
+ +# Overview ([ZH](README_zh.md), EN) + +This project is the backend API of Oxygen Toolbox. Provides tool store, tool management, authentication, user management and other functions. + +# Requires + +- Java 17+ +- MySQL +- Redis + +# Related projects + +[Web UI of Oxygen Toolbox](https://github.com/FatttSnake/oxygen-ui) + +[Desktop Client of Oxygen Toolbox](https://github.com/FatttSnake/oxygen-desktop) + +[Android Client of Oxygen Toolbox](https://github.com/FatttSnake/oxygen-android) + +# Quick Start + +1. First run, generate configuration file template + +```shell +java -jar oxygen-api.jar +``` + +2. Copy the `application-config.example.yml` file in the `data` directory to the running directory and rename it to `application-config.yml` + +```shell +cp ./data/application-config.example.yml application-config.yml +``` + +3. Edit the content of the configuration file `application-config.yml` + + +4. Run again + +```shell +java -jar oxygen-api.jar +``` + +# Security + +Integration with Spring Security and add other filter for jwt token process. The secret key is stored in `application-config.yml`. + +# Database + +Two databases, MySQL + SQLite, are used. MySQL is used to store key data, and SQLite is used to store logs and other data that require a large amount of reading and writing. + +# Q&A + +> **Q: What is the default administrator account and password?** +> +> A: If configured in `application-config.yml` before initializing the database, use the specified account and password. If not configured, a random password will be generated by default. See the console output for details. + +> **Q: Do I need to initialize the database?** +> +> A: This project uses `Flyway` to automatically initialize the database without manually defining the data table structure. To ensure data security, please back up the database before upgrading. diff --git a/README_zh.md b/README_zh.md new file mode 100644 index 0000000..5860633 --- /dev/null +++ b/README_zh.md @@ -0,0 +1,80 @@ +
+

+ Logo +
+ API of Oxygen Toolbox +

+
+ +--- + +
+ + Build + + + Release + + + LICENSE + +
+ +# 概述 (ZH, [EN](README.md)) + +本项目为 Oxygen Toolbox 的后端 API。提供工具商店、工具管理、认证鉴权、用户管理等功能。 + +# 环境要求 + +- Java 17+ +- MySQL +- Redis + +# 关联项目 + +[Web UI of Oxygen Toolbox](https://github.com/FatttSnake/oxygen-ui) + +[Desktop Client of Oxygen Toolbox](https://github.com/FatttSnake/oxygen-desktop) + +[Android Client of Oxygen Toolbox](https://github.com/FatttSnake/oxygen-android) + +# 快速开始 + +1. 初次运行,生成配置文件模板 + +```shell +java -jar oxygen-api.jar +``` + +2. 将 `data` 目录下的 `application-config.example.yml` 文件复制到运行目录下,并重命名为 `application-config.yml` + +```shell +cp ./data/application-config.example.yml application-config.yml +``` + +3. 编辑配置文件 `application-config.yml` 内容 + + +4. 再次运行 + +```shell +java -jar oxygen-api.jar +``` + +# 安全 + +集成 Spring Security 并采用 jwt 令牌, 密钥存储在 `application-config.yml` 中。 + +# 数据库 + +采用 MySQL + SQLite 双数据库,MySQL 用于存放关键数据,SQLite 用于存放日志等需要大量读写的数据。 + +# Q&A + +> **Q: 默认管理员账号和密码是什么?** +> +> A: 初始化数据库前配置在 `application-config.yml` 中,则使用所指定账号密码。未配置则默认生成随机密码,详见控制台输出。 + +> **Q: 是否需要初始化数据库?** +> +> A: 本项目采用 `Flyway` 自动初始化数据库,无需手动定义数据表结构。为保证数据安全,升级时请先备份数据库。 diff --git a/doc/logo.svg b/doc/logo.svg new file mode 100644 index 0000000..6b67342 --- /dev/null +++ b/doc/logo.svg @@ -0,0 +1 @@ + From 6b3639232baa99a49a213f54733f1162ffedb0f5 Mon Sep 17 00:00:00 2001 From: FatttSnake Date: Wed, 4 Sep 2024 17:35:42 +0800 Subject: [PATCH 3/5] Build(pom): Update version from 0.0.1-SNAPSHOT to 1.0.0-SNAPSHOT --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d50f75d..8032bfb 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ top.fatweb.oxygen api - 0.0.1-SNAPSHOT + 1.0.0-SNAPSHOT oxygen-api API of Oxygen Toolbox From 126af27c02aedfa4cc72fefed69666985c3ff688 Mon Sep 17 00:00:00 2001 From: FatttSnake Date: Wed, 4 Sep 2024 17:37:31 +0800 Subject: [PATCH 4/5] Refactor(README): Update README.md and README_zh.md --- README.md | 3 --- README_zh.md | 3 --- 2 files changed, 6 deletions(-) diff --git a/README.md b/README.md index e979450..3f634ba 100644 --- a/README.md +++ b/README.md @@ -5,9 +5,6 @@ API of Oxygen Toolbox - ---- - - ---- -
Build From 3202bb5422019efa9be7f79b9bb3b264b42da897 Mon Sep 17 00:00:00 2001 From: FatttSnake Date: Wed, 4 Sep 2024 18:12:54 +0800 Subject: [PATCH 5/5] Build(build-docker.sh): Optimize script --- build-docker.sh | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/build-docker.sh b/build-docker.sh index d615bdb..1d585aa 100644 --- a/build-docker.sh +++ b/build-docker.sh @@ -1,24 +1,17 @@ #!/bin/bash -JAR_NAME=`ls target | grep api-|grep -v original` +JAR_NAME=`ls target | grep oxygen-api- | grep -vE "original|asc|pom|javadoc"` JAR_VERSION=${JAR_NAME%.*} JAR_VERSION=${JAR_VERSION#*-} +JAR_VERSION=${JAR_VERSION#*-} BUILD_TIME=$(date "+%Y%m%d%H%M%S") mkdir target/extracted -java -Djarmode=layertools -jar target/*.jar extract --destination target/extracted +java -Djarmode=layertools -jar target/${JAR_NAME} extract --destination target/extracted if [[ "${JAR_VERSION}" =~ ^.*SNAPSHOT$ ]] then - docker build -t ${DOCKER_HUB_URL}/oxygen-api:snapshot-latest -t ${DOCKER_HUB_URL}/oxygen-api:$JAR_VERSION -t ${DOCKER_HUB_URL}/oxygen-api:$JAR_VERSION-${BUILD_TIME} . - cat "${KEYS_PATH}/docker.password" | docker login ${DOCKER_HUB_URL} -u jenkins --password-stdin - docker push ${DOCKER_HUB_URL}/oxygen-api:snapshot-latest - docker push ${DOCKER_HUB_URL}/oxygen-api:$JAR_VERSION - docker push ${DOCKER_HUB_URL}/oxygen-api:$JAR_VERSION-${BUILD_TIME} + docker build -t ${DOCKER_HUB_URL}/oxygen-api:snapshot-latest -t ${DOCKER_HUB_URL}/oxygen-api:${JAR_VERSION} -t ${DOCKER_HUB_URL}/oxygen-api:${JAR_VERSION}-${BUILD_TIME} . else - docker build -t ${DOCKER_HUB_URL}/oxygen-api:latest -t ${DOCKER_HUB_URL}/oxygen-api:$JAR_VERSION -t ${DOCKER_HUB_URL}/oxygen-api:$JAR_VERSION-${BUILD_TIME} . - cat "${KEYS_PATH}/docker.password" | docker login ${DOCKER_HUB_URL} -u jenkins --password-stdin - docker push ${DOCKER_HUB_URL}/oxygen-api:latest - docker push ${DOCKER_HUB_URL}/oxygen-api:$JAR_VERSION - docker push ${DOCKER_HUB_URL}/oxygen-api:$JAR_VERSION-${BUILD_TIME} + docker build -t ${DOCKER_HUB_URL}/oxygen-api:latest -t ${DOCKER_HUB_URL}/oxygen-api:${JAR_VERSION} -t ${DOCKER_HUB_URL}/oxygen-api:${JAR_VERSION}-${BUILD_TIME} . fi \ No newline at end of file