Skip to content

Commit f65fa12

Browse files
committed
feat: HaloLight API Java - 企业级后端服务实现
基于 Spring Boot 3.4.1 + Java 23 构建的企业级后端 API, 与 NestJS 版本共用同一数据库(PostgreSQL/Neon)和接口规范。 主要功能: - JWT 双令牌认证机制 (AccessToken + RefreshToken) - RBAC 角色权限控制 - 12 个核心业务模块 (Auth, Users, Roles, Permissions, Documents, Files, Folders, Calendar, Teams, Messages, Notifications, Dashboard) - Springdoc OpenAPI 文档 - Caffeine 本地缓存 + Bucket4j 限流 - Spring Actuator + Micrometer + Prometheus 可观测性 - Fly.io 部署支持
0 parents  commit f65fa12

File tree

177 files changed

+13761
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

177 files changed

+13761
-0
lines changed

.env.example

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Database Configuration
2+
DATABASE_URL=jdbc:postgresql://localhost:5432/halolight
3+
DATABASE_USERNAME=postgres
4+
DATABASE_PASSWORD=postgres
5+
6+
# JWT Configuration
7+
JWT_SECRET=halolight-secret-key-change-in-production-minimum-256-bits
8+
JWT_EXPIRATION=86400000
9+
JWT_REFRESH_EXPIRATION=604800000
10+
11+
# CORS Configuration
12+
CORS_ALLOWED_ORIGINS=http://localhost:3000,http://localhost:5173
13+
CORS_ALLOWED_METHODS=GET,POST,PUT,DELETE,OPTIONS,PATCH
14+
CORS_ALLOWED_HEADERS=*
15+
CORS_ALLOW_CREDENTIALS=true
16+
17+
# Application Configuration
18+
APP_NAME=HaloLight
19+
PORT=8000
20+
SPRING_PROFILES_ACTIVE=dev
21+
22+
# Logging
23+
LOG_LEVEL=DEBUG
24+
SQL_LOG_LEVEL=DEBUG
25+
SHOW_SQL=true

.github/workflows/ci.yml

Lines changed: 221 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,221 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main, master, develop]
6+
pull_request:
7+
branches: [main, master, develop]
8+
workflow_dispatch:
9+
10+
# 取消同一分支的之前运行,节省资源
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.ref }}
13+
cancel-in-progress: true
14+
15+
env:
16+
JAVA_VERSION: "23"
17+
JAVA_DISTRIBUTION: "temurin"
18+
CI: "true"
19+
20+
jobs:
21+
# ============================================================================
22+
# 代码质量检查
23+
# ============================================================================
24+
lint:
25+
name: Lint & Compile
26+
runs-on: ubuntu-latest
27+
steps:
28+
- name: Checkout repository
29+
uses: actions/checkout@v4
30+
31+
- name: Setup Java
32+
uses: actions/setup-java@v4
33+
with:
34+
java-version: ${{ env.JAVA_VERSION }}
35+
distribution: ${{ env.JAVA_DISTRIBUTION }}
36+
cache: maven
37+
38+
- name: Cache Maven packages
39+
uses: actions/cache@v4
40+
with:
41+
path: ~/.m2/repository
42+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
43+
restore-keys: |
44+
${{ runner.os }}-maven-
45+
46+
- name: Compile project
47+
run: ./mvnw compile -DskipTests -q
48+
49+
- name: Check code style with Checkstyle
50+
run: ./mvnw checkstyle:check -q || true
51+
continue-on-error: true
52+
53+
# ============================================================================
54+
# 单元测试
55+
# ============================================================================
56+
test:
57+
name: Unit Tests
58+
runs-on: ubuntu-latest
59+
needs: lint
60+
steps:
61+
- name: Checkout repository
62+
uses: actions/checkout@v4
63+
64+
- name: Setup Java
65+
uses: actions/setup-java@v4
66+
with:
67+
java-version: ${{ env.JAVA_VERSION }}
68+
distribution: ${{ env.JAVA_DISTRIBUTION }}
69+
cache: maven
70+
71+
- name: Cache Maven packages
72+
uses: actions/cache@v4
73+
with:
74+
path: ~/.m2/repository
75+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
76+
restore-keys: |
77+
${{ runner.os }}-maven-
78+
79+
- name: Run unit tests with coverage
80+
run: ./mvnw test -q
81+
continue-on-error: true
82+
83+
- name: Upload coverage to Codecov
84+
uses: codecov/codecov-action@v4
85+
if: always()
86+
with:
87+
token: ${{ secrets.CODECOV_TOKEN }}
88+
fail_ci_if_error: false
89+
files: target/site/jacoco/jacoco.xml
90+
flags: unittests
91+
name: codecov-umbrella
92+
93+
# ============================================================================
94+
# 集成测试
95+
# ============================================================================
96+
integration-test:
97+
name: Integration Tests
98+
runs-on: ubuntu-latest
99+
needs: lint
100+
101+
# PostgreSQL 服务
102+
services:
103+
postgres:
104+
image: postgres:16-alpine
105+
env:
106+
POSTGRES_USER: test
107+
POSTGRES_PASSWORD: test
108+
POSTGRES_DB: test
109+
options: >-
110+
--health-cmd pg_isready
111+
--health-interval 10s
112+
--health-timeout 5s
113+
--health-retries 5
114+
ports:
115+
- 5432:5432
116+
117+
env:
118+
SPRING_PROFILES_ACTIVE: test
119+
SPRING_DATASOURCE_URL: jdbc:postgresql://localhost:5432/test
120+
SPRING_DATASOURCE_USERNAME: test
121+
SPRING_DATASOURCE_PASSWORD: test
122+
JWT_SECRET: test-secret-key-for-ci-must-be-at-least-32-chars
123+
REFRESH_TOKEN_SECRET: test-refresh-secret-key-for-ci-32chars
124+
125+
steps:
126+
- name: Checkout repository
127+
uses: actions/checkout@v4
128+
129+
- name: Setup Java
130+
uses: actions/setup-java@v4
131+
with:
132+
java-version: ${{ env.JAVA_VERSION }}
133+
distribution: ${{ env.JAVA_DISTRIBUTION }}
134+
cache: maven
135+
136+
- name: Cache Maven packages
137+
uses: actions/cache@v4
138+
with:
139+
path: ~/.m2/repository
140+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
141+
restore-keys: |
142+
${{ runner.os }}-maven-
143+
144+
- name: Run integration tests
145+
run: ./mvnw verify -DskipTests=false -q
146+
continue-on-error: true
147+
148+
# ============================================================================
149+
# 构建检查
150+
# ============================================================================
151+
build:
152+
name: Build
153+
runs-on: ubuntu-latest
154+
needs: lint
155+
steps:
156+
- name: Checkout repository
157+
uses: actions/checkout@v4
158+
159+
- name: Setup Java
160+
uses: actions/setup-java@v4
161+
with:
162+
java-version: ${{ env.JAVA_VERSION }}
163+
distribution: ${{ env.JAVA_DISTRIBUTION }}
164+
cache: maven
165+
166+
- name: Cache Maven packages
167+
uses: actions/cache@v4
168+
with:
169+
path: ~/.m2/repository
170+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
171+
restore-keys: |
172+
${{ runner.os }}-maven-
173+
174+
- name: Build application
175+
run: ./mvnw package -DskipTests -q
176+
177+
- name: Upload build artifacts
178+
uses: actions/upload-artifact@v4
179+
with:
180+
name: build-output
181+
path: |
182+
target/*.jar
183+
retention-days: 7
184+
185+
# ============================================================================
186+
# 依赖安全审计
187+
# ============================================================================
188+
security:
189+
name: Security Audit
190+
runs-on: ubuntu-latest
191+
steps:
192+
- name: Checkout repository
193+
uses: actions/checkout@v4
194+
195+
- name: Setup Java
196+
uses: actions/setup-java@v4
197+
with:
198+
java-version: ${{ env.JAVA_VERSION }}
199+
distribution: ${{ env.JAVA_DISTRIBUTION }}
200+
cache: maven
201+
202+
- name: Run OWASP Dependency Check
203+
run: ./mvnw org.owasp:dependency-check-maven:check -q || true
204+
continue-on-error: true
205+
206+
# ============================================================================
207+
# 依赖更新检查(仅 PR)
208+
# ============================================================================
209+
dependency-review:
210+
name: Dependency Review
211+
runs-on: ubuntu-latest
212+
if: github.event_name == 'pull_request'
213+
steps:
214+
- name: Checkout repository
215+
uses: actions/checkout@v4
216+
217+
- name: Dependency Review
218+
uses: actions/dependency-review-action@v4
219+
with:
220+
fail-on-severity: high
221+
allow-licenses: MIT, Apache-2.0, BSD-2-Clause, BSD-3-Clause, EPL-1.0, EPL-2.0, LGPL-2.1, LGPL-3.0

.gitignore

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
HELP.md
2+
target/
3+
!.mvn/wrapper/maven-wrapper.jar
4+
!**/src/main/**/target/
5+
!**/src/test/**/target/
6+
7+
### STS ###
8+
.apt_generated
9+
.classpath
10+
.factorypath
11+
.project
12+
.settings
13+
.springBeans
14+
.sts4-cache
15+
16+
### IntelliJ IDEA ###
17+
.idea
18+
*.iws
19+
*.iml
20+
*.ipr
21+
22+
### NetBeans ###
23+
/nbproject/private/
24+
/nbbuild/
25+
/dist/
26+
/nbdist/
27+
/.nb-gradle/
28+
build/
29+
!**/src/main/**/build/
30+
!**/src/test/**/build/
31+
32+
### VS Code ###
33+
.vscode/
34+
35+
### Environment ###
36+
.env
37+
.env.local
38+
.env.*.local
39+
40+
### Logs ###
41+
*.log
42+
logs/
43+
44+
### OS ###
45+
.DS_Store
46+
Thumbs.db
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
wrapperVersion=3.3.4
2+
distributionType=only-script
3+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip

0 commit comments

Comments
 (0)