102 lines
1.6 KiB
Markdown
102 lines
1.6 KiB
Markdown
# 快速启动指南
|
|
|
|
## 环境要求
|
|
|
|
- JDK 17+
|
|
- Maven 3.9+
|
|
- PostgreSQL 16+
|
|
|
|
## 数据库准备
|
|
|
|
```bash
|
|
# 1. 创建数据库
|
|
psql -U postgres
|
|
CREATE DATABASE gym_manage;
|
|
\q
|
|
|
|
# 2. 执行初始化脚本
|
|
psql -U postgres -d gym_manage -f src/main/resources/schema.sql
|
|
```
|
|
|
|
## 启动应用
|
|
|
|
```bash
|
|
# 1. 编译项目
|
|
mvn clean install
|
|
|
|
# 2. 启动应用
|
|
mvn spring-boot:run
|
|
|
|
# 或者直接运行jar
|
|
java -jar target/gym-manage-1.0.0-SNAPSHOT.jar
|
|
```
|
|
|
|
## 访问应用
|
|
|
|
- 应用地址: http://localhost:8080
|
|
- Swagger文档: http://localhost:8080/swagger-ui.html
|
|
- 健康检查: http://localhost:8080/actuator/health
|
|
|
|
## API测试
|
|
|
|
### 创建会员
|
|
|
|
```bash
|
|
curl -X POST http://localhost:8080/api/v1/members \
|
|
-H "Content-Type: application/json" \
|
|
-d '{
|
|
"tenantId": 1,
|
|
"storeId": 1,
|
|
"name": "张三",
|
|
"phone": "13800138000",
|
|
"gender": "MALE",
|
|
"level": "NORMAL"
|
|
}'
|
|
```
|
|
|
|
### 查询会员
|
|
|
|
```bash
|
|
curl -X GET http://localhost:8080/api/v1/members/1
|
|
```
|
|
|
|
### 创建预约
|
|
|
|
```bash
|
|
curl -X POST http://localhost:8080/api/v1/bookings \
|
|
-H "Content-Type: application/json" \
|
|
-d '{
|
|
"memberId": 1,
|
|
"slotId": 1
|
|
}'
|
|
```
|
|
|
|
## 运行测试
|
|
|
|
```bash
|
|
# 运行所有测试
|
|
mvn test
|
|
|
|
# 运行特定测试
|
|
mvn test -Dtest=MemberServiceTest
|
|
```
|
|
|
|
## 常见问题
|
|
|
|
### 1. 数据库连接失败
|
|
|
|
检查 application.yml 中的数据库配置是否正确。
|
|
|
|
### 2. 端口被占用
|
|
|
|
修改 application.yml 中的 server.port 配置。
|
|
|
|
### 3. 依赖下载失败
|
|
|
|
检查 Maven 仓库配置,或使用阿里云镜像。
|
|
|
|
## 技术支持
|
|
|
|
- 技术负责人: 张翔
|
|
- 邮箱: zhangxiang@example.com
|