diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0aca4ed --- /dev/null +++ b/.gitignore @@ -0,0 +1,21 @@ +node_modules/ +.DS_Store +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# 后端 +backend/.env +backend/uploads/ +backend/logs/ + +# 前端 +frontend/dist/ +frontend/node_modules/ + +# IDE +.idea/ +.vscode/ +*.swp +*.swo diff --git a/README.md b/README.md index 3b1c850..70c60de 100644 --- a/README.md +++ b/README.md @@ -1 +1,330 @@ -# NullRepo +# 本地小众商户引流平台 + +一个前后端一体的本地小众商户引流平台,支持商户入驻、优惠券发布、用户预约、评价等功能。 + +## 功能特性 + +### 商户功能 +- ✅ 商户入驻申请与资质审核 +- ✅ 店铺信息编辑与管理 +- ✅ 优惠券发布与管理(支持设置金额、限量、有效期) +- ✅ 优惠券核销 +- ✅ 预约管理(确认、完成) +- ✅ 评价查看与回复 + +### 用户功能 +- ✅ 用户注册与登录 +- ✅ 浏览与筛选商户/店铺 +- ✅ 领取优惠券 +- ✅ 预约到店 +- ✅ 发布图文评分评价 +- ✅ 商户收藏 +- ✅ 浏览记录查询 + +### 管理员功能 +- ✅ 商户资质审核 +- ✅ 用户管理 +- ✅ 店铺管理 +- ✅ 评价管理 +- ✅ 数据统计 + +## 技术栈 + +### 后端 +- Node.js + Express +- MySQL 数据库 +- JWT 认证 +- bcryptjs 密码加密 +- express-validator 数据验证 + +### 前端 +- Vue.js 3 +- Vue Router 路由 +- Pinia 状态管理 +- Axios HTTP 客户端 +- Vite 构建工具 + +## 项目结构 + +``` +NullRepo/ +├── backend/ # 后端项目 +│ ├── config/ # 配置文件 +│ │ └── database.js # 数据库连接配置 +│ ├── controllers/ # 控制器 +│ │ ├── adminController.js +│ │ ├── authController.js +│ │ ├── couponController.js +│ │ ├── favoriteController.js +│ │ ├── historyController.js +│ │ ├── merchantController.js +│ │ ├── reservationController.js +│ │ ├── reviewController.js +│ │ └── shopController.js +│ ├── middleware/ # 中间件 +│ │ └── auth.js # 认证中间件 +│ ├── routes/ # 路由 +│ │ ├── admin.js +│ │ ├── auth.js +│ │ ├── coupon.js +│ │ ├── favorite.js +│ │ ├── history.js +│ │ ├── merchant.js +│ │ ├── reservation.js +│ │ ├── review.js +│ │ └── shop.js +│ ├── app.js # 应用入口 +│ ├── package.json +│ └── .env.example # 环境变量示例 +├── frontend/ # 前端项目 +│ ├── src/ +│ │ ├── api/ # API 接口 +│ │ │ ├── admin.js +│ │ │ ├── auth.js +│ │ │ ├── coupon.js +│ │ │ ├── favorite.js +│ │ │ ├── history.js +│ │ │ ├── merchant.js +│ │ │ ├── reservation.js +│ │ │ ├── review.js +│ │ │ └── shop.js +│ │ ├── router/ # 路由配置 +│ │ │ └── index.js +│ │ ├── stores/ # 状态管理 +│ │ │ └── user.js +│ │ ├── utils/ # 工具函数 +│ │ │ └── request.js # Axios 封装 +│ │ ├── views/ # 页面组件 +│ │ │ ├── merchant/ # 商户端页面 +│ │ │ │ ├── Apply.vue +│ │ │ │ └── Dashboard.vue +│ │ │ ├── Home.vue +│ │ │ ├── Login.vue +│ │ │ ├── Profile.vue +│ │ │ ├── Register.vue +│ │ │ ├── ShopDetail.vue +│ │ │ └── Shops.vue +│ │ ├── App.vue +│ │ ├── main.js +│ │ └── style.css +│ ├── index.html +│ ├── package.json +│ └── vite.config.js +├── database/ # 数据库 +│ └── schema.sql # 数据库模型 +└── README.md +``` + +## 安装与运行 + +### 前置要求 +- Node.js (>= 14.0.0) +- MySQL (>= 5.7) + +### 数据库配置 + +1. 创建数据库并导入数据模型: +```bash +mysql -u root -p < database/schema.sql +``` + +或者手动执行 `database/schema.sql` 中的 SQL 语句。 + +### 后端配置 + +1. 进入后端目录: +```bash +cd backend +``` + +2. 安装依赖: +```bash +npm install +``` + +3. 复制环境变量配置: +```bash +cp .env.example .env +``` + +4. 编辑 `.env` 文件,配置数据库连接和 JWT 密钥: +```env +PORT=3000 +NODE_ENV=development + +# 数据库配置 +DB_HOST=localhost +DB_PORT=3306 +DB_USER=root +DB_PASSWORD=your_password +DB_NAME=merchant_platform + +# JWT 配置 +JWT_SECRET=your_jwt_secret_key_here +JWT_EXPIRES_IN=7d + +# 上传配置 +UPLOAD_PATH=./uploads +MAX_FILE_SIZE=5242880 +``` + +5. 启动后端服务: +```bash +# 开发模式(使用 nodemon 自动重启) +npm run dev + +# 生产模式 +npm start +``` + +后端服务将运行在 http://localhost:3000 + +### 前端配置 + +1. 进入前端目录: +```bash +cd frontend +``` + +2. 安装依赖: +```bash +npm install +``` + +3. 启动开发服务器: +```bash +npm run dev +``` + +前端服务将运行在 http://localhost:5173 + +4. 构建生产版本: +```bash +npm run build +``` + +## API 文档 + +### 认证接口 +- `POST /api/auth/register` - 用户注册 +- `POST /api/auth/login` - 用户登录 +- `GET /api/auth/me` - 获取当前用户信息 +- `PUT /api/auth/profile` - 更新用户信息 +- `PUT /api/auth/password` - 修改密码 + +### 商户接口 +- `POST /api/merchant/apply` - 提交商户资质申请 +- `GET /api/merchant/application` - 获取申请状态 +- `GET /api/merchant/applications` - 获取所有申请(管理员) +- `PUT /api/merchant/applications/:id/review` - 审核申请(管理员) + +### 店铺接口 +- `GET /api/shops` - 获取所有店铺 +- `GET /api/shops/:id` - 获取店铺详情 +- `GET /api/shops/search` - 搜索店铺 +- `POST /api/shops` - 创建店铺(商户) +- `GET /api/shops/my/shop` - 获取当前商户的店铺 +- `PUT /api/shops/my/shop` - 更新店铺信息(商户) + +### 优惠券接口 +- `GET /api/coupons/available` - 获取可用优惠券 +- `GET /api/coupons/:id` - 获取优惠券详情 +- `POST /api/coupons/:id/claim` - 领取优惠券 +- `GET /api/coupons/my/list` - 获取我的优惠券 +- `POST /api/coupons/my/:id/use` - 使用优惠券 +- `POST /api/coupons/verify` - 商户核销优惠券 +- `POST /api/coupons` - 发布优惠券(商户) +- `GET /api/coupons/my/merchant` - 获取商户的优惠券列表 + +### 预约接口 +- `POST /api/reservations` - 创建预约 +- `GET /api/reservations/my/list` - 获取我的预约 +- `GET /api/reservations/:id` - 获取预约详情 +- `PUT /api/reservations/:id/cancel` - 取消预约 +- `GET /api/reservations/shop/list` - 获取店铺的预约(商户) +- `PUT /api/reservations/:id/confirm` - 确认预约(商户) +- `PUT /api/reservations/:id/complete` - 完成预约(商户) + +### 评价接口 +- `POST /api/reviews` - 创建评价 +- `GET /api/reviews/my/list` - 获取我的评价 +- `GET /api/reviews/:id` - 获取评价详情 +- `PUT /api/reviews/:id` - 更新评价 +- `PUT /api/reviews/:id/reply` - 回复评价(商户) +- `GET /api/reviews/shop/list` - 获取店铺的评价(商户) + +### 收藏接口 +- `POST /api/favorites` - 添加收藏 +- `DELETE /api/favorites/:shopId` - 移除收藏 +- `GET /api/favorites/my/list` - 获取我的收藏 +- `GET /api/favorites/check/:shopId` - 检查是否已收藏 + +### 浏览记录接口 +- `GET /api/history/my/list` - 获取浏览记录 +- `DELETE /api/history/clear` - 清空浏览记录 + +### 管理员接口 +- `GET /api/admin/dashboard` - 获取统计数据 +- `GET /api/admin/users` - 获取用户列表 +- `PUT /api/admin/users/:id/status` - 更新用户状态 +- `GET /api/admin/shops` - 获取店铺列表 +- `PUT /api/admin/shops/:id/status` - 更新店铺状态 +- `GET /api/admin/coupons` - 获取优惠券列表 +- `GET /api/admin/reviews` - 获取评价列表 +- `DELETE /api/admin/reviews/:id` - 删除评价 + +## 数据库表结构 + +### users(用户表) +- id, username, password, email, phone, avatar, role, status, created_at, updated_at + +### merchant_applications(商户资质审核表) +- id, user_id, business_name, business_license, legal_person, id_card, id_card_front, id_card_back, contact_phone, contact_email, business_type, business_description, status, rejection_reason, submitted_at, reviewed_at, reviewed_by + +### shops(店铺表) +- id, merchant_id, shop_name, shop_logo, shop_photos, shop_type, business_hours, address, latitude, longitude, contact_phone, description, average_rating, rating_count, status, created_at, updated_at + +### coupons(优惠券表) +- id, shop_id, coupon_name, coupon_type, discount_value, min_spend, total_quantity, used_quantity, claimed_quantity, start_date, end_date, usage_type, description, terms_and_conditions, status, created_at, updated_at + +### user_coupons(用户优惠券表) +- id, user_id, coupon_id, claimed_at, used_at, status + +### reservations(预约表) +- id, user_id, shop_id, reservation_date, reservation_time, people_count, contact_name, contact_phone, special_requests, status, created_at, updated_at + +### reviews(评价表) +- id, user_id, shop_id, reservation_id, rating, content, images, is_anonymous, reply, reply_at, status, created_at, updated_at + +### favorites(收藏表) +- id, user_id, shop_id, created_at + +### browsing_history(浏览记录表) +- id, user_id, shop_id, viewed_at + +## 开发说明 + +### 用户角色 +- `user` - 普通用户 +- `merchant` - 商户用户 +- `admin` - 管理员 + +### 优惠券类型 +- `fixed` - 固定金额减免 +- `percentage` - 折扣 +- `free` - 免费 + +### 预约状态 +- `pending` - 待确认 +- `confirmed` - 已确认 +- `cancelled` - 已取消 +- `completed` - 已完成 + +### 商户申请状态 +- `pending` - 待审核 +- `approved` - 已通过 +- `rejected` - 已拒绝 + +## 许可证 + +ISC diff --git a/backend/.env.example b/backend/.env.example new file mode 100644 index 0000000..c728a9c --- /dev/null +++ b/backend/.env.example @@ -0,0 +1,18 @@ +# 服务器配置 +PORT=3000 +NODE_ENV=development + +# 数据库配置 +DB_HOST=localhost +DB_PORT=3306 +DB_USER=root +DB_PASSWORD=your_password +DB_NAME=merchant_platform + +# JWT 配置 +JWT_SECRET=your_jwt_secret_key_here +JWT_EXPIRES_IN=7d + +# 上传配置 +UPLOAD_PATH=./uploads +MAX_FILE_SIZE=5242880 diff --git a/backend/.gitignore b/backend/.gitignore new file mode 100644 index 0000000..65b68d2 --- /dev/null +++ b/backend/.gitignore @@ -0,0 +1,9 @@ +node_modules/ +.env +uploads/ +logs/ +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +.DS_Store diff --git a/backend/app.js b/backend/app.js new file mode 100644 index 0000000..a1c5666 --- /dev/null +++ b/backend/app.js @@ -0,0 +1,90 @@ +const express = require('express'); +const cors = require('cors'); +const path = require('path'); +require('dotenv').config(); + +// 创建 Express 应用 +const app = express(); + +// 中间件配置 +app.use(cors()); +app.use(express.json()); +app.use(express.urlencoded({ extended: true })); + +// 静态文件服务 +app.use('/uploads', express.static(path.join(__dirname, 'uploads'))); + +// 路由 +app.get('/', (req, res) => { + res.json({ + success: true, + message: '本地小众商户引流平台 API 服务', + version: '1.0.0' + }); +}); + +// 导入路由模块 +const authRoutes = require('./routes/auth'); +const merchantRoutes = require('./routes/merchant'); +const shopRoutes = require('./routes/shop'); +const couponRoutes = require('./routes/coupon'); +const reservationRoutes = require('./routes/reservation'); +const reviewRoutes = require('./routes/review'); +const favoriteRoutes = require('./routes/favorite'); +const historyRoutes = require('./routes/history'); +const adminRoutes = require('./routes/admin'); + +// 使用路由 +app.use('/api/auth', authRoutes); +app.use('/api/merchant', merchantRoutes); +app.use('/api/shops', shopRoutes); +app.use('/api/coupons', couponRoutes); +app.use('/api/reservations', reservationRoutes); +app.use('/api/reviews', reviewRoutes); +app.use('/api/favorites', favoriteRoutes); +app.use('/api/history', historyRoutes); +app.use('/api/admin', adminRoutes); + +// 错误处理中间件 +app.use((err, req, res, next) => { + console.error('Error:', err); + + if (err.name === 'ValidationError') { + return res.status(400).json({ + success: false, + message: '数据验证失败', + errors: err.errors + }); + } + + if (err.code === 'LIMIT_FILE_SIZE') { + return res.status(400).json({ + success: false, + message: '文件大小超过限制' + }); + } + + res.status(500).json({ + success: false, + message: '服务器内部错误', + error: process.env.NODE_ENV === 'development' ? err.message : undefined + }); +}); + +// 404 处理 +app.use((req, res) => { + res.status(404).json({ + success: false, + message: '请求的资源不存在' + }); +}); + +// 启动服务器 +const PORT = process.env.PORT || 3000; + +app.listen(PORT, () => { + console.log(`服务器运行在端口 ${PORT}`); + console.log(`API 地址: http://localhost:${PORT}`); +}); + +module.exports = app; diff --git a/backend/config/database.js b/backend/config/database.js new file mode 100644 index 0000000..dfadf4d --- /dev/null +++ b/backend/config/database.js @@ -0,0 +1,15 @@ +const mysql = require('mysql2/promise'); +require('dotenv').config(); + +const pool = mysql.createPool({ + host: process.env.DB_HOST || 'localhost', + port: process.env.DB_PORT || 3306, + user: process.env.DB_USER || 'root', + password: process.env.DB_PASSWORD || '', + database: process.env.DB_NAME || 'merchant_platform', + waitForConnections: true, + connectionLimit: 10, + queueLimit: 0 +}); + +module.exports = pool; diff --git a/backend/controllers/adminController.js b/backend/controllers/adminController.js new file mode 100644 index 0000000..4a46b55 --- /dev/null +++ b/backend/controllers/adminController.js @@ -0,0 +1,458 @@ +const pool = require('../config/database'); + +// 获取统计数据 +const getDashboard = async (req, res) => { + try { + // 获取用户总数 + const [userCount] = await pool.execute( + 'SELECT COUNT(*) as total FROM users' + ); + + // 获取商户数量 + const [merchantCount] = await pool.execute( + 'SELECT COUNT(*) as total FROM users WHERE role = "merchant"' + ); + + // 获取店铺数量 + const [shopCount] = await pool.execute( + 'SELECT COUNT(*) as total FROM shops WHERE status = "active"' + ); + + // 获取优惠券数量 + const [couponCount] = await pool.execute( + 'SELECT COUNT(*) as total FROM coupons WHERE status = "active"' + ); + + // 获取待审核的商户申请数量 + const [pendingApplicationCount] = await pool.execute( + 'SELECT COUNT(*) as total FROM merchant_applications WHERE status = "pending"' + ); + + // 获取今日预约数量 + const today = new Date().toISOString().split('T')[0]; + const [todayReservationCount] = await pool.execute( + 'SELECT COUNT(*) as total FROM reservations WHERE reservation_date = ?', + [today] + ); + + res.json({ + success: true, + data: { + userCount: userCount[0].total, + merchantCount: merchantCount[0].total, + shopCount: shopCount[0].total, + couponCount: couponCount[0].total, + pendingApplicationCount: pendingApplicationCount[0].total, + todayReservationCount: todayReservationCount[0].total + } + }); + } catch (error) { + console.error('Get dashboard error:', error); + res.status(500).json({ + success: false, + message: '服务器内部错误' + }); + } +}; + +// 获取用户列表 +const getUsers = async (req, res) => { + try { + const { role, status, page = 1, limit = 10 } = req.query; + const offset = (page - 1) * limit; + + let query = ` + SELECT id, username, email, phone, avatar, role, status, created_at + FROM users + `; + let countQuery = 'SELECT COUNT(*) as total FROM users'; + let queryParams = []; + let countParams = []; + let conditions = []; + + if (role) { + conditions.push('role = ?'); + queryParams.push(role); + countParams.push(role); + } + + if (status) { + conditions.push('status = ?'); + queryParams.push(status); + countParams.push(status); + } + + if (conditions.length > 0) { + query += ' WHERE ' + conditions.join(' AND '); + countQuery += ' WHERE ' + conditions.join(' AND '); + } + + query += ' ORDER BY created_at DESC LIMIT ? OFFSET ?'; + queryParams.push(parseInt(limit), parseInt(offset)); + + const [users] = await pool.execute(query, queryParams); + const [countResult] = await pool.execute(countQuery, countParams); + + res.json({ + success: true, + data: { + users, + total: countResult[0].total, + page: parseInt(page), + limit: parseInt(limit) + } + }); + } catch (error) { + console.error('Get users error:', error); + res.status(500).json({ + success: false, + message: '服务器内部错误' + }); + } +}; + +// 更新用户状态 +const updateUserStatus = async (req, res) => { + try { + const userId = req.params.id; + const { status } = req.body; + + if (!status || !['active', 'inactive', 'banned'].includes(status)) { + return res.status(400).json({ + success: false, + message: '无效的状态值' + }); + } + + // 检查用户是否存在 + const [users] = await pool.execute( + 'SELECT id, role FROM users WHERE id = ?', + [userId] + ); + + if (users.length === 0) { + return res.status(404).json({ + success: false, + message: '用户不存在' + }); + } + + // 不能修改自己的状态 + if (users[0].id === req.user.id) { + return res.status(400).json({ + success: false, + message: '不能修改自己的状态' + }); + } + + // 更新用户状态 + await pool.execute( + 'UPDATE users SET status = ? WHERE id = ?', + [status, userId] + ); + + res.json({ + success: true, + message: '用户状态更新成功' + }); + } catch (error) { + console.error('Update user status error:', error); + res.status(500).json({ + success: false, + message: '服务器内部错误' + }); + } +}; + +// 获取店铺列表 +const getShops = async (req, res) => { + try { + const { status, shopType, page = 1, limit = 10 } = req.query; + const offset = (page - 1) * limit; + + let query = ` + SELECT s.*, u.username as merchant_name, u.email as merchant_email + FROM shops s + JOIN users u ON s.merchant_id = u.id + `; + let countQuery = 'SELECT COUNT(*) as total FROM shops'; + let queryParams = []; + let countParams = []; + let conditions = []; + + if (status) { + conditions.push('s.status = ?'); + queryParams.push(status); + countParams.push(status); + } + + if (shopType) { + conditions.push('s.shop_type = ?'); + queryParams.push(shopType); + countParams.push(shopType); + } + + if (conditions.length > 0) { + query += ' WHERE ' + conditions.join(' AND '); + countQuery += ' WHERE ' + conditions.join(' AND '); + } + + query += ' ORDER BY s.created_at DESC LIMIT ? OFFSET ?'; + queryParams.push(parseInt(limit), parseInt(offset)); + + const [shops] = await pool.execute(query, queryParams); + const [countResult] = await pool.execute(countQuery, countParams); + + res.json({ + success: true, + data: { + shops, + total: countResult[0].total, + page: parseInt(page), + limit: parseInt(limit) + } + }); + } catch (error) { + console.error('Get shops error:', error); + res.status(500).json({ + success: false, + message: '服务器内部错误' + }); + } +}; + +// 更新店铺状态 +const updateShopStatus = async (req, res) => { + try { + const shopId = req.params.id; + const { status } = req.body; + + if (!status || !['active', 'inactive', 'closed'].includes(status)) { + return res.status(400).json({ + success: false, + message: '无效的状态值' + }); + } + + // 检查店铺是否存在 + const [shops] = await pool.execute( + 'SELECT id FROM shops WHERE id = ?', + [shopId] + ); + + if (shops.length === 0) { + return res.status(404).json({ + success: false, + message: '店铺不存在' + }); + } + + // 更新店铺状态 + await pool.execute( + 'UPDATE shops SET status = ? WHERE id = ?', + [status, shopId] + ); + + res.json({ + success: true, + message: '店铺状态更新成功' + }); + } catch (error) { + console.error('Update shop status error:', error); + res.status(500).json({ + success: false, + message: '服务器内部错误' + }); + } +}; + +// 获取优惠券列表 +const getCoupons = async (req, res) => { + try { + const { status, shopId, page = 1, limit = 10 } = req.query; + const offset = (page - 1) * limit; + + let query = ` + SELECT c.*, s.shop_name + FROM coupons c + JOIN shops s ON c.shop_id = s.id + `; + let countQuery = 'SELECT COUNT(*) as total FROM coupons'; + let queryParams = []; + let countParams = []; + let conditions = []; + + if (status) { + conditions.push('c.status = ?'); + queryParams.push(status); + countParams.push(status); + } + + if (shopId) { + conditions.push('c.shop_id = ?'); + queryParams.push(shopId); + countParams.push(shopId); + } + + if (conditions.length > 0) { + query += ' WHERE ' + conditions.join(' AND '); + countQuery += ' WHERE ' + conditions.join(' AND '); + } + + query += ' ORDER BY c.created_at DESC LIMIT ? OFFSET ?'; + queryParams.push(parseInt(limit), parseInt(offset)); + + const [coupons] = await pool.execute(query, queryParams); + const [countResult] = await pool.execute(countQuery, countParams); + + res.json({ + success: true, + data: { + coupons, + total: countResult[0].total, + page: parseInt(page), + limit: parseInt(limit) + } + }); + } catch (error) { + console.error('Get coupons error:', error); + res.status(500).json({ + success: false, + message: '服务器内部错误' + }); + } +}; + +// 获取评价列表 +const getReviews = async (req, res) => { + try { + const { status, shopId, page = 1, limit = 10 } = req.query; + const offset = (page - 1) * limit; + + let query = ` + SELECT r.*, u.username, u.avatar, s.shop_name + FROM reviews r + JOIN users u ON r.user_id = u.id + JOIN shops s ON r.shop_id = s.id + `; + let countQuery = 'SELECT COUNT(*) as total FROM reviews'; + let queryParams = []; + let countParams = []; + let conditions = []; + + if (status) { + conditions.push('r.status = ?'); + queryParams.push(status); + countParams.push(status); + } + + if (shopId) { + conditions.push('r.shop_id = ?'); + queryParams.push(shopId); + countParams.push(shopId); + } + + if (conditions.length > 0) { + query += ' WHERE ' + conditions.join(' AND '); + countQuery += ' WHERE ' + conditions.join(' AND '); + } + + query += ' ORDER BY r.created_at DESC LIMIT ? OFFSET ?'; + queryParams.push(parseInt(limit), parseInt(offset)); + + const [reviews] = await pool.execute(query, queryParams); + const [countResult] = await pool.execute(countQuery, countParams); + + res.json({ + success: true, + data: { + reviews, + total: countResult[0].total, + page: parseInt(page), + limit: parseInt(limit) + } + }); + } catch (error) { + console.error('Get reviews error:', error); + res.status(500).json({ + success: false, + message: '服务器内部错误' + }); + } +}; + +// 删除评价 +const deleteReview = async (req, res) => { + try { + const reviewId = req.params.id; + + // 检查评价是否存在 + const [reviews] = await pool.execute( + 'SELECT id, shop_id, rating FROM reviews WHERE id = ?', + [reviewId] + ); + + if (reviews.length === 0) { + return res.status(404).json({ + success: false, + message: '评价不存在' + }); + } + + const review = reviews[0]; + + // 开始事务 + const connection = await pool.getConnection(); + await connection.beginTransaction(); + + try { + // 软删除评价 + await connection.execute( + 'UPDATE reviews SET status = "deleted" WHERE id = ?', + [reviewId] + ); + + // 更新店铺的评分和评分数量 + await connection.execute( + `UPDATE shops + SET average_rating = ( + SELECT AVG(rating) FROM reviews WHERE shop_id = ? AND status = 'active' + ), + rating_count = ( + SELECT COUNT(*) FROM reviews WHERE shop_id = ? AND status = 'active' + ) + WHERE id = ?`, + [review.shop_id, review.shop_id, review.shop_id] + ); + + await connection.commit(); + + res.json({ + success: true, + message: '评价删除成功' + }); + } catch (error) { + await connection.rollback(); + throw error; + } finally { + connection.release(); + } + } catch (error) { + console.error('Delete review error:', error); + res.status(500).json({ + success: false, + message: '服务器内部错误' + }); + } +}; + +module.exports = { + getDashboard, + getUsers, + updateUserStatus, + getShops, + updateShopStatus, + getCoupons, + getReviews, + deleteReview +}; diff --git a/backend/controllers/authController.js b/backend/controllers/authController.js new file mode 100644 index 0000000..5a34418 --- /dev/null +++ b/backend/controllers/authController.js @@ -0,0 +1,309 @@ +const bcrypt = require('bcryptjs'); +const jwt = require('jsonwebtoken'); +const pool = require('../config/database'); + +// 用户注册 +const register = async (req, res) => { + try { + const { username, email, password, phone } = req.body; + + // 检查用户名是否已存在 + const [existingUsername] = await pool.execute( + 'SELECT id FROM users WHERE username = ?', + [username] + ); + + if (existingUsername.length > 0) { + return res.status(400).json({ + success: false, + message: '用户名已被使用' + }); + } + + // 检查邮箱是否已存在 + const [existingEmail] = await pool.execute( + 'SELECT id FROM users WHERE email = ?', + [email] + ); + + if (existingEmail.length > 0) { + return res.status(400).json({ + success: false, + message: '邮箱已被注册' + }); + } + + // 加密密码 + const saltRounds = 10; + const hashedPassword = await bcrypt.hash(password, saltRounds); + + // 创建用户 + const [result] = await pool.execute( + 'INSERT INTO users (username, email, password, phone) VALUES (?, ?, ?, ?)', + [username, email, hashedPassword, phone || null] + ); + + // 生成 JWT 令牌 + const token = jwt.sign( + { id: result.insertId }, + process.env.JWT_SECRET, + { expiresIn: process.env.JWT_EXPIRES_IN || '7d' } + ); + + // 获取用户信息 + const [users] = await pool.execute( + 'SELECT id, username, email, phone, avatar, role, status, created_at FROM users WHERE id = ?', + [result.insertId] + ); + + res.status(201).json({ + success: true, + message: '注册成功', + data: { + user: users[0], + token + } + }); + } catch (error) { + console.error('Register error:', error); + res.status(500).json({ + success: false, + message: '服务器内部错误' + }); + } +}; + +// 用户登录 +const login = async (req, res) => { + try { + const { email, password } = req.body; + + // 检查用户是否存在 + const [users] = await pool.execute( + 'SELECT * FROM users WHERE email = ?', + [email] + ); + + if (users.length === 0) { + return res.status(401).json({ + success: false, + message: '邮箱或密码错误' + }); + } + + const user = users[0]; + + // 验证密码 + const isMatch = await bcrypt.compare(password, user.password); + + if (!isMatch) { + return res.status(401).json({ + success: false, + message: '邮箱或密码错误' + }); + } + + // 检查账户状态 + if (user.status !== 'active') { + return res.status(403).json({ + success: false, + message: '账户已被禁用,请联系管理员' + }); + } + + // 生成 JWT 令牌 + const token = jwt.sign( + { id: user.id }, + process.env.JWT_SECRET, + { expiresIn: process.env.JWT_EXPIRES_IN || '7d' } + ); + + // 移除密码字段 + const { password: _, ...userWithoutPassword } = user; + + res.json({ + success: true, + message: '登录成功', + data: { + user: userWithoutPassword, + token + } + }); + } catch (error) { + console.error('Login error:', error); + res.status(500).json({ + success: false, + message: '服务器内部错误' + }); + } +}; + +// 获取当前用户信息 +const getCurrentUser = async (req, res) => { + try { + const user = req.user; + + // 获取更完整的用户信息 + const [users] = await pool.execute( + 'SELECT id, username, email, phone, avatar, role, status, created_at FROM users WHERE id = ?', + [user.id] + ); + + if (users.length === 0) { + return res.status(404).json({ + success: false, + message: '用户不存在' + }); + } + + res.json({ + success: true, + data: { + user: users[0] + } + }); + } catch (error) { + console.error('Get current user error:', error); + res.status(500).json({ + success: false, + message: '服务器内部错误' + }); + } +}; + +// 更新用户信息 +const updateProfile = async (req, res) => { + try { + const { username, phone, avatar } = req.body; + const userId = req.user.id; + + // 检查用户名是否已被其他用户使用 + if (username) { + const [existingUsername] = await pool.execute( + 'SELECT id FROM users WHERE username = ? AND id != ?', + [username, userId] + ); + + if (existingUsername.length > 0) { + return res.status(400).json({ + success: false, + message: '用户名已被使用' + }); + } + } + + // 构建更新语句 + let updateFields = []; + let updateValues = []; + + if (username) { + updateFields.push('username = ?'); + updateValues.push(username); + } + + if (phone) { + updateFields.push('phone = ?'); + updateValues.push(phone); + } + + if (avatar) { + updateFields.push('avatar = ?'); + updateValues.push(avatar); + } + + if (updateFields.length === 0) { + return res.status(400).json({ + success: false, + message: '没有提供要更新的信息' + }); + } + + updateValues.push(userId); + + // 执行更新 + await pool.execute( + `UPDATE users SET ${updateFields.join(', ')} WHERE id = ?`, + updateValues + ); + + // 获取更新后的用户信息 + const [users] = await pool.execute( + 'SELECT id, username, email, phone, avatar, role, status, created_at FROM users WHERE id = ?', + [userId] + ); + + res.json({ + success: true, + message: '更新成功', + data: { + user: users[0] + } + }); + } catch (error) { + console.error('Update profile error:', error); + res.status(500).json({ + success: false, + message: '服务器内部错误' + }); + } +}; + +// 修改密码 +const changePassword = async (req, res) => { + try { + const { oldPassword, newPassword } = req.body; + const userId = req.user.id; + + // 获取用户当前密码 + const [users] = await pool.execute( + 'SELECT password FROM users WHERE id = ?', + [userId] + ); + + if (users.length === 0) { + return res.status(404).json({ + success: false, + message: '用户不存在' + }); + } + + // 验证旧密码 + const isMatch = await bcrypt.compare(oldPassword, users[0].password); + + if (!isMatch) { + return res.status(400).json({ + success: false, + message: '旧密码不正确' + }); + } + + // 加密新密码 + const saltRounds = 10; + const hashedNewPassword = await bcrypt.hash(newPassword, saltRounds); + + // 更新密码 + await pool.execute( + 'UPDATE users SET password = ? WHERE id = ?', + [hashedNewPassword, userId] + ); + + res.json({ + success: true, + message: '密码修改成功' + }); + } catch (error) { + console.error('Change password error:', error); + res.status(500).json({ + success: false, + message: '服务器内部错误' + }); + } +}; + +module.exports = { + register, + login, + getCurrentUser, + updateProfile, + changePassword +}; diff --git a/backend/controllers/couponController.js b/backend/controllers/couponController.js new file mode 100644 index 0000000..18a1780 --- /dev/null +++ b/backend/controllers/couponController.js @@ -0,0 +1,752 @@ +const pool = require('../config/database'); + +// 获取所有可用优惠券 +const getAvailableCoupons = async (req, res) => { + try { + const { shopType, page = 1, limit = 10 } = req.query; + const offset = (page - 1) * limit; + + let query = ` + SELECT c.*, s.shop_name, s.shop_logo, s.shop_type + FROM coupons c + JOIN shops s ON c.shop_id = s.id + WHERE c.status = 'active' + AND s.status = 'active' + AND c.start_date <= CURDATE() + AND c.end_date >= CURDATE() + AND c.total_quantity > c.claimed_quantity + `; + let countQuery = ` + SELECT COUNT(*) as total + FROM coupons c + JOIN shops s ON c.shop_id = s.id + WHERE c.status = 'active' + AND s.status = 'active' + AND c.start_date <= CURDATE() + AND c.end_date >= CURDATE() + AND c.total_quantity > c.claimed_quantity + `; + let queryParams = []; + let countParams = []; + + if (shopType) { + query += ' AND s.shop_type = ?'; + countQuery += ' AND s.shop_type = ?'; + queryParams.push(shopType); + countParams.push(shopType); + } + + query += ' ORDER BY c.created_at DESC LIMIT ? OFFSET ?'; + queryParams.push(parseInt(limit), parseInt(offset)); + + const [coupons] = await pool.execute(query, queryParams); + const [countResult] = await pool.execute(countQuery, countParams); + + res.json({ + success: true, + data: { + coupons, + total: countResult[0].total, + page: parseInt(page), + limit: parseInt(limit) + } + }); + } catch (error) { + console.error('Get available coupons error:', error); + res.status(500).json({ + success: false, + message: '服务器内部错误' + }); + } +}; + +// 获取单个优惠券详情 +const getCouponById = async (req, res) => { + try { + const couponId = req.params.id; + + const [coupons] = await pool.execute( + `SELECT c.*, s.shop_name, s.shop_logo, s.shop_type, s.address, s.contact_phone + FROM coupons c + JOIN shops s ON c.shop_id = s.id + WHERE c.id = ?`, + [couponId] + ); + + if (coupons.length === 0) { + return res.status(404).json({ + success: false, + message: '优惠券不存在' + }); + } + + res.json({ + success: true, + data: { + coupon: coupons[0] + } + }); + } catch (error) { + console.error('Get coupon by id error:', error); + res.status(500).json({ + success: false, + message: '服务器内部错误' + }); + } +}; + +// 领取优惠券 +const claimCoupon = async (req, res) => { + try { + const userId = req.user.id; + const couponId = req.params.id; + + // 检查优惠券是否存在 + const [coupons] = await pool.execute( + `SELECT c.*, s.status as shop_status + FROM coupons c + JOIN shops s ON c.shop_id = s.id + WHERE c.id = ?`, + [couponId] + ); + + if (coupons.length === 0) { + return res.status(404).json({ + success: false, + message: '优惠券不存在' + }); + } + + const coupon = coupons[0]; + + // 检查店铺状态 + if (coupon.shop_status !== 'active') { + return res.status(400).json({ + success: false, + message: '该店铺已关闭,无法领取优惠券' + }); + } + + // 检查优惠券状态 + if (coupon.status !== 'active') { + return res.status(400).json({ + success: false, + message: '优惠券已失效' + }); + } + + // 检查优惠券是否在有效期内 + const today = new Date(); + const startDate = new Date(coupon.start_date); + const endDate = new Date(coupon.end_date); + + if (today < startDate || today > endDate) { + return res.status(400).json({ + success: false, + message: '优惠券不在有效期内' + }); + } + + // 检查优惠券是否还有库存 + if (coupon.claimed_quantity >= coupon.total_quantity) { + return res.status(400).json({ + success: false, + message: '优惠券已被领完' + }); + } + + // 检查用户是否已经领取过该优惠券 + const [existingClaims] = await pool.execute( + 'SELECT id FROM user_coupons WHERE user_id = ? AND coupon_id = ?', + [userId, couponId] + ); + + if (existingClaims.length > 0) { + return res.status(400).json({ + success: false, + message: '您已经领取过该优惠券' + }); + } + + // 开始事务 + const connection = await pool.getConnection(); + await connection.beginTransaction(); + + try { + // 创建用户优惠券记录 + await connection.execute( + 'INSERT INTO user_coupons (user_id, coupon_id) VALUES (?, ?)', + [userId, couponId] + ); + + // 更新优惠券领取数量 + await connection.execute( + 'UPDATE coupons SET claimed_quantity = claimed_quantity + 1 WHERE id = ?', + [couponId] + ); + + await connection.commit(); + + res.json({ + success: true, + message: '优惠券领取成功' + }); + } catch (error) { + await connection.rollback(); + throw error; + } finally { + connection.release(); + } + } catch (error) { + console.error('Claim coupon error:', error); + res.status(500).json({ + success: false, + message: '服务器内部错误' + }); + } +}; + +// 获取当前用户的优惠券列表 +const getMyCoupons = async (req, res) => { + try { + const userId = req.user.id; + const { status, page = 1, limit = 10 } = req.query; + const offset = (page - 1) * limit; + + let query = ` + SELECT uc.*, c.*, s.shop_name, s.shop_logo + FROM user_coupons uc + JOIN coupons c ON uc.coupon_id = c.id + JOIN shops s ON c.shop_id = s.id + WHERE uc.user_id = ? + `; + let countQuery = ` + SELECT COUNT(*) as total + FROM user_coupons uc + JOIN coupons c ON uc.coupon_id = c.id + WHERE uc.user_id = ? + `; + let queryParams = [userId]; + let countParams = [userId]; + + if (status) { + query += ' AND uc.status = ?'; + countQuery += ' AND uc.status = ?'; + queryParams.push(status); + countParams.push(status); + } + + query += ' ORDER BY uc.claimed_at DESC LIMIT ? OFFSET ?'; + queryParams.push(parseInt(limit), parseInt(offset)); + + const [coupons] = await pool.execute(query, queryParams); + const [countResult] = await pool.execute(countQuery, countParams); + + res.json({ + success: true, + data: { + coupons, + total: countResult[0].total, + page: parseInt(page), + limit: parseInt(limit) + } + }); + } catch (error) { + console.error('Get my coupons error:', error); + res.status(500).json({ + success: false, + message: '服务器内部错误' + }); + } +}; + +// 使用/核销优惠券 +const useCoupon = async (req, res) => { + try { + const userId = req.user.id; + const userCouponId = req.params.id; + + // 检查用户优惠券是否存在 + const [userCoupons] = await pool.execute( + `SELECT uc.*, c.*, s.id as shop_id, s.shop_name + FROM user_coupons uc + JOIN coupons c ON uc.coupon_id = c.id + JOIN shops s ON c.shop_id = s.id + WHERE uc.id = ? AND uc.user_id = ?`, + [userCouponId, userId] + ); + + if (userCoupons.length === 0) { + return res.status(404).json({ + success: false, + message: '优惠券不存在' + }); + } + + const userCoupon = userCoupons[0]; + + // 检查优惠券状态 + if (userCoupon.status === 'used') { + return res.status(400).json({ + success: false, + message: '优惠券已使用' + }); + } + + if (userCoupon.status === 'expired') { + return res.status(400).json({ + success: false, + message: '优惠券已过期' + }); + } + + // 检查优惠券是否在有效期内 + const today = new Date(); + const endDate = new Date(userCoupon.end_date); + + if (today > endDate) { + // 更新优惠券状态为过期 + await pool.execute( + 'UPDATE user_coupons SET status = "expired" WHERE id = ?', + [userCouponId] + ); + + return res.status(400).json({ + success: false, + message: '优惠券已过期' + }); + } + + // 这里可以添加更多使用逻辑,比如验证使用金额等 + // 简单起见,这里直接标记为已使用 + + // 开始事务 + const connection = await pool.getConnection(); + await connection.beginTransaction(); + + try { + // 更新用户优惠券状态 + await connection.execute( + 'UPDATE user_coupons SET status = "used", used_at = NOW() WHERE id = ?', + [userCouponId] + ); + + // 更新优惠券使用数量 + await connection.execute( + 'UPDATE coupons SET used_quantity = used_quantity + 1 WHERE id = ?', + [userCoupon.coupon_id] + ); + + await connection.commit(); + + res.json({ + success: true, + message: '优惠券使用成功', + data: { + couponId: userCouponId, + usedAt: new Date() + } + }); + } catch (error) { + await connection.rollback(); + throw error; + } finally { + connection.release(); + } + } catch (error) { + console.error('Use coupon error:', error); + res.status(500).json({ + success: false, + message: '服务器内部错误' + }); + } +}; + +// 商户核销优惠券 +const verifyCoupon = async (req, res) => { + try { + const shopId = req.shopId; + const { couponCode } = req.body; + + // 这里简单实现,实际应用中可能需要更复杂的券码生成和验证逻辑 + // 这里假设 couponCode 是 user_coupons 的 id + const [userCoupons] = await pool.execute( + `SELECT uc.*, c.*, s.id as shop_id + FROM user_coupons uc + JOIN coupons c ON uc.coupon_id = c.id + JOIN shops s ON c.shop_id = s.id + WHERE uc.id = ? AND s.id = ?`, + [couponCode, shopId] + ); + + if (userCoupons.length === 0) { + return res.status(404).json({ + success: false, + message: '优惠券不存在或不属于此店铺' + }); + } + + const userCoupon = userCoupons[0]; + + // 检查优惠券状态 + if (userCoupon.status === 'used') { + return res.status(400).json({ + success: false, + message: '优惠券已使用' + }); + } + + if (userCoupon.status === 'expired') { + return res.status(400).json({ + success: false, + message: '优惠券已过期' + }); + } + + // 检查优惠券是否在有效期内 + const today = new Date(); + const endDate = new Date(userCoupon.end_date); + + if (today > endDate) { + return res.status(400).json({ + success: false, + message: '优惠券已过期' + }); + } + + // 开始事务 + const connection = await pool.getConnection(); + await connection.beginTransaction(); + + try { + // 更新用户优惠券状态 + await connection.execute( + 'UPDATE user_coupons SET status = "used", used_at = NOW() WHERE id = ?', + [couponCode] + ); + + // 更新优惠券使用数量 + await connection.execute( + 'UPDATE coupons SET used_quantity = used_quantity + 1 WHERE id = ?', + [userCoupon.coupon_id] + ); + + await connection.commit(); + + res.json({ + success: true, + message: '优惠券核销成功', + data: { + couponId: couponCode, + couponName: userCoupon.coupon_name, + discountValue: userCoupon.discount_value, + usedAt: new Date() + } + }); + } catch (error) { + await connection.rollback(); + throw error; + } finally { + connection.release(); + } + } catch (error) { + console.error('Verify coupon error:', error); + res.status(500).json({ + success: false, + message: '服务器内部错误' + }); + } +}; + +// 商户发布优惠券 +const createCoupon = async (req, res) => { + try { + const shopId = req.shopId; + const { + couponName, + couponType, + discountValue, + minSpend, + totalQuantity, + startDate, + endDate, + usageType, + description, + termsAndConditions + } = req.body; + + // 检查结束日期是否晚于开始日期 + if (new Date(endDate) <= new Date(startDate)) { + return res.status(400).json({ + success: false, + message: '结束日期必须晚于开始日期' + }); + } + + // 创建优惠券 + const [result] = await pool.execute( + `INSERT INTO coupons + (shop_id, coupon_name, coupon_type, discount_value, min_spend, + total_quantity, start_date, end_date, usage_type, description, + terms_and_conditions) + VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, + [ + shopId, + couponName, + couponType, + discountValue, + minSpend || 0, + totalQuantity, + startDate, + endDate, + usageType || 'once', + description || null, + termsAndConditions || null + ] + ); + + res.status(201).json({ + success: true, + message: '优惠券发布成功', + data: { + couponId: result.insertId + } + }); + } catch (error) { + console.error('Create coupon error:', error); + res.status(500).json({ + success: false, + message: '服务器内部错误' + }); + } +}; + +// 商户获取自己的优惠券列表 +const getMerchantCoupons = async (req, res) => { + try { + const shopId = req.shopId; + const { status, page = 1, limit = 10 } = req.query; + const offset = (page - 1) * limit; + + let query = ` + SELECT * + FROM coupons + WHERE shop_id = ? + `; + let countQuery = 'SELECT COUNT(*) as total FROM coupons WHERE shop_id = ?'; + let queryParams = [shopId]; + let countParams = [shopId]; + + if (status) { + query += ' AND status = ?'; + countQuery += ' AND status = ?'; + queryParams.push(status); + countParams.push(status); + } + + query += ' ORDER BY created_at DESC LIMIT ? OFFSET ?'; + queryParams.push(parseInt(limit), parseInt(offset)); + + const [coupons] = await pool.execute(query, queryParams); + const [countResult] = await pool.execute(countQuery, countParams); + + res.json({ + success: true, + data: { + coupons, + total: countResult[0].total, + page: parseInt(page), + limit: parseInt(limit) + } + }); + } catch (error) { + console.error('Get merchant coupons error:', error); + res.status(500).json({ + success: false, + message: '服务器内部错误' + }); + } +}; + +// 商户更新优惠券 +const updateCoupon = async (req, res) => { + try { + const shopId = req.shopId; + const couponId = req.params.id; + const { + couponName, + couponType, + discountValue, + minSpend, + totalQuantity, + startDate, + endDate, + usageType, + description, + termsAndConditions, + status + } = req.body; + + // 检查优惠券是否存在且属于当前商户 + const [coupons] = await pool.execute( + 'SELECT id FROM coupons WHERE id = ? AND shop_id = ?', + [couponId, shopId] + ); + + if (coupons.length === 0) { + return res.status(404).json({ + success: false, + message: '优惠券不存在或您没有权限修改' + }); + } + + // 构建更新语句 + let updateFields = []; + let updateValues = []; + + if (couponName) { + updateFields.push('coupon_name = ?'); + updateValues.push(couponName); + } + + if (couponType) { + updateFields.push('coupon_type = ?'); + updateValues.push(couponType); + } + + if (discountValue !== undefined) { + updateFields.push('discount_value = ?'); + updateValues.push(discountValue); + } + + if (minSpend !== undefined) { + updateFields.push('min_spend = ?'); + updateValues.push(minSpend); + } + + if (totalQuantity !== undefined) { + updateFields.push('total_quantity = ?'); + updateValues.push(totalQuantity); + } + + if (startDate) { + updateFields.push('start_date = ?'); + updateValues.push(startDate); + } + + if (endDate) { + updateFields.push('end_date = ?'); + updateValues.push(endDate); + } + + if (usageType) { + updateFields.push('usage_type = ?'); + updateValues.push(usageType); + } + + if (description !== undefined) { + updateFields.push('description = ?'); + updateValues.push(description); + } + + if (termsAndConditions !== undefined) { + updateFields.push('terms_and_conditions = ?'); + updateValues.push(termsAndConditions); + } + + if (status) { + updateFields.push('status = ?'); + updateValues.push(status); + } + + if (updateFields.length === 0) { + return res.status(400).json({ + success: false, + message: '没有提供要更新的信息' + }); + } + + updateValues.push(couponId); + + // 执行更新 + await pool.execute( + `UPDATE coupons SET ${updateFields.join(', ')} WHERE id = ?`, + updateValues + ); + + res.json({ + success: true, + message: '优惠券更新成功' + }); + } catch (error) { + console.error('Update coupon error:', error); + res.status(500).json({ + success: false, + message: '服务器内部错误' + }); + } +}; + +// 商户删除优惠券 +const deleteCoupon = async (req, res) => { + try { + const shopId = req.shopId; + const couponId = req.params.id; + + // 检查优惠券是否存在且属于当前商户 + const [coupons] = await pool.execute( + 'SELECT id FROM coupons WHERE id = ? AND shop_id = ?', + [couponId, shopId] + ); + + if (coupons.length === 0) { + return res.status(404).json({ + success: false, + message: '优惠券不存在或您没有权限删除' + }); + } + + // 检查是否有用户已领取该优惠券 + const [userCoupons] = await pool.execute( + 'SELECT id FROM user_coupons WHERE coupon_id = ? AND status = "available"', + [couponId] + ); + + if (userCoupons.length > 0) { + return res.status(400).json({ + success: false, + message: '该优惠券已有用户领取,无法删除' + }); + } + + // 删除优惠券 + await pool.execute( + 'DELETE FROM coupons WHERE id = ?', + [couponId] + ); + + res.json({ + success: true, + message: '优惠券删除成功' + }); + } catch (error) { + console.error('Delete coupon error:', error); + res.status(500).json({ + success: false, + message: '服务器内部错误' + }); + } +}; + +module.exports = { + getAvailableCoupons, + getCouponById, + claimCoupon, + getMyCoupons, + useCoupon, + verifyCoupon, + createCoupon, + getMerchantCoupons, + updateCoupon, + deleteCoupon +}; diff --git a/backend/controllers/favoriteController.js b/backend/controllers/favoriteController.js new file mode 100644 index 0000000..c426e79 --- /dev/null +++ b/backend/controllers/favoriteController.js @@ -0,0 +1,174 @@ +const pool = require('../config/database'); + +// 添加收藏 +const addFavorite = async (req, res) => { + try { + const userId = req.user.id; + const { shopId } = req.body; + + if (!shopId) { + return res.status(400).json({ + success: false, + message: '店铺ID不能为空' + }); + } + + // 检查店铺是否存在 + const [shops] = await pool.execute( + 'SELECT id FROM shops WHERE id = ? AND status = "active"', + [shopId] + ); + + if (shops.length === 0) { + return res.status(404).json({ + success: false, + message: '店铺不存在或已关闭' + }); + } + + // 检查是否已经收藏 + const [existingFavorites] = await pool.execute( + 'SELECT id FROM favorites WHERE user_id = ? AND shop_id = ?', + [userId, shopId] + ); + + if (existingFavorites.length > 0) { + return res.status(400).json({ + success: false, + message: '已经收藏过该店铺' + }); + } + + // 添加收藏 + await pool.execute( + 'INSERT INTO favorites (user_id, shop_id) VALUES (?, ?)', + [userId, shopId] + ); + + res.json({ + success: true, + message: '收藏成功' + }); + } catch (error) { + console.error('Add favorite error:', error); + res.status(500).json({ + success: false, + message: '服务器内部错误' + }); + } +}; + +// 移除收藏 +const removeFavorite = async (req, res) => { + try { + const userId = req.user.id; + const shopId = req.params.shopId; + + // 检查是否已收藏 + const [existingFavorites] = await pool.execute( + 'SELECT id FROM favorites WHERE user_id = ? AND shop_id = ?', + [userId, shopId] + ); + + if (existingFavorites.length === 0) { + return res.status(404).json({ + success: false, + message: '未收藏该店铺' + }); + } + + // 移除收藏 + await pool.execute( + 'DELETE FROM favorites WHERE user_id = ? AND shop_id = ?', + [userId, shopId] + ); + + res.json({ + success: true, + message: '取消收藏成功' + }); + } catch (error) { + console.error('Remove favorite error:', error); + res.status(500).json({ + success: false, + message: '服务器内部错误' + }); + } +}; + +// 获取用户的收藏列表 +const getMyFavorites = async (req, res) => { + try { + const userId = req.user.id; + const { page = 1, limit = 10 } = req.query; + const offset = (page - 1) * limit; + + const [favorites] = await pool.execute( + `SELECT f.*, s.shop_name, s.shop_logo, s.shop_type, s.address, + s.average_rating, s.rating_count, s.business_hours + FROM favorites f + JOIN shops s ON f.shop_id = s.id + WHERE f.user_id = ? AND s.status = 'active' + ORDER BY f.created_at DESC + LIMIT ? OFFSET ?`, + [userId, parseInt(limit), parseInt(offset)] + ); + + const [countResult] = await pool.execute( + `SELECT COUNT(*) as total + FROM favorites f + JOIN shops s ON f.shop_id = s.id + WHERE f.user_id = ? AND s.status = 'active'`, + [userId] + ); + + res.json({ + success: true, + data: { + favorites, + total: countResult[0].total, + page: parseInt(page), + limit: parseInt(limit) + } + }); + } catch (error) { + console.error('Get my favorites error:', error); + res.status(500).json({ + success: false, + message: '服务器内部错误' + }); + } +}; + +// 检查是否已收藏 +const checkFavorite = async (req, res) => { + try { + const userId = req.user.id; + const shopId = req.params.shopId; + + const [favorites] = await pool.execute( + 'SELECT id FROM favorites WHERE user_id = ? AND shop_id = ?', + [userId, shopId] + ); + + res.json({ + success: true, + data: { + isFavorited: favorites.length > 0 + } + }); + } catch (error) { + console.error('Check favorite error:', error); + res.status(500).json({ + success: false, + message: '服务器内部错误' + }); + } +}; + +module.exports = { + addFavorite, + removeFavorite, + getMyFavorites, + checkFavorite +}; diff --git a/backend/controllers/historyController.js b/backend/controllers/historyController.js new file mode 100644 index 0000000..e9bb25f --- /dev/null +++ b/backend/controllers/historyController.js @@ -0,0 +1,83 @@ +const pool = require('../config/database'); + +// 获取用户的浏览记录 +const getMyHistory = async (req, res) => { + try { + const userId = req.user.id; + const { page = 1, limit = 10 } = req.query; + const offset = (page - 1) * limit; + + // 获取去重的浏览记录,只显示每个店铺的最新浏览记录 + const [history] = await pool.execute( + `SELECT DISTINCT + bh.shop_id, + (SELECT MAX(viewed_at) FROM browsing_history WHERE user_id = ? AND shop_id = bh.shop_id) as last_viewed_at, + s.shop_name, + s.shop_logo, + s.shop_type, + s.address, + s.average_rating, + s.rating_count, + s.business_hours + FROM browsing_history bh + JOIN shops s ON bh.shop_id = s.id + WHERE bh.user_id = ? AND s.status = 'active' + GROUP BY bh.shop_id, s.id + ORDER BY last_viewed_at DESC + LIMIT ? OFFSET ?`, + [userId, userId, parseInt(limit), parseInt(offset)] + ); + + // 获取总数量 + const [countResult] = await pool.execute( + `SELECT COUNT(DISTINCT shop_id) as total + FROM browsing_history + WHERE user_id = ?`, + [userId] + ); + + res.json({ + success: true, + data: { + history, + total: countResult[0].total, + page: parseInt(page), + limit: parseInt(limit) + } + }); + } catch (error) { + console.error('Get my history error:', error); + res.status(500).json({ + success: false, + message: '服务器内部错误' + }); + } +}; + +// 清空浏览记录 +const clearHistory = async (req, res) => { + try { + const userId = req.user.id; + + await pool.execute( + 'DELETE FROM browsing_history WHERE user_id = ?', + [userId] + ); + + res.json({ + success: true, + message: '浏览记录已清空' + }); + } catch (error) { + console.error('Clear history error:', error); + res.status(500).json({ + success: false, + message: '服务器内部错误' + }); + } +}; + +module.exports = { + getMyHistory, + clearHistory +}; diff --git a/backend/controllers/merchantController.js b/backend/controllers/merchantController.js new file mode 100644 index 0000000..2d7d9ae --- /dev/null +++ b/backend/controllers/merchantController.js @@ -0,0 +1,275 @@ +const pool = require('../config/database'); + +// 提交商户资质申请 +const submitApplication = async (req, res) => { + try { + const userId = req.user.id; + const { + businessName, + businessLicense, + legalPerson, + idCard, + idCardFront, + idCardBack, + contactPhone, + contactEmail, + businessType, + businessDescription + } = req.body; + + // 检查用户是否已经提交过申请 + const [existingApplication] = await pool.execute( + 'SELECT id FROM merchant_applications WHERE user_id = ?', + [userId] + ); + + if (existingApplication.length > 0) { + // 检查是否有未处理的申请 + const [pendingApplication] = await pool.execute( + 'SELECT id, status FROM merchant_applications WHERE user_id = ? AND status = "pending"', + [userId] + ); + + if (pendingApplication.length > 0) { + return res.status(400).json({ + success: false, + message: '您已有待审核的商户申请,请等待审核结果' + }); + } + + // 如果申请被拒绝,可以重新提交 + const [rejectedApplication] = await pool.execute( + 'SELECT id FROM merchant_applications WHERE user_id = ? AND status = "rejected"', + [userId] + ); + + if (rejectedApplication.length > 0) { + // 删除被拒绝的申请,允许重新提交 + await pool.execute( + 'DELETE FROM merchant_applications WHERE user_id = ? AND status = "rejected"', + [userId] + ); + } + } + + // 检查用户是否已经是商户 + const [user] = await pool.execute( + 'SELECT role FROM users WHERE id = ?', + [userId] + ); + + if (user[0].role === 'merchant') { + return res.status(400).json({ + success: false, + message: '您已经是商户,无需再次申请' + }); + } + + // 创建商户申请 + const [result] = await pool.execute( + `INSERT INTO merchant_applications + (user_id, business_name, business_license, legal_person, id_card, + id_card_front, id_card_back, contact_phone, contact_email, + business_type, business_description) + VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, + [ + userId, + businessName, + businessLicense, + legalPerson, + idCard, + idCardFront, + idCardBack, + contactPhone, + contactEmail || null, + businessType, + businessDescription || null + ] + ); + + res.status(201).json({ + success: true, + message: '商户资质申请提交成功,请等待审核', + data: { + applicationId: result.insertId, + status: 'pending' + } + }); + } catch (error) { + console.error('Submit application error:', error); + res.status(500).json({ + success: false, + message: '服务器内部错误' + }); + } +}; + +// 获取当前用户的商户申请状态 +const getApplicationStatus = async (req, res) => { + try { + const userId = req.user.id; + + const [applications] = await pool.execute( + `SELECT id, business_name, business_type, status, rejection_reason, + submitted_at, reviewed_at + FROM merchant_applications + WHERE user_id = ? + ORDER BY submitted_at DESC + LIMIT 1`, + [userId] + ); + + if (applications.length === 0) { + return res.json({ + success: true, + data: { + hasApplication: false, + application: null + } + }); + } + + res.json({ + success: true, + data: { + hasApplication: true, + application: applications[0] + } + }); + } catch (error) { + console.error('Get application status error:', error); + res.status(500).json({ + success: false, + message: '服务器内部错误' + }); + } +}; + +// 获取所有商户申请(管理员) +const getAllApplications = async (req, res) => { + try { + const { status, page = 1, limit = 10 } = req.query; + const offset = (page - 1) * limit; + + let query = ` + SELECT ma.*, u.username, u.email + FROM merchant_applications ma + JOIN users u ON ma.user_id = u.id + `; + let countQuery = `SELECT COUNT(*) as total FROM merchant_applications`; + let queryParams = []; + let countParams = []; + + if (status) { + query += ' WHERE ma.status = ?'; + countQuery += ' WHERE status = ?'; + queryParams.push(status); + countParams.push(status); + } + + query += ' ORDER BY ma.submitted_at DESC LIMIT ? OFFSET ?'; + queryParams.push(parseInt(limit), parseInt(offset)); + + const [applications] = await pool.execute(query, queryParams); + const [countResult] = await pool.execute(countQuery, countParams); + + res.json({ + success: true, + data: { + applications, + total: countResult[0].total, + page: parseInt(page), + limit: parseInt(limit) + } + }); + } catch (error) { + console.error('Get all applications error:', error); + res.status(500).json({ + success: false, + message: '服务器内部错误' + }); + } +}; + +// 审核商户申请(管理员) +const reviewApplication = async (req, res) => { + try { + const applicationId = req.params.id; + const { status, rejectionReason } = req.body; + const adminId = req.user.id; + + // 检查申请是否存在 + const [applications] = await pool.execute( + 'SELECT * FROM merchant_applications WHERE id = ?', + [applicationId] + ); + + if (applications.length === 0) { + return res.status(404).json({ + success: false, + message: '商户申请不存在' + }); + } + + const application = applications[0]; + + // 检查申请状态 + if (application.status !== 'pending') { + return res.status(400).json({ + success: false, + message: '该申请已被审核,无法再次审核' + }); + } + + // 开始事务 + const connection = await pool.getConnection(); + await connection.beginTransaction(); + + try { + // 更新申请状态 + await connection.execute( + `UPDATE merchant_applications + SET status = ?, rejection_reason = ?, reviewed_at = NOW(), reviewed_by = ? + WHERE id = ?`, + [status, rejectionReason || null, adminId, applicationId] + ); + + // 如果审核通过,将用户角色更新为商户 + if (status === 'approved') { + await connection.execute( + 'UPDATE users SET role = "merchant" WHERE id = ?', + [application.user_id] + ); + } + + await connection.commit(); + + res.json({ + success: true, + message: status === 'approved' ? '商户申请已通过' : '商户申请已拒绝', + data: { + applicationId, + status + } + }); + } catch (error) { + await connection.rollback(); + throw error; + } finally { + connection.release(); + } + } catch (error) { + console.error('Review application error:', error); + res.status(500).json({ + success: false, + message: '服务器内部错误' + }); + } +}; + +module.exports = { + submitApplication, + getApplicationStatus, + getAllApplications, + reviewApplication +}; diff --git a/backend/controllers/reservationController.js b/backend/controllers/reservationController.js new file mode 100644 index 0000000..46ac80b --- /dev/null +++ b/backend/controllers/reservationController.js @@ -0,0 +1,388 @@ +const pool = require('../config/database'); + +// 创建预约 +const createReservation = async (req, res) => { + try { + const userId = req.user.id; + const { + shopId, + reservationDate, + reservationTime, + peopleCount, + contactName, + contactPhone, + specialRequests + } = req.body; + + // 检查店铺是否存在 + const [shops] = await pool.execute( + 'SELECT id, shop_name FROM shops WHERE id = ? AND status = "active"', + [shopId] + ); + + if (shops.length === 0) { + return res.status(404).json({ + success: false, + message: '店铺不存在或已关闭' + }); + } + + // 检查预约日期是否是过去的日期 + const reservationDateTime = new Date(`${reservationDate}T${reservationTime}`); + const now = new Date(); + + if (reservationDateTime < now) { + return res.status(400).json({ + success: false, + message: '预约时间不能是过去的时间' + }); + } + + // 创建预约 + const [result] = await pool.execute( + `INSERT INTO reservations + (user_id, shop_id, reservation_date, reservation_time, people_count, + contact_name, contact_phone, special_requests) + VALUES (?, ?, ?, ?, ?, ?, ?, ?)`, + [ + userId, + shopId, + reservationDate, + reservationTime, + peopleCount || 1, + contactName, + contactPhone, + specialRequests || null + ] + ); + + res.status(201).json({ + success: true, + message: '预约创建成功', + data: { + reservationId: result.insertId + } + }); + } catch (error) { + console.error('Create reservation error:', error); + res.status(500).json({ + success: false, + message: '服务器内部错误' + }); + } +}; + +// 获取用户的预约列表 +const getMyReservations = async (req, res) => { + try { + const userId = req.user.id; + const { status, page = 1, limit = 10 } = req.query; + const offset = (page - 1) * limit; + + let query = ` + SELECT r.*, s.shop_name, s.shop_logo, s.address, s.contact_phone + FROM reservations r + JOIN shops s ON r.shop_id = s.id + WHERE r.user_id = ? + `; + let countQuery = ` + SELECT COUNT(*) as total + FROM reservations + WHERE user_id = ? + `; + let queryParams = [userId]; + let countParams = [userId]; + + if (status) { + query += ' AND r.status = ?'; + countQuery += ' AND status = ?'; + queryParams.push(status); + countParams.push(status); + } + + query += ' ORDER BY r.reservation_date DESC, r.reservation_time DESC LIMIT ? OFFSET ?'; + queryParams.push(parseInt(limit), parseInt(offset)); + + const [reservations] = await pool.execute(query, queryParams); + const [countResult] = await pool.execute(countQuery, countParams); + + res.json({ + success: true, + data: { + reservations, + total: countResult[0].total, + page: parseInt(page), + limit: parseInt(limit) + } + }); + } catch (error) { + console.error('Get my reservations error:', error); + res.status(500).json({ + success: false, + message: '服务器内部错误' + }); + } +}; + +// 获取单个预约详情 +const getReservationById = async (req, res) => { + try { + const userId = req.user.id; + const reservationId = req.params.id; + + const [reservations] = await pool.execute( + `SELECT r.*, s.shop_name, s.shop_logo, s.address, s.contact_phone, s.description + FROM reservations r + JOIN shops s ON r.shop_id = s.id + WHERE r.id = ? AND r.user_id = ?`, + [reservationId, userId] + ); + + if (reservations.length === 0) { + return res.status(404).json({ + success: false, + message: '预约不存在' + }); + } + + res.json({ + success: true, + data: { + reservation: reservations[0] + } + }); + } catch (error) { + console.error('Get reservation by id error:', error); + res.status(500).json({ + success: false, + message: '服务器内部错误' + }); + } +}; + +// 取消预约 +const cancelReservation = async (req, res) => { + try { + const userId = req.user.id; + const reservationId = req.params.id; + + // 检查预约是否存在 + const [reservations] = await pool.execute( + 'SELECT * FROM reservations WHERE id = ? AND user_id = ?', + [reservationId, userId] + ); + + if (reservations.length === 0) { + return res.status(404).json({ + success: false, + message: '预约不存在' + }); + } + + const reservation = reservations[0]; + + // 检查预约状态 + if (reservation.status === 'cancelled') { + return res.status(400).json({ + success: false, + message: '预约已取消' + }); + } + + if (reservation.status === 'completed') { + return res.status(400).json({ + success: false, + message: '预约已完成,无法取消' + }); + } + + // 更新预约状态 + await pool.execute( + 'UPDATE reservations SET status = "cancelled" WHERE id = ?', + [reservationId] + ); + + res.json({ + success: true, + message: '预约取消成功' + }); + } catch (error) { + console.error('Cancel reservation error:', error); + res.status(500).json({ + success: false, + message: '服务器内部错误' + }); + } +}; + +// 获取店铺的预约列表 +const getShopReservations = async (req, res) => { + try { + const shopId = req.shopId; + const { status, date, page = 1, limit = 10 } = req.query; + const offset = (page - 1) * limit; + + let query = ` + SELECT r.*, u.username, u.avatar, u.email + FROM reservations r + JOIN users u ON r.user_id = u.id + WHERE r.shop_id = ? + `; + let countQuery = ` + SELECT COUNT(*) as total + FROM reservations + WHERE shop_id = ? + `; + let queryParams = [shopId]; + let countParams = [shopId]; + + if (status) { + query += ' AND r.status = ?'; + countQuery += ' AND status = ?'; + queryParams.push(status); + countParams.push(status); + } + + if (date) { + query += ' AND r.reservation_date = ?'; + countQuery += ' AND reservation_date = ?'; + queryParams.push(date); + countParams.push(date); + } + + query += ' ORDER BY r.reservation_date DESC, r.reservation_time DESC LIMIT ? OFFSET ?'; + queryParams.push(parseInt(limit), parseInt(offset)); + + const [reservations] = await pool.execute(query, queryParams); + const [countResult] = await pool.execute(countQuery, countParams); + + res.json({ + success: true, + data: { + reservations, + total: countResult[0].total, + page: parseInt(page), + limit: parseInt(limit) + } + }); + } catch (error) { + console.error('Get shop reservations error:', error); + res.status(500).json({ + success: false, + message: '服务器内部错误' + }); + } +}; + +// 确认预约 +const confirmReservation = async (req, res) => { + try { + const shopId = req.shopId; + const reservationId = req.params.id; + + // 检查预约是否存在 + const [reservations] = await pool.execute( + 'SELECT * FROM reservations WHERE id = ? AND shop_id = ?', + [reservationId, shopId] + ); + + if (reservations.length === 0) { + return res.status(404).json({ + success: false, + message: '预约不存在' + }); + } + + const reservation = reservations[0]; + + // 检查预约状态 + if (reservation.status !== 'pending') { + return res.status(400).json({ + success: false, + message: '只能确认待处理的预约' + }); + } + + // 更新预约状态 + await pool.execute( + 'UPDATE reservations SET status = "confirmed" WHERE id = ?', + [reservationId] + ); + + res.json({ + success: true, + message: '预约确认成功' + }); + } catch (error) { + console.error('Confirm reservation error:', error); + res.status(500).json({ + success: false, + message: '服务器内部错误' + }); + } +}; + +// 完成预约 +const completeReservation = async (req, res) => { + try { + const shopId = req.shopId; + const reservationId = req.params.id; + + // 检查预约是否存在 + const [reservations] = await pool.execute( + 'SELECT * FROM reservations WHERE id = ? AND shop_id = ?', + [reservationId, shopId] + ); + + if (reservations.length === 0) { + return res.status(404).json({ + success: false, + message: '预约不存在' + }); + } + + const reservation = reservations[0]; + + // 检查预约状态 + if (reservation.status === 'cancelled') { + return res.status(400).json({ + success: false, + message: '已取消的预约无法完成' + }); + } + + if (reservation.status === 'completed') { + return res.status(400).json({ + success: false, + message: '预约已完成' + }); + } + + // 更新预约状态 + await pool.execute( + 'UPDATE reservations SET status = "completed" WHERE id = ?', + [reservationId] + ); + + res.json({ + success: true, + message: '预约完成成功' + }); + } catch (error) { + console.error('Complete reservation error:', error); + res.status(500).json({ + success: false, + message: '服务器内部错误' + }); + } +}; + +module.exports = { + createReservation, + getMyReservations, + getReservationById, + cancelReservation, + getShopReservations, + confirmReservation, + completeReservation +}; diff --git a/backend/controllers/reviewController.js b/backend/controllers/reviewController.js new file mode 100644 index 0000000..91003f5 --- /dev/null +++ b/backend/controllers/reviewController.js @@ -0,0 +1,389 @@ +const pool = require('../config/database'); + +// 创建评价 +const createReview = async (req, res) => { + try { + const userId = req.user.id; + const { + shopId, + reservationId, + rating, + content, + images, + isAnonymous + } = req.body; + + // 检查店铺是否存在 + const [shops] = await pool.execute( + 'SELECT id, shop_name FROM shops WHERE id = ? AND status = "active"', + [shopId] + ); + + if (shops.length === 0) { + return res.status(404).json({ + success: false, + message: '店铺不存在或已关闭' + }); + } + + // 检查用户是否已经对该店铺评价过 + const [existingReviews] = await pool.execute( + 'SELECT id FROM reviews WHERE user_id = ? AND shop_id = ?', + [userId, shopId] + ); + + if (existingReviews.length > 0) { + return res.status(400).json({ + success: false, + message: '您已经对该店铺评价过了' + }); + } + + // 开始事务 + const connection = await pool.getConnection(); + await connection.beginTransaction(); + + try { + // 创建评价 + const [result] = await connection.execute( + `INSERT INTO reviews + (user_id, shop_id, reservation_id, rating, content, images, is_anonymous) + VALUES (?, ?, ?, ?, ?, ?, ?)`, + [ + userId, + shopId, + reservationId || null, + rating, + content || null, + images ? JSON.stringify(images) : null, + isAnonymous || false + ] + ); + + // 更新店铺的评分和评分数量 + await connection.execute( + `UPDATE shops + SET average_rating = ( + SELECT AVG(rating) FROM reviews WHERE shop_id = ? AND status = 'active' + ), + rating_count = ( + SELECT COUNT(*) FROM reviews WHERE shop_id = ? AND status = 'active' + ) + WHERE id = ?`, + [shopId, shopId, shopId] + ); + + await connection.commit(); + + res.status(201).json({ + success: true, + message: '评价发布成功', + data: { + reviewId: result.insertId + } + }); + } catch (error) { + await connection.rollback(); + throw error; + } finally { + connection.release(); + } + } catch (error) { + console.error('Create review error:', error); + res.status(500).json({ + success: false, + message: '服务器内部错误' + }); + } +}; + +// 获取用户的评价列表 +const getMyReviews = async (req, res) => { + try { + const userId = req.user.id; + const { page = 1, limit = 10 } = req.query; + const offset = (page - 1) * limit; + + const [reviews] = await pool.execute( + `SELECT r.*, s.shop_name, s.shop_logo, s.address + FROM reviews r + JOIN shops s ON r.shop_id = s.id + WHERE r.user_id = ? AND r.status = 'active' + ORDER BY r.created_at DESC + LIMIT ? OFFSET ?`, + [userId, parseInt(limit), parseInt(offset)] + ); + + const [countResult] = await pool.execute( + 'SELECT COUNT(*) as total FROM reviews WHERE user_id = ? AND status = "active"', + [userId] + ); + + res.json({ + success: true, + data: { + reviews, + total: countResult[0].total, + page: parseInt(page), + limit: parseInt(limit) + } + }); + } catch (error) { + console.error('Get my reviews error:', error); + res.status(500).json({ + success: false, + message: '服务器内部错误' + }); + } +}; + +// 获取单个评价详情 +const getReviewById = async (req, res) => { + try { + const userId = req.user.id; + const reviewId = req.params.id; + + const [reviews] = await pool.execute( + `SELECT r.*, s.shop_name, s.shop_logo, s.address, s.contact_phone + FROM reviews r + JOIN shops s ON r.shop_id = s.id + WHERE r.id = ? AND r.user_id = ? AND r.status = 'active'`, + [reviewId, userId] + ); + + if (reviews.length === 0) { + return res.status(404).json({ + success: false, + message: '评价不存在' + }); + } + + res.json({ + success: true, + data: { + review: reviews[0] + } + }); + } catch (error) { + console.error('Get review by id error:', error); + res.status(500).json({ + success: false, + message: '服务器内部错误' + }); + } +}; + +// 更新评价 +const updateReview = async (req, res) => { + try { + const userId = req.user.id; + const reviewId = req.params.id; + const { rating, content, images, isAnonymous } = req.body; + + // 检查评价是否存在 + const [reviews] = await pool.execute( + 'SELECT * FROM reviews WHERE id = ? AND user_id = ?', + [reviewId, userId] + ); + + if (reviews.length === 0) { + return res.status(404).json({ + success: false, + message: '评价不存在' + }); + } + + const review = reviews[0]; + + // 检查评价状态 + if (review.status !== 'active') { + return res.status(400).json({ + success: false, + message: '评价已被删除或隐藏,无法更新' + }); + } + + // 构建更新语句 + let updateFields = []; + let updateValues = []; + + if (rating !== undefined) { + updateFields.push('rating = ?'); + updateValues.push(rating); + } + + if (content !== undefined) { + updateFields.push('content = ?'); + updateValues.push(content); + } + + if (images !== undefined) { + updateFields.push('images = ?'); + updateValues.push(images ? JSON.stringify(images) : null); + } + + if (isAnonymous !== undefined) { + updateFields.push('is_anonymous = ?'); + updateValues.push(isAnonymous); + } + + if (updateFields.length === 0) { + return res.status(400).json({ + success: false, + message: '没有提供要更新的信息' + }); + } + + updateValues.push(reviewId); + + // 开始事务 + const connection = await pool.getConnection(); + await connection.beginTransaction(); + + try { + // 更新评价 + await connection.execute( + `UPDATE reviews SET ${updateFields.join(', ')} WHERE id = ?`, + updateValues + ); + + // 更新店铺的评分 + await connection.execute( + `UPDATE shops + SET average_rating = ( + SELECT AVG(rating) FROM reviews WHERE shop_id = ? AND status = 'active' + ) + WHERE id = ?`, + [review.shop_id, review.shop_id] + ); + + await connection.commit(); + + res.json({ + success: true, + message: '评价更新成功' + }); + } catch (error) { + await connection.rollback(); + throw error; + } finally { + connection.release(); + } + } catch (error) { + console.error('Update review error:', error); + res.status(500).json({ + success: false, + message: '服务器内部错误' + }); + } +}; + +// 回复评价 +const replyReview = async (req, res) => { + try { + const shopId = req.shopId; + const reviewId = req.params.id; + const { reply } = req.body; + + // 检查评价是否存在且属于当前店铺 + const [reviews] = await pool.execute( + 'SELECT * FROM reviews WHERE id = ? AND shop_id = ?', + [reviewId, shopId] + ); + + if (reviews.length === 0) { + return res.status(404).json({ + success: false, + message: '评价不存在或不属于此店铺' + }); + } + + const review = reviews[0]; + + // 检查评价状态 + if (review.status !== 'active') { + return res.status(400).json({ + success: false, + message: '评价已被删除或隐藏,无法回复' + }); + } + + // 更新评价的回复 + await pool.execute( + 'UPDATE reviews SET reply = ?, reply_at = NOW() WHERE id = ?', + [reply, reviewId] + ); + + res.json({ + success: true, + message: '回复成功' + }); + } catch (error) { + console.error('Reply review error:', error); + res.status(500).json({ + success: false, + message: '服务器内部错误' + }); + } +}; + +// 获取店铺的评价列表 +const getShopReviews = async (req, res) => { + try { + const shopId = req.shopId; + const { rating, page = 1, limit = 10 } = req.query; + const offset = (page - 1) * limit; + + let query = ` + SELECT r.*, u.username, u.avatar + FROM reviews r + LEFT JOIN users u ON r.user_id = u.id + WHERE r.shop_id = ? AND r.status = 'active' + `; + let countQuery = ` + SELECT COUNT(*) as total + FROM reviews + WHERE shop_id = ? AND status = 'active' + `; + let queryParams = [shopId]; + let countParams = [shopId]; + + if (rating) { + query += ' AND r.rating = ?'; + countQuery += ' AND rating = ?'; + queryParams.push(parseInt(rating)); + countParams.push(parseInt(rating)); + } + + query += ' ORDER BY r.created_at DESC LIMIT ? OFFSET ?'; + queryParams.push(parseInt(limit), parseInt(offset)); + + const [reviews] = await pool.execute(query, queryParams); + const [countResult] = await pool.execute(countQuery, countParams); + + res.json({ + success: true, + data: { + reviews, + total: countResult[0].total, + page: parseInt(page), + limit: parseInt(limit) + } + }); + } catch (error) { + console.error('Get shop reviews error:', error); + res.status(500).json({ + success: false, + message: '服务器内部错误' + }); + } +}; + +module.exports = { + createReview, + getMyReviews, + getReviewById, + updateReview, + replyReview, + getShopReviews +}; diff --git a/backend/controllers/shopController.js b/backend/controllers/shopController.js new file mode 100644 index 0000000..85b2948 --- /dev/null +++ b/backend/controllers/shopController.js @@ -0,0 +1,498 @@ +const pool = require('../config/database'); + +// 获取所有店铺 +const getAllShops = async (req, res) => { + try { + const { shopType, page = 1, limit = 10, sortBy = 'rating' } = req.query; + const offset = (page - 1) * limit; + + let query = ` + SELECT id, shop_name, shop_logo, shop_type, business_hours, address, + latitude, longitude, contact_phone, description, average_rating, + rating_count, status, created_at + FROM shops + WHERE status = 'active' + `; + let countQuery = 'SELECT COUNT(*) as total FROM shops WHERE status = "active"'; + let queryParams = []; + let countParams = []; + + if (shopType) { + query += ' AND shop_type = ?'; + countQuery += ' AND shop_type = ?'; + queryParams.push(shopType); + countParams.push(shopType); + } + + // 排序 + if (sortBy === 'rating') { + query += ' ORDER BY average_rating DESC, rating_count DESC'; + } else if (sortBy === 'newest') { + query += ' ORDER BY created_at DESC'; + } else { + query += ' ORDER BY average_rating DESC'; + } + + query += ' LIMIT ? OFFSET ?'; + queryParams.push(parseInt(limit), parseInt(offset)); + + const [shops] = await pool.execute(query, queryParams); + const [countResult] = await pool.execute(countQuery, countParams); + + res.json({ + success: true, + data: { + shops, + total: countResult[0].total, + page: parseInt(page), + limit: parseInt(limit) + } + }); + } catch (error) { + console.error('Get all shops error:', error); + res.status(500).json({ + success: false, + message: '服务器内部错误' + }); + } +}; + +// 获取单个店铺详情 +const getShopById = async (req, res) => { + try { + const shopId = req.params.id; + + const [shops] = await pool.execute( + `SELECT id, merchant_id, shop_name, shop_logo, shop_photos, shop_type, + business_hours, address, latitude, longitude, contact_phone, + description, average_rating, rating_count, status, created_at + FROM shops + WHERE id = ? AND status = 'active'`, + [shopId] + ); + + if (shops.length === 0) { + return res.status(404).json({ + success: false, + message: '店铺不存在或已关闭' + }); + } + + // 记录浏览历史(如果用户已登录) + if (req.user && req.user.id) { + await pool.execute( + 'INSERT INTO browsing_history (user_id, shop_id) VALUES (?, ?)', + [req.user.id, shopId] + ); + } + + res.json({ + success: true, + data: { + shop: shops[0] + } + }); + } catch (error) { + console.error('Get shop by id error:', error); + res.status(500).json({ + success: false, + message: '服务器内部错误' + }); + } +}; + +// 搜索店铺 +const searchShops = async (req, res) => { + try { + const { keyword, shopType, page = 1, limit = 10 } = req.query; + const offset = (page - 1) * limit; + + if (!keyword && !shopType) { + return res.status(400).json({ + success: false, + message: '请提供搜索关键词或店铺类型' + }); + } + + let query = ` + SELECT id, shop_name, shop_logo, shop_type, business_hours, address, + average_rating, rating_count, status + FROM shops + WHERE status = 'active' + `; + let countQuery = 'SELECT COUNT(*) as total FROM shops WHERE status = "active"'; + let queryParams = []; + let countParams = []; + + if (keyword) { + const searchPattern = `%${keyword}%`; + query += ' AND (shop_name LIKE ? OR description LIKE ? OR shop_type LIKE ?)'; + countQuery += ' AND (shop_name LIKE ? OR description LIKE ? OR shop_type LIKE ?)'; + queryParams.push(searchPattern, searchPattern, searchPattern); + countParams.push(searchPattern, searchPattern, searchPattern); + } + + if (shopType) { + query += ' AND shop_type = ?'; + countQuery += ' AND shop_type = ?'; + queryParams.push(shopType); + countParams.push(shopType); + } + + query += ' ORDER BY average_rating DESC, rating_count DESC LIMIT ? OFFSET ?'; + queryParams.push(parseInt(limit), parseInt(offset)); + + const [shops] = await pool.execute(query, queryParams); + const [countResult] = await pool.execute(countQuery, countParams); + + res.json({ + success: true, + data: { + shops, + total: countResult[0].total, + page: parseInt(page), + limit: parseInt(limit) + } + }); + } catch (error) { + console.error('Search shops error:', error); + res.status(500).json({ + success: false, + message: '服务器内部错误' + }); + } +}; + +// 创建店铺 +const createShop = async (req, res) => { + try { + const userId = req.user.id; + const { + shopName, + shopLogo, + shopPhotos, + shopType, + businessHours, + address, + latitude, + longitude, + contactPhone, + description + } = req.body; + + // 检查用户是否已经有店铺 + const [existingShops] = await pool.execute( + 'SELECT id FROM shops WHERE merchant_id = ?', + [userId] + ); + + if (existingShops.length > 0) { + return res.status(400).json({ + success: false, + message: '您已经有一个店铺,每个商户只能创建一个店铺' + }); + } + + // 创建店铺 + const [result] = await pool.execute( + `INSERT INTO shops + (merchant_id, shop_name, shop_logo, shop_photos, shop_type, + business_hours, address, latitude, longitude, contact_phone, description) + VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, + [ + userId, + shopName, + shopLogo || null, + shopPhotos ? JSON.stringify(shopPhotos) : null, + shopType, + businessHours || null, + address, + latitude || null, + longitude || null, + contactPhone || null, + description || null + ] + ); + + res.status(201).json({ + success: true, + message: '店铺创建成功', + data: { + shopId: result.insertId + } + }); + } catch (error) { + console.error('Create shop error:', error); + res.status(500).json({ + success: false, + message: '服务器内部错误' + }); + } +}; + +// 获取当前商户的店铺信息 +const getMyShop = async (req, res) => { + try { + const shopId = req.shopId; + + const [shops] = await pool.execute( + `SELECT id, merchant_id, shop_name, shop_logo, shop_photos, shop_type, + business_hours, address, latitude, longitude, contact_phone, + description, average_rating, rating_count, status, created_at + FROM shops + WHERE id = ?`, + [shopId] + ); + + if (shops.length === 0) { + return res.status(404).json({ + success: false, + message: '店铺不存在' + }); + } + + res.json({ + success: true, + data: { + shop: shops[0] + } + }); + } catch (error) { + console.error('Get my shop error:', error); + res.status(500).json({ + success: false, + message: '服务器内部错误' + }); + } +}; + +// 更新店铺信息 +const updateShop = async (req, res) => { + try { + const shopId = req.shopId; + const { + shopName, + shopLogo, + shopPhotos, + shopType, + businessHours, + address, + latitude, + longitude, + contactPhone, + description, + status + } = req.body; + + // 构建更新语句 + let updateFields = []; + let updateValues = []; + + if (shopName) { + updateFields.push('shop_name = ?'); + updateValues.push(shopName); + } + + if (shopLogo !== undefined) { + updateFields.push('shop_logo = ?'); + updateValues.push(shopLogo); + } + + if (shopPhotos !== undefined) { + updateFields.push('shop_photos = ?'); + updateValues.push(shopPhotos ? JSON.stringify(shopPhotos) : null); + } + + if (shopType) { + updateFields.push('shop_type = ?'); + updateValues.push(shopType); + } + + if (businessHours !== undefined) { + updateFields.push('business_hours = ?'); + updateValues.push(businessHours); + } + + if (address) { + updateFields.push('address = ?'); + updateValues.push(address); + } + + if (latitude !== undefined) { + updateFields.push('latitude = ?'); + updateValues.push(latitude); + } + + if (longitude !== undefined) { + updateFields.push('longitude = ?'); + updateValues.push(longitude); + } + + if (contactPhone !== undefined) { + updateFields.push('contact_phone = ?'); + updateValues.push(contactPhone); + } + + if (description !== undefined) { + updateFields.push('description = ?'); + updateValues.push(description); + } + + if (status) { + updateFields.push('status = ?'); + updateValues.push(status); + } + + if (updateFields.length === 0) { + return res.status(400).json({ + success: false, + message: '没有提供要更新的信息' + }); + } + + updateValues.push(shopId); + + // 执行更新 + await pool.execute( + `UPDATE shops SET ${updateFields.join(', ')} WHERE id = ?`, + updateValues + ); + + // 获取更新后的店铺信息 + const [shops] = await pool.execute( + `SELECT id, shop_name, shop_logo, shop_photos, shop_type, + business_hours, address, latitude, longitude, contact_phone, + description, status + FROM shops WHERE id = ?`, + [shopId] + ); + + res.json({ + success: true, + message: '店铺信息更新成功', + data: { + shop: shops[0] + } + }); + } catch (error) { + console.error('Update shop error:', error); + res.status(500).json({ + success: false, + message: '服务器内部错误' + }); + } +}; + +// 获取店铺的评价列表 +const getShopReviews = async (req, res) => { + try { + const shopId = req.params.id; + const { page = 1, limit = 10 } = req.query; + const offset = (page - 1) * limit; + + // 检查店铺是否存在 + const [shops] = await pool.execute( + 'SELECT id FROM shops WHERE id = ? AND status = "active"', + [shopId] + ); + + if (shops.length === 0) { + return res.status(404).json({ + success: false, + message: '店铺不存在或已关闭' + }); + } + + // 获取评价列表 + const [reviews] = await pool.execute( + `SELECT r.id, r.user_id, r.rating, r.content, r.images, r.is_anonymous, + r.reply, r.reply_at, r.created_at, + u.username, u.avatar + FROM reviews r + LEFT JOIN users u ON r.user_id = u.id + WHERE r.shop_id = ? AND r.status = 'active' + ORDER BY r.created_at DESC + LIMIT ? OFFSET ?`, + [shopId, parseInt(limit), parseInt(offset)] + ); + + // 获取评价总数 + const [countResult] = await pool.execute( + 'SELECT COUNT(*) as total FROM reviews WHERE shop_id = ? AND status = "active"', + [shopId] + ); + + res.json({ + success: true, + data: { + reviews, + total: countResult[0].total, + page: parseInt(page), + limit: parseInt(limit) + } + }); + } catch (error) { + console.error('Get shop reviews error:', error); + res.status(500).json({ + success: false, + message: '服务器内部错误' + }); + } +}; + +// 获取店铺的优惠券列表 +const getShopCoupons = async (req, res) => { + try { + const shopId = req.params.id; + + // 检查店铺是否存在 + const [shops] = await pool.execute( + 'SELECT id FROM shops WHERE id = ? AND status = "active"', + [shopId] + ); + + if (shops.length === 0) { + return res.status(404).json({ + success: false, + message: '店铺不存在或已关闭' + }); + } + + // 获取有效的优惠券列表 + const [coupons] = await pool.execute( + `SELECT id, shop_id, coupon_name, coupon_type, discount_value, min_spend, + total_quantity, used_quantity, claimed_quantity, start_date, end_date, + usage_type, description, terms_and_conditions, status + FROM coupons + WHERE shop_id = ? AND status = 'active' + AND start_date <= CURDATE() AND end_date >= CURDATE() + AND (total_quantity > claimed_quantity) + ORDER BY created_at DESC`, + [shopId] + ); + + res.json({ + success: true, + data: { + coupons + } + }); + } catch (error) { + console.error('Get shop coupons error:', error); + res.status(500).json({ + success: false, + message: '服务器内部错误' + }); + } +}; + +module.exports = { + getAllShops, + getShopById, + searchShops, + createShop, + getMyShop, + updateShop, + getShopReviews, + getShopCoupons +}; diff --git a/backend/middleware/auth.js b/backend/middleware/auth.js new file mode 100644 index 0000000..2ae9f96 --- /dev/null +++ b/backend/middleware/auth.js @@ -0,0 +1,117 @@ +const jwt = require('jsonwebtoken'); +const pool = require('../config/database'); + +const authMiddleware = async (req, res, next) => { + try { + const token = req.header('Authorization')?.replace('Bearer ', ''); + + if (!token) { + return res.status(401).json({ + success: false, + message: '访问被拒绝,未提供令牌' + }); + } + + const decoded = jwt.verify(token, process.env.JWT_SECRET); + + // 检查用户是否存在 + const [users] = await pool.execute( + 'SELECT id, username, email, role, status FROM users WHERE id = ?', + [decoded.id] + ); + + if (users.length === 0) { + return res.status(401).json({ + success: false, + message: '无效的令牌,用户不存在' + }); + } + + const user = users[0]; + + if (user.status !== 'active') { + return res.status(403).json({ + success: false, + message: '账户已被禁用,请联系管理员' + }); + } + + req.user = user; + next(); + } catch (error) { + console.error('Auth middleware error:', error); + + if (error.name === 'JsonWebTokenError') { + return res.status(401).json({ + success: false, + message: '无效的令牌' + }); + } + + if (error.name === 'TokenExpiredError') { + return res.status(401).json({ + success: false, + message: '令牌已过期' + }); + } + + res.status(500).json({ + success: false, + message: '服务器内部错误' + }); + } +}; + +const roleMiddleware = (...roles) => { + return (req, res, next) => { + if (!req.user || !roles.includes(req.user.role)) { + return res.status(403).json({ + success: false, + message: '权限不足,无法访问此资源' + }); + } + next(); + }; +}; + +const merchantMiddleware = async (req, res, next) => { + try { + const user = req.user; + + // 检查用户是否是商户 + if (user.role !== 'merchant') { + return res.status(403).json({ + success: false, + message: '只有商户可以访问此资源' + }); + } + + // 检查商户是否有店铺 + const [shops] = await pool.execute( + 'SELECT id FROM shops WHERE merchant_id = ?', + [user.id] + ); + + if (shops.length === 0) { + return res.status(403).json({ + success: false, + message: '您还没有创建店铺,请先创建店铺' + }); + } + + req.shopId = shops[0].id; + next(); + } catch (error) { + console.error('Merchant middleware error:', error); + res.status(500).json({ + success: false, + message: '服务器内部错误' + }); + } +}; + +module.exports = { + authMiddleware, + roleMiddleware, + merchantMiddleware +}; diff --git a/backend/package-lock.json b/backend/package-lock.json new file mode 100644 index 0000000..f3be78c --- /dev/null +++ b/backend/package-lock.json @@ -0,0 +1,1726 @@ +{ + "name": "merchant-platform-backend", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "merchant-platform-backend", + "version": "1.0.0", + "license": "ISC", + "dependencies": { + "bcryptjs": "^2.4.3", + "cors": "^2.8.5", + "dotenv": "^16.0.3", + "express": "^4.18.2", + "express-validator": "^7.0.1", + "jsonwebtoken": "^9.0.0", + "multer": "^1.4.5-lts.1", + "mysql2": "^3.2.0", + "uuid": "^9.0.0" + }, + "devDependencies": { + "nodemon": "^2.0.22" + } + }, + "node_modules/@types/node": { + "version": "25.6.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-25.6.0.tgz", + "integrity": "sha512-+qIYRKdNYJwY3vRCZMdJbPLJAtGjQBudzZzdzwQYkEPQd+PJGixUL5QfvCLDaULoLv+RhT3LDkwEfKaAkgSmNQ==", + "license": "MIT", + "peer": true, + "dependencies": { + "undici-types": "~7.19.0" + } + }, + "node_modules/accepts": { + "version": "1.3.8", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", + "integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==", + "license": "MIT", + "dependencies": { + "mime-types": "~2.1.34", + "negotiator": "0.6.3" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/anymatch": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", + "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", + "dev": true, + "license": "ISC", + "dependencies": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/append-field": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/append-field/-/append-field-1.0.0.tgz", + "integrity": "sha512-klpgFSWLW1ZEs8svjfb7g4qWY0YS5imI82dTg+QahUvJ8YqAY0P10Uk8tTyh9ZGuYEZEMaeJYCF5BFuX552hsw==", + "license": "MIT" + }, + "node_modules/array-flatten": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", + "integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==", + "license": "MIT" + }, + "node_modules/aws-ssl-profiles": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/aws-ssl-profiles/-/aws-ssl-profiles-1.1.2.tgz", + "integrity": "sha512-NZKeq9AfyQvEeNlN0zSYAaWrmBffJh3IELMZfRpJVWgrpEbtEpnjvzqBPf+mxoI287JohRDoa+/nsfqqiZmF6g==", + "license": "MIT", + "engines": { + "node": ">= 6.0.0" + } + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true, + "license": "MIT" + }, + "node_modules/bcryptjs": { + "version": "2.4.3", + "resolved": "https://registry.npmjs.org/bcryptjs/-/bcryptjs-2.4.3.tgz", + "integrity": "sha512-V/Hy/X9Vt7f3BbPJEi8BdVFMByHi+jNXrYkW3huaybV/kQ0KJg0Y6PkEMbn+zeT+i+SiKZ/HMqJGIIt4LZDqNQ==", + "license": "MIT" + }, + "node_modules/binary-extensions": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz", + "integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/body-parser": { + "version": "1.20.5", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.5.tgz", + "integrity": "sha512-3grm+/2tUOvu2cjJkvsIxrv/wVpfXQW4PsQHYm7yk4vfpu7Ekl6nEsYBoJUL6qDwZUx8wUhQ8tR2qz+ad9c9OA==", + "license": "MIT", + "dependencies": { + "bytes": "~3.1.2", + "content-type": "~1.0.5", + "debug": "2.6.9", + "depd": "2.0.0", + "destroy": "~1.2.0", + "http-errors": "~2.0.1", + "iconv-lite": "~0.4.24", + "on-finished": "~2.4.1", + "qs": "~6.15.1", + "raw-body": "~2.5.3", + "type-is": "~1.6.18", + "unpipe": "~1.0.0" + }, + "engines": { + "node": ">= 0.8", + "npm": "1.2.8000 || >= 1.4.16" + } + }, + "node_modules/body-parser/node_modules/qs": { + "version": "6.15.1", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.15.1.tgz", + "integrity": "sha512-6YHEFRL9mfgcAvql/XhwTvf5jKcOiiupt2FiJxHkiX1z4j7WL8J/jRHYLluORvc1XxB5rV20KoeK00gVJamspg==", + "license": "BSD-3-Clause", + "dependencies": { + "side-channel": "^1.1.0" + }, + "engines": { + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/brace-expansion": { + "version": "1.1.14", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.14.tgz", + "integrity": "sha512-MWPGfDxnyzKU7rNOW9SP/c50vi3xrmrua/+6hfPbCS2ABNWfx24vPidzvC7krjU/RTo235sV776ymlsMtGKj8g==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/braces": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", + "dev": true, + "license": "MIT", + "dependencies": { + "fill-range": "^7.1.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/buffer-equal-constant-time": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz", + "integrity": "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA==", + "license": "BSD-3-Clause" + }, + "node_modules/buffer-from": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", + "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", + "license": "MIT" + }, + "node_modules/busboy": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/busboy/-/busboy-1.6.0.tgz", + "integrity": "sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA==", + "dependencies": { + "streamsearch": "^1.1.0" + }, + "engines": { + "node": ">=10.16.0" + } + }, + "node_modules/bytes": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", + "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/call-bind-apply-helpers": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz", + "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/call-bound": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz", + "integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "get-intrinsic": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/chokidar": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", + "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", + "dev": true, + "license": "MIT", + "dependencies": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + }, + "engines": { + "node": ">= 8.10.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", + "dev": true, + "license": "MIT" + }, + "node_modules/concat-stream": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", + "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", + "engines": [ + "node >= 0.8" + ], + "license": "MIT", + "dependencies": { + "buffer-from": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^2.2.2", + "typedarray": "^0.0.6" + } + }, + "node_modules/content-disposition": { + "version": "0.5.4", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz", + "integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==", + "license": "MIT", + "dependencies": { + "safe-buffer": "5.2.1" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/content-type": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", + "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie": { + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz", + "integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie-signature": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.7.tgz", + "integrity": "sha512-NXdYc3dLr47pBkpUCHtKSwIOQXLVn8dZEuywboCOJY/osA0wFSLlSawr3KN8qXJEyX66FcONTH8EIlVuK0yyFA==", + "license": "MIT" + }, + "node_modules/core-util-is": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", + "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==", + "license": "MIT" + }, + "node_modules/cors": { + "version": "2.8.6", + "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.6.tgz", + "integrity": "sha512-tJtZBBHA6vjIAaF6EnIaq6laBBP9aq/Y3ouVJjEfoHbRBcHBAHYcMh/w8LDrk2PvIMMq8gmopa5D4V8RmbrxGw==", + "license": "MIT", + "dependencies": { + "object-assign": "^4", + "vary": "^1" + }, + "engines": { + "node": ">= 0.10" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "license": "MIT", + "dependencies": { + "ms": "2.0.0" + } + }, + "node_modules/denque": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/denque/-/denque-2.1.0.tgz", + "integrity": "sha512-HVQE3AAb/pxF8fQAoiqpvg9i3evqug3hoiwakOyZAwJm+6vZehbkYXZ0l4JxS+I3QxM97v5aaRNhj8v5oBhekw==", + "license": "Apache-2.0", + "engines": { + "node": ">=0.10" + } + }, + "node_modules/depd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/destroy": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz", + "integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==", + "license": "MIT", + "engines": { + "node": ">= 0.8", + "npm": "1.2.8000 || >= 1.4.16" + } + }, + "node_modules/dotenv": { + "version": "16.6.1", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.6.1.tgz", + "integrity": "sha512-uBq4egWHTcTt33a72vpSG0z3HnPuIl6NqYcTrKEg2azoEyl2hpW0zqlxysq2pK9HlDIHyHyakeYaYnSAwd8bow==", + "license": "BSD-2-Clause", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, + "node_modules/dunder-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", + "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.1", + "es-errors": "^1.3.0", + "gopd": "^1.2.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/ecdsa-sig-formatter": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz", + "integrity": "sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==", + "license": "Apache-2.0", + "dependencies": { + "safe-buffer": "^5.0.1" + } + }, + "node_modules/ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==", + "license": "MIT" + }, + "node_modules/encodeurl": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz", + "integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/es-define-property": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", + "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-object-atoms": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz", + "integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==", + "license": "MIT" + }, + "node_modules/etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/express": { + "version": "4.22.1", + "resolved": "https://registry.npmjs.org/express/-/express-4.22.1.tgz", + "integrity": "sha512-F2X8g9P1X7uCPZMA3MVf9wcTqlyNp7IhH5qPCI0izhaOIYXaW9L535tGA3qmjRzpH+bZczqq7hVKxTR4NWnu+g==", + "license": "MIT", + "dependencies": { + "accepts": "~1.3.8", + "array-flatten": "1.1.1", + "body-parser": "~1.20.3", + "content-disposition": "~0.5.4", + "content-type": "~1.0.4", + "cookie": "~0.7.1", + "cookie-signature": "~1.0.6", + "debug": "2.6.9", + "depd": "2.0.0", + "encodeurl": "~2.0.0", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "finalhandler": "~1.3.1", + "fresh": "~0.5.2", + "http-errors": "~2.0.0", + "merge-descriptors": "1.0.3", + "methods": "~1.1.2", + "on-finished": "~2.4.1", + "parseurl": "~1.3.3", + "path-to-regexp": "~0.1.12", + "proxy-addr": "~2.0.7", + "qs": "~6.14.0", + "range-parser": "~1.2.1", + "safe-buffer": "5.2.1", + "send": "~0.19.0", + "serve-static": "~1.16.2", + "setprototypeof": "1.2.0", + "statuses": "~2.0.1", + "type-is": "~1.6.18", + "utils-merge": "1.0.1", + "vary": "~1.1.2" + }, + "engines": { + "node": ">= 0.10.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/express-validator": { + "version": "7.3.2", + "resolved": "https://registry.npmjs.org/express-validator/-/express-validator-7.3.2.tgz", + "integrity": "sha512-ctLw1Vl6dXVH62dIQMDdTAQkrh480mkFuG6/SGXOaVlwPNukhRAe7EgJIMJ2TSAni8iwHBRp530zAZE5ZPF2IA==", + "license": "MIT", + "dependencies": { + "lodash": "^4.18.1", + "validator": "~13.15.23" + }, + "engines": { + "node": ">= 8.0.0" + } + }, + "node_modules/fill-range": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", + "dev": true, + "license": "MIT", + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/finalhandler": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.3.2.tgz", + "integrity": "sha512-aA4RyPcd3badbdABGDuTXCMTtOneUCAYH/gxoYRTZlIJdF0YPWuGqiAsIrhNnnqdXGswYk6dGujem4w80UJFhg==", + "license": "MIT", + "dependencies": { + "debug": "2.6.9", + "encodeurl": "~2.0.0", + "escape-html": "~1.0.3", + "on-finished": "~2.4.1", + "parseurl": "~1.3.3", + "statuses": "~2.0.2", + "unpipe": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/forwarded": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", + "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/fresh": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", + "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/generate-function": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/generate-function/-/generate-function-2.3.1.tgz", + "integrity": "sha512-eeB5GfMNeevm/GRYq20ShmsaGcmI81kIX2K9XQx5miC8KdHaC6Jm0qQ8ZNeGOi7wYB8OsdxKs+Y2oVuTFuVwKQ==", + "license": "MIT", + "dependencies": { + "is-property": "^1.0.2" + } + }, + "node_modules/get-intrinsic": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz", + "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "es-define-property": "^1.0.1", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.1.1", + "function-bind": "^1.1.2", + "get-proto": "^1.0.1", + "gopd": "^1.2.0", + "has-symbols": "^1.1.0", + "hasown": "^2.0.2", + "math-intrinsics": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz", + "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==", + "license": "MIT", + "dependencies": { + "dunder-proto": "^1.0.1", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, + "license": "ISC", + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/gopd": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", + "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/has-symbols": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", + "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/hasown": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.3.tgz", + "integrity": "sha512-ej4AhfhfL2Q2zpMmLo7U1Uv9+PyhIZpgQLGT1F9miIGmiCJIoCgSmczFdrc97mWT4kVY72KA+WnnhJ5pghSvSg==", + "license": "MIT", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/http-errors": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.1.tgz", + "integrity": "sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ==", + "license": "MIT", + "dependencies": { + "depd": "~2.0.0", + "inherits": "~2.0.4", + "setprototypeof": "~1.2.0", + "statuses": "~2.0.2", + "toidentifier": "~1.0.1" + }, + "engines": { + "node": ">= 0.8" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "license": "MIT", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/ignore-by-default": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/ignore-by-default/-/ignore-by-default-1.0.1.tgz", + "integrity": "sha512-Ius2VYcGNk7T90CppJqcIkS5ooHUZyIQK+ClZfMfMNFEF9VSE73Fq+906u/CWu92x4gzZMWOwfFYckPObzdEbA==", + "dev": true, + "license": "ISC" + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "license": "ISC" + }, + "node_modules/ipaddr.js": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", + "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==", + "license": "MIT", + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "dev": true, + "license": "MIT", + "dependencies": { + "binary-extensions": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/is-property": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-property/-/is-property-1.0.2.tgz", + "integrity": "sha512-Ks/IoX00TtClbGQr4TWXemAnktAQvYB7HzcCxDGqEZU6oCmb2INHuOoKxbtR+HFkmYWBKv/dOZtGRiAjDhj92g==", + "license": "MIT" + }, + "node_modules/isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==", + "license": "MIT" + }, + "node_modules/jsonwebtoken": { + "version": "9.0.3", + "resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-9.0.3.tgz", + "integrity": "sha512-MT/xP0CrubFRNLNKvxJ2BYfy53Zkm++5bX9dtuPbqAeQpTVe0MQTFhao8+Cp//EmJp244xt6Drw/GVEGCUj40g==", + "license": "MIT", + "dependencies": { + "jws": "^4.0.1", + "lodash.includes": "^4.3.0", + "lodash.isboolean": "^3.0.3", + "lodash.isinteger": "^4.0.4", + "lodash.isnumber": "^3.0.3", + "lodash.isplainobject": "^4.0.6", + "lodash.isstring": "^4.0.1", + "lodash.once": "^4.0.0", + "ms": "^2.1.1", + "semver": "^7.5.4" + }, + "engines": { + "node": ">=12", + "npm": ">=6" + } + }, + "node_modules/jsonwebtoken/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "license": "MIT" + }, + "node_modules/jwa": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/jwa/-/jwa-2.0.1.tgz", + "integrity": "sha512-hRF04fqJIP8Abbkq5NKGN0Bbr3JxlQ+qhZufXVr0DvujKy93ZCbXZMHDL4EOtodSbCWxOqR8MS1tXA5hwqCXDg==", + "license": "MIT", + "dependencies": { + "buffer-equal-constant-time": "^1.0.1", + "ecdsa-sig-formatter": "1.0.11", + "safe-buffer": "^5.0.1" + } + }, + "node_modules/jws": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/jws/-/jws-4.0.1.tgz", + "integrity": "sha512-EKI/M/yqPncGUUh44xz0PxSidXFr/+r0pA70+gIYhjv+et7yxM+s29Y+VGDkovRofQem0fs7Uvf4+YmAdyRduA==", + "license": "MIT", + "dependencies": { + "jwa": "^2.0.1", + "safe-buffer": "^5.0.1" + } + }, + "node_modules/lodash": { + "version": "4.18.1", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.18.1.tgz", + "integrity": "sha512-dMInicTPVE8d1e5otfwmmjlxkZoUpiVLwyeTdUsi/Caj/gfzzblBcCE5sRHV/AsjuCmxWrte2TNGSYuCeCq+0Q==", + "license": "MIT" + }, + "node_modules/lodash.includes": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/lodash.includes/-/lodash.includes-4.3.0.tgz", + "integrity": "sha512-W3Bx6mdkRTGtlJISOvVD/lbqjTlPPUDTMnlXZFnVwi9NKJ6tiAk6LVdlhZMm17VZisqhKcgzpO5Wz91PCt5b0w==", + "license": "MIT" + }, + "node_modules/lodash.isboolean": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/lodash.isboolean/-/lodash.isboolean-3.0.3.tgz", + "integrity": "sha512-Bz5mupy2SVbPHURB98VAcw+aHh4vRV5IPNhILUCsOzRmsTmSQ17jIuqopAentWoehktxGd9e/hbIXq980/1QJg==", + "license": "MIT" + }, + "node_modules/lodash.isinteger": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/lodash.isinteger/-/lodash.isinteger-4.0.4.tgz", + "integrity": "sha512-DBwtEWN2caHQ9/imiNeEA5ys1JoRtRfY3d7V9wkqtbycnAmTvRRmbHKDV4a0EYc678/dia0jrte4tjYwVBaZUA==", + "license": "MIT" + }, + "node_modules/lodash.isnumber": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/lodash.isnumber/-/lodash.isnumber-3.0.3.tgz", + "integrity": "sha512-QYqzpfwO3/CWf3XP+Z+tkQsfaLL/EnUlXWVkIk5FUPc4sBdTehEqZONuyRt2P67PXAk+NXmTBcc97zw9t1FQrw==", + "license": "MIT" + }, + "node_modules/lodash.isplainobject": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz", + "integrity": "sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA==", + "license": "MIT" + }, + "node_modules/lodash.isstring": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/lodash.isstring/-/lodash.isstring-4.0.1.tgz", + "integrity": "sha512-0wJxfxH1wgO3GrbuP+dTTk7op+6L41QCXbGINEmD+ny/G/eCqGzxyCsh7159S+mgDDcoarnBw6PC1PS5+wUGgw==", + "license": "MIT" + }, + "node_modules/lodash.once": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz", + "integrity": "sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg==", + "license": "MIT" + }, + "node_modules/long": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/long/-/long-5.3.2.tgz", + "integrity": "sha512-mNAgZ1GmyNhD7AuqnTG3/VQ26o760+ZYBPKjPvugO8+nLbYfX6TVpJPseBvopbdY+qpZ/lKUnmEc1LeZYS3QAA==", + "license": "Apache-2.0" + }, + "node_modules/lru.min": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/lru.min/-/lru.min-1.1.4.tgz", + "integrity": "sha512-DqC6n3QQ77zdFpCMASA1a3Jlb64Hv2N2DciFGkO/4L9+q/IpIAuRlKOvCXabtRW6cQf8usbmM6BE/TOPysCdIA==", + "license": "MIT", + "engines": { + "bun": ">=1.0.0", + "deno": ">=1.30.0", + "node": ">=8.0.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wellwelwel" + } + }, + "node_modules/math-intrinsics": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", + "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/media-typer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/merge-descriptors": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.3.tgz", + "integrity": "sha512-gaNvAS7TZ897/rVaZ0nMtAyxNyi/pdbjbAwUpFQpN70GqnVfOiXpeUUMKRBmzXaSQ8DdTX4/0ms62r2K+hE6mQ==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/methods": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", + "integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", + "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", + "license": "MIT", + "bin": { + "mime": "cli.js" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "license": "MIT", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/minimatch": { + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.5.tgz", + "integrity": "sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/minimist": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", + "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/mkdirp": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", + "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", + "license": "MIT", + "dependencies": { + "minimist": "^1.2.6" + }, + "bin": { + "mkdirp": "bin/cmd.js" + } + }, + "node_modules/ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", + "license": "MIT" + }, + "node_modules/multer": { + "version": "1.4.5-lts.2", + "resolved": "https://registry.npmjs.org/multer/-/multer-1.4.5-lts.2.tgz", + "integrity": "sha512-VzGiVigcG9zUAoCNU+xShztrlr1auZOlurXynNvO9GiWD1/mTBbUljOKY+qMeazBqXgRnjzeEgJI/wyjJUHg9A==", + "deprecated": "Multer 1.x is impacted by a number of vulnerabilities, which have been patched in 2.x. You should upgrade to the latest 2.x version.", + "license": "MIT", + "dependencies": { + "append-field": "^1.0.0", + "busboy": "^1.0.0", + "concat-stream": "^1.5.2", + "mkdirp": "^0.5.4", + "object-assign": "^4.1.1", + "type-is": "^1.6.4", + "xtend": "^4.0.0" + }, + "engines": { + "node": ">= 6.0.0" + } + }, + "node_modules/mysql2": { + "version": "3.22.3", + "resolved": "https://registry.npmjs.org/mysql2/-/mysql2-3.22.3.tgz", + "integrity": "sha512-uWWxvZSRvRhtBdh2CdcuK83YcOfPdmEeEYB069bAmPnV93QApDGVPuvCQOLjlh7tYHEWdgQPrn6kosDxHBVLkA==", + "license": "MIT", + "dependencies": { + "aws-ssl-profiles": "^1.1.2", + "denque": "^2.1.0", + "generate-function": "^2.3.1", + "iconv-lite": "^0.7.2", + "long": "^5.3.2", + "lru.min": "^1.1.4", + "named-placeholders": "^1.1.6", + "sql-escaper": "^1.3.3" + }, + "engines": { + "node": ">= 8.0" + }, + "peerDependencies": { + "@types/node": ">= 8" + } + }, + "node_modules/mysql2/node_modules/iconv-lite": { + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.2.tgz", + "integrity": "sha512-im9DjEDQ55s9fL4EYzOAv0yMqmMBSZp6G0VvFyTMPKWxiSBHUj9NW/qqLmXUwXrrM7AvqSlTCfvqRb0cM8yYqw==", + "license": "MIT", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + }, + "engines": { + "node": ">=0.10.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/named-placeholders": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/named-placeholders/-/named-placeholders-1.1.6.tgz", + "integrity": "sha512-Tz09sEL2EEuv5fFowm419c1+a/jSMiBjI9gHxVLrVdbUkkNUUfjsVYs9pVZu5oCon/kmRh9TfLEObFtkVxmY0w==", + "license": "MIT", + "dependencies": { + "lru.min": "^1.1.0" + }, + "engines": { + "node": ">=8.0.0" + } + }, + "node_modules/negotiator": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", + "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/nodemon": { + "version": "2.0.22", + "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-2.0.22.tgz", + "integrity": "sha512-B8YqaKMmyuCO7BowF1Z1/mkPqLk6cs/l63Ojtd6otKjMx47Dq1utxfRxcavH1I7VSaL8n5BUaoutadnsX3AAVQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "chokidar": "^3.5.2", + "debug": "^3.2.7", + "ignore-by-default": "^1.0.1", + "minimatch": "^3.1.2", + "pstree.remy": "^1.1.8", + "semver": "^5.7.1", + "simple-update-notifier": "^1.0.7", + "supports-color": "^5.5.0", + "touch": "^3.1.0", + "undefsafe": "^2.0.5" + }, + "bin": { + "nodemon": "bin/nodemon.js" + }, + "engines": { + "node": ">=8.10.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/nodemon" + } + }, + "node_modules/nodemon/node_modules/debug": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "ms": "^2.1.1" + } + }, + "node_modules/nodemon/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true, + "license": "MIT" + }, + "node_modules/nodemon/node_modules/semver": { + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz", + "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver" + } + }, + "node_modules/normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/object-inspect": { + "version": "1.13.4", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz", + "integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/on-finished": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", + "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", + "license": "MIT", + "dependencies": { + "ee-first": "1.1.1" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/parseurl": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/path-to-regexp": { + "version": "0.1.13", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.13.tgz", + "integrity": "sha512-A/AGNMFN3c8bOlvV9RreMdrv7jsmF9XIfDeCd87+I8RNg6s78BhJxMu69NEMHBSJFxKidViTEdruRwEk/WIKqA==", + "license": "MIT" + }, + "node_modules/picomatch": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.2.tgz", + "integrity": "sha512-V7+vQEJ06Z+c5tSye8S+nHUfI51xoXIXjHQ99cQtKUkQqqO1kO/KCJUfZXuB47h/YBlDhah2H3hdUGXn8ie0oA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/process-nextick-args": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", + "license": "MIT" + }, + "node_modules/proxy-addr": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", + "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==", + "license": "MIT", + "dependencies": { + "forwarded": "0.2.0", + "ipaddr.js": "1.9.1" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/pstree.remy": { + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/pstree.remy/-/pstree.remy-1.1.8.tgz", + "integrity": "sha512-77DZwxQmxKnu3aR542U+X8FypNzbfJ+C5XQDk3uWjWxn6151aIMGthWYRXTqT1E5oJvg+ljaa2OJi+VfvCOQ8w==", + "dev": true, + "license": "MIT" + }, + "node_modules/qs": { + "version": "6.14.2", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.14.2.tgz", + "integrity": "sha512-V/yCWTTF7VJ9hIh18Ugr2zhJMP01MY7c5kh4J870L7imm6/DIzBsNLTXzMwUA3yZ5b/KBqLx8Kp3uRvd7xSe3Q==", + "license": "BSD-3-Clause", + "dependencies": { + "side-channel": "^1.1.0" + }, + "engines": { + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/range-parser": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", + "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/raw-body": { + "version": "2.5.3", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.3.tgz", + "integrity": "sha512-s4VSOf6yN0rvbRZGxs8Om5CWj6seneMwK3oDb4lWDH0UPhWcxwOWw5+qk24bxq87szX1ydrwylIOp2uG1ojUpA==", + "license": "MIT", + "dependencies": { + "bytes": "~3.1.2", + "http-errors": "~2.0.1", + "iconv-lite": "~0.4.24", + "unpipe": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/readable-stream": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz", + "integrity": "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==", + "license": "MIT", + "dependencies": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "node_modules/readable-stream/node_modules/safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "license": "MIT" + }, + "node_modules/readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "dev": true, + "license": "MIT", + "dependencies": { + "picomatch": "^2.2.1" + }, + "engines": { + "node": ">=8.10.0" + } + }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "license": "MIT" + }, + "node_modules/semver": { + "version": "7.7.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.4.tgz", + "integrity": "sha512-vFKC2IEtQnVhpT78h1Yp8wzwrf8CM+MzKMHGJZfBtzhZNycRFnXsHk6E5TxIkkMsgNS7mdX3AGB7x2QM2di4lA==", + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/send": { + "version": "0.19.2", + "resolved": "https://registry.npmjs.org/send/-/send-0.19.2.tgz", + "integrity": "sha512-VMbMxbDeehAxpOtWJXlcUS5E8iXh6QmN+BkRX1GARS3wRaXEEgzCcB10gTQazO42tpNIya8xIyNx8fll1OFPrg==", + "license": "MIT", + "dependencies": { + "debug": "2.6.9", + "depd": "2.0.0", + "destroy": "1.2.0", + "encodeurl": "~2.0.0", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "fresh": "~0.5.2", + "http-errors": "~2.0.1", + "mime": "1.6.0", + "ms": "2.1.3", + "on-finished": "~2.4.1", + "range-parser": "~1.2.1", + "statuses": "~2.0.2" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/send/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "license": "MIT" + }, + "node_modules/serve-static": { + "version": "1.16.3", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.16.3.tgz", + "integrity": "sha512-x0RTqQel6g5SY7Lg6ZreMmsOzncHFU7nhnRWkKgWuMTu5NN0DR5oruckMqRvacAN9d5w6ARnRBXl9xhDCgfMeA==", + "license": "MIT", + "dependencies": { + "encodeurl": "~2.0.0", + "escape-html": "~1.0.3", + "parseurl": "~1.3.3", + "send": "~0.19.1" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/setprototypeof": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", + "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==", + "license": "ISC" + }, + "node_modules/side-channel": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.0.tgz", + "integrity": "sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.3", + "side-channel-list": "^1.0.0", + "side-channel-map": "^1.0.1", + "side-channel-weakmap": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-list": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.1.tgz", + "integrity": "sha512-mjn/0bi/oUURjc5Xl7IaWi/OJJJumuoJFQJfDDyO46+hBWsfaVM65TBHq2eoZBhzl9EchxOijpkbRC8SVBQU0w==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.4" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-map": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz", + "integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-weakmap": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz", + "integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3", + "side-channel-map": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/simple-update-notifier": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/simple-update-notifier/-/simple-update-notifier-1.1.0.tgz", + "integrity": "sha512-VpsrsJSUcJEseSbMHkrsrAVSdvVS5I96Qo1QAQ4FxQ9wXFcB+pjj7FB7/us9+GcgfW4ziHtYMc1J0PLczb55mg==", + "dev": true, + "license": "MIT", + "dependencies": { + "semver": "~7.0.0" + }, + "engines": { + "node": ">=8.10.0" + } + }, + "node_modules/simple-update-notifier/node_modules/semver": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.0.0.tgz", + "integrity": "sha512-+GB6zVA9LWh6zovYQLALHwv5rb2PHGlJi3lfiqIHxR0uuwCgefcOJc59v9fv1w8GbStwxuuqqAjI9NMAOOgq1A==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/sql-escaper": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/sql-escaper/-/sql-escaper-1.3.3.tgz", + "integrity": "sha512-BsTCV265VpTp8tm1wyIm1xqQCS+Q9NHx2Sr+WcnUrgLrQ6yiDIvHYJV5gHxsj1lMBy2zm5twLaZao8Jd+S8JJw==", + "license": "MIT", + "engines": { + "bun": ">=1.0.0", + "deno": ">=2.0.0", + "node": ">=12.0.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/mysqljs/sql-escaper?sponsor=1" + } + }, + "node_modules/statuses": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz", + "integrity": "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/streamsearch": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-1.1.0.tgz", + "integrity": "sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg==", + "engines": { + "node": ">=10.0.0" + } + }, + "node_modules/string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "license": "MIT", + "dependencies": { + "safe-buffer": "~5.1.0" + } + }, + "node_modules/string_decoder/node_modules/safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "license": "MIT" + }, + "node_modules/supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-flag": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" + } + }, + "node_modules/toidentifier": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", + "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", + "license": "MIT", + "engines": { + "node": ">=0.6" + } + }, + "node_modules/touch": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/touch/-/touch-3.1.1.tgz", + "integrity": "sha512-r0eojU4bI8MnHr8c5bNo7lJDdI2qXlWWJk6a9EAFG7vbhTjElYhBVS3/miuE0uOuoLdb8Mc/rVfsmm6eo5o9GA==", + "dev": true, + "license": "ISC", + "bin": { + "nodetouch": "bin/nodetouch.js" + } + }, + "node_modules/type-is": { + "version": "1.6.18", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", + "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", + "license": "MIT", + "dependencies": { + "media-typer": "0.3.0", + "mime-types": "~2.1.24" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/typedarray": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", + "integrity": "sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==", + "license": "MIT" + }, + "node_modules/undefsafe": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/undefsafe/-/undefsafe-2.0.5.tgz", + "integrity": "sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA==", + "dev": true, + "license": "MIT" + }, + "node_modules/undici-types": { + "version": "7.19.2", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.19.2.tgz", + "integrity": "sha512-qYVnV5OEm2AW8cJMCpdV20CDyaN3g0AjDlOGf1OW4iaDEx8MwdtChUp4zu4H0VP3nDRF/8RKWH+IPp9uW0YGZg==", + "license": "MIT", + "peer": true + }, + "node_modules/unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", + "license": "MIT" + }, + "node_modules/utils-merge": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", + "integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==", + "license": "MIT", + "engines": { + "node": ">= 0.4.0" + } + }, + "node_modules/uuid": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz", + "integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==", + "funding": [ + "https://github.com/sponsors/broofa", + "https://github.com/sponsors/ctavan" + ], + "license": "MIT", + "bin": { + "uuid": "dist/bin/uuid" + } + }, + "node_modules/validator": { + "version": "13.15.35", + "resolved": "https://registry.npmjs.org/validator/-/validator-13.15.35.tgz", + "integrity": "sha512-TQ5pAGhd5whStmqWvYF4OjQROlmv9SMFVt37qoCBdqRffuuklWYQlCNnEs2ZaIBD1kZRNnikiZOS1eqgkar0iw==", + "license": "MIT", + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/xtend": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", + "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==", + "license": "MIT", + "engines": { + "node": ">=0.4" + } + } + } +} diff --git a/backend/package.json b/backend/package.json new file mode 100644 index 0000000..ea5d823 --- /dev/null +++ b/backend/package.json @@ -0,0 +1,34 @@ +{ + "name": "merchant-platform-backend", + "version": "1.0.0", + "description": "本地小众商户引流平台 - 后端", + "main": "app.js", + "scripts": { + "start": "node app.js", + "dev": "nodemon app.js", + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [ + "merchant", + "platform", + "backend", + "express", + "mysql" + ], + "author": "", + "license": "ISC", + "dependencies": { + "bcryptjs": "^2.4.3", + "cors": "^2.8.5", + "dotenv": "^16.0.3", + "express": "^4.18.2", + "express-validator": "^7.0.1", + "jsonwebtoken": "^9.0.0", + "multer": "^1.4.5-lts.1", + "mysql2": "^3.2.0", + "uuid": "^9.0.0" + }, + "devDependencies": { + "nodemon": "^2.0.22" + } +} diff --git a/backend/routes/admin.js b/backend/routes/admin.js new file mode 100644 index 0000000..acf0d61 --- /dev/null +++ b/backend/routes/admin.js @@ -0,0 +1,31 @@ +const express = require('express'); +const adminController = require('../controllers/adminController'); +const { authMiddleware, roleMiddleware } = require('../middleware/auth'); + +const router = express.Router(); + +// 获取统计数据 +router.get('/dashboard', authMiddleware, roleMiddleware('admin'), adminController.getDashboard); + +// 获取用户列表 +router.get('/users', authMiddleware, roleMiddleware('admin'), adminController.getUsers); + +// 更新用户状态 +router.put('/users/:id/status', authMiddleware, roleMiddleware('admin'), adminController.updateUserStatus); + +// 获取店铺列表 +router.get('/shops', authMiddleware, roleMiddleware('admin'), adminController.getShops); + +// 更新店铺状态 +router.put('/shops/:id/status', authMiddleware, roleMiddleware('admin'), adminController.updateShopStatus); + +// 获取优惠券列表 +router.get('/coupons', authMiddleware, roleMiddleware('admin'), adminController.getCoupons); + +// 获取评价列表 +router.get('/reviews', authMiddleware, roleMiddleware('admin'), adminController.getReviews); + +// 删除评价 +router.delete('/reviews/:id', authMiddleware, roleMiddleware('admin'), adminController.deleteReview); + +module.exports = router; diff --git a/backend/routes/auth.js b/backend/routes/auth.js new file mode 100644 index 0000000..507febd --- /dev/null +++ b/backend/routes/auth.js @@ -0,0 +1,73 @@ +const express = require('express'); +const { check, validationResult } = require('express-validator'); +const authController = require('../controllers/authController'); +const { authMiddleware } = require('../middleware/auth'); + +const router = express.Router(); + +// 用户注册 +router.post('/register', [ + check('username', '用户名不能为空').not().isEmpty(), + check('username', '用户名长度必须在3-50个字符之间').isLength({ min: 3, max: 50 }), + check('email', '邮箱格式不正确').isEmail(), + check('password', '密码不能为空').not().isEmpty(), + check('password', '密码长度必须在6-100个字符之间').isLength({ min: 6, max: 100 }) +], (req, res, next) => { + const errors = validationResult(req); + if (!errors.isEmpty()) { + const firstError = errors.array()[0]; + return res.status(400).json({ + success: false, + message: firstError.msg, + errors: errors.array() + }); + } + next(); +}, authController.register); + +// 用户登录 +router.post('/login', [ + check('email', '邮箱格式不正确').isEmail(), + check('password', '密码不能为空').not().isEmpty() +], (req, res, next) => { + const errors = validationResult(req); + if (!errors.isEmpty()) { + const firstError = errors.array()[0]; + return res.status(400).json({ + success: false, + message: firstError.msg, + errors: errors.array() + }); + } + next(); +}, authController.login); + +// 获取当前用户信息 +router.get('/me', authMiddleware, authController.getCurrentUser); + +// 更新用户信息 +router.put('/profile', authMiddleware, [ + check('username', '用户名长度必须在3-50个字符之间').optional().isLength({ min: 3, max: 50 }), + check('phone', '手机号格式不正确').optional().matches(/^1[3-9]\d{9}$/) +], (req, res, next) => { + const errors = validationResult(req); + if (!errors.isEmpty()) { + return res.status(400).json({ success: false, errors: errors.array() }); + } + next(); +}, authController.updateProfile); + +// 修改密码 +router.put('/password', authMiddleware, [ + check('oldPassword', '旧密码不能为空').not().isEmpty(), + check('newPassword', '新密码不能为空').not().isEmpty(), + check('newPassword', '新密码长度必须在6-100个字符之间').isLength({ min: 6, max: 100 }) +], (req, res, next) => { + const errors = validationResult(req); + if (!errors.isEmpty()) { + return res.status(400).json({ success: false, errors: errors.array() }); + } + next(); +}, authController.changePassword); + +module.exports = router; diff --git a/backend/routes/coupon.js b/backend/routes/coupon.js new file mode 100644 index 0000000..395648b --- /dev/null +++ b/backend/routes/coupon.js @@ -0,0 +1,73 @@ +const express = require('express'); +const { check, validationResult } = require('express-validator'); +const couponController = require('../controllers/couponController'); +const { authMiddleware, merchantMiddleware } = require('../middleware/auth'); + +const router = express.Router(); + +// 获取所有可用优惠券(公开接口) +router.get('/available', couponController.getAvailableCoupons); + +// 获取单个优惠券详情(公开接口) +router.get('/:id', couponController.getCouponById); + +// 领取优惠券(用户) +router.post('/:id/claim', authMiddleware, couponController.claimCoupon); + +// 获取当前用户的优惠券列表 +router.get('/my/list', authMiddleware, couponController.getMyCoupons); + +// 使用/核销优惠券(用户) +router.post('/my/:id/use', authMiddleware, couponController.useCoupon); + +// 商户核销优惠券 +router.post('/verify', authMiddleware, merchantMiddleware, [ + check('couponCode', '优惠券码不能为空').not().isEmpty() +], (req, res, next) => { + const errors = validationResult(req); + if (!errors.isEmpty()) { + return res.status(400).json({ success: false, errors: errors.array() }); + } + next(); +}, couponController.verifyCoupon); + +// 商户发布优惠券 +router.post('/', authMiddleware, merchantMiddleware, [ + check('couponName', '优惠券名称不能为空').not().isEmpty(), + check('couponType', '优惠券类型不能为空').not().isEmpty(), + check('couponType', '优惠券类型只能是 fixed, percentage, free').isIn(['fixed', 'percentage', 'free']), + check('discountValue', '折扣金额不能为空').not().isEmpty(), + check('discountValue', '折扣金额必须是正数').isFloat({ min: 0 }), + check('totalQuantity', '总数量不能为空').not().isEmpty(), + check('totalQuantity', '总数量必须是正整数').isInt({ min: 1 }), + check('startDate', '开始日期不能为空').not().isEmpty(), + check('endDate', '结束日期不能为空').not().isEmpty() +], (req, res, next) => { + const errors = validationResult(req); + if (!errors.isEmpty()) { + return res.status(400).json({ success: false, errors: errors.array() }); + } + next(); +}, couponController.createCoupon); + +// 商户获取自己的优惠券列表 +router.get('/my/merchant', authMiddleware, merchantMiddleware, couponController.getMerchantCoupons); + +// 商户更新优惠券 +router.put('/:id', authMiddleware, merchantMiddleware, [ + check('couponName', '优惠券名称不能为空').optional().not().isEmpty(), + check('couponType', '优惠券类型只能是 fixed, percentage, free').optional().isIn(['fixed', 'percentage', 'free']), + check('discountValue', '折扣金额必须是正数').optional().isFloat({ min: 0 }), + check('totalQuantity', '总数量必须是正整数').optional().isInt({ min: 1 }) +], (req, res, next) => { + const errors = validationResult(req); + if (!errors.isEmpty()) { + return res.status(400).json({ success: false, errors: errors.array() }); + } + next(); +}, couponController.updateCoupon); + +// 商户删除优惠券 +router.delete('/:id', authMiddleware, merchantMiddleware, couponController.deleteCoupon); + +module.exports = router; diff --git a/backend/routes/favorite.js b/backend/routes/favorite.js new file mode 100644 index 0000000..9fc5c39 --- /dev/null +++ b/backend/routes/favorite.js @@ -0,0 +1,19 @@ +const express = require('express'); +const favoriteController = require('../controllers/favoriteController'); +const { authMiddleware } = require('../middleware/auth'); + +const router = express.Router(); + +// 添加收藏 +router.post('/', authMiddleware, favoriteController.addFavorite); + +// 移除收藏 +router.delete('/:shopId', authMiddleware, favoriteController.removeFavorite); + +// 获取用户的收藏列表 +router.get('/my/list', authMiddleware, favoriteController.getMyFavorites); + +// 检查是否已收藏 +router.get('/check/:shopId', authMiddleware, favoriteController.checkFavorite); + +module.exports = router; diff --git a/backend/routes/history.js b/backend/routes/history.js new file mode 100644 index 0000000..010d343 --- /dev/null +++ b/backend/routes/history.js @@ -0,0 +1,13 @@ +const express = require('express'); +const historyController = require('../controllers/historyController'); +const { authMiddleware } = require('../middleware/auth'); + +const router = express.Router(); + +// 获取用户的浏览记录 +router.get('/my/list', authMiddleware, historyController.getMyHistory); + +// 清空浏览记录 +router.delete('/clear', authMiddleware, historyController.clearHistory); + +module.exports = router; diff --git a/backend/routes/merchant.js b/backend/routes/merchant.js new file mode 100644 index 0000000..3e1b1fc --- /dev/null +++ b/backend/routes/merchant.js @@ -0,0 +1,44 @@ +const express = require('express'); +const { check, validationResult } = require('express-validator'); +const merchantController = require('../controllers/merchantController'); +const { authMiddleware, roleMiddleware } = require('../middleware/auth'); + +const router = express.Router(); + +// 提交商户资质申请 +router.post('/apply', authMiddleware, [ + check('businessName', '企业名称不能为空').not().isEmpty(), + check('businessLicense', '营业执照编号不能为空').not().isEmpty(), + check('legalPerson', '法人姓名不能为空').not().isEmpty(), + check('idCard', '身份证号不能为空').not().isEmpty(), + check('idCardFront', '身份证正面照片不能为空').not().isEmpty(), + check('idCardBack', '身份证背面照片不能为空').not().isEmpty(), + check('contactPhone', '联系电话不能为空').not().isEmpty(), + check('businessType', '经营类型不能为空').not().isEmpty() +], (req, res, next) => { + const errors = validationResult(req); + if (!errors.isEmpty()) { + return res.status(400).json({ success: false, errors: errors.array() }); + } + next(); +}, merchantController.submitApplication); + +// 获取当前用户的商户申请状态 +router.get('/application', authMiddleware, merchantController.getApplicationStatus); + +// 获取所有商户申请(管理员) +router.get('/applications', authMiddleware, roleMiddleware('admin'), merchantController.getAllApplications); + +// 审核商户申请(管理员) +router.put('/applications/:id/review', authMiddleware, roleMiddleware('admin'), [ + check('status', '审核状态不能为空').not().isEmpty(), + check('status', '审核状态只能是 approved 或 rejected').isIn(['approved', 'rejected']) +], (req, res, next) => { + const errors = validationResult(req); + if (!errors.isEmpty()) { + return res.status(400).json({ success: false, errors: errors.array() }); + } + next(); +}, merchantController.reviewApplication); + +module.exports = router; diff --git a/backend/routes/reservation.js b/backend/routes/reservation.js new file mode 100644 index 0000000..215ca32 --- /dev/null +++ b/backend/routes/reservation.js @@ -0,0 +1,41 @@ +const express = require('express'); +const { check, validationResult } = require('express-validator'); +const reservationController = require('../controllers/reservationController'); +const { authMiddleware, merchantMiddleware } = require('../middleware/auth'); + +const router = express.Router(); + +// 用户创建预约 +router.post('/', authMiddleware, [ + check('shopId', '店铺ID不能为空').not().isEmpty(), + check('reservationDate', '预约日期不能为空').not().isEmpty(), + check('reservationTime', '预约时间不能为空').not().isEmpty(), + check('contactName', '联系人姓名不能为空').not().isEmpty(), + check('contactPhone', '联系电话不能为空').not().isEmpty() +], (req, res, next) => { + const errors = validationResult(req); + if (!errors.isEmpty()) { + return res.status(400).json({ success: false, errors: errors.array() }); + } + next(); +}, reservationController.createReservation); + +// 用户获取自己的预约列表 +router.get('/my/list', authMiddleware, reservationController.getMyReservations); + +// 用户获取单个预约详情 +router.get('/:id', authMiddleware, reservationController.getReservationById); + +// 用户取消预约 +router.put('/:id/cancel', authMiddleware, reservationController.cancelReservation); + +// 商户获取自己店铺的预约列表 +router.get('/shop/list', authMiddleware, merchantMiddleware, reservationController.getShopReservations); + +// 商户确认预约 +router.put('/:id/confirm', authMiddleware, merchantMiddleware, reservationController.confirmReservation); + +// 商户完成预约 +router.put('/:id/complete', authMiddleware, merchantMiddleware, reservationController.completeReservation); + +module.exports = router; diff --git a/backend/routes/review.js b/backend/routes/review.js new file mode 100644 index 0000000..900e81b --- /dev/null +++ b/backend/routes/review.js @@ -0,0 +1,52 @@ +const express = require('express'); +const { check, validationResult } = require('express-validator'); +const reviewController = require('../controllers/reviewController'); +const { authMiddleware, merchantMiddleware } = require('../middleware/auth'); + +const router = express.Router(); + +// 用户发布评价 +router.post('/', authMiddleware, [ + check('shopId', '店铺ID不能为空').not().isEmpty(), + check('rating', '评分不能为空').not().isEmpty(), + check('rating', '评分必须在1-5之间').isInt({ min: 1, max: 5 }) +], (req, res, next) => { + const errors = validationResult(req); + if (!errors.isEmpty()) { + return res.status(400).json({ success: false, errors: errors.array() }); + } + next(); +}, reviewController.createReview); + +// 用户获取自己的评价列表 +router.get('/my/list', authMiddleware, reviewController.getMyReviews); + +// 用户获取单个评价详情 +router.get('/:id', authMiddleware, reviewController.getReviewById); + +// 用户更新评价 +router.put('/:id', authMiddleware, [ + check('rating', '评分必须在1-5之间').optional().isInt({ min: 1, max: 5 }) +], (req, res, next) => { + const errors = validationResult(req); + if (!errors.isEmpty()) { + return res.status(400).json({ success: false, errors: errors.array() }); + } + next(); +}, reviewController.updateReview); + +// 商户回复评价 +router.put('/:id/reply', authMiddleware, merchantMiddleware, [ + check('reply', '回复内容不能为空').not().isEmpty() +], (req, res, next) => { + const errors = validationResult(req); + if (!errors.isEmpty()) { + return res.status(400).json({ success: false, errors: errors.array() }); + } + next(); +}, reviewController.replyReview); + +// 商户获取自己店铺的评价列表 +router.get('/shop/list', authMiddleware, merchantMiddleware, reviewController.getShopReviews); + +module.exports = router; diff --git a/backend/routes/shop.js b/backend/routes/shop.js new file mode 100644 index 0000000..006048a --- /dev/null +++ b/backend/routes/shop.js @@ -0,0 +1,52 @@ +const express = require('express'); +const { check, validationResult } = require('express-validator'); +const shopController = require('../controllers/shopController'); +const { authMiddleware, merchantMiddleware } = require('../middleware/auth'); + +const router = express.Router(); + +// 获取所有店铺(公开接口) +router.get('/', shopController.getAllShops); + +// 获取单个店铺详情(公开接口) +router.get('/:id', shopController.getShopById); + +// 搜索店铺(公开接口) +router.get('/search', shopController.searchShops); + +// 创建店铺(商户) +router.post('/', authMiddleware, [ + check('shopName', '店铺名称不能为空').not().isEmpty(), + check('shopType', '店铺类型不能为空').not().isEmpty(), + check('address', '店铺地址不能为空').not().isEmpty() +], (req, res, next) => { + const errors = validationResult(req); + if (!errors.isEmpty()) { + return res.status(400).json({ success: false, errors: errors.array() }); + } + next(); +}, shopController.createShop); + +// 获取当前商户的店铺信息 +router.get('/my/shop', authMiddleware, merchantMiddleware, shopController.getMyShop); + +// 更新店铺信息(商户) +router.put('/my/shop', authMiddleware, merchantMiddleware, [ + check('shopName', '店铺名称不能为空').optional().not().isEmpty(), + check('shopType', '店铺类型不能为空').optional().not().isEmpty(), + check('address', '店铺地址不能为空').optional().not().isEmpty() +], (req, res, next) => { + const errors = validationResult(req); + if (!errors.isEmpty()) { + return res.status(400).json({ success: false, errors: errors.array() }); + } + next(); +}, shopController.updateShop); + +// 获取店铺的评价列表(公开接口) +router.get('/:id/reviews', shopController.getShopReviews); + +// 获取店铺的优惠券列表(公开接口) +router.get('/:id/coupons', shopController.getShopCoupons); + +module.exports = router; diff --git a/database/schema.sql b/database/schema.sql new file mode 100644 index 0000000..3eaec64 --- /dev/null +++ b/database/schema.sql @@ -0,0 +1,174 @@ +-- 创建数据库 +CREATE DATABASE IF NOT EXISTS merchant_platform DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; + +USE merchant_platform; + +-- 用户表 +CREATE TABLE IF NOT EXISTS users ( + id INT AUTO_INCREMENT PRIMARY KEY, + username VARCHAR(50) NOT NULL UNIQUE, + password VARCHAR(255) NOT NULL, + email VARCHAR(100) NOT NULL UNIQUE, + phone VARCHAR(20), + avatar VARCHAR(255), + role ENUM('user', 'merchant', 'admin') DEFAULT 'user', + status ENUM('active', 'inactive', 'banned') DEFAULT 'active', + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +-- 商户资质审核表 +CREATE TABLE IF NOT EXISTS merchant_applications ( + id INT AUTO_INCREMENT PRIMARY KEY, + user_id INT NOT NULL, + business_name VARCHAR(100) NOT NULL, + business_license VARCHAR(255) NOT NULL, + legal_person VARCHAR(50) NOT NULL, + id_card VARCHAR(50) NOT NULL, + id_card_front VARCHAR(255) NOT NULL, + id_card_back VARCHAR(255) NOT NULL, + contact_phone VARCHAR(20) NOT NULL, + contact_email VARCHAR(100), + business_type VARCHAR(100) NOT NULL, + business_description TEXT, + status ENUM('pending', 'approved', 'rejected') DEFAULT 'pending', + rejection_reason TEXT, + submitted_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + reviewed_at TIMESTAMP NULL, + reviewed_by INT NULL, + FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE, + FOREIGN KEY (reviewed_by) REFERENCES users(id) ON DELETE SET NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +-- 店铺表 +CREATE TABLE IF NOT EXISTS shops ( + id INT AUTO_INCREMENT PRIMARY KEY, + merchant_id INT NOT NULL, + shop_name VARCHAR(100) NOT NULL, + shop_logo VARCHAR(255), + shop_photos JSON, + shop_type VARCHAR(100) NOT NULL, + business_hours VARCHAR(255), + address VARCHAR(255) NOT NULL, + latitude DECIMAL(10, 8), + longitude DECIMAL(11, 8), + contact_phone VARCHAR(20), + description TEXT, + average_rating DECIMAL(3, 2) DEFAULT 0.00, + rating_count INT DEFAULT 0, + status ENUM('active', 'inactive', 'closed') DEFAULT 'active', + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + FOREIGN KEY (merchant_id) REFERENCES users(id) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +-- 优惠券表 +CREATE TABLE IF NOT EXISTS coupons ( + id INT AUTO_INCREMENT PRIMARY KEY, + shop_id INT NOT NULL, + coupon_name VARCHAR(100) NOT NULL, + coupon_type ENUM('fixed', 'percentage', 'free') NOT NULL, + discount_value DECIMAL(10, 2) NOT NULL, + min_spend DECIMAL(10, 2) DEFAULT 0.00, + total_quantity INT NOT NULL, + used_quantity INT DEFAULT 0, + claimed_quantity INT DEFAULT 0, + start_date DATE NOT NULL, + end_date DATE NOT NULL, + usage_type ENUM('once', 'multiple') DEFAULT 'once', + description TEXT, + terms_and_conditions TEXT, + status ENUM('active', 'inactive', 'expired') DEFAULT 'active', + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + FOREIGN KEY (shop_id) REFERENCES shops(id) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +-- 用户优惠券表 +CREATE TABLE IF NOT EXISTS user_coupons ( + id INT AUTO_INCREMENT PRIMARY KEY, + user_id INT NOT NULL, + coupon_id INT NOT NULL, + claimed_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + used_at TIMESTAMP NULL, + status ENUM('available', 'used', 'expired') DEFAULT 'available', + FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE, + FOREIGN KEY (coupon_id) REFERENCES coupons(id) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +-- 预约表 +CREATE TABLE IF NOT EXISTS reservations ( + id INT AUTO_INCREMENT PRIMARY KEY, + user_id INT NOT NULL, + shop_id INT NOT NULL, + reservation_date DATE NOT NULL, + reservation_time TIME NOT NULL, + people_count INT DEFAULT 1, + contact_name VARCHAR(50) NOT NULL, + contact_phone VARCHAR(20) NOT NULL, + special_requests TEXT, + status ENUM('pending', 'confirmed', 'cancelled', 'completed') DEFAULT 'pending', + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE, + FOREIGN KEY (shop_id) REFERENCES shops(id) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +-- 评价表 +CREATE TABLE IF NOT EXISTS reviews ( + id INT AUTO_INCREMENT PRIMARY KEY, + user_id INT NOT NULL, + shop_id INT NOT NULL, + reservation_id INT NULL, + rating INT NOT NULL CHECK (rating >= 1 AND rating <= 5), + content TEXT, + images JSON, + is_anonymous BOOLEAN DEFAULT FALSE, + reply TEXT, + reply_at TIMESTAMP NULL, + status ENUM('active', 'hidden', 'deleted') DEFAULT 'active', + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE, + FOREIGN KEY (shop_id) REFERENCES shops(id) ON DELETE CASCADE, + FOREIGN KEY (reservation_id) REFERENCES reservations(id) ON DELETE SET NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +-- 收藏表 +CREATE TABLE IF NOT EXISTS favorites ( + id INT AUTO_INCREMENT PRIMARY KEY, + user_id INT NOT NULL, + shop_id INT NOT NULL, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + UNIQUE KEY unique_user_shop (user_id, shop_id), + FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE, + FOREIGN KEY (shop_id) REFERENCES shops(id) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +-- 浏览记录表 +CREATE TABLE IF NOT EXISTS browsing_history ( + id INT AUTO_INCREMENT PRIMARY KEY, + user_id INT NOT NULL, + shop_id INT NOT NULL, + viewed_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE, + FOREIGN KEY (shop_id) REFERENCES shops(id) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +-- 创建索引以提高查询性能 +CREATE INDEX idx_shops_type ON shops(shop_type); +CREATE INDEX idx_shops_location ON shops(latitude, longitude); +CREATE INDEX idx_coupons_shop ON coupons(shop_id); +CREATE INDEX idx_coupons_dates ON coupons(start_date, end_date); +CREATE INDEX idx_user_coupons_user ON user_coupons(user_id); +CREATE INDEX idx_user_coupons_coupon ON user_coupons(coupon_id); +CREATE INDEX idx_reservations_user ON reservations(user_id); +CREATE INDEX idx_reservations_shop ON reservations(shop_id); +CREATE INDEX idx_reservations_date ON reservations(reservation_date); +CREATE INDEX idx_reviews_shop ON reviews(shop_id); +CREATE INDEX idx_reviews_user ON reviews(user_id); +CREATE INDEX idx_reviews_rating ON reviews(rating); +CREATE INDEX idx_favorites_user ON favorites(user_id); +CREATE INDEX idx_browsing_user ON browsing_history(user_id); +CREATE INDEX idx_merchant_applications_user ON merchant_applications(user_id); +CREATE INDEX idx_merchant_applications_status ON merchant_applications(status); diff --git a/frontend/.gitignore b/frontend/.gitignore new file mode 100644 index 0000000..144683e --- /dev/null +++ b/frontend/.gitignore @@ -0,0 +1,5 @@ +node_modules/ +dist/ +.DS_Store +.vscode/ +*.local diff --git a/frontend/index.html b/frontend/index.html new file mode 100644 index 0000000..e3550d5 --- /dev/null +++ b/frontend/index.html @@ -0,0 +1,13 @@ + + +
+ + + +发现周边优质小众商户,享受专属优惠
+用户角色:{{ userStore.user.role }}
+账户状态:{{ userStore.user.status }}
+注册时间:{{ userStore.user.created_at }}
+用户ID:{{ userStore.user.id }}
+类型:{{ shop.shop_type }}
+地址:{{ shop.address }}
+营业时间:{{ shop.business_hours || '暂无' }}
+联系电话:{{ shop.contact_phone || '暂无' }}
+共 {{ shop.rating_count }} 条评价
+ +{{ shop.description || '暂无店铺介绍' }}
++ + {{ coupon.coupon_type === 'fixed' ? '¥' + coupon.discount_value : coupon.discount_value + '折' }} + +
+使用条件:{{ coupon.min_spend > 0 ? '满' + coupon.min_spend + '元可用' : '无门槛' }}
+有效期:{{ coupon.start_date }} 至 {{ coupon.end_date }}
+剩余:{{ coupon.total_quantity - coupon.claimed_quantity }} 张
+{{ review.is_anonymous ? '匿名用户' : review.username }}
+ +{{ review.content }}
+发布时间:{{ review.created_at }}
+商家回复:
+{{ review.reply }}
+回复时间:{{ review.reply_at }}
+类型:{{ shop.shop_type }}
+地址:{{ shop.address }}
+营业时间:{{ shop.business_hours || '暂无' }}
+联系电话:{{ shop.contact_phone || '暂无' }}
+共 {{ shop.rating_count }} 条评价
+企业名称:{{ applicationStatus.business_name }}
+经营类型:{{ applicationStatus.business_type }}
+申请状态: + + {{ statusText }} + +
+提交时间:{{ applicationStatus.submitted_at }}
+审核时间:{{ applicationStatus.reviewed_at }}
++ 拒绝原因:{{ applicationStatus.rejection_reason }} +
+店铺名称:{{ shop.shop_name }}
+店铺类型:{{ shop.shop_type }}
+评分:{{ shop.average_rating }} ({{ shop.rating_count }} 条评价)
+状态:{{ shop.status === 'active' ? '营业中' : shop.status === 'inactive' ? '暂停营业' : '已关闭' }}
+您还没有创建店铺
+今日预约:{{ todayReservations }} 个
+今日优惠券领取:{{ todayCouponsClaimed }} 张
+今日优惠券使用:{{ todayCouponsUsed }} 张
+今日新评价:{{ todayNewReviews }} 条
+预约日期:{{ reservation.reservation_date }} {{ reservation.reservation_time }}
+联系人:{{ reservation.contact_name }} ({{ reservation.contact_phone }})
+人数:{{ reservation.people_count }} 人
+用户:{{ review.is_anonymous ? '匿名用户' : review.username }}
+ +{{ review.content }}
+{{ review.created_at }}
+