You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

87 lines
2.2 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

# SZKP 地图服务 - 后端Laravel + MySQL
## 本地环境
- PHP8.1(当前工程初始化为 Laravel 10
- MySQL8.x
## 数据库配置(本地)
已按你的要求写入 `.env`
- **DB_DATABASE**: `szkp_map_local`
- **DB_USERNAME**: `root`
- **DB_PASSWORD**: `root123456`
## 初始化与启动
```bash
composer install
# 首次需要创建数据库(已创建可跳过)
mysql -uroot -proot123456 -e "CREATE DATABASE IF NOT EXISTS szkp_map_local DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"
php artisan migrate
php artisan serve --host=127.0.0.1 --port=8000
```
启动后访问 `http://127.0.0.1:8000/`
## 本地与测试环境切换
项目已提供两套后端环境文件:
- 本地:`.env`
- 测试:`.env.testing`(域名 `szkp-map.ali251.langye.net`
本地启动(默认读取 `.env`
```bash
php artisan config:clear
php artisan serve --host=127.0.0.1 --port=8000
```
测试配置启动(读取 `.env.testing`
```bash
php artisan config:clear
php artisan serve --env=testing --host=0.0.0.0 --port=8000
```
如果测试库用户名不是 `szkp_map_ali251_`,请修改 `.env.testing``DB_USERNAME`
### 前端测试模式
- 后台管理(`szkp-map-web`
- 本地:`npm run dev`
- 测试:`npm run dev:testing`
- H5`szkp-map-h5`
- 本地:`npm run dev:h5`
- 测试:`npm run dev:h5:testing`
跨域已改为白名单配置,默认放行:
- `http://localhost:5173`
- `http://127.0.0.1:5173`
- `http://localhost:5174`
- `http://127.0.0.1:5174`
- `https://szkp-map.ali251.langye.net`
## 默认测试账号(`php artisan db:seed` 后)
- 超级管理员:`admin` / `admin123456`
- 场馆管理员:`venue_admin_01` / `admin123456`
场馆管理员已绑定一个默认场馆,用于测试“仅可编辑自己场馆、仅可核销自己场馆预约二维码”。
## 已提供接口(管理员与场馆权限)
- `POST /api/auth/login`
- `POST /api/auth/logout`
- `GET /api/me`
- `GET/POST/PUT /api/venues`(场馆管理员仅能查看/编辑自己绑定场馆)
- `GET/POST/PUT /api/admin-users`(仅超级管理员)
- `POST /api/reservations/verify`(按二维码核销,且限制到当前账号绑定场馆)