Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8958ffaa9e |
File diff suppressed because it is too large
Load Diff
@@ -26,32 +26,11 @@
|
||||
- [查询会员预约记录](#查询会员预约记录)
|
||||
- [查询预约详情](#查询预约详情)
|
||||
- [查询课程预约记录](#查询课程预约记录)
|
||||
5. [团课类型管理接口](#团课类型管理接口)
|
||||
- [获取所有团课类型](#获取所有团课类型)
|
||||
- [根据ID获取团课类型](#根据ID获取团课类型)
|
||||
- [搜索团课类型](#搜索团课类型)
|
||||
- [根据分类获取团课类型](#根据分类获取团课类型)
|
||||
- [获取所有分类](#获取所有分类)
|
||||
- [创建团课类型](#创建团课类型)
|
||||
- [更新团课类型](#更新团课类型)
|
||||
- [删除团课类型](#删除团课类型)
|
||||
6. [团课标签管理接口](#团课标签管理接口)
|
||||
- [获取所有标签](#获取所有标签)
|
||||
- [根据ID获取标签](#根据ID获取标签)
|
||||
- [搜索标签](#搜索标签)
|
||||
- [获取类型的标签](#获取类型的标签)
|
||||
- [创建标签](#创建标签)
|
||||
- [更新标签](#更新标签)
|
||||
- [删除标签](#删除标签)
|
||||
- [为类型添加标签](#为类型添加标签)
|
||||
- [从类型移除标签](#从类型移除标签)
|
||||
- [清空类型标签](#清空类型标签)
|
||||
7. [数据模型](#数据模型)
|
||||
5. [数据模型](#数据模型)
|
||||
- [GroupCourse(团课)](#GroupCourse团课)
|
||||
- [GroupCourseBooking(团课预约)](#GroupCourseBooking团课预约)
|
||||
- [GroupCourseType(团课类型)](#GroupCourseType团课类型)
|
||||
7. [状态码说明](#状态码说明)
|
||||
8. [业务规则](#业务规则)
|
||||
6. [状态码说明](#状态码说明)
|
||||
7. [业务规则](#业务规则)
|
||||
|
||||
---
|
||||
|
||||
@@ -199,78 +178,6 @@
|
||||
|
||||
---
|
||||
|
||||
### 根据ID获取团课完整信息
|
||||
|
||||
| 属性 | 值 |
|
||||
|------|-----|
|
||||
| **HTTP方法** | GET |
|
||||
| **接口路径** | `/api/groupCourse/{id}/detail` |
|
||||
| **所属文件** | `GroupCourseHandler.java` |
|
||||
|
||||
**路径参数**:
|
||||
|
||||
| 参数名 | 类型 | 必填 | 说明 |
|
||||
|--------|------|------|------|
|
||||
| id | Long | 是 | 团课ID |
|
||||
|
||||
**成功响应** (200 OK):
|
||||
|
||||
```json
|
||||
{
|
||||
"id": 1,
|
||||
"courseName": "瑜伽入门",
|
||||
"coachId": 1,
|
||||
"courseType": 1,
|
||||
"startTime": "2026-06-02T09:00:00",
|
||||
"endTime": "2026-06-02T10:00:00",
|
||||
"maxMembers": 20,
|
||||
"currentMembers": 15,
|
||||
"status": 0,
|
||||
"location": "健身房A区",
|
||||
"coverImage": "https://example.com/yoga.jpg",
|
||||
"description": "适合初学者的瑜伽课程",
|
||||
"pointCardAmount": 1,
|
||||
"storedValueAmount": 50.00,
|
||||
"typeName": "瑜伽入门",
|
||||
"typeCategory": "柔韧与平衡类",
|
||||
"baseDifficulty": 2,
|
||||
"difficultyLevel": "初级",
|
||||
"calculatedDifficulty": 2,
|
||||
"typeInfo": {
|
||||
"id": 1,
|
||||
"typeName": "瑜伽入门",
|
||||
"baseDifficulty": 2,
|
||||
"calculatedDifficulty": 2,
|
||||
"difficultyLevel": "初级",
|
||||
"description": "适合初学者的瑜伽课程,注重基础体式",
|
||||
"category": "柔韧与平衡类",
|
||||
"labels": [
|
||||
{"id": 1, "labelName": "适合新手", "color": "#52c41a"},
|
||||
{"id": 3, "labelName": "减压放松", "color": "#1890ff"}
|
||||
]
|
||||
},
|
||||
"labels": [
|
||||
{"id": 1, "labelName": "适合新手", "color": "#52c41a"},
|
||||
{"id": 3, "labelName": "减压放松", "color": "#1890ff"}
|
||||
],
|
||||
"createdAt": "2026-06-01T10:00:00",
|
||||
"updatedAt": "2026-06-01T10:00:00"
|
||||
}
|
||||
```
|
||||
|
||||
**失败响应** (404 Not Found):
|
||||
|
||||
```json
|
||||
{}
|
||||
```
|
||||
|
||||
**说明**: 此接口返回团课的完整信息,包括:
|
||||
- 团课基础信息
|
||||
- 团课对应的类型信息(包含基础难度、综合难度、难度等级等)
|
||||
- 该类型的所有标签信息
|
||||
|
||||
---
|
||||
|
||||
### 创建团课
|
||||
|
||||
| 属性 | 值 |
|
||||
@@ -721,625 +628,6 @@
|
||||
|
||||
---
|
||||
|
||||
## 团课类型管理接口
|
||||
|
||||
### 获取所有团课类型
|
||||
|
||||
| 属性 | 值 |
|
||||
|------|-----|
|
||||
| **HTTP方法** | GET |
|
||||
| **接口路径** | `/api/groupCourse/types` |
|
||||
| **所属文件** | `GroupCourseTypeHandler.java` |
|
||||
|
||||
**请求参数**:
|
||||
|
||||
| 参数名 | 类型 | 必填 | 默认值 | 说明 |
|
||||
|--------|------|------|--------|------|
|
||||
| includeDeleted | boolean | 否 | false | 是否包含已删除的类型 |
|
||||
|
||||
**成功响应** (200 OK):
|
||||
|
||||
```json
|
||||
[
|
||||
{
|
||||
"id": 1,
|
||||
"typeName": "瑜伽入门",
|
||||
"baseDifficulty": 2,
|
||||
"calculatedDifficulty": 2,
|
||||
"difficultyLevel": "初级",
|
||||
"description": "适合初学者的瑜伽课程,注重基础体式",
|
||||
"category": "柔韧与平衡类",
|
||||
"createdAt": "2026-06-01T10:00:00",
|
||||
"updatedAt": "2026-06-01T10:00:00"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 根据ID获取团课类型
|
||||
|
||||
| 属性 | 值 |
|
||||
|------|-----|
|
||||
| **HTTP方法** | GET |
|
||||
| **接口路径** | `/api/groupCourse/types/{id}` |
|
||||
| **所属文件** | `GroupCourseTypeHandler.java` |
|
||||
|
||||
**路径参数**:
|
||||
|
||||
| 参数名 | 类型 | 必填 | 说明 |
|
||||
|--------|------|------|------|
|
||||
| id | Long | 是 | 团课类型ID |
|
||||
|
||||
**成功响应** (200 OK):
|
||||
|
||||
```json
|
||||
{
|
||||
"id": 1,
|
||||
"typeName": "瑜伽入门",
|
||||
"baseDifficulty": 2,
|
||||
"calculatedDifficulty": 2,
|
||||
"difficultyLevel": "初级",
|
||||
"description": "适合初学者的瑜伽课程,注重基础体式",
|
||||
"category": "柔韧与平衡类",
|
||||
"createdAt": "2026-06-01T10:00:00",
|
||||
"updatedAt": "2026-06-01T10:00:00"
|
||||
}
|
||||
```
|
||||
|
||||
**失败响应** (404 Not Found):
|
||||
|
||||
```json
|
||||
{}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 搜索团课类型
|
||||
|
||||
| 属性 | 值 |
|
||||
|------|-----|
|
||||
| **HTTP方法** | GET |
|
||||
| **接口路径** | `/api/groupCourse/types/search` |
|
||||
| **所属文件** | `GroupCourseTypeHandler.java` |
|
||||
|
||||
**请求参数**:
|
||||
|
||||
| 参数名 | 类型 | 必填 | 默认值 | 说明 |
|
||||
|--------|------|------|--------|------|
|
||||
| keyword | string | 否 | - | 搜索关键词(匹配类型名称) |
|
||||
|
||||
**成功响应** (200 OK):
|
||||
|
||||
```json
|
||||
[
|
||||
{
|
||||
"id": 1,
|
||||
"typeName": "瑜伽入门",
|
||||
"baseDifficulty": 2,
|
||||
"difficultyLevel": "初级",
|
||||
"category": "柔韧与平衡类"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 根据分类获取团课类型
|
||||
|
||||
| 属性 | 值 |
|
||||
|------|-----|
|
||||
| **HTTP方法** | GET |
|
||||
| **接口路径** | `/api/groupCourse/types/category/{category}` |
|
||||
| **所属文件** | `GroupCourseTypeHandler.java` |
|
||||
|
||||
**路径参数**:
|
||||
|
||||
| 参数名 | 类型 | 必填 | 说明 |
|
||||
|--------|------|------|------|
|
||||
| category | String | 是 | 分类名称 |
|
||||
|
||||
**请求参数**:
|
||||
|
||||
| 参数名 | 类型 | 必填 | 默认值 | 说明 |
|
||||
|--------|------|------|--------|------|
|
||||
| keyword | string | 否 | - | 搜索关键词 |
|
||||
|
||||
**成功响应** (200 OK):
|
||||
|
||||
```json
|
||||
[
|
||||
{
|
||||
"id": 1,
|
||||
"typeName": "瑜伽入门",
|
||||
"baseDifficulty": 2,
|
||||
"difficultyLevel": "初级",
|
||||
"category": "柔韧与平衡类"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 获取所有分类
|
||||
|
||||
| 属性 | 值 |
|
||||
|------|-----|
|
||||
| **HTTP方法** | GET |
|
||||
| **接口路径** | `/api/groupCourse/types/categories` |
|
||||
| **所属文件** | `GroupCourseTypeHandler.java` |
|
||||
|
||||
**成功响应** (200 OK):
|
||||
|
||||
```json
|
||||
["基础有氧与热身", "固定器械训练", "自重基础动作", "自由重量杠铃/哑铃", "高强度与爆发力", "柔韧与平衡类"]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 创建团课类型
|
||||
|
||||
| 属性 | 值 |
|
||||
|------|-----|
|
||||
| **HTTP方法** | POST |
|
||||
| **接口路径** | `/api/groupCourse/types` |
|
||||
| **所属文件** | `GroupCourseTypeHandler.java` |
|
||||
|
||||
**请求体**:
|
||||
|
||||
```json
|
||||
{
|
||||
"typeName": "核心力量训练",
|
||||
"baseDifficulty": 4,
|
||||
"description": "针对核心肌群的专项训练课程",
|
||||
"category": "自重基础动作"
|
||||
}
|
||||
```
|
||||
|
||||
| 参数名 | 类型 | 必填 | 默认值 | 说明 |
|
||||
|--------|------|------|--------|------|
|
||||
| typeName | String | **是** | - | 类型名称 |
|
||||
| baseDifficulty | Integer | 否 | 1 | 基础难度(1-10) |
|
||||
| description | String | 否 | - | 类型描述 |
|
||||
| category | String | 否 | - | 分类 |
|
||||
|
||||
**成功响应** (200 OK):
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"message": "团课类型创建成功",
|
||||
"data": {
|
||||
"id": 40,
|
||||
"typeName": "核心力量训练",
|
||||
"baseDifficulty": 4,
|
||||
"calculatedDifficulty": 4,
|
||||
"difficultyLevel": "中级",
|
||||
"description": "针对核心肌群的专项训练课程",
|
||||
"category": "自重基础动作"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**失败响应** (400 Bad Request):
|
||||
|
||||
```json
|
||||
{
|
||||
"success": false,
|
||||
"message": "类型名称不能为空"
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 更新团课类型
|
||||
|
||||
| 属性 | 值 |
|
||||
|------|-----|
|
||||
| **HTTP方法** | PUT |
|
||||
| **接口路径** | `/api/groupCourse/types/{id}` |
|
||||
| **所属文件** | `GroupCourseTypeHandler.java` |
|
||||
|
||||
**路径参数**:
|
||||
|
||||
| 参数名 | 类型 | 必填 | 说明 |
|
||||
|--------|------|------|------|
|
||||
| id | Long | 是 | 团课类型ID |
|
||||
|
||||
**请求体**:
|
||||
|
||||
```json
|
||||
{
|
||||
"typeName": "核心力量训练进阶",
|
||||
"baseDifficulty": 6,
|
||||
"description": "进阶核心训练课程"
|
||||
}
|
||||
```
|
||||
|
||||
| 参数名 | 类型 | 必填 | 说明 |
|
||||
|--------|------|------|------|
|
||||
| typeName | String | 否 | 类型名称 |
|
||||
| baseDifficulty | Integer | 否 | 基础难度(1-10) |
|
||||
| description | String | 否 | 类型描述 |
|
||||
| category | String | 否 | 分类 |
|
||||
|
||||
**成功响应** (200 OK):
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"message": "团课类型更新成功",
|
||||
"data": {
|
||||
"id": 40,
|
||||
"typeName": "核心力量训练进阶",
|
||||
"baseDifficulty": 6,
|
||||
"calculatedDifficulty": 6,
|
||||
"difficultyLevel": "中高级",
|
||||
"description": "进阶核心训练课程",
|
||||
"category": "自重基础动作"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 删除团课类型
|
||||
|
||||
| 属性 | 值 |
|
||||
|------|-----|
|
||||
| **HTTP方法** | DELETE |
|
||||
| **接口路径** | `/api/groupCourse/types/{id}` |
|
||||
| **所属文件** | `GroupCourseTypeHandler.java` |
|
||||
|
||||
**路径参数**:
|
||||
|
||||
| 参数名 | 类型 | 必填 | 说明 |
|
||||
|--------|------|------|------|
|
||||
| id | Long | 是 | 团课类型ID |
|
||||
|
||||
**成功响应** (200 OK):
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"message": "团课类型删除成功"
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 团课标签管理接口
|
||||
|
||||
### 获取所有标签
|
||||
|
||||
| 属性 | 值 |
|
||||
|------|-----|
|
||||
| **HTTP方法** | GET |
|
||||
| **接口路径** | `/api/groupCourse/labels` |
|
||||
| **所属文件** | `CourseLabelHandler.java` |
|
||||
|
||||
**成功响应** (200 OK):
|
||||
|
||||
```json
|
||||
[
|
||||
{
|
||||
"id": 1,
|
||||
"labelName": "适合新手",
|
||||
"color": "#52c41a",
|
||||
"createdAt": "2026-06-01T10:00:00",
|
||||
"updatedAt": "2026-06-01T10:00:00"
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"labelName": "中级过渡",
|
||||
"color": "#faad14",
|
||||
"createdAt": "2026-06-01T10:00:00",
|
||||
"updatedAt": "2026-06-01T10:00:00"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 根据ID获取标签
|
||||
|
||||
| 属性 | 值 |
|
||||
|------|-----|
|
||||
| **HTTP方法** | GET |
|
||||
| **接口路径** | `/api/groupCourse/labels/{id}` |
|
||||
| **所属文件** | `CourseLabelHandler.java` |
|
||||
|
||||
**路径参数**:
|
||||
|
||||
| 参数名 | 类型 | 必填 | 说明 |
|
||||
|--------|------|------|------|
|
||||
| id | Long | 是 | 标签ID |
|
||||
|
||||
**成功响应** (200 OK):
|
||||
|
||||
```json
|
||||
{
|
||||
"id": 1,
|
||||
"labelName": "适合新手",
|
||||
"color": "#52c41a",
|
||||
"createdAt": "2026-06-01T10:00:00",
|
||||
"updatedAt": "2026-06-01T10:00:00"
|
||||
}
|
||||
```
|
||||
|
||||
**失败响应** (404 Not Found):
|
||||
|
||||
```json
|
||||
{}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 搜索标签
|
||||
|
||||
| 属性 | 值 |
|
||||
|------|-----|
|
||||
| **HTTP方法** | GET |
|
||||
| **接口路径** | `/api/groupCourse/labels/search` |
|
||||
| **所属文件** | `CourseLabelHandler.java` |
|
||||
|
||||
**请求参数**:
|
||||
|
||||
| 参数名 | 类型 | 必填 | 默认值 | 说明 |
|
||||
|--------|------|------|--------|------|
|
||||
| keyword | string | 否 | - | 搜索关键词(匹配标签名称) |
|
||||
|
||||
**成功响应** (200 OK):
|
||||
|
||||
```json
|
||||
[
|
||||
{
|
||||
"id": 1,
|
||||
"labelName": "适合新手",
|
||||
"color": "#52c41a"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 获取类型的标签
|
||||
|
||||
| 属性 | 值 |
|
||||
|------|-----|
|
||||
| **HTTP方法** | GET |
|
||||
| **接口路径** | `/api/groupCourse/types/{typeId}/labels` |
|
||||
| **所属文件** | `CourseLabelHandler.java` |
|
||||
|
||||
**路径参数**:
|
||||
|
||||
| 参数名 | 类型 | 必填 | 说明 |
|
||||
|--------|------|------|------|
|
||||
| typeId | Long | 是 | 团课类型ID |
|
||||
|
||||
**成功响应** (200 OK):
|
||||
|
||||
```json
|
||||
[
|
||||
{
|
||||
"id": 1,
|
||||
"labelName": "适合新手",
|
||||
"color": "#52c41a"
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"labelName": "减压放松",
|
||||
"color": "#1890ff"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 创建标签
|
||||
|
||||
| 属性 | 值 |
|
||||
|------|-----|
|
||||
| **HTTP方法** | POST |
|
||||
| **接口路径** | `/api/groupCourse/labels` |
|
||||
| **所属文件** | `CourseLabelHandler.java` |
|
||||
|
||||
**请求体**:
|
||||
|
||||
```json
|
||||
{
|
||||
"labelName": "燃脂塑形",
|
||||
"color": "#f5222d"
|
||||
}
|
||||
```
|
||||
|
||||
| 参数名 | 类型 | 必填 | 默认值 | 说明 |
|
||||
|--------|------|------|--------|------|
|
||||
| labelName | String | **是** | - | 标签名称(最大50字符) |
|
||||
| color | String | 否 | #1890ff | 标签颜色(十六进制颜色值) |
|
||||
|
||||
**成功响应** (200 OK):
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"message": "标签创建成功",
|
||||
"data": {
|
||||
"id": 15,
|
||||
"labelName": "燃脂塑形",
|
||||
"color": "#f5222d"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**失败响应** (400 Bad Request):
|
||||
|
||||
```json
|
||||
{
|
||||
"success": false,
|
||||
"message": "标签名称已存在"
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 更新标签
|
||||
|
||||
| 属性 | 值 |
|
||||
|------|-----|
|
||||
| **HTTP方法** | PUT |
|
||||
| **接口路径** | `/api/groupCourse/labels/{id}` |
|
||||
| **所属文件** | `CourseLabelHandler.java` |
|
||||
|
||||
**路径参数**:
|
||||
|
||||
| 参数名 | 类型 | 必填 | 说明 |
|
||||
|--------|------|------|------|
|
||||
| id | Long | 是 | 标签ID |
|
||||
|
||||
**请求体**:
|
||||
|
||||
```json
|
||||
{
|
||||
"labelName": "燃脂塑形进阶",
|
||||
"color": "#fa541c"
|
||||
}
|
||||
```
|
||||
|
||||
| 参数名 | 类型 | 必填 | 说明 |
|
||||
|--------|------|------|------|
|
||||
| labelName | String | 否 | 标签名称(最大50字符) |
|
||||
| color | String | 否 | 标签颜色(十六进制颜色值) |
|
||||
|
||||
**成功响应** (200 OK):
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"message": "标签更新成功",
|
||||
"data": {
|
||||
"id": 15,
|
||||
"labelName": "燃脂塑形进阶",
|
||||
"color": "#fa541c"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 删除标签
|
||||
|
||||
| 属性 | 值 |
|
||||
|------|-----|
|
||||
| **HTTP方法** | DELETE |
|
||||
| **接口路径** | `/api/groupCourse/labels/{id}` |
|
||||
| **所属文件** | `CourseLabelHandler.java` |
|
||||
|
||||
**路径参数**:
|
||||
|
||||
| 参数名 | 类型 | 必填 | 说明 |
|
||||
|--------|------|------|------|
|
||||
| id | Long | 是 | 标签ID |
|
||||
|
||||
**成功响应** (200 OK):
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"message": "标签删除成功"
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 为类型添加标签
|
||||
|
||||
| 属性 | 值 |
|
||||
|------|-----|
|
||||
| **HTTP方法** | POST |
|
||||
| **接口路径** | `/api/groupCourse/types/{typeId}/labels` |
|
||||
| **所属文件** | `CourseLabelHandler.java` |
|
||||
|
||||
**路径参数**:
|
||||
|
||||
| 参数名 | 类型 | 必填 | 说明 |
|
||||
|--------|------|------|------|
|
||||
| typeId | Long | 是 | 团课类型ID |
|
||||
|
||||
**请求体**:
|
||||
|
||||
```json
|
||||
{
|
||||
"labelIds": [1, 3, 5]
|
||||
}
|
||||
```
|
||||
|
||||
| 参数名 | 类型 | 必填 | 说明 |
|
||||
|--------|------|------|------|
|
||||
| labelIds | List\<Long\> | **是** | 要添加的标签ID列表 |
|
||||
|
||||
**成功响应** (200 OK):
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"message": "标签添加成功"
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 从类型移除标签
|
||||
|
||||
| 属性 | 值 |
|
||||
|------|-----|
|
||||
| **HTTP方法** | DELETE |
|
||||
| **接口路径** | `/api/groupCourse/types/{typeId}/labels/{labelId}` |
|
||||
| **所属文件** | `CourseLabelHandler.java` |
|
||||
|
||||
**路径参数**:
|
||||
|
||||
| 参数名 | 类型 | 必填 | 说明 |
|
||||
|--------|------|------|------|
|
||||
| typeId | Long | 是 | 团课类型ID |
|
||||
| labelId | Long | 是 | 标签ID |
|
||||
|
||||
**成功响应** (200 OK):
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"message": "标签移除成功"
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 清空类型标签
|
||||
|
||||
| 属性 | 值 |
|
||||
|------|-----|
|
||||
| **HTTP方法** | DELETE |
|
||||
| **接口路径** | `/api/groupCourse/types/{typeId}/labels` |
|
||||
| **所属文件** | `CourseLabelHandler.java` |
|
||||
|
||||
**路径参数**:
|
||||
|
||||
| 参数名 | 类型 | 必填 | 说明 |
|
||||
|--------|------|------|------|
|
||||
| typeId | Long | 是 | 团课类型ID |
|
||||
|
||||
**成功响应** (200 OK):
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"message": "标签清空成功"
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 数据模型
|
||||
|
||||
### GroupCourse(团课)
|
||||
@@ -1387,84 +675,6 @@
|
||||
| updatedAt | LocalDateTime | 更新时间 |
|
||||
| deletedAt | LocalDateTime | 删除时间(软删除) |
|
||||
|
||||
### GroupCourseType(团课类型)
|
||||
|
||||
| 字段名 | 类型 | 说明 |
|
||||
|--------|------|------|
|
||||
| id | Long | 主键ID |
|
||||
| typeName | String | 类型名称 |
|
||||
| baseDifficulty | Integer | 基础难度(1-10) |
|
||||
| calculatedDifficulty | Integer | 综合难度系数(预留扩展字段) |
|
||||
| difficultyLevel | String | 难度等级描述(初级/中级/中高级/高级/专家级) |
|
||||
| description | String | 类型描述 |
|
||||
| category | String | 分类(如:有氧、力量、柔韧等) |
|
||||
| labels | List\<CourseLabel\> | 标签列表 |
|
||||
| createdBy | String | 创建人 |
|
||||
| updatedBy | String | 更新人 |
|
||||
| createdAt | LocalDateTime | 创建时间 |
|
||||
| updatedAt | LocalDateTime | 更新时间 |
|
||||
| deletedAt | LocalDateTime | 删除时间(软删除) |
|
||||
|
||||
### CourseLabel(团课标签)
|
||||
|
||||
| 字段名 | 类型 | 说明 |
|
||||
|--------|------|------|
|
||||
| id | Long | 主键ID |
|
||||
| labelName | String | 标签名称(最大50字符) |
|
||||
| color | String | 标签颜色(十六进制颜色值,默认#1890ff) |
|
||||
| createdBy | String | 创建人 |
|
||||
| updatedBy | String | 更新人 |
|
||||
| createdAt | LocalDateTime | 创建时间 |
|
||||
| updatedAt | LocalDateTime | 更新时间 |
|
||||
| deletedAt | LocalDateTime | 删除时间(软删除) |
|
||||
|
||||
### GroupCourseDetail(团课完整信息)
|
||||
|
||||
| 字段名 | 类型 | 说明 |
|
||||
|--------|------|------|
|
||||
| id | Long | 主键ID |
|
||||
| courseName | String | 课程名称 |
|
||||
| coachId | Long | 教练ID |
|
||||
| courseType | Long | 课程类型ID |
|
||||
| startTime | LocalDateTime | 开始时间 |
|
||||
| endTime | LocalDateTime | 结束时间 |
|
||||
| maxMembers | Integer | 最大参与人数 |
|
||||
| currentMembers | Integer | 当前参与人数 |
|
||||
| status | Long | 状态(0-正常,1-已取消,2-已结束) |
|
||||
| location | String | 上课地点 |
|
||||
| coverImage | String | 封面图URL |
|
||||
| description | String | 课程描述 |
|
||||
| pointCardAmount | Integer | 点卡额度(消耗次数) |
|
||||
| storedValueAmount | BigDecimal | 储值卡额度(消耗金额) |
|
||||
| typeName | String | 类型名称(快捷访问) |
|
||||
| typeCategory | String | 类型分类(快捷访问) |
|
||||
| baseDifficulty | Integer | 基础难度(快捷访问) |
|
||||
| difficultyLevel | String | 难度等级描述(快捷访问) |
|
||||
| calculatedDifficulty | Integer | 综合难度系数(快捷访问) |
|
||||
| typeInfo | GroupCourseType | 类型信息 |
|
||||
| labels | List\<CourseLabel\> | 标签列表 |
|
||||
| createdAt | LocalDateTime | 创建时间 |
|
||||
| updatedAt | LocalDateTime | 更新时间 |
|
||||
|
||||
**难度等级对应关系**:
|
||||
|
||||
| 基础难度 | 难度等级 |
|
||||
|----------|----------|
|
||||
| 1-2 | 初级 |
|
||||
| 3-4 | 中级 |
|
||||
| 5-6 | 中高级 |
|
||||
| 7-8 | 高级 |
|
||||
| 9-10 | 专家级 |
|
||||
|
||||
**难度扩展说明**:
|
||||
|
||||
`calculatedDifficulty` 字段为预留扩展字段,当前实现仅返回 `baseDifficulty`。未来可扩展的影响因素包括:
|
||||
|
||||
1. **课程时长系数**:时长越长难度越高
|
||||
2. **教练难度调整系数**:教练可根据实际情况微调
|
||||
3. **会员等级适配系数**:根据会员等级动态调整显示难度
|
||||
4. **课程强度系数**:高强度课程难度加成
|
||||
|
||||
---
|
||||
|
||||
## 状态码说明
|
||||
|
||||
@@ -1,87 +0,0 @@
|
||||
一、基础有氧与热身(难度 1-3)
|
||||
|
||||
主要是低冲击、低技巧,用于建立运动基础。
|
||||
|
||||
慢走/椭圆机轻松模式:1(几乎无难度,适合所有人)
|
||||
|
||||
固定自行车(低阻力):2(注意座椅高度调节即可)
|
||||
|
||||
跑步机慢跑:3(需要基本协调性,膝盖有压力)
|
||||
|
||||
跳绳(连续基础跳):3(需要手脚配合,心肺要求明显)
|
||||
|
||||
二、固定器械训练(难度 2-5)
|
||||
|
||||
轨迹固定,主要考验力量和耐力,技巧要求低。
|
||||
|
||||
坐姿腿屈伸/腿弯举:2(很容易找到发力感)
|
||||
|
||||
坐姿推胸机:3(需注意肩胛后收,避免耸肩)
|
||||
|
||||
高位下拉(坐姿):3(需控制不要过度后仰)
|
||||
|
||||
史密斯机深蹲:4(轨迹固定,但需保持核心稳定)
|
||||
|
||||
蝴蝶机夹胸:3(易用肘关节代偿,需锁定肩关节)
|
||||
|
||||
三、自重基础动作(难度 3-7)
|
||||
|
||||
需要一定的力量-体重比和身体控制能力。
|
||||
|
||||
平板支撑:3(耐力考验,技巧低)
|
||||
|
||||
跪姿俯卧撑:3(上肢力量较弱者首选)
|
||||
|
||||
标准俯卧撑:5(需核心收紧,身体成直线)
|
||||
|
||||
引体向上(弹力带辅助):6(背部和手臂力量要求高)
|
||||
|
||||
标准引体向上:8(力量-体重比极高,多数男性无法完成1次)
|
||||
|
||||
徒手深蹲:3(注意膝盖方向与背部直立)
|
||||
|
||||
单腿深蹲(手枪蹲):8(需要极高下肢力量、柔韧性和平衡)
|
||||
|
||||
四、自由重量杠铃/哑铃(难度 5-9)
|
||||
|
||||
技巧风险最高,需要神经系统协调和长期动作打磨。
|
||||
|
||||
哑铃二头弯举:4(容易晃动借力,但较安全)
|
||||
|
||||
哑铃侧平举:5(极易用斜方肌代偿,真正练到三角肌中束很难)
|
||||
|
||||
杠铃卧推:7(肩关节压力大,起桥、沉肩、稳定手腕均有技巧,有压伤风险)
|
||||
|
||||
杠铃深蹲(颈后):8(全身协调性、核心抗压、杠位放置、呼吸模式,学习曲线陡峭)
|
||||
|
||||
传统硬拉:9(风险极高,需要精确的脊柱中立、髋铰链、背阔肌收紧,错误时伤腰)
|
||||
|
||||
高翻/抓举(奥运举重):10(需要爆发力、柔韧、精准衔接,非数月训练不能掌握)
|
||||
|
||||
五、高强度与爆发力(难度 6-10)
|
||||
|
||||
对心肺、神经系统和恢复能力要求极高。
|
||||
|
||||
波比跳(标准版):6(连续做时心肺压力极大)
|
||||
|
||||
冲刺跑(短跑):7(对腘绳肌和脚踝爆发力要求高)
|
||||
|
||||
跳箱(合理高度):6(需要落地缓冲技巧)
|
||||
|
||||
负重雪橇推:6(主要考验腿部耐力和意志力)
|
||||
|
||||
双力臂(引体向上后翻腕上杠):9(需要爆发引体 + 极高相对力量)
|
||||
|
||||
六、柔韧与平衡类(难度 3-8)
|
||||
|
||||
考验本体感觉和关节活动度。
|
||||
|
||||
静态拉伸(坐姿体前屈):2(无风险,但需要坚持)
|
||||
|
||||
瑜伽下犬式:3(常见,但需背部与手臂对齐)
|
||||
|
||||
单腿罗马尼亚硬拉(徒手):6(极考验平衡和髋稳定)
|
||||
|
||||
全深蹲(脚跟贴地,亚洲蹲):5(踝关节灵活度限制多数人)
|
||||
|
||||
竖叉/横叉:8(需要数月甚至数年拉伸)
|
||||
@@ -1,48 +0,0 @@
|
||||
# Compiled class file
|
||||
*.class
|
||||
|
||||
# Log file
|
||||
*.log
|
||||
|
||||
# BlueJ files
|
||||
*.ctxt
|
||||
|
||||
# Mobile Tools for Java (J2ME)
|
||||
.mtj.tmp/
|
||||
|
||||
# Package Files
|
||||
*.jar
|
||||
*.war
|
||||
*.nar
|
||||
*.ear
|
||||
*.zip
|
||||
*.tar.gz
|
||||
*.rar
|
||||
|
||||
# Virtual machine crash logs
|
||||
hs_err_pid*
|
||||
replay_pid*
|
||||
|
||||
# Maven
|
||||
target/
|
||||
pom.xml.tag
|
||||
pom.xml.releaseBackup
|
||||
pom.xml.versionsBackup
|
||||
pom.xml.next
|
||||
release.properties
|
||||
dependency-reduced-pom.xml
|
||||
buildNumber.properties
|
||||
.mvn/timing.properties
|
||||
.mvn/wrapper/maven-wrapper.jar
|
||||
|
||||
# IDE
|
||||
.idea/
|
||||
*.iml
|
||||
.vscode/
|
||||
.settings/
|
||||
.classpath
|
||||
.project
|
||||
|
||||
# OS
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
@@ -1,252 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>cn.novalon.gym.manage</groupId>
|
||||
<artifactId>gym-manage-api</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>gym-checkIn</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>Gym CheckIn</name>
|
||||
<description>Check-In Management Module - Member Attendance Services</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>cn.novalon.gym.manage</groupId>
|
||||
<artifactId>manage-common</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.novalon.gym.manage</groupId>
|
||||
<artifactId>manage-db</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.novalon.gym.manage</groupId>
|
||||
<artifactId>gym-member</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.novalon.gym.manage</groupId>
|
||||
<artifactId>gym-groupCourse</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-webflux</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-aop</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springdoc</groupId>
|
||||
<artifactId>springdoc-openapi-starter-webflux-ui</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-security</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-commons</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>spring-security-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.projectreactor</groupId>
|
||||
<artifactId>reactor-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.github.resilience4j</groupId>
|
||||
<artifactId>resilience4j-spring-boot3</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.github.resilience4j</groupId>
|
||||
<artifactId>resilience4j-reactor</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.testcontainers</groupId>
|
||||
<artifactId>testcontainers</artifactId>
|
||||
<version>1.21.4</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.testcontainers</groupId>
|
||||
<artifactId>postgresql</artifactId>
|
||||
<version>1.21.4</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.testcontainers</groupId>
|
||||
<artifactId>junit-jupiter</artifactId>
|
||||
<version>1.21.4</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.r2dbc</groupId>
|
||||
<artifactId>r2dbc-h2</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.postgresql</groupId>
|
||||
<artifactId>r2dbc-postgresql</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
<version>5.8.25</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.zxing</groupId>
|
||||
<artifactId>core</artifactId>
|
||||
<version>3.5.1</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 添加 ZXing JavaSE 扩展(用于生成图片) -->
|
||||
<dependency>
|
||||
<groupId>com.google.zxing</groupId>
|
||||
<artifactId>javase</artifactId>
|
||||
<version>3.5.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-websocket</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.4.2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>default-jar</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.11.0</version>
|
||||
<configuration>
|
||||
<source>21</source>
|
||||
<target>21</target>
|
||||
<annotationProcessorPaths>
|
||||
<path>
|
||||
<groupId>org.mapstruct</groupId>
|
||||
<artifactId>mapstruct-processor</artifactId>
|
||||
<version>1.5.5.Final</version>
|
||||
</path>
|
||||
<path>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>${lombok.version}</version>
|
||||
</path>
|
||||
<path>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok-mapstruct-binding</artifactId>
|
||||
<version>0.2.0</version>
|
||||
</path>
|
||||
</annotationProcessorPaths>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.jacoco</groupId>
|
||||
<artifactId>jacoco-maven-plugin</artifactId>
|
||||
<version>0.8.12</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>prepare-agent</id>
|
||||
<goals>
|
||||
<goal>prepare-agent</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>report</id>
|
||||
<phase>verify</phase>
|
||||
<goals>
|
||||
<goal>report</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>check</id>
|
||||
<phase>verify</phase>
|
||||
<goals>
|
||||
<goal>check</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<rules>
|
||||
<rule>
|
||||
<element>BUNDLE</element>
|
||||
<limits>
|
||||
<limit>
|
||||
<counter>INSTRUCTION</counter>
|
||||
<value>COVEREDRATIO</value>
|
||||
<minimum>0.60</minimum>
|
||||
</limit>
|
||||
</limits>
|
||||
</rule>
|
||||
</rules>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.github.spotbugs</groupId>
|
||||
<artifactId>spotbugs-maven-plugin</artifactId>
|
||||
<version>4.8.6.0</version>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.github.spotbugs</groupId>
|
||||
<artifactId>spotbugs</artifactId>
|
||||
<version>4.8.6</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>spotbugs-check</id>
|
||||
<phase>verify</phase>
|
||||
<goals>
|
||||
<goal>check</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<effort>Max</effort>
|
||||
<threshold>High</threshold>
|
||||
<failOnError>true</failOnError>
|
||||
<excludeFilterFile>spotbugs-exclude.xml</excludeFilterFile>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
-43
@@ -1,43 +0,0 @@
|
||||
package cn.novalon.gym.manage.checkIn.config;
|
||||
|
||||
import cn.novalon.gym.manage.checkIn.websocket.MyWebSocketHandler;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.reactive.HandlerMapping;
|
||||
import org.springframework.web.reactive.handler.SimpleUrlHandlerMapping;
|
||||
import org.springframework.web.reactive.socket.WebSocketHandler;
|
||||
import org.springframework.web.reactive.socket.server.support.WebSocketHandlerAdapter;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Configuration
|
||||
public class CheckInWebSocketConfig {
|
||||
|
||||
@Autowired
|
||||
private MyWebSocketHandler myWebSocketHandler;
|
||||
|
||||
/**
|
||||
* 注册 WebSocket 路由映射
|
||||
* 路径对应前端连接的 ws://xxx/webSocket/checkIn
|
||||
*/
|
||||
@Bean
|
||||
public HandlerMapping webSocketMapping() {
|
||||
Map<String, WebSocketHandler> map = new HashMap<>();
|
||||
map.put("/webSocket/checkIn", myWebSocketHandler);
|
||||
|
||||
SimpleUrlHandlerMapping mapping = new SimpleUrlHandlerMapping();
|
||||
mapping.setUrlMap(map);
|
||||
mapping.setOrder(10); // 设置优先级
|
||||
return mapping;
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册 WebSocket 处理器适配器(必须)
|
||||
*/
|
||||
@Bean
|
||||
public WebSocketHandlerAdapter handlerAdapter() {
|
||||
return new WebSocketHandlerAdapter();
|
||||
}
|
||||
}
|
||||
-46
@@ -1,46 +0,0 @@
|
||||
package cn.novalon.gym.manage.checkIn.config;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Data
|
||||
@Configuration
|
||||
@ConfigurationProperties(prefix = "qr.config")
|
||||
public class QRCodeConfig {
|
||||
|
||||
/**
|
||||
* 二维码宽度(像素)
|
||||
*/
|
||||
private Integer width = 300;
|
||||
|
||||
/**
|
||||
* 二维码高度(像素)
|
||||
*/
|
||||
private Integer height = 300;
|
||||
|
||||
/**
|
||||
* 白边宽度
|
||||
*/
|
||||
private Integer margin = 1;
|
||||
|
||||
/**
|
||||
* 容错率:L, M, Q, H
|
||||
*/
|
||||
private String errorCorrection = "M";
|
||||
|
||||
/**
|
||||
* 图片格式:png, jpg
|
||||
*/
|
||||
private String format = "png";
|
||||
|
||||
/**
|
||||
* 是否启用Logo
|
||||
*/
|
||||
private Boolean logoEnabled = false;
|
||||
|
||||
/**
|
||||
* Logo路径
|
||||
*/
|
||||
private String logoPath = "";
|
||||
}
|
||||
-43
@@ -1,43 +0,0 @@
|
||||
package cn.novalon.gym.manage.checkIn.constant;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* 打卡模块 Redis 键常量
|
||||
*
|
||||
* @author 付嘉
|
||||
* @date 2026-05-30
|
||||
*/
|
||||
public final class QRRedisKey {
|
||||
|
||||
private static final String SEPARATOR = ":";
|
||||
private static final String QRCODE_USER_DAILY = "qrcode:user:daily";
|
||||
private static final String QRCODE_CONTENT = "QR_";
|
||||
private QRRedisKey() {
|
||||
// 私有构造,防止实例化
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户当日二维码
|
||||
* 格式:qrcode:user:daily:{userId}:{date}
|
||||
* 示例:qrcode:user:daily:1001:2026-05-30
|
||||
*/
|
||||
public static String qrcodeUserDaily(Long userId, LocalDate date) {
|
||||
return QRCODE_USER_DAILY + SEPARATOR + userId + SEPARATOR + date;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户当日二维码(今天)
|
||||
*/
|
||||
public static String qrcodeUserToday(Long userId) {
|
||||
return qrcodeUserDaily(userId, LocalDate.now());
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成二维码内容(每个用户每次调用都不同)
|
||||
*/
|
||||
public static String generateQrcodeContent() {
|
||||
return QRCODE_CONTENT + UUID.randomUUID().toString().replace("-", "");
|
||||
}
|
||||
}
|
||||
-13
@@ -1,13 +0,0 @@
|
||||
package cn.novalon.gym.manage.checkIn.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class QRCodeDto {
|
||||
|
||||
private String qrContent;
|
||||
|
||||
private boolean isUsed;
|
||||
}
|
||||
-209
@@ -1,209 +0,0 @@
|
||||
package cn.novalon.gym.manage.checkIn.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.data.annotation.CreatedDate;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.annotation.LastModifiedDate;
|
||||
import org.springframework.data.relational.core.mapping.Column;
|
||||
import org.springframework.data.relational.core.mapping.Table;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 会员到店签到记录实体
|
||||
*
|
||||
* @author 付嘉
|
||||
* @date 2026-06-08
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Table("sign_in_record")
|
||||
public class SignInRecord {
|
||||
|
||||
/**
|
||||
* 自增主键
|
||||
*/
|
||||
@Id
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 会员ID,关联member表
|
||||
*/
|
||||
@Column("member_id")
|
||||
private Long memberId;
|
||||
|
||||
/**
|
||||
* 签到时使用的会员卡ID
|
||||
*/
|
||||
@Column("member_card_id")
|
||||
private Long memberCardId;
|
||||
|
||||
/**
|
||||
* 签到入场时间
|
||||
*/
|
||||
@Column("sign_in_time")
|
||||
private LocalDateTime signInTime;
|
||||
|
||||
/**
|
||||
* 签到方式:QR_CODE-扫码签到,MANUAL-手动签到,FACE-人脸识别
|
||||
*/
|
||||
@Column("sign_in_type")
|
||||
private String signInType;
|
||||
|
||||
/**
|
||||
* 签到状态:SUCCESS-成功,FAILED-失败
|
||||
*/
|
||||
@Column("sign_in_status")
|
||||
private String signInStatus;
|
||||
|
||||
/**
|
||||
* JSONB格式,存储会员卡验证时的快照数据
|
||||
*/
|
||||
@Column("verification_details")
|
||||
private String verificationDetails;
|
||||
|
||||
/**
|
||||
* 失败时的具体原因文案
|
||||
*/
|
||||
@Column("fail_reason")
|
||||
private String failReason;
|
||||
|
||||
/**
|
||||
* 操作人ID(前台人员),自助签到时为NULL
|
||||
*/
|
||||
@Column("operator_id")
|
||||
private Long operatorId;
|
||||
|
||||
/**
|
||||
* 操作人姓名冗余
|
||||
*/
|
||||
@Column("operator_name")
|
||||
private String operatorName;
|
||||
|
||||
/**
|
||||
* 签到设备标识或型号
|
||||
*/
|
||||
@Column("device_info")
|
||||
private String deviceInfo;
|
||||
|
||||
/**
|
||||
* 客户端IP地址
|
||||
*/
|
||||
@Column("ip_address")
|
||||
private String ipAddress;
|
||||
|
||||
/**
|
||||
* 签到来源:MINI_PROGRAM-小程序扫码,PC_BACKEND-后台管理端
|
||||
*/
|
||||
@Column("source")
|
||||
private String source;
|
||||
|
||||
/**
|
||||
* 软删除标识:false-未删除,true-已删除
|
||||
*/
|
||||
@Column("is_delete")
|
||||
private Boolean isDelete;
|
||||
|
||||
/**
|
||||
* 记录创建时间
|
||||
*/
|
||||
@CreatedDate
|
||||
@Column("created_at")
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
/**
|
||||
* 记录更新时间
|
||||
*/
|
||||
@LastModifiedDate
|
||||
@Column("updated_at")
|
||||
private LocalDateTime updatedAt;
|
||||
|
||||
// ========== 常量定义 ==========
|
||||
|
||||
/**
|
||||
* 签到类型常量
|
||||
*/
|
||||
public static final class SignInType {
|
||||
/** 扫码签到 */
|
||||
public static final String QR_CODE = "QR_CODE";
|
||||
/** 手动签到 */
|
||||
public static final String MANUAL = "MANUAL";
|
||||
/** 人脸识别 */
|
||||
public static final String FACE = "FACE";
|
||||
|
||||
private SignInType() {}
|
||||
}
|
||||
|
||||
/**
|
||||
* 签到状态常量
|
||||
*/
|
||||
public static final class SignInStatus {
|
||||
/** 成功 */
|
||||
public static final String SUCCESS = "SUCCESS";
|
||||
/** 失败 */
|
||||
public static final String FAILED = "FAILED";
|
||||
|
||||
private SignInStatus() {}
|
||||
}
|
||||
|
||||
/**
|
||||
* 签到来源常量
|
||||
*/
|
||||
public static final class Source {
|
||||
/** 小程序扫码 */
|
||||
public static final String MINI_PROGRAM = "MINI_PROGRAM";
|
||||
/** 后台管理端手动签到 */
|
||||
public static final String PC_BACKEND = "PC_BACKEND";
|
||||
|
||||
private Source() {}
|
||||
}
|
||||
|
||||
// ========== 辅助方法 ==========
|
||||
|
||||
/**
|
||||
* 判断签到是否成功
|
||||
*/
|
||||
public boolean isSuccess() {
|
||||
return SignInStatus.SUCCESS.equals(this.signInStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断签到是否失败
|
||||
*/
|
||||
public boolean isFailed() {
|
||||
return SignInStatus.FAILED.equals(this.signInStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否为扫码签到
|
||||
*/
|
||||
public boolean isQrCodeSign() {
|
||||
return SignInType.QR_CODE.equals(this.signInType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否已删除
|
||||
*/
|
||||
public boolean isDeleted() {
|
||||
return Boolean.TRUE.equals(this.isDelete);
|
||||
}
|
||||
|
||||
/**
|
||||
* 软删除
|
||||
*/
|
||||
public void softDelete() {
|
||||
this.isDelete = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 恢复删除
|
||||
*/
|
||||
public void restore() {
|
||||
this.isDelete = false;
|
||||
}
|
||||
}
|
||||
-193
@@ -1,193 +0,0 @@
|
||||
package cn.novalon.gym.manage.checkIn.handler;
|
||||
|
||||
import cn.novalon.gym.manage.checkIn.service.impl.CheckServiceImpl;
|
||||
import cn.novalon.gym.manage.checkIn.websocket.MyWebSocketHandler;
|
||||
import cn.novalon.gym.manage.sys.util.AuthUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.reactive.function.server.ServerRequest;
|
||||
import org.springframework.web.reactive.function.server.ServerResponse;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class CheckInHandler {
|
||||
|
||||
private final AuthUtil authUtil;
|
||||
private final CheckServiceImpl checkService;
|
||||
|
||||
private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
|
||||
/**
|
||||
* 签到
|
||||
*
|
||||
* POST /api/checkIn
|
||||
*
|
||||
*/
|
||||
public Mono<ServerResponse> checkIn(ServerRequest request) {
|
||||
|
||||
Long memberId = authUtil.getMemberIdOrThrow(request);
|
||||
return request.bodyToMono(Map.class)
|
||||
.flatMap(body -> {
|
||||
String qrContent = (String) body.get("qrContent");
|
||||
log.info("收到签到请求, memberId: {}, qrContent: {}", memberId, qrContent);
|
||||
boolean messageToClient = MyWebSocketHandler.sendMessageToClient(qrContent, "正在进行签到");
|
||||
log.info("WebSocket 推送结果: {}", messageToClient);
|
||||
return checkService.checkIn(memberId, qrContent)
|
||||
.flatMap(result -> ServerResponse.ok()
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.bodyValue(result));
|
||||
})
|
||||
.onErrorResume(e -> {
|
||||
log.error("签到失败", e);
|
||||
return ServerResponse.status(HttpStatus.BAD_REQUEST)
|
||||
.bodyValue(Map.of("code", 400, "message", e.getMessage()));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取二维码
|
||||
*
|
||||
* GET /api/checkin/qrcode
|
||||
*
|
||||
*/
|
||||
public Mono<ServerResponse> getQRCode(ServerRequest request) {
|
||||
|
||||
Long memberId = authUtil.getMemberIdOrThrow(request);
|
||||
|
||||
log.info("收到用户{}获取二维码请求", memberId);
|
||||
|
||||
return checkService.getQRCode(memberId)
|
||||
.flatMap(qrCodeVo -> ServerResponse.ok()
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.bodyValue(qrCodeVo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询签到记录列表
|
||||
*
|
||||
* GET /api/checkIn/records
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
public Mono<ServerResponse> getSignInRecords(ServerRequest request) {
|
||||
Long memberId = authUtil.getMemberIdOrThrow(request);
|
||||
|
||||
String startDateStr = request.queryParam("startDate").orElse(null);
|
||||
String endDateStr = request.queryParam("endDate").orElse(null);
|
||||
|
||||
LocalDate startDate = startDateStr != null ? LocalDate.parse(startDateStr, DATE_FORMATTER) : LocalDate.now().minusDays(30);
|
||||
LocalDate endDate = endDateStr != null ? LocalDate.parse(endDateStr, DATE_FORMATTER) : LocalDate.now();
|
||||
|
||||
log.info("查询签到记录, memberId: {}, startDate: {}, endDate: {}", memberId, startDate, endDate);
|
||||
|
||||
return checkService.getSignInRecords(memberId, startDate, endDate)
|
||||
.collectList()
|
||||
.flatMap(records -> ServerResponse.ok()
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.bodyValue(Map.of("code", 200, "message", "success", "data", records)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询单条签到记录
|
||||
*
|
||||
* GET /api/checkIn/records/{id}
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
public Mono<ServerResponse> getSignInRecordById(ServerRequest request) {
|
||||
Long id = Long.parseLong(request.pathVariable("id"));
|
||||
|
||||
log.info("查询签到记录详情, id: {}", id);
|
||||
|
||||
return checkService.getSignInRecordById(id)
|
||||
.flatMap(record -> ServerResponse.ok()
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.bodyValue(Map.of("code", 200, "message", "success", "data", record)))
|
||||
.switchIfEmpty(ServerResponse.notFound().build());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取签到统计
|
||||
*
|
||||
* GET /api/checkIn/statistics
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
public Mono<ServerResponse> getSignInStatistics(ServerRequest request) {
|
||||
Long memberId = authUtil.getMemberIdOrThrow(request);
|
||||
|
||||
String startDateStr = request.queryParam("startDate").orElse(null);
|
||||
String endDateStr = request.queryParam("endDate").orElse(null);
|
||||
|
||||
LocalDate startDate = startDateStr != null ? LocalDate.parse(startDateStr, DATE_FORMATTER) : LocalDate.now().minusDays(30);
|
||||
LocalDate endDate = endDateStr != null ? LocalDate.parse(endDateStr, DATE_FORMATTER) : LocalDate.now();
|
||||
|
||||
log.info("查询签到统计, memberId: {}, startDate: {}, endDate: {}", memberId, startDate, endDate);
|
||||
|
||||
return checkService.getSignInStats(memberId, startDate, endDate)
|
||||
.flatMap(stats -> ServerResponse.ok()
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.bodyValue(Map.of("code", 200, "message", "success", "data", stats)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出签到记录
|
||||
*
|
||||
* GET /api/checkIn/records/export
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
public Mono<ServerResponse> exportSignInRecords(ServerRequest request) {
|
||||
Long memberId = authUtil.getMemberIdOrThrow(request);
|
||||
|
||||
String startDateStr = request.queryParam("startDate").orElse(null);
|
||||
String endDateStr = request.queryParam("endDate").orElse(null);
|
||||
|
||||
LocalDate startDate = startDateStr != null ? LocalDate.parse(startDateStr, DATE_FORMATTER) : LocalDate.now().minusDays(30);
|
||||
LocalDate endDate = endDateStr != null ? LocalDate.parse(endDateStr, DATE_FORMATTER) : LocalDate.now();
|
||||
|
||||
log.info("导出签到记录, memberId: {}, startDate: {}, endDate: {}", memberId, startDate, endDate);
|
||||
|
||||
String filename = "签到记录_" + startDateStr + "_" + endDateStr + ".csv";
|
||||
|
||||
return checkService.exportSignInRecords(memberId, startDate, endDate)
|
||||
.flatMap(bytes -> ServerResponse.ok()
|
||||
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + filename + "\"")
|
||||
.contentType(MediaType.parseMediaType("text/csv; charset=UTF-8"))
|
||||
.bodyValue(bytes));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取每日签到统计
|
||||
*
|
||||
* GET /api/checkIn/daily-stats
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
public Mono<ServerResponse> getDailySignInStats(ServerRequest request) {
|
||||
String dateStr = request.queryParam("date").orElse(null);
|
||||
LocalDate date = dateStr != null ? LocalDate.parse(dateStr, DATE_FORMATTER) : LocalDate.now();
|
||||
|
||||
log.info("查询每日签到统计, date: {}", date);
|
||||
|
||||
return checkService.getDailySignInStats(date)
|
||||
.flatMap(stats -> ServerResponse.ok()
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.bodyValue(Map.of("code", 200, "message", "success", "data", stats)));
|
||||
}
|
||||
}
|
||||
-101
@@ -1,101 +0,0 @@
|
||||
package cn.novalon.gym.manage.checkIn.repository;
|
||||
|
||||
import cn.novalon.gym.manage.checkIn.entity.SignInRecord;
|
||||
import org.springframework.data.r2dbc.repository.Query;
|
||||
import org.springframework.data.r2dbc.repository.R2dbcRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 签到记录 Repository
|
||||
*
|
||||
* @author 付嘉
|
||||
* @date 2026-06-08
|
||||
*/
|
||||
@Repository
|
||||
public interface SignInRecordRepository extends R2dbcRepository<SignInRecord, Long> {
|
||||
|
||||
/**
|
||||
* 查询会员某天的签到记录
|
||||
*/
|
||||
@Query("SELECT * FROM sign_in_record WHERE member_id = :memberId AND sign_in_time >= :startTime AND sign_in_time < :endTime AND is_delete = false")
|
||||
Mono<SignInRecord> findByMemberIdAndDate(Long memberId, LocalDateTime startTime, LocalDateTime endTime);
|
||||
|
||||
/**
|
||||
* 查询会员的签到记录列表
|
||||
*/
|
||||
@Query("SELECT * FROM sign_in_record WHERE member_id = :memberId AND is_delete = false ORDER BY sign_in_time DESC")
|
||||
Flux<SignInRecord> findByMemberId(Long memberId);
|
||||
|
||||
/**
|
||||
* 统计会员某天的签到次数
|
||||
*/
|
||||
@Query("SELECT COUNT(*) FROM sign_in_record WHERE member_id = :memberId AND sign_in_time >= :startTime AND sign_in_time < :endTime AND is_delete = false")
|
||||
Mono<Long> countByMemberIdAndDate(Long memberId, LocalDateTime startTime, LocalDateTime endTime);
|
||||
|
||||
/**
|
||||
* 插入签到记录
|
||||
*/
|
||||
@Query("INSERT INTO sign_in_record (member_id, member_card_id, sign_in_time, sign_in_type, sign_in_status, verification_details, fail_reason, source, created_at, updated_at, is_delete) " +
|
||||
"VALUES (:memberId, :memberCardId, :signInTime, :signInType, :signInStatus, :verificationDetails, :failReason, :source, NOW(), NOW(), false)")
|
||||
Mono<Void> insertRecord(Long memberId, Long memberCardId, LocalDateTime signInTime,
|
||||
String signInType, String signInStatus, String verificationDetails,
|
||||
String failReason, String source);
|
||||
|
||||
/**
|
||||
* 根据会员ID和时间范围查询签到记录
|
||||
*/
|
||||
@Query("SELECT * FROM sign_in_record WHERE member_id = :memberId AND sign_in_time >= :startTime AND sign_in_time <= :endTime AND is_delete = false ORDER BY sign_in_time DESC")
|
||||
Flux<SignInRecord> findByMemberIdAndTimeRange(Long memberId, LocalDateTime startTime, LocalDateTime endTime);
|
||||
|
||||
/**
|
||||
* 根据时间范围查询签到记录
|
||||
*/
|
||||
@Query("SELECT * FROM sign_in_record WHERE sign_in_time >= :startTime AND sign_in_time <= :endTime AND is_delete = false ORDER BY sign_in_time DESC")
|
||||
Flux<SignInRecord> findByTimeRange(LocalDateTime startTime, LocalDateTime endTime);
|
||||
|
||||
/**
|
||||
* 统计会员在时间范围内的签到次数
|
||||
*/
|
||||
@Query("SELECT COUNT(*) FROM sign_in_record WHERE member_id = :memberId AND sign_in_time >= :startTime AND sign_in_time <= :endTime AND is_delete = false")
|
||||
Mono<Long> countByMemberIdAndTimeRange(Long memberId, LocalDateTime startTime, LocalDateTime endTime);
|
||||
|
||||
/**
|
||||
* 统计时间范围内的签到次数
|
||||
*/
|
||||
@Query("SELECT COUNT(*) FROM sign_in_record WHERE sign_in_time >= :startTime AND sign_in_time <= :endTime AND is_delete = false")
|
||||
Mono<Long> countByTimeRange(LocalDateTime startTime, LocalDateTime endTime);
|
||||
|
||||
/**
|
||||
* 统计会员在时间范围内的成功签到次数
|
||||
*/
|
||||
@Query("SELECT COUNT(*) FROM sign_in_record WHERE member_id = :memberId AND sign_in_time >= :startTime AND sign_in_time <= :endTime AND sign_in_status = 'SUCCESS' AND is_delete = false")
|
||||
Mono<Long> countSuccessByMemberIdAndTimeRange(Long memberId, LocalDateTime startTime, LocalDateTime endTime);
|
||||
|
||||
/**
|
||||
* 统计时间范围内的成功签到次数
|
||||
*/
|
||||
@Query("SELECT COUNT(*) FROM sign_in_record WHERE sign_in_time >= :startTime AND sign_in_time <= :endTime AND sign_in_status = 'SUCCESS' AND is_delete = false")
|
||||
Mono<Long> countSuccessByTimeRange(LocalDateTime startTime, LocalDateTime endTime);
|
||||
|
||||
/**
|
||||
* 统计时间范围内签到的独立会员数
|
||||
*/
|
||||
@Query("SELECT COUNT(DISTINCT member_id) FROM sign_in_record WHERE sign_in_time >= :startTime AND sign_in_time <= :endTime AND is_delete = false")
|
||||
Mono<Long> countDistinctMembersByTimeRange(LocalDateTime startTime, LocalDateTime endTime);
|
||||
|
||||
/**
|
||||
* 获取会员在时间范围内的首次签到时间
|
||||
*/
|
||||
@Query("SELECT MIN(sign_in_time) FROM sign_in_record WHERE member_id = :memberId AND sign_in_time >= :startTime AND sign_in_time <= :endTime AND is_delete = false")
|
||||
Mono<LocalDateTime> getFirstSignInTime(Long memberId, LocalDateTime startTime, LocalDateTime endTime);
|
||||
|
||||
/**
|
||||
* 获取会员在时间范围内的最后签到时间
|
||||
*/
|
||||
@Query("SELECT MAX(sign_in_time) FROM sign_in_record WHERE member_id = :memberId AND sign_in_time >= :startTime AND sign_in_time <= :endTime AND is_delete = false")
|
||||
Mono<LocalDateTime> getLastSignInTime(Long memberId, LocalDateTime startTime, LocalDateTime endTime);
|
||||
}
|
||||
-81
@@ -1,81 +0,0 @@
|
||||
package cn.novalon.gym.manage.checkIn.service;
|
||||
|
||||
import cn.novalon.gym.manage.checkIn.vo.QRCodeVo;
|
||||
import cn.novalon.gym.manage.checkIn.vo.SignInRecordVO;
|
||||
import cn.novalon.gym.manage.checkIn.vo.SignInStatsVO;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
/**
|
||||
* 签到服务接口
|
||||
*
|
||||
* @author 付嘉
|
||||
* @date 2026-06-08
|
||||
*/
|
||||
public interface ICheckInService {
|
||||
|
||||
/**
|
||||
* 获取签到二维码
|
||||
*
|
||||
* @param memberId 会员ID
|
||||
* @return 二维码VO
|
||||
*/
|
||||
Mono<QRCodeVo> getQRCode(Long memberId);
|
||||
|
||||
/**
|
||||
* 扫码签到
|
||||
*
|
||||
* @param memberId 会员ID
|
||||
* @param qrContent 二维码内容
|
||||
* @return 签到结果JSON字符串
|
||||
*/
|
||||
Mono<String> checkIn(Long memberId, String qrContent);
|
||||
|
||||
/**
|
||||
* 查询会员签到记录列表
|
||||
*
|
||||
* @param memberId 会员ID
|
||||
* @param startTime 开始时间
|
||||
* @param endTime 结束时间
|
||||
* @return 签到记录列表
|
||||
*/
|
||||
Flux<SignInRecordVO> getSignInRecords(Long memberId, LocalDate startTime, LocalDate endTime);
|
||||
|
||||
/**
|
||||
* 根据ID查询签到记录
|
||||
*
|
||||
* @param id 签到记录ID
|
||||
* @return 签到记录VO
|
||||
*/
|
||||
Mono<SignInRecordVO> getSignInRecordById(Long id);
|
||||
|
||||
/**
|
||||
* 获取会员签到统计
|
||||
*
|
||||
* @param memberId 会员ID
|
||||
* @param startTime 开始时间
|
||||
* @param endTime 结束时间
|
||||
* @return 签到统计VO
|
||||
*/
|
||||
Mono<SignInStatsVO> getSignInStats(Long memberId, LocalDate startTime, LocalDate endTime);
|
||||
|
||||
/**
|
||||
* 导出会员签到记录
|
||||
*
|
||||
* @param memberId 会员ID
|
||||
* @param startTime 开始时间
|
||||
* @param endTime 结束时间
|
||||
* @return CSV格式的字节数组
|
||||
*/
|
||||
Mono<byte[]> exportSignInRecords(Long memberId, LocalDate startTime, LocalDate endTime);
|
||||
|
||||
/**
|
||||
* 获取每日签到统计
|
||||
*
|
||||
* @param date 日期
|
||||
* @return 签到统计VO
|
||||
*/
|
||||
Mono<SignInStatsVO> getDailySignInStats(LocalDate date);
|
||||
}
|
||||
-439
@@ -1,439 +0,0 @@
|
||||
package cn.novalon.gym.manage.checkIn.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.novalon.gym.manage.checkIn.config.QRCodeConfig;
|
||||
import cn.novalon.gym.manage.checkIn.constant.QRRedisKey;
|
||||
import cn.novalon.gym.manage.checkIn.entity.SignInRecord;
|
||||
import cn.novalon.gym.manage.checkIn.repository.SignInRecordRepository;
|
||||
import cn.novalon.gym.manage.checkIn.service.ICheckInService;
|
||||
import cn.novalon.gym.manage.checkIn.vo.QRCodeVo;
|
||||
import cn.novalon.gym.manage.checkIn.vo.SignInRecordVO;
|
||||
import cn.novalon.gym.manage.checkIn.vo.SignInStatsVO;
|
||||
import cn.novalon.gym.manage.checkIn.websocket.MyWebSocketHandler;
|
||||
import cn.novalon.gym.manage.common.constant.RedisKeyConstants;
|
||||
import cn.novalon.gym.manage.common.util.RedisUtil;
|
||||
import cn.novalon.gym.manage.groupcourse.service.IGroupCourseBookingService;
|
||||
import cn.novalon.gym.manage.member.entity.MemberCard;
|
||||
import cn.novalon.gym.manage.member.entity.MemberCardRecord;
|
||||
import cn.novalon.gym.manage.member.enums.MemberCardType;
|
||||
import cn.novalon.gym.manage.member.repository.MemberCardRecordRepository;
|
||||
import cn.novalon.gym.manage.member.repository.MemberCardRepository;
|
||||
import cn.hutool.extra.qrcode.QrCodeUtil;
|
||||
import cn.hutool.extra.qrcode.QrConfig;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class CheckServiceImpl implements ICheckInService {
|
||||
|
||||
private final QRCodeConfig qrCodeConfig;
|
||||
private final RedisUtil redisUtil;
|
||||
private final MemberCardRecordRepository memberCardRecordRepository;
|
||||
private final MemberCardRepository memberCardRepository;
|
||||
private final SignInRecordRepository signInRecordRepository;
|
||||
private final IGroupCourseBookingService groupCourseBookingService;
|
||||
|
||||
private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
@Override
|
||||
public Mono<QRCodeVo> getQRCode(Long memberId) {
|
||||
log.info("开始查询会员信息, memberId: {}", memberId);
|
||||
|
||||
return findValidMemberCard(memberId)
|
||||
.flatMap(cardRecord -> {
|
||||
log.info("会员信息查询完成, memberCardRecordId: {}", cardRecord.getMemberCardRecordId());
|
||||
|
||||
log.info("开始生成二维码");
|
||||
String qrContent = QRRedisKey.generateQrcodeContent();
|
||||
Map<String, Object> redisMap = new HashMap<>();
|
||||
redisMap.put("qrContent", qrContent);
|
||||
redisMap.put("isUsed", false);
|
||||
redisMap.put("memberId", memberId);
|
||||
redisMap.put("memberCardRecordId", cardRecord.getMemberCardRecordId());
|
||||
|
||||
return redisUtil.setWithExpire(
|
||||
RedisKeyConstants.QRCODE_USER_DAILY + memberId + LocalDate.now(),
|
||||
redisMap,
|
||||
getSecondsUntilEndOfDay()
|
||||
)
|
||||
.then(Mono.fromSupplier(() -> {
|
||||
String qrCodeBase64 = QrCodeUtil.generateAsBase64(qrContent,
|
||||
BeanUtil.copyProperties(qrCodeConfig, QrConfig.class), "png");
|
||||
return new QRCodeVo(qrCodeBase64, false, qrContent, qrCodeConfig.getWidth(), qrCodeConfig.getHeight(), LocalDate.now());
|
||||
}));
|
||||
})
|
||||
.switchIfEmpty(Mono.error(new RuntimeException("该会员没有可用的会员卡")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<String> checkIn(Long memberId, String qrContent) {
|
||||
String key = RedisKeyConstants.QRCODE_USER_DAILY + memberId + LocalDate.now();
|
||||
|
||||
// 先检查当天是否已经签到(从数据库查询,作为重复签到的额外保障)
|
||||
return checkTodayAlreadySignedIn(memberId)
|
||||
.flatMap(existingRecord -> {
|
||||
String checkInTime = existingRecord.getSignInTime().format(DATE_FORMATTER);
|
||||
log.error("重复签到, memberId: {}", memberId);
|
||||
MyWebSocketHandler.sendFailure(qrContent, "您已经在" + checkInTime + "完成签到,请勿重复签到");
|
||||
return Mono.error(new RuntimeException("您已经在" + checkInTime + "完成签到,请勿重复签到"));
|
||||
})
|
||||
.then(Mono.defer(() -> redisUtil.get(key)))
|
||||
.flatMap(cachedObj -> {
|
||||
if (cachedObj != null) {
|
||||
Map<String, Object> map;
|
||||
if (cachedObj instanceof Map) {
|
||||
map = (Map<String, Object>) cachedObj;
|
||||
} else if (cachedObj instanceof String) {
|
||||
map = JSONUtil.parseObj((String) cachedObj);
|
||||
} else {
|
||||
MyWebSocketHandler.sendFailure(qrContent, "二维码数据格式错误");
|
||||
return Mono.error(new RuntimeException("二维码数据格式错误"));
|
||||
}
|
||||
if (map.get("qrContent").equals(qrContent)) {
|
||||
if ((boolean) map.get("isUsed")) {
|
||||
String checkInTime = String.valueOf(map.get("checkInTime"));
|
||||
log.error("重复签到(缓存), memberId: {}", memberId);
|
||||
MyWebSocketHandler.sendFailure(qrContent, "您已经在" + checkInTime + "完成签到,请勿重复签到");
|
||||
return Mono.error(new RuntimeException("您已经在" + checkInTime + "完成签到,请勿重复签到"));
|
||||
}
|
||||
log.info("二维码匹配成功,memberId: {}", memberId);
|
||||
|
||||
Long memberCardRecordId = ((Number) map.get("memberCardRecordId")).longValue();
|
||||
|
||||
return processCheckIn(memberId, memberCardRecordId, map, qrContent);
|
||||
} else {
|
||||
MyWebSocketHandler.sendFailure(qrContent, "二维码无效");
|
||||
return Mono.error(new RuntimeException("二维码无效"));
|
||||
}
|
||||
}
|
||||
MyWebSocketHandler.sendFailure(qrContent, "二维码已过期或不存在");
|
||||
return Mono.error(new RuntimeException("二维码已过期或不存在"));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查会员当天是否已经签到
|
||||
* @param memberId 会员ID
|
||||
* @return 如果已签到返回签到记录,否则返回空
|
||||
*/
|
||||
private Mono<SignInRecord> checkTodayAlreadySignedIn(Long memberId) {
|
||||
LocalDateTime startOfDay = LocalDate.now().atStartOfDay();
|
||||
LocalDateTime endOfDay = LocalDate.now().atTime(LocalTime.MAX);
|
||||
|
||||
return signInRecordRepository.findByMemberIdAndDate(memberId, startOfDay, endOfDay);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理签到逻辑
|
||||
*/
|
||||
private Mono<String> processCheckIn(Long memberId, Long memberCardRecordId, Map<String, Object> redisMap, String qrContent) {
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
|
||||
// 发送实时进度通知
|
||||
MyWebSocketHandler.sendProgress(qrContent, "VALIDATE_CARD", "正在验证会员卡...");
|
||||
|
||||
return memberCardRecordRepository.findById(memberCardRecordId)
|
||||
.switchIfEmpty(Mono.defer(() -> {
|
||||
MyWebSocketHandler.sendFailure(qrContent, "会员卡记录不存在");
|
||||
return Mono.error(new RuntimeException("会员卡记录不存在"));
|
||||
}))
|
||||
.flatMap(cardRecord -> {
|
||||
if (!"ACTIVE".equals(cardRecord.getStatus().name())) {
|
||||
MyWebSocketHandler.sendFailure(qrContent, "会员卡状态不正确");
|
||||
return Mono.error(new RuntimeException("会员卡状态不正确"));
|
||||
}
|
||||
|
||||
if (cardRecord.getExpireTime() != null && cardRecord.getExpireTime().isBefore(now)) {
|
||||
MyWebSocketHandler.sendFailure(qrContent, "会员卡已过期");
|
||||
return Mono.error(new RuntimeException("会员卡已过期"));
|
||||
}
|
||||
|
||||
// 发送实时进度通知
|
||||
MyWebSocketHandler.sendProgress(qrContent, "VALIDATE_BOOKING", "会员卡验证通过,正在检查预约信息...");
|
||||
|
||||
// 检查是否有需要签到的团课预约
|
||||
return validateBooking(memberId, now)
|
||||
.then(memberCardRepository.findByMemberCardIdAndDeletedAtIsNull(cardRecord.getMemberCardId())
|
||||
.switchIfEmpty(Mono.defer(() -> {
|
||||
MyWebSocketHandler.sendFailure(qrContent, "会员卡类型不存在");
|
||||
return Mono.error(new RuntimeException("会员卡类型不存在"));
|
||||
}))
|
||||
.flatMap(card -> {
|
||||
// 发送实时进度通知
|
||||
MyWebSocketHandler.sendProgress(qrContent, "DEDUCT_USAGE", "正在扣减会员卡次数...");
|
||||
|
||||
return deductCardUsage(cardRecord, card)
|
||||
.flatMap(updatedRecord -> {
|
||||
redisMap.put("isUsed", true);
|
||||
redisMap.put("checkInTime", now.format(DATE_FORMATTER));
|
||||
|
||||
return saveSignInRecord(memberId, cardRecord.getMemberCardRecordId(), card.getMemberCardId())
|
||||
.then(redisUtil.set(RedisKeyConstants.QRCODE_USER_DAILY + memberId + LocalDate.now(), redisMap))
|
||||
.then(Mono.defer(() -> {
|
||||
String successMsg = buildSuccessResponse(now);
|
||||
MyWebSocketHandler.sendSuccess(qrContent, memberId, now.format(DATE_FORMATTER));
|
||||
log.info("签到成功, memberId: {}, cardRecordId: {}", memberId, memberCardRecordId);
|
||||
return Mono.just(successMsg);
|
||||
}));
|
||||
});
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证预约信息
|
||||
*/
|
||||
private Mono<Void> validateBooking(Long memberId, LocalDateTime now) {
|
||||
return groupCourseBookingService.getBookingsByMemberId(memberId)
|
||||
.filter(booking -> {
|
||||
String status = booking.getStatus();
|
||||
LocalDateTime startTime = booking.getCourseStartTime();
|
||||
return "0".equals(status) &&
|
||||
startTime != null &&
|
||||
startTime.toLocalDate().equals(now.toLocalDate()) &&
|
||||
!startTime.isBefore(now.minusMinutes(30));
|
||||
})
|
||||
.collectList()
|
||||
.flatMap(bookings -> {
|
||||
if (bookings.isEmpty()) {
|
||||
return Mono.empty();
|
||||
}
|
||||
boolean hasValidBooking = bookings.stream()
|
||||
.anyMatch(b -> {
|
||||
LocalDateTime startTime = b.getCourseStartTime();
|
||||
return startTime != null &&
|
||||
!startTime.isBefore(now.minusMinutes(30)) &&
|
||||
!startTime.isAfter(now.plusMinutes(30));
|
||||
});
|
||||
if (hasValidBooking) {
|
||||
log.info("会员{}有有效的团课预约", memberId);
|
||||
} else {
|
||||
log.warn("会员{}有预约但不在签到时间范围内", memberId);
|
||||
}
|
||||
return Mono.empty();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 扣减会员卡使用次数/金额
|
||||
*/
|
||||
private Mono<MemberCardRecord> deductCardUsage(MemberCardRecord record, MemberCard card) {
|
||||
MemberCardType cardType = MemberCardType.valueOf(card.getMemberCardType());
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
|
||||
switch (cardType) {
|
||||
case TIME_CARD:
|
||||
if (record.getExpireTime() != null && record.getExpireTime().isBefore(now)) {
|
||||
return Mono.error(new RuntimeException("时长卡已过期"));
|
||||
}
|
||||
return Mono.just(record);
|
||||
case COUNT_CARD:
|
||||
int currentTimes = record.getRemainingTimes() != null ? record.getRemainingTimes() : 0;
|
||||
if (currentTimes < 1) {
|
||||
return Mono.error(new RuntimeException("次卡剩余次数不足"));
|
||||
}
|
||||
record.setRemainingTimes(currentTimes - 1);
|
||||
if (record.getRemainingTimes() == 0) {
|
||||
record.setStatus(cn.novalon.gym.manage.member.enums.MemberCardRecordStatus.USED_UP);
|
||||
}
|
||||
return memberCardRecordRepository.save(record);
|
||||
case STORED_VALUE_CARD:
|
||||
double currentAmount = record.getRemainingAmount() != null ? record.getRemainingAmount() : 0.0;
|
||||
if (currentAmount < 0.01) {
|
||||
return Mono.error(new RuntimeException("储值卡余额不足"));
|
||||
}
|
||||
record.setRemainingAmount(Math.max(0, currentAmount - 1));
|
||||
if (record.getRemainingAmount() <= 0) {
|
||||
record.setStatus(cn.novalon.gym.manage.member.enums.MemberCardRecordStatus.USED_UP);
|
||||
}
|
||||
return memberCardRecordRepository.save(record);
|
||||
default:
|
||||
return Mono.error(new RuntimeException("不支持的会员卡类型"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存签到记录
|
||||
*/
|
||||
private Mono<Void> saveSignInRecord(Long memberId, Long memberCardRecordId, Long memberCardId) {
|
||||
SignInRecord record = SignInRecord.builder()
|
||||
.memberId(memberId)
|
||||
.memberCardId(memberCardId)
|
||||
.signInTime(LocalDateTime.now())
|
||||
.signInType(SignInRecord.SignInType.QR_CODE)
|
||||
.signInStatus(SignInRecord.SignInStatus.SUCCESS)
|
||||
.source(SignInRecord.Source.MINI_PROGRAM)
|
||||
.isDelete(false)
|
||||
.build();
|
||||
|
||||
return signInRecordRepository.save(record).then();
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建成功响应
|
||||
*/
|
||||
private String buildSuccessResponse(LocalDateTime dateTime) {
|
||||
Map<String, Object> res = new HashMap<>();
|
||||
res.put("message", "签到成功");
|
||||
res.put("dateTime", dateTime.format(DATE_FORMATTER));
|
||||
return JSONUtil.toJsonStr(res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找会员的有效会员卡(优先选择有效期最早到期的)
|
||||
*/
|
||||
private Mono<MemberCardRecord> findValidMemberCard(Long memberId) {
|
||||
return memberCardRecordRepository.findActiveCardsByMemberId(memberId)
|
||||
.filter(record -> {
|
||||
LocalDateTime expireTime = record.getExpireTime();
|
||||
return expireTime == null || expireTime.isAfter(LocalDateTime.now());
|
||||
})
|
||||
.sort((r1, r2) -> {
|
||||
LocalDateTime e1 = r1.getExpireTime();
|
||||
LocalDateTime e2 = r2.getExpireTime();
|
||||
if (e1 == null && e2 == null) return 0;
|
||||
if (e1 == null) return 1;
|
||||
if (e2 == null) return -1;
|
||||
return e1.compareTo(e2);
|
||||
})
|
||||
.next();
|
||||
}
|
||||
|
||||
// ==================== 签到记录管理功能 ====================
|
||||
|
||||
@Override
|
||||
public Flux<SignInRecordVO> getSignInRecords(Long memberId, LocalDate startTime, LocalDate endTime) {
|
||||
LocalDateTime start = startTime.atStartOfDay();
|
||||
LocalDateTime end = endTime.atTime(LocalTime.MAX);
|
||||
|
||||
return signInRecordRepository.findByMemberIdAndTimeRange(memberId, start, end)
|
||||
.map(this::convertToVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<SignInRecordVO> getSignInRecordById(Long id) {
|
||||
return signInRecordRepository.findById(id)
|
||||
.map(this::convertToVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<SignInStatsVO> getSignInStats(Long memberId, LocalDate startTime, LocalDate endTime) {
|
||||
LocalDateTime start = startTime.atStartOfDay();
|
||||
LocalDateTime end = endTime.atTime(LocalTime.MAX);
|
||||
|
||||
return Mono.zip(
|
||||
(Object[] results) -> {
|
||||
Long total = (Long) results[0];
|
||||
Long success = (Long) results[1];
|
||||
LocalDateTime first = (LocalDateTime) results[2];
|
||||
LocalDateTime last = (LocalDateTime) results[3];
|
||||
SignInStatsVO stats = new SignInStatsVO();
|
||||
stats.setTotalCount(total);
|
||||
stats.setSuccessCount(success);
|
||||
stats.setStartDate(startTime);
|
||||
stats.setEndDate(endTime);
|
||||
stats.setFirstSignInTime(first);
|
||||
stats.setLastSignInTime(last);
|
||||
stats.setSuccessRate(total > 0 ? (double) success / total * 100.0 : 0.0);
|
||||
return stats;
|
||||
},
|
||||
signInRecordRepository.countByMemberIdAndTimeRange(memberId, start, end),
|
||||
signInRecordRepository.countSuccessByMemberIdAndTimeRange(memberId, start, end),
|
||||
signInRecordRepository.getFirstSignInTime(memberId, start, end),
|
||||
signInRecordRepository.getLastSignInTime(memberId, start, end)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<byte[]> exportSignInRecords(Long memberId, LocalDate startTime, LocalDate endTime) {
|
||||
LocalDateTime start = startTime.atStartOfDay();
|
||||
LocalDateTime end = endTime.atTime(LocalTime.MAX);
|
||||
|
||||
return signInRecordRepository.findByMemberIdAndTimeRange(memberId, start, end)
|
||||
.map(record -> {
|
||||
String status = "SUCCESS".equals(record.getSignInStatus()) ? "成功" : "失败";
|
||||
String type = "QR_CODE".equals(record.getSignInType()) ? "扫码签到" :
|
||||
"MANUAL".equals(record.getSignInType()) ? "手动签到" : "人脸识别";
|
||||
return String.join(",",
|
||||
record.getId().toString(),
|
||||
record.getMemberId().toString(),
|
||||
record.getMemberCardId() != null ? record.getMemberCardId().toString() : "",
|
||||
record.getSignInTime() != null ? record.getSignInTime().format(DATE_FORMATTER) : "",
|
||||
type,
|
||||
status,
|
||||
record.getFailReason() != null ? record.getFailReason() : ""
|
||||
);
|
||||
})
|
||||
.collectList()
|
||||
.map(rows -> {
|
||||
List<String> csvLines = new java.util.ArrayList<>();
|
||||
csvLines.add("签到记录ID,会员ID,会员卡ID,签到时间,签到方式,签到状态,失败原因");
|
||||
csvLines.addAll(rows);
|
||||
return String.join("\n", csvLines).getBytes(java.nio.charset.StandardCharsets.UTF_8);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<SignInStatsVO> getDailySignInStats(LocalDate date) {
|
||||
LocalDateTime start = date.atStartOfDay();
|
||||
LocalDateTime end = date.atTime(LocalTime.MAX);
|
||||
|
||||
return Mono.zip(
|
||||
(Object[] results) -> {
|
||||
Long total = (Long) results[0];
|
||||
Long success = (Long) results[1];
|
||||
Long members = (Long) results[2];
|
||||
SignInStatsVO stats = new SignInStatsVO();
|
||||
stats.setTotalCount(total);
|
||||
stats.setSuccessCount(success);
|
||||
stats.setStartDate(date);
|
||||
stats.setEndDate(date);
|
||||
stats.setUniqueMemberCount(members);
|
||||
stats.setSuccessRate(total > 0 ? (double) success / total * 100.0 : 0.0);
|
||||
return stats;
|
||||
},
|
||||
signInRecordRepository.countByTimeRange(start, end),
|
||||
signInRecordRepository.countSuccessByTimeRange(start, end),
|
||||
signInRecordRepository.countDistinctMembersByTimeRange(start, end)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换实体到VO
|
||||
*/
|
||||
private SignInRecordVO convertToVO(SignInRecord record) {
|
||||
SignInRecordVO vo = new SignInRecordVO();
|
||||
vo.setId(record.getId());
|
||||
vo.setMemberId(record.getMemberId());
|
||||
vo.setMemberCardId(record.getMemberCardId());
|
||||
vo.setSignInTime(record.getSignInTime());
|
||||
vo.setSignInType(record.getSignInType());
|
||||
vo.setSignInStatus(record.getSignInStatus());
|
||||
vo.setFailReason(record.getFailReason());
|
||||
vo.setSource(record.getSource());
|
||||
vo.setCreatedAt(record.getCreatedAt());
|
||||
return vo;
|
||||
}
|
||||
|
||||
private long getSecondsUntilEndOfDay() {
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
LocalDateTime endOfDay = now.toLocalDate().atTime(23, 59, 59);
|
||||
if (now.isAfter(endOfDay)) return 1;
|
||||
return ChronoUnit.SECONDS.between(now, endOfDay);
|
||||
}
|
||||
}
|
||||
-23
@@ -1,23 +0,0 @@
|
||||
package cn.novalon.gym.manage.checkIn.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class QRCodeVo {
|
||||
|
||||
private String qrCodeBase64;
|
||||
|
||||
private boolean isUsed;
|
||||
|
||||
private String qrContent;
|
||||
|
||||
private Integer width;
|
||||
|
||||
private Integer height;
|
||||
|
||||
private LocalDate createTime;
|
||||
}
|
||||
-66
@@ -1,66 +0,0 @@
|
||||
package cn.novalon.gym.manage.checkIn.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 签到记录VO
|
||||
*
|
||||
* @author 付嘉
|
||||
* @date 2026-06-08
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class SignInRecordVO {
|
||||
|
||||
/**
|
||||
* 签到记录ID
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 会员ID
|
||||
*/
|
||||
private Long memberId;
|
||||
|
||||
/**
|
||||
* 会员卡ID
|
||||
*/
|
||||
private Long memberCardId;
|
||||
|
||||
/**
|
||||
* 签到时间
|
||||
*/
|
||||
private LocalDateTime signInTime;
|
||||
|
||||
/**
|
||||
* 签到类型:QR_CODE-扫码签到,MANUAL-手动签到,FACE-人脸识别
|
||||
*/
|
||||
private String signInType;
|
||||
|
||||
/**
|
||||
* 签到状态:SUCCESS-成功,FAILED-失败
|
||||
*/
|
||||
private String signInStatus;
|
||||
|
||||
/**
|
||||
* 失败原因
|
||||
*/
|
||||
private String failReason;
|
||||
|
||||
/**
|
||||
* 签到来源:MINI_PROGRAM-小程序扫码,PC_BACKEND-后台管理端
|
||||
*/
|
||||
private String source;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createdAt;
|
||||
}
|
||||
-62
@@ -1,62 +0,0 @@
|
||||
package cn.novalon.gym.manage.checkIn.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 签到统计VO
|
||||
*
|
||||
* @author 付嘉
|
||||
* @date 2026-06-08
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class SignInStatsVO {
|
||||
|
||||
/**
|
||||
* 统计开始日期
|
||||
*/
|
||||
private LocalDate startDate;
|
||||
|
||||
/**
|
||||
* 统计结束日期
|
||||
*/
|
||||
private LocalDate endDate;
|
||||
|
||||
/**
|
||||
* 总签到次数
|
||||
*/
|
||||
private Long totalCount;
|
||||
|
||||
/**
|
||||
* 成功签到次数
|
||||
*/
|
||||
private Long successCount;
|
||||
|
||||
/**
|
||||
* 成功率(百分比)
|
||||
*/
|
||||
private Double successRate;
|
||||
|
||||
/**
|
||||
* 独立会员数
|
||||
*/
|
||||
private Long uniqueMemberCount;
|
||||
|
||||
/**
|
||||
* 首次签到时间
|
||||
*/
|
||||
private LocalDateTime firstSignInTime;
|
||||
|
||||
/**
|
||||
* 最后签到时间
|
||||
*/
|
||||
private LocalDateTime lastSignInTime;
|
||||
}
|
||||
-202
@@ -1,202 +0,0 @@
|
||||
package cn.novalon.gym.manage.checkIn.websocket;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.novalon.gym.manage.checkIn.dto.QRCodeDto;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.reactive.socket.WebSocketHandler;
|
||||
import org.springframework.web.reactive.socket.WebSocketSession;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.core.publisher.Sinks;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* WebSocket 处理类,用于实时签到反馈
|
||||
*
|
||||
* 技术要点:
|
||||
* - 使用 Sinks 实现响应式消息推送
|
||||
* - 使用 ConcurrentHashMap 管理 qrContent 与 sink 的映射
|
||||
* - 支持实时推送签到进度和结果
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class MyWebSocketHandler implements WebSocketHandler {
|
||||
|
||||
/**
|
||||
* qrContent -> Sink 映射,用于根据二维码内容找到对应的客户端连接
|
||||
*/
|
||||
private static final Map<String, Sinks.Many<String>> qrContentToSink = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* 连接创建时间映射,用于超时清理
|
||||
*/
|
||||
private static final Map<String, LocalDateTime> qrContentToCreateTime = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* 超时时间(秒),超过此时间未使用的连接将被清理
|
||||
*/
|
||||
private static final long TIMEOUT_SECONDS = 300;
|
||||
|
||||
@Override
|
||||
public Mono<Void> handle(WebSocketSession session) {
|
||||
String sessionId = session.getId();
|
||||
log.info("WebSocket 连接建立,sessionId: {}", sessionId);
|
||||
|
||||
// 创建 sink,用于向客户端发送消息
|
||||
Sinks.Many<String> sink = Sinks.many().unicast().onBackpressureBuffer();
|
||||
|
||||
// 订阅接收客户端消息(异步处理)
|
||||
session.receive()
|
||||
.doOnNext(message -> {
|
||||
String payload = message.getPayloadAsText();
|
||||
log.debug("收到消息:sessionId={}, payload={}", sessionId, payload);
|
||||
|
||||
try {
|
||||
QRCodeDto qrCodeDto = JSONUtil.toBean(payload, QRCodeDto.class);
|
||||
String qrContent = qrCodeDto.getQrContent();
|
||||
|
||||
if (qrContent != null && !qrContent.isEmpty()) {
|
||||
// 绑定 qrContent 和 sink
|
||||
qrContentToSink.put(qrContent, sink);
|
||||
qrContentToCreateTime.put(qrContent, LocalDateTime.now());
|
||||
log.info("绑定成功: qrContent={}, sessionId={}", qrContent, sessionId);
|
||||
|
||||
// 发送连接成功消息
|
||||
sink.tryEmitNext(buildMessage("CONNECTED", "签到监听已建立,请扫描二维码"));
|
||||
} else {
|
||||
sink.tryEmitNext(buildMessage("ERROR", "二维码内容为空"));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("解析消息失败,sessionId={}", sessionId, e);
|
||||
sink.tryEmitNext(buildMessage("ERROR", "消息格式错误: " + e.getMessage()));
|
||||
}
|
||||
})
|
||||
.doOnError(e -> {
|
||||
log.error("接收消息出错,sessionId={}", sessionId, e);
|
||||
})
|
||||
.subscribe(); // 必须订阅,否则不会执行
|
||||
|
||||
// 发送流给客户端
|
||||
return session.send(sink.asFlux().map(session::textMessage))
|
||||
.doFinally(signal -> {
|
||||
// 连接关闭时清理映射
|
||||
qrContentToSink.entrySet().removeIf(entry -> entry.getValue() == sink);
|
||||
qrContentToCreateTime.entrySet().removeIf(entry -> {
|
||||
Sinks.Many<String> s = qrContentToSink.get(entry.getKey());
|
||||
return s == null || s == sink;
|
||||
});
|
||||
log.info("WebSocket 连接关闭,sessionId={}", sessionId);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 向客户端发送消息
|
||||
*
|
||||
* @param qrContent 二维码内容
|
||||
* @param message 消息内容
|
||||
* @return 是否发送成功
|
||||
*/
|
||||
public static boolean sendMessageToClient(String qrContent, String message) {
|
||||
// 先清理超时连接
|
||||
cleanupTimeoutConnections();
|
||||
|
||||
Sinks.Many<String> sink = qrContentToSink.get(qrContent);
|
||||
if (sink == null) {
|
||||
log.warn("未找到绑定的连接,qrContent: {}", qrContent);
|
||||
return false;
|
||||
}
|
||||
|
||||
Sinks.EmitResult result = sink.tryEmitNext(message);
|
||||
if (result.isSuccess()) {
|
||||
log.info("主动推送成功,qrContent: {}, message: {}", qrContent, message);
|
||||
return true;
|
||||
} else {
|
||||
log.warn("推送失败,qrContent: {}, result: {}", qrContent, result);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送签到进度消息
|
||||
*
|
||||
* @param qrContent 二维码内容
|
||||
* @param step 进度步骤
|
||||
* @param message 进度消息
|
||||
*/
|
||||
public static void sendProgress(String qrContent, String step, String message) {
|
||||
String progressMessage = buildMessage("PROGRESS", message);
|
||||
sendMessageToClient(qrContent, progressMessage);
|
||||
log.debug("发送进度消息: qrContent={}, step={}, message={}", qrContent, step, message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送签到成功消息
|
||||
*
|
||||
* @param qrContent 二维码内容
|
||||
* @param memberId 会员ID
|
||||
* @param signInTime 签到时间
|
||||
*/
|
||||
public static void sendSuccess(String qrContent, Long memberId, String signInTime) {
|
||||
String successMessage = buildMessage("SUCCESS", "签到成功!欢迎光临\n会员ID: " + memberId + "\n签到时间: " + signInTime);
|
||||
sendMessageToClient(qrContent, successMessage);
|
||||
log.info("发送成功消息: qrContent={}, memberId={}", qrContent, memberId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送签到失败消息
|
||||
*
|
||||
* @param qrContent 二维码内容
|
||||
* @param reason 失败原因
|
||||
*/
|
||||
public static void sendFailure(String qrContent, String reason) {
|
||||
String failureMessage = buildMessage("FAILURE", "签到失败:" + reason);
|
||||
sendMessageToClient(qrContent, failureMessage);
|
||||
log.warn("发送失败消息: qrContent={}, reason={}", qrContent, reason);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建标准消息格式
|
||||
*
|
||||
* @param type 消息类型
|
||||
* @param content 消息内容
|
||||
* @return 格式化后的消息字符串
|
||||
*/
|
||||
private static String buildMessage(String type, String content) {
|
||||
return JSONUtil.toJsonStr(Map.of(
|
||||
"type", type,
|
||||
"content", content,
|
||||
"timestamp", System.currentTimeMillis()
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理超时连接
|
||||
*/
|
||||
private static void cleanupTimeoutConnections() {
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
qrContentToCreateTime.entrySet().removeIf(entry -> {
|
||||
LocalDateTime createTime = entry.getValue();
|
||||
long secondsDiff = java.time.Duration.between(createTime, now).getSeconds();
|
||||
if (secondsDiff > TIMEOUT_SECONDS) {
|
||||
String qrContent = entry.getKey();
|
||||
qrContentToSink.remove(qrContent);
|
||||
log.debug("清理超时连接: qrContent={}, 超时时间={}秒", qrContent, secondsDiff);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前连接数
|
||||
*
|
||||
* @return 连接数
|
||||
*/
|
||||
public static int getConnectionCount() {
|
||||
cleanupTimeoutConnections();
|
||||
return qrContentToSink.size();
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
# 二维码配置
|
||||
qr:
|
||||
config:
|
||||
width: 300 # 二维码宽度(像素)
|
||||
height: 300 # 二维码高度(像素)
|
||||
margin: 1 # 白边宽度(像素)
|
||||
format: png # 图片格式:png / jpg
|
||||
error-correction: L #容错率:L, M, Q, H,如果启用Logo(logo-enabled: true),必须设置为 H
|
||||
logo-enabled: false # 是否启用Logo(启用时error-correction必须为H)
|
||||
# logo-path: static/logo.png # Logo图片路径(支持相对路径或绝对路径)
|
||||
-281
@@ -1,281 +0,0 @@
|
||||
package cn.novalon.gym.manage.checkin;
|
||||
|
||||
import cn.novalon.gym.manage.checkIn.config.QRCodeConfig;
|
||||
import cn.novalon.gym.manage.checkIn.entity.SignInRecord;
|
||||
import cn.novalon.gym.manage.checkIn.repository.SignInRecordRepository;
|
||||
import cn.novalon.gym.manage.groupcourse.service.IGroupCourseBookingService;
|
||||
import cn.novalon.gym.manage.checkIn.service.impl.CheckServiceImpl;
|
||||
import cn.novalon.gym.manage.checkIn.vo.QRCodeVo;
|
||||
import cn.novalon.gym.manage.checkIn.vo.SignInRecordVO;
|
||||
import cn.novalon.gym.manage.checkIn.vo.SignInStatsVO;
|
||||
import cn.novalon.gym.manage.common.constant.RedisKeyConstants;
|
||||
import cn.novalon.gym.manage.common.util.RedisUtil;
|
||||
import cn.novalon.gym.manage.member.entity.MemberCard;
|
||||
import cn.novalon.gym.manage.member.entity.MemberCardRecord;
|
||||
import cn.novalon.gym.manage.member.repository.MemberCardRecordRepository;
|
||||
import cn.novalon.gym.manage.member.repository.MemberCardRepository;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
* 签到模块接口测试类
|
||||
* 测试模块三(gym-checkIn)的所有接口
|
||||
*/
|
||||
class CheckInModuleTest {
|
||||
|
||||
@Mock
|
||||
private QRCodeConfig qrCodeConfig;
|
||||
|
||||
@Mock
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
@Mock
|
||||
private MemberCardRecordRepository memberCardRecordRepository;
|
||||
|
||||
@Mock
|
||||
private MemberCardRepository memberCardRepository;
|
||||
|
||||
@Mock
|
||||
private SignInRecordRepository signInRecordRepository;
|
||||
|
||||
@Mock
|
||||
private IGroupCourseBookingService groupCourseBookingService;
|
||||
|
||||
@Mock
|
||||
private MemberCard mockMemberCard;
|
||||
|
||||
@Mock
|
||||
private SignInRecord mockSignInRecord;
|
||||
|
||||
@Mock
|
||||
private MemberCardRecord mockMemberCardRecord;
|
||||
|
||||
private CheckServiceImpl checkService;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
MockitoAnnotations.openMocks(this);
|
||||
checkService = new CheckServiceImpl(qrCodeConfig, redisUtil, memberCardRecordRepository,
|
||||
memberCardRepository, signInRecordRepository, groupCourseBookingService);
|
||||
|
||||
when(mockMemberCard.getId()).thenReturn(1L);
|
||||
when(mockMemberCard.getMemberCardType()).thenReturn("TIME_CARD");
|
||||
|
||||
when(mockSignInRecord.getId()).thenReturn(1L);
|
||||
when(mockSignInRecord.getMemberId()).thenReturn(1L);
|
||||
when(mockSignInRecord.getMemberCardId()).thenReturn(1L);
|
||||
when(mockSignInRecord.getSignInTime()).thenReturn(LocalDateTime.now());
|
||||
when(mockSignInRecord.getSignInType()).thenReturn("QR_CODE");
|
||||
when(mockSignInRecord.getSignInStatus()).thenReturn("SUCCESS");
|
||||
when(mockSignInRecord.getSource()).thenReturn("MINI_PROGRAM");
|
||||
|
||||
when(mockMemberCardRecord.getMemberCardRecordId()).thenReturn(1L);
|
||||
when(mockMemberCardRecord.getMemberCardId()).thenReturn(1L);
|
||||
when(mockMemberCardRecord.getRemainingTimes()).thenReturn(10);
|
||||
when(mockMemberCardRecord.getRemainingAmount()).thenReturn(100.0);
|
||||
when(mockMemberCardRecord.getExpireTime()).thenReturn(LocalDateTime.now().plusDays(30));
|
||||
when(mockMemberCardRecord.getStatus()).thenReturn(cn.novalon.gym.manage.member.enums.MemberCardRecordStatus.ACTIVE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("测试1: 获取二维码 - getQRCode")
|
||||
void testGetQRCode() {
|
||||
when(memberCardRecordRepository.findActiveCardsByMemberId(1L))
|
||||
.thenReturn(Flux.just(mockMemberCardRecord));
|
||||
when(redisUtil.setWithExpire(any(String.class), any(Map.class), any(Long.class)))
|
||||
.thenReturn(Mono.just(true));
|
||||
|
||||
Mono<QRCodeVo> result = checkService.getQRCode(1L);
|
||||
|
||||
StepVerifier.create(result)
|
||||
.expectNextMatches(qrCodeVo -> {
|
||||
org.junit.jupiter.api.Assertions.assertNotNull(qrCodeVo);
|
||||
org.junit.jupiter.api.Assertions.assertNotNull(qrCodeVo.getQrContent());
|
||||
return true;
|
||||
})
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("测试2: 签到 - checkIn")
|
||||
void testCheckIn() {
|
||||
Long memberId = 1L;
|
||||
Map<String, Object> qrData = new HashMap<>();
|
||||
qrData.put("qrContent", "test-qr-content");
|
||||
qrData.put("memberId", memberId);
|
||||
qrData.put("memberCardRecordId", 1L);
|
||||
qrData.put("isUsed", false);
|
||||
qrData.put("expireTime", System.currentTimeMillis() + 3600000);
|
||||
|
||||
String key = RedisKeyConstants.QRCODE_USER_DAILY + memberId + LocalDate.now();
|
||||
|
||||
when(redisUtil.get(eq(key))).thenReturn(Mono.just(qrData));
|
||||
when(memberCardRecordRepository.findById(1L)).thenReturn(Mono.just(mockMemberCardRecord));
|
||||
when(memberCardRepository.findByMemberCardIdAndDeletedAtIsNull(1L)).thenReturn(Mono.just(mockMemberCard));
|
||||
when(signInRecordRepository.save(any(SignInRecord.class))).thenReturn(Mono.just(mockSignInRecord));
|
||||
when(redisUtil.set(any(String.class), any(Map.class))).thenReturn(Mono.just(true));
|
||||
when(groupCourseBookingService.getBookingsByMemberId(memberId)).thenReturn(Flux.empty());
|
||||
when(signInRecordRepository.findByMemberIdAndDate(eq(memberId), any(LocalDateTime.class), any(LocalDateTime.class)))
|
||||
.thenReturn(Mono.empty());
|
||||
|
||||
Mono<String> result = checkService.checkIn(memberId, "test-qr-content");
|
||||
|
||||
StepVerifier.create(result)
|
||||
.expectNextMatches(response -> response.contains("签到成功"))
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("测试3: 查询签到记录列表 - getSignInRecords")
|
||||
void testGetSignInRecords() {
|
||||
when(signInRecordRepository.findByMemberIdAndTimeRange(
|
||||
eq(1L), any(LocalDateTime.class), any(LocalDateTime.class)))
|
||||
.thenReturn(Flux.just(mockSignInRecord));
|
||||
|
||||
Flux<SignInRecordVO> result = checkService.getSignInRecords(1L,
|
||||
LocalDate.now().minusDays(30), LocalDate.now());
|
||||
|
||||
StepVerifier.create(result)
|
||||
.expectNextCount(1)
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("测试4: 查询单条签到记录 - getSignInRecordById")
|
||||
void testGetSignInRecordById() {
|
||||
when(signInRecordRepository.findById(1L))
|
||||
.thenReturn(Mono.just(mockSignInRecord));
|
||||
|
||||
Mono<SignInRecordVO> result = checkService.getSignInRecordById(1L);
|
||||
|
||||
StepVerifier.create(result)
|
||||
.expectNextMatches(vo -> vo.getId() == 1L)
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("测试5: 查询签到记录 - 记录不存在")
|
||||
void testGetSignInRecordById_NotFound() {
|
||||
when(signInRecordRepository.findById(999L))
|
||||
.thenReturn(Mono.empty());
|
||||
|
||||
Mono<SignInRecordVO> result = checkService.getSignInRecordById(999L);
|
||||
|
||||
StepVerifier.create(result)
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("测试6: 获取签到统计 - getSignInStats")
|
||||
void testGetSignInStats() {
|
||||
when(signInRecordRepository.countByMemberIdAndTimeRange(
|
||||
eq(1L), any(LocalDateTime.class), any(LocalDateTime.class)))
|
||||
.thenReturn(Mono.just(10L));
|
||||
when(signInRecordRepository.countSuccessByMemberIdAndTimeRange(
|
||||
eq(1L), any(LocalDateTime.class), any(LocalDateTime.class)))
|
||||
.thenReturn(Mono.just(8L));
|
||||
when(signInRecordRepository.getFirstSignInTime(
|
||||
eq(1L), any(LocalDateTime.class), any(LocalDateTime.class)))
|
||||
.thenReturn(Mono.just(LocalDateTime.now().minusDays(29)));
|
||||
when(signInRecordRepository.getLastSignInTime(
|
||||
eq(1L), any(LocalDateTime.class), any(LocalDateTime.class)))
|
||||
.thenReturn(Mono.just(LocalDateTime.now()));
|
||||
|
||||
Mono<SignInStatsVO> result = checkService.getSignInStats(1L,
|
||||
LocalDate.now().minusDays(30), LocalDate.now());
|
||||
|
||||
StepVerifier.create(result)
|
||||
.expectNextMatches(stats -> {
|
||||
org.junit.jupiter.api.Assertions.assertEquals(10L, stats.getTotalCount());
|
||||
org.junit.jupiter.api.Assertions.assertEquals(8L, stats.getSuccessCount());
|
||||
return true;
|
||||
})
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("测试7: 获取每日签到统计 - getDailySignInStats")
|
||||
void testGetDailySignInStats() {
|
||||
when(signInRecordRepository.countByTimeRange(any(LocalDateTime.class), any(LocalDateTime.class)))
|
||||
.thenReturn(Mono.just(50L));
|
||||
when(signInRecordRepository.countSuccessByTimeRange(
|
||||
any(LocalDateTime.class), any(LocalDateTime.class)))
|
||||
.thenReturn(Mono.just(45L));
|
||||
when(signInRecordRepository.countDistinctMembersByTimeRange(
|
||||
any(LocalDateTime.class), any(LocalDateTime.class)))
|
||||
.thenReturn(Mono.just(30L));
|
||||
|
||||
Mono<SignInStatsVO> result = checkService.getDailySignInStats(LocalDate.now());
|
||||
|
||||
StepVerifier.create(result)
|
||||
.expectNextMatches(stats -> {
|
||||
org.junit.jupiter.api.Assertions.assertEquals(50L, stats.getTotalCount());
|
||||
org.junit.jupiter.api.Assertions.assertEquals(45L, stats.getSuccessCount());
|
||||
org.junit.jupiter.api.Assertions.assertEquals(30L, stats.getUniqueMemberCount());
|
||||
return true;
|
||||
})
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("测试8: 导出签到记录 - exportSignInRecords")
|
||||
void testExportSignInRecords() {
|
||||
when(signInRecordRepository.findByMemberIdAndTimeRange(
|
||||
eq(1L), any(LocalDateTime.class), any(LocalDateTime.class)))
|
||||
.thenReturn(Flux.just(mockSignInRecord));
|
||||
|
||||
Mono<byte[]> result = checkService.exportSignInRecords(1L,
|
||||
LocalDate.now().minusDays(7), LocalDate.now());
|
||||
|
||||
StepVerifier.create(result)
|
||||
.expectNextMatches(bytes -> bytes.length > 0)
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("测试9: 签到失败 - 二维码无效")
|
||||
void testCheckIn_QRCodeInvalid() {
|
||||
Long memberId = 1L;
|
||||
String key = RedisKeyConstants.QRCODE_USER_DAILY + memberId + LocalDate.now();
|
||||
when(redisUtil.get(eq(key))).thenReturn(Mono.just(new HashMap<>()));
|
||||
when(signInRecordRepository.findByMemberIdAndDate(eq(memberId), any(LocalDateTime.class), any(LocalDateTime.class)))
|
||||
.thenReturn(Mono.empty());
|
||||
|
||||
Mono<String> result = checkService.checkIn(memberId, "invalid-qr");
|
||||
|
||||
StepVerifier.create(result)
|
||||
.expectError(RuntimeException.class)
|
||||
.verify();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("测试10: 签到失败 - 二维码不存在")
|
||||
void testCheckIn_QRCodeNotFound() {
|
||||
Long memberId = 1L;
|
||||
String key = RedisKeyConstants.QRCODE_USER_DAILY + memberId + LocalDate.now();
|
||||
when(redisUtil.get(eq(key))).thenReturn(Mono.empty());
|
||||
when(signInRecordRepository.findByMemberIdAndDate(eq(memberId), any(LocalDateTime.class), any(LocalDateTime.class)))
|
||||
.thenReturn(Mono.empty());
|
||||
|
||||
Mono<String> result = checkService.checkIn(memberId, "not-exist");
|
||||
|
||||
StepVerifier.create(result)
|
||||
.verifyComplete();
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
# Test Configuration
|
||||
@@ -1,33 +0,0 @@
|
||||
HELP.md
|
||||
target/
|
||||
.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### STS ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
@@ -12,89 +12,81 @@
|
||||
<artifactId>gym-dataCount</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<name>gym-dataCount</name>
|
||||
<description>Data Statistics Module for Gym Management</description>
|
||||
|
||||
<description>Data Statistics Module</description>
|
||||
<url/>
|
||||
<licenses>
|
||||
<license/>
|
||||
</licenses>
|
||||
<developers>
|
||||
<developer/>
|
||||
</developers>
|
||||
<scm>
|
||||
<connection/>
|
||||
<developerConnection/>
|
||||
<tag/>
|
||||
<url/>
|
||||
</scm>
|
||||
<properties>
|
||||
<java.version>21</java.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<!-- Common模块 -->
|
||||
<dependency>
|
||||
<groupId>cn.novalon.gym.manage</groupId>
|
||||
<artifactId>manage-common</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 数据库模块 -->
|
||||
<dependency>
|
||||
<groupId>cn.novalon.gym.manage</groupId>
|
||||
<artifactId>manage-db</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- WebFlux -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-webflux</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- R2dbc -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-r2dbc</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-validation</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springdoc</groupId>
|
||||
<artifactId>springdoc-openapi-starter-webflux-ui</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.swagger.core.v3</groupId>
|
||||
<artifactId>swagger-annotations-jakarta</artifactId>
|
||||
<version>2.2.43</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Redis -->
|
||||
<!-- Redis依赖-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Validation -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-validation</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Swagger -->
|
||||
<dependency>
|
||||
<groupId>org.springdoc</groupId>
|
||||
<artifactId>springdoc-openapi-starter-webflux-ui</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- POI for Excel export -->
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
<version>5.2.5</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Gym Modules -->
|
||||
<!-- 会员模块依赖 -->
|
||||
<dependency>
|
||||
<groupId>cn.novalon.gym.manage</groupId>
|
||||
<artifactId>gym-member</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 团课模块依赖 -->
|
||||
<dependency>
|
||||
<groupId>cn.novalon.gym.manage</groupId>
|
||||
<artifactId>gym-groupCourse</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.novalon.gym.manage</groupId>
|
||||
<artifactId>gym-checkIn</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Test -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
@@ -105,4 +97,5 @@
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
package cn.novalon.gym.manage.datacount;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.security.reactive.ReactiveUserDetailsServiceAutoConfiguration;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.data.r2dbc.repository.config.EnableR2dbcRepositories;
|
||||
|
||||
@SpringBootApplication(scanBasePackages = "cn.novalon.gym.manage", exclude = {
|
||||
ReactiveUserDetailsServiceAutoConfiguration.class })
|
||||
@EnableR2dbcRepositories(basePackages = {
|
||||
"cn.novalon.gym.manage.db.dao",
|
||||
"cn.novalon.gym.manage.member.repository",
|
||||
"cn.novalon.gym.manage.groupcourse.dao",
|
||||
"cn.novalon.gym.manage.datacount.dao"
|
||||
})
|
||||
@ComponentScan(basePackages = "cn.novalon.gym.manage")
|
||||
public class GymDataCountApplication {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(GymDataCountApplication.class);
|
||||
|
||||
public static void main(String[] args) {
|
||||
logger.info("数据统计模块启动中...");
|
||||
SpringApplication.run(GymDataCountApplication.class, args);
|
||||
logger.info("数据统计模块启动完成");
|
||||
}
|
||||
}
|
||||
-15
@@ -1,15 +0,0 @@
|
||||
package cn.novalon.gym.manage.datacount.config;
|
||||
|
||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
|
||||
/**
|
||||
* 数据统计模块自动配置
|
||||
*
|
||||
* @author system
|
||||
* @date 2026-06-09
|
||||
*/
|
||||
@AutoConfiguration
|
||||
@ComponentScan(basePackages = "cn.novalon.gym.manage.datacount")
|
||||
public class DataCountAutoConfiguration {
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
package cn.novalon.gym.manage.datacount.config;
|
||||
|
||||
import cn.novalon.gym.manage.datacount.handler.DataCountHandler;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.reactive.function.server.RouterFunction;
|
||||
import org.springframework.web.reactive.function.server.ServerResponse;
|
||||
|
||||
import static org.springframework.web.reactive.function.server.RouterFunctions.route;
|
||||
|
||||
@Configuration
|
||||
public class DataCountRouter {
|
||||
|
||||
@Bean
|
||||
public RouterFunction<ServerResponse> dataCountRoutes(DataCountHandler dataCountHandler) {
|
||||
return route()
|
||||
// ========== 会员数据统计路由 ==========
|
||||
.GET("/api/stats/member/date/{date}", dataCountHandler::getMemberStatisticsByDate)
|
||||
.GET("/api/stats/member/range", dataCountHandler::getMemberStatisticsByDateRange)
|
||||
.GET("/api/stats/member/summary", dataCountHandler::getMemberStatisticsSummary)
|
||||
|
||||
// ========== 预约数据统计路由 ==========
|
||||
.GET("/api/stats/booking/date/{date}", dataCountHandler::getBookingStatisticsByDate)
|
||||
.GET("/api/stats/booking/range", dataCountHandler::getBookingStatisticsByDateRange)
|
||||
.GET("/api/stats/booking/summary", dataCountHandler::getBookingStatisticsSummary)
|
||||
|
||||
// ========== 数据导出路由 ==========
|
||||
.GET("/api/stats/export/member", dataCountHandler::exportMemberStatistics)
|
||||
.GET("/api/stats/export/booking", dataCountHandler::exportBookingStatistics)
|
||||
.GET("/api/stats/export/all", dataCountHandler::exportAllStatistics)
|
||||
|
||||
.build();
|
||||
}
|
||||
}
|
||||
-183
@@ -1,183 +0,0 @@
|
||||
package cn.novalon.gym.manage.datacount.dao;
|
||||
|
||||
import org.springframework.r2dbc.core.DatabaseClient;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 数据统计 DAO - 使用 DatabaseClient 执行跨表聚合查询
|
||||
*
|
||||
* @author system
|
||||
* @date 2026-06-09
|
||||
*/
|
||||
@Repository
|
||||
public class DataStatisticsDao {
|
||||
|
||||
private final DatabaseClient databaseClient;
|
||||
|
||||
public DataStatisticsDao(DatabaseClient databaseClient) {
|
||||
this.databaseClient = databaseClient;
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计指定时间范围内新增会员数
|
||||
*/
|
||||
public Mono<Long> countNewMembers(LocalDateTime startTime, LocalDateTime endTime) {
|
||||
return databaseClient.sql("SELECT COUNT(*) FROM member_user WHERE created_at >= :startTime AND created_at < :endTime AND is_deleted = false")
|
||||
.bind("startTime", startTime)
|
||||
.bind("endTime", endTime)
|
||||
.map(row -> row.get(0, Long.class))
|
||||
.one();
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计总会员数
|
||||
*/
|
||||
public Mono<Long> countTotalMembers() {
|
||||
return databaseClient.sql("SELECT COUNT(*) FROM member_user WHERE is_deleted = false")
|
||||
.map(row -> row.get(0, Long.class))
|
||||
.one();
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计指定时间范围内的签到次数
|
||||
*/
|
||||
public Mono<Long> countSignIns(LocalDateTime startTime, LocalDateTime endTime) {
|
||||
return databaseClient.sql("SELECT COUNT(*) FROM sign_in_record WHERE sign_in_time >= :startTime AND sign_in_time < :endTime AND is_delete = false")
|
||||
.bind("startTime", startTime)
|
||||
.bind("endTime", endTime)
|
||||
.map(row -> row.get(0, Long.class))
|
||||
.one();
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计指定时间范围内的成功签到次数
|
||||
*/
|
||||
public Mono<Long> countSuccessSignIns(LocalDateTime startTime, LocalDateTime endTime) {
|
||||
return databaseClient.sql("SELECT COUNT(*) FROM sign_in_record WHERE sign_in_time >= :startTime AND sign_in_time < :endTime AND sign_in_status = 'SUCCESS' AND is_delete = false")
|
||||
.bind("startTime", startTime)
|
||||
.bind("endTime", endTime)
|
||||
.map(row -> row.get(0, Long.class))
|
||||
.one();
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计指定时间范围内签到的独立会员数
|
||||
*/
|
||||
public Mono<Long> countDistinctSignInMembers(LocalDateTime startTime, LocalDateTime endTime) {
|
||||
return databaseClient.sql("SELECT COUNT(DISTINCT member_id) FROM sign_in_record WHERE sign_in_time >= :startTime AND sign_in_time < :endTime AND is_delete = false")
|
||||
.bind("startTime", startTime)
|
||||
.bind("endTime", endTime)
|
||||
.map(row -> row.get(0, Long.class))
|
||||
.one();
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计指定时间范围内的预约数
|
||||
*/
|
||||
public Mono<Long> countBookings(LocalDateTime startTime, LocalDateTime endTime) {
|
||||
return databaseClient.sql("SELECT COUNT(*) FROM group_course_booking WHERE booking_time >= :startTime AND booking_time < :endTime AND deleted_at IS NULL")
|
||||
.bind("startTime", startTime)
|
||||
.bind("endTime", endTime)
|
||||
.map(row -> row.get(0, Long.class))
|
||||
.one();
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计指定时间范围内的取消预约数
|
||||
*/
|
||||
public Mono<Long> countCancelBookings(LocalDateTime startTime, LocalDateTime endTime) {
|
||||
return databaseClient.sql("SELECT COUNT(*) FROM group_course_booking WHERE booking_time >= :startTime AND booking_time < :endTime AND status = '1' AND deleted_at IS NULL")
|
||||
.bind("startTime", startTime)
|
||||
.bind("endTime", endTime)
|
||||
.map(row -> row.get(0, Long.class))
|
||||
.one();
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计指定时间范围内的出席预约数
|
||||
*/
|
||||
public Mono<Long> countAttendBookings(LocalDateTime startTime, LocalDateTime endTime) {
|
||||
return databaseClient.sql("SELECT COUNT(*) FROM group_course_booking WHERE booking_time >= :startTime AND booking_time < :endTime AND status = '2' AND deleted_at IS NULL")
|
||||
.bind("startTime", startTime)
|
||||
.bind("endTime", endTime)
|
||||
.map(row -> row.get(0, Long.class))
|
||||
.one();
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计指定时间范围内的缺席预约数
|
||||
*/
|
||||
public Mono<Long> countAbsentBookings(LocalDateTime startTime, LocalDateTime endTime) {
|
||||
return databaseClient.sql("SELECT COUNT(*) FROM group_course_booking WHERE booking_time >= :startTime AND booking_time < :endTime AND status = '3' AND deleted_at IS NULL")
|
||||
.bind("startTime", startTime)
|
||||
.bind("endTime", endTime)
|
||||
.map(row -> row.get(0, Long.class))
|
||||
.one();
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计指定时间范围内有预约的独立会员数
|
||||
*/
|
||||
public Mono<Long> countDistinctBookingMembers(LocalDateTime startTime, LocalDateTime endTime) {
|
||||
return databaseClient.sql("SELECT COUNT(DISTINCT member_id) FROM group_course_booking WHERE booking_time >= :startTime AND booking_time < :endTime AND deleted_at IS NULL")
|
||||
.bind("startTime", startTime)
|
||||
.bind("endTime", endTime)
|
||||
.map(row -> row.get(0, Long.class))
|
||||
.one();
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计指定时间范围内取消预约的独立会员数
|
||||
*/
|
||||
public Mono<Long> countDistinctCancelMembers(LocalDateTime startTime, LocalDateTime endTime) {
|
||||
return databaseClient.sql("SELECT COUNT(DISTINCT member_id) FROM group_course_booking WHERE booking_time >= :startTime AND booking_time < :endTime AND status = '1' AND deleted_at IS NULL")
|
||||
.bind("startTime", startTime)
|
||||
.bind("endTime", endTime)
|
||||
.map(row -> row.get(0, Long.class))
|
||||
.one();
|
||||
}
|
||||
|
||||
/**
|
||||
* 按签到类型统计次数
|
||||
*/
|
||||
public Flux<SignInTypeCount> countSignInsByType(LocalDateTime startTime, LocalDateTime endTime) {
|
||||
return databaseClient.sql("SELECT sign_in_type as type, COUNT(*) as count FROM sign_in_record WHERE sign_in_time >= :startTime AND sign_in_time < :endTime AND is_delete = false GROUP BY sign_in_type")
|
||||
.bind("startTime", startTime)
|
||||
.bind("endTime", endTime)
|
||||
.map(row -> {
|
||||
SignInTypeCount result = new SignInTypeCount();
|
||||
result.setType(row.get("type", String.class));
|
||||
result.setCount(row.get("count", Long.class));
|
||||
return result;
|
||||
})
|
||||
.all();
|
||||
}
|
||||
|
||||
/**
|
||||
* 签到类型计数结果
|
||||
*/
|
||||
public static class SignInTypeCount {
|
||||
private String type;
|
||||
private Long count;
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public Long getCount() {
|
||||
return count;
|
||||
}
|
||||
|
||||
public void setCount(Long count) {
|
||||
this.count = count;
|
||||
}
|
||||
}
|
||||
}
|
||||
+175
@@ -0,0 +1,175 @@
|
||||
package cn.novalon.gym.manage.datacount.dao;
|
||||
|
||||
import org.springframework.data.r2dbc.core.R2dbcEntityTemplate;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 统计数据访问层
|
||||
* 使用 R2dbcEntityTemplate 执行原生SQL查询
|
||||
*
|
||||
* @author 数据统计模块
|
||||
* @date 2026-06-06
|
||||
*/
|
||||
@Repository
|
||||
public class StatisticsDao {
|
||||
|
||||
private final R2dbcEntityTemplate r2dbcEntityTemplate;
|
||||
|
||||
public StatisticsDao(R2dbcEntityTemplate r2dbcEntityTemplate) {
|
||||
this.r2dbcEntityTemplate = r2dbcEntityTemplate;
|
||||
}
|
||||
|
||||
// ========== 会员数据统计 ==========
|
||||
|
||||
public Mono<Integer> countTotalMembers() {
|
||||
String sql = "SELECT COUNT(*) FROM member_user WHERE is_deleted = FALSE";
|
||||
return r2dbcEntityTemplate.getDatabaseClient()
|
||||
.sql(sql)
|
||||
.map(row -> row.get(0, Integer.class))
|
||||
.one();
|
||||
}
|
||||
|
||||
public Mono<Integer> countNewMembersByDate(LocalDate date) {
|
||||
String sql = "SELECT COUNT(*) FROM member_user WHERE is_deleted = FALSE AND DATE(created_at) = $1";
|
||||
return r2dbcEntityTemplate.getDatabaseClient()
|
||||
.sql(sql)
|
||||
.bind(0, date)
|
||||
.map(row -> row.get(0, Integer.class))
|
||||
.one();
|
||||
}
|
||||
|
||||
public Mono<Integer> countActiveMembersByDate(LocalDate date) {
|
||||
String sql = "SELECT COUNT(DISTINCT m.id) FROM member_user m LEFT JOIN member_card_record r ON m.id = r.member_id WHERE m.is_deleted = FALSE AND r.deleted_at IS NULL AND DATE(r.created_at) = $1";
|
||||
return r2dbcEntityTemplate.getDatabaseClient()
|
||||
.sql(sql)
|
||||
.bind(0, date)
|
||||
.map(row -> row.get(0, Integer.class))
|
||||
.one();
|
||||
}
|
||||
|
||||
public Mono<Integer> countMaleMembers() {
|
||||
String sql = "SELECT COUNT(*) FROM member_user WHERE is_deleted = FALSE AND gender = 1";
|
||||
return r2dbcEntityTemplate.getDatabaseClient()
|
||||
.sql(sql)
|
||||
.map(row -> row.get(0, Integer.class))
|
||||
.one();
|
||||
}
|
||||
|
||||
public Mono<Integer> countFemaleMembers() {
|
||||
String sql = "SELECT COUNT(*) FROM member_user WHERE is_deleted = FALSE AND gender = 2";
|
||||
return r2dbcEntityTemplate.getDatabaseClient()
|
||||
.sql(sql)
|
||||
.map(row -> row.get(0, Integer.class))
|
||||
.one();
|
||||
}
|
||||
|
||||
public Mono<Integer> countCardPurchaseByDate(LocalDate date) {
|
||||
String sql = "SELECT COUNT(DISTINCT r.member_id) FROM member_card_record r WHERE r.deleted_at IS NULL AND DATE(r.created_at) = $1";
|
||||
return r2dbcEntityTemplate.getDatabaseClient()
|
||||
.sql(sql)
|
||||
.bind(0, date)
|
||||
.map(row -> row.get(0, Integer.class))
|
||||
.one();
|
||||
}
|
||||
|
||||
public Mono<Double> calculateAverageAge() {
|
||||
String sql = "SELECT AVG(EXTRACT(YEAR FROM AGE(CURRENT_DATE, birthday))) FROM member_user WHERE is_deleted = FALSE AND birthday IS NOT NULL";
|
||||
return r2dbcEntityTemplate.getDatabaseClient()
|
||||
.sql(sql)
|
||||
.map(row -> row.get(0, Double.class))
|
||||
.one();
|
||||
}
|
||||
|
||||
public Mono<Integer> countActiveMembersByTimeRange(LocalDateTime startTime, LocalDateTime endTime) {
|
||||
String sql = "SELECT COUNT(*) FROM member_user WHERE is_deleted = FALSE AND last_login_at >= $1 AND last_login_at < $2";
|
||||
return r2dbcEntityTemplate.getDatabaseClient()
|
||||
.sql(sql)
|
||||
.bind(0, startTime)
|
||||
.bind(1, endTime)
|
||||
.map(row -> row.get(0, Integer.class))
|
||||
.one();
|
||||
}
|
||||
|
||||
// ========== 预约数据统计 ==========
|
||||
|
||||
public Mono<Integer> countTotalBookingsByDate(LocalDate date) {
|
||||
String sql = "SELECT COUNT(*) FROM group_course_booking WHERE deleted_at IS NULL AND DATE(created_at) = $1";
|
||||
return r2dbcEntityTemplate.getDatabaseClient()
|
||||
.sql(sql)
|
||||
.bind(0, date)
|
||||
.map(row -> row.get(0, Integer.class))
|
||||
.one();
|
||||
}
|
||||
|
||||
public Mono<Integer> countCancelledBookingsByDate(LocalDate date) {
|
||||
String sql = "SELECT COUNT(*) FROM group_course_booking WHERE deleted_at IS NULL AND status = '1' AND DATE(cancel_time) = $1";
|
||||
return r2dbcEntityTemplate.getDatabaseClient()
|
||||
.sql(sql)
|
||||
.bind(0, date)
|
||||
.map(row -> row.get(0, Integer.class))
|
||||
.one();
|
||||
}
|
||||
|
||||
public Mono<Integer> countAttendedBookingsByDate(LocalDate date) {
|
||||
String sql = "SELECT COUNT(*) FROM group_course_booking WHERE deleted_at IS NULL AND status = '2' AND DATE(created_at) = $1";
|
||||
return r2dbcEntityTemplate.getDatabaseClient()
|
||||
.sql(sql)
|
||||
.bind(0, date)
|
||||
.map(row -> row.get(0, Integer.class))
|
||||
.one();
|
||||
}
|
||||
|
||||
public Mono<Integer> countTotalCoursesByDate(LocalDate date) {
|
||||
String sql = "SELECT COUNT(*) FROM group_course WHERE deleted_at IS NULL AND DATE(start_time) = $1";
|
||||
return r2dbcEntityTemplate.getDatabaseClient()
|
||||
.sql(sql)
|
||||
.bind(0, date)
|
||||
.map(row -> row.get(0, Integer.class))
|
||||
.one();
|
||||
}
|
||||
|
||||
public Mono<Integer> countFullCoursesByDate(LocalDate date) {
|
||||
String sql = "SELECT COUNT(*) FROM group_course WHERE deleted_at IS NULL AND current_members = max_members AND DATE(start_time) = $1";
|
||||
return r2dbcEntityTemplate.getDatabaseClient()
|
||||
.sql(sql)
|
||||
.bind(0, date)
|
||||
.map(row -> row.get(0, Integer.class))
|
||||
.one();
|
||||
}
|
||||
|
||||
public Mono<Object[]> findMostPopularCourseByDate(LocalDate date) {
|
||||
String sql = "SELECT c.course_name, COUNT(b.id) as booking_count FROM group_course_booking b LEFT JOIN group_course c ON b.course_id = c.id WHERE b.deleted_at IS NULL AND c.deleted_at IS NULL AND DATE(b.created_at) = $1 GROUP BY c.id, c.course_name ORDER BY booking_count DESC LIMIT 1";
|
||||
return r2dbcEntityTemplate.getDatabaseClient()
|
||||
.sql(sql)
|
||||
.bind(0, date)
|
||||
.map(row -> new Object[]{row.get(0, String.class), row.get(1, Integer.class)})
|
||||
.one();
|
||||
}
|
||||
|
||||
// ========== 日期范围查询 ==========
|
||||
|
||||
public Flux<Object[]> findMemberStatisticsByDateRange(LocalDate startDate, LocalDate endDate) {
|
||||
String sql = "SELECT DATE(m.created_at) as date, COUNT(*) as new_members FROM member_user m WHERE m.is_deleted = FALSE AND DATE(m.created_at) BETWEEN $1 AND $2 GROUP BY DATE(m.created_at) ORDER BY date";
|
||||
return r2dbcEntityTemplate.getDatabaseClient()
|
||||
.sql(sql)
|
||||
.bind(0, startDate)
|
||||
.bind(1, endDate)
|
||||
.map(row -> new Object[]{row.get(0, LocalDate.class), row.get(1, Integer.class)})
|
||||
.all();
|
||||
}
|
||||
|
||||
public Flux<Object[]> findBookingStatisticsByDateRange(LocalDate startDate, LocalDate endDate) {
|
||||
String sql = "SELECT DATE(b.created_at) as date, COUNT(*) as total_bookings, SUM(CASE WHEN b.status = '1' THEN 1 ELSE 0 END) as cancelled_bookings, SUM(CASE WHEN b.status = '2' THEN 1 ELSE 0 END) as attended_bookings FROM group_course_booking b WHERE b.deleted_at IS NULL AND DATE(b.created_at) BETWEEN $1 AND $2 GROUP BY DATE(b.created_at) ORDER BY date";
|
||||
return r2dbcEntityTemplate.getDatabaseClient()
|
||||
.sql(sql)
|
||||
.bind(0, startDate)
|
||||
.bind(1, endDate)
|
||||
.map(row -> new Object[]{row.get(0, LocalDate.class), row.get(1, Integer.class), row.get(2, Integer.class), row.get(3, Integer.class)})
|
||||
.all();
|
||||
}
|
||||
}
|
||||
+154
-49
@@ -1,64 +1,169 @@
|
||||
package cn.novalon.gym.manage.datacount.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
/**
|
||||
* 预约数据统计结果
|
||||
*
|
||||
* @author system
|
||||
* @date 2026-06-09
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
import java.time.LocalDate;
|
||||
|
||||
@Schema(description = "预约数据统计")
|
||||
public class BookingStatistics {
|
||||
|
||||
/**
|
||||
* 统计日期
|
||||
*/
|
||||
private String statDate;
|
||||
@Schema(description = "统计日期", example = "2026-01-01")
|
||||
private LocalDate date;
|
||||
|
||||
/**
|
||||
* 新增预约数
|
||||
*/
|
||||
private Long newBookings;
|
||||
@Schema(description = "预约总数", example = "100")
|
||||
private Integer totalBookings;
|
||||
|
||||
/**
|
||||
* 取消预约数
|
||||
*/
|
||||
private Long cancelBookings;
|
||||
@Schema(description = "取消预约数", example = "10")
|
||||
private Integer cancelledBookings;
|
||||
|
||||
/**
|
||||
* 出席预约数
|
||||
*/
|
||||
private Long attendBookings;
|
||||
@Schema(description = "实际到场数", example = "85")
|
||||
private Integer attendedBookings;
|
||||
|
||||
/**
|
||||
* 缺席预约数
|
||||
*/
|
||||
private Long absentBookings;
|
||||
@Schema(description = "预约成功率", example = "0.85")
|
||||
private Double bookingSuccessRate;
|
||||
|
||||
/**
|
||||
* 预约出席率
|
||||
*/
|
||||
@Schema(description = "取消率", example = "0.10")
|
||||
private Double cancellationRate;
|
||||
|
||||
@Schema(description = "到场率", example = "0.85")
|
||||
private Double attendanceRate;
|
||||
|
||||
/**
|
||||
* 取消率
|
||||
*/
|
||||
private Double cancelRate;
|
||||
@Schema(description = "热门课程名称", example = "动感单车")
|
||||
private String popularCourseName;
|
||||
|
||||
/**
|
||||
* 预约人数(独立会员数)
|
||||
*/
|
||||
private Long bookingMembers;
|
||||
@Schema(description = "热门课程预约数", example = "25")
|
||||
private Integer popularCourseCount;
|
||||
|
||||
/**
|
||||
* 取消人数(独立会员数)
|
||||
*/
|
||||
private Long cancelMembers;
|
||||
@Schema(description = "团课总数", example = "20")
|
||||
private Integer totalCourses;
|
||||
|
||||
@Schema(description = "满员课程数", example = "5")
|
||||
private Integer fullCourses;
|
||||
|
||||
@Schema(description = "开始日期(用于汇总统计)")
|
||||
private LocalDate startDate;
|
||||
|
||||
@Schema(description = "结束日期(用于汇总统计)")
|
||||
private LocalDate endDate;
|
||||
|
||||
public BookingStatistics() {
|
||||
}
|
||||
|
||||
public BookingStatistics(LocalDate date) {
|
||||
this.date = date;
|
||||
this.totalBookings = 0;
|
||||
this.cancelledBookings = 0;
|
||||
this.attendedBookings = 0;
|
||||
this.bookingSuccessRate = 0.0;
|
||||
this.cancellationRate = 0.0;
|
||||
this.attendanceRate = 0.0;
|
||||
this.popularCourseName = "";
|
||||
this.popularCourseCount = 0;
|
||||
this.totalCourses = 0;
|
||||
this.fullCourses = 0;
|
||||
}
|
||||
|
||||
public LocalDate getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public void setDate(LocalDate date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
public Integer getTotalBookings() {
|
||||
return totalBookings;
|
||||
}
|
||||
|
||||
public void setTotalBookings(Integer totalBookings) {
|
||||
this.totalBookings = totalBookings;
|
||||
}
|
||||
|
||||
public Integer getCancelledBookings() {
|
||||
return cancelledBookings;
|
||||
}
|
||||
|
||||
public void setCancelledBookings(Integer cancelledBookings) {
|
||||
this.cancelledBookings = cancelledBookings;
|
||||
}
|
||||
|
||||
public Integer getAttendedBookings() {
|
||||
return attendedBookings;
|
||||
}
|
||||
|
||||
public void setAttendedBookings(Integer attendedBookings) {
|
||||
this.attendedBookings = attendedBookings;
|
||||
}
|
||||
|
||||
public Double getBookingSuccessRate() {
|
||||
return bookingSuccessRate;
|
||||
}
|
||||
|
||||
public void setBookingSuccessRate(Double bookingSuccessRate) {
|
||||
this.bookingSuccessRate = bookingSuccessRate;
|
||||
}
|
||||
|
||||
public Double getCancellationRate() {
|
||||
return cancellationRate;
|
||||
}
|
||||
|
||||
public void setCancellationRate(Double cancellationRate) {
|
||||
this.cancellationRate = cancellationRate;
|
||||
}
|
||||
|
||||
public Double getAttendanceRate() {
|
||||
return attendanceRate;
|
||||
}
|
||||
|
||||
public void setAttendanceRate(Double attendanceRate) {
|
||||
this.attendanceRate = attendanceRate;
|
||||
}
|
||||
|
||||
public String getPopularCourseName() {
|
||||
return popularCourseName;
|
||||
}
|
||||
|
||||
public void setPopularCourseName(String popularCourseName) {
|
||||
this.popularCourseName = popularCourseName;
|
||||
}
|
||||
|
||||
public Integer getPopularCourseCount() {
|
||||
return popularCourseCount;
|
||||
}
|
||||
|
||||
public void setPopularCourseCount(Integer popularCourseCount) {
|
||||
this.popularCourseCount = popularCourseCount;
|
||||
}
|
||||
|
||||
public Integer getTotalCourses() {
|
||||
return totalCourses;
|
||||
}
|
||||
|
||||
public void setTotalCourses(Integer totalCourses) {
|
||||
this.totalCourses = totalCourses;
|
||||
}
|
||||
|
||||
public Integer getFullCourses() {
|
||||
return fullCourses;
|
||||
}
|
||||
|
||||
public void setFullCourses(Integer fullCourses) {
|
||||
this.fullCourses = fullCourses;
|
||||
}
|
||||
|
||||
public LocalDate getStartDate() {
|
||||
return startDate;
|
||||
}
|
||||
|
||||
public void setStartDate(LocalDate startDate) {
|
||||
this.startDate = startDate;
|
||||
}
|
||||
|
||||
public LocalDate getEndDate() {
|
||||
return endDate;
|
||||
}
|
||||
|
||||
public void setEndDate(LocalDate endDate) {
|
||||
this.endDate = endDate;
|
||||
}
|
||||
}
|
||||
-79
@@ -1,79 +0,0 @@
|
||||
package cn.novalon.gym.manage.datacount.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 数据统计结果域对象
|
||||
*
|
||||
* @author system
|
||||
* @date 2026-06-09
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DataStatistics {
|
||||
|
||||
/**
|
||||
* 统计类型:MEMBER-会员统计,BOOKING-预约统计,SIGN_IN-签到统计
|
||||
*/
|
||||
private String statType;
|
||||
|
||||
/**
|
||||
* 统计周期:DAY-日统计,WEEK-周统计,MONTH-月统计
|
||||
*/
|
||||
private String periodType;
|
||||
|
||||
/**
|
||||
* 统计日期(DAY时为具体日期,WEEK时为周开始日期,MONTH时为月份第一天)
|
||||
*/
|
||||
private LocalDateTime statDate;
|
||||
|
||||
/**
|
||||
* 统计数据值
|
||||
*/
|
||||
private Long count;
|
||||
|
||||
/**
|
||||
* 关联ID(如会员ID等)
|
||||
*/
|
||||
private Long relatedId;
|
||||
|
||||
/**
|
||||
* 扩展数据(JSON格式存储额外信息)
|
||||
*/
|
||||
private String extraData;
|
||||
|
||||
/**
|
||||
* 统计周期常量
|
||||
*/
|
||||
public static final class PeriodType {
|
||||
/** 日统计 */
|
||||
public static final String DAY = "DAY";
|
||||
/** 周统计 */
|
||||
public static final String WEEK = "WEEK";
|
||||
/** 月统计 */
|
||||
public static final String MONTH = "MONTH";
|
||||
|
||||
private PeriodType() {}
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计类型常量
|
||||
*/
|
||||
public static final class StatType {
|
||||
/** 会员统计 */
|
||||
public static final String MEMBER = "MEMBER";
|
||||
/** 预约统计 */
|
||||
public static final String BOOKING = "BOOKING";
|
||||
/** 签到统计 */
|
||||
public static final String SIGN_IN = "SIGN_IN";
|
||||
|
||||
private StatType() {}
|
||||
}
|
||||
}
|
||||
+133
-42
@@ -1,54 +1,145 @@
|
||||
package cn.novalon.gym.manage.datacount.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
/**
|
||||
* 会员数据统计结果
|
||||
*
|
||||
* @author system
|
||||
* @date 2026-06-09
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
import java.time.LocalDate;
|
||||
|
||||
@Schema(description = "会员数据统计")
|
||||
public class MemberStatistics {
|
||||
|
||||
/**
|
||||
* 统计日期
|
||||
*/
|
||||
private String statDate;
|
||||
@Schema(description = "统计日期", example = "2026-01-01")
|
||||
private LocalDate date;
|
||||
|
||||
/**
|
||||
* 新增会员数
|
||||
*/
|
||||
private Long newMembers;
|
||||
@Schema(description = "新增会员数", example = "10")
|
||||
private Integer newMembers;
|
||||
|
||||
/**
|
||||
* 活跃会员数(当天有签到或预约的会员)
|
||||
*/
|
||||
private Long activeMembers;
|
||||
@Schema(description = "活跃会员数", example = "50")
|
||||
private Integer activeMembers;
|
||||
|
||||
/**
|
||||
* 累计会员总数
|
||||
*/
|
||||
private Long totalMembers;
|
||||
@Schema(description = "留存会员数", example = "45")
|
||||
private Integer retainedMembers;
|
||||
|
||||
/**
|
||||
* 今日签到会员数
|
||||
*/
|
||||
private Long signInMembers;
|
||||
@Schema(description = "总会员数", example = "200")
|
||||
private Integer totalMembers;
|
||||
|
||||
/**
|
||||
* 今日预约会员数
|
||||
*/
|
||||
private Long bookingMembers;
|
||||
@Schema(description = "男性会员数", example = "100")
|
||||
private Integer maleMembers;
|
||||
|
||||
/**
|
||||
* 今日取消预约会员数
|
||||
*/
|
||||
private Long cancelBookingMembers;
|
||||
@Schema(description = "女性会员数", example = "100")
|
||||
private Integer femaleMembers;
|
||||
|
||||
@Schema(description = "会员卡购买人数", example = "30")
|
||||
private Integer cardPurchaseCount;
|
||||
|
||||
@Schema(description = "平均年龄", example = "28")
|
||||
private Double averageAge;
|
||||
|
||||
@Schema(description = "开始日期(用于汇总统计)")
|
||||
private LocalDate startDate;
|
||||
|
||||
@Schema(description = "结束日期(用于汇总统计)")
|
||||
private LocalDate endDate;
|
||||
|
||||
public MemberStatistics() {
|
||||
}
|
||||
|
||||
public MemberStatistics(LocalDate date) {
|
||||
this.date = date;
|
||||
this.newMembers = 0;
|
||||
this.activeMembers = 0;
|
||||
this.retainedMembers = 0;
|
||||
this.totalMembers = 0;
|
||||
this.maleMembers = 0;
|
||||
this.femaleMembers = 0;
|
||||
this.cardPurchaseCount = 0;
|
||||
this.averageAge = 0.0;
|
||||
}
|
||||
|
||||
public LocalDate getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public void setDate(LocalDate date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
public Integer getNewMembers() {
|
||||
return newMembers;
|
||||
}
|
||||
|
||||
public void setNewMembers(Integer newMembers) {
|
||||
this.newMembers = newMembers;
|
||||
}
|
||||
|
||||
public Integer getActiveMembers() {
|
||||
return activeMembers;
|
||||
}
|
||||
|
||||
public void setActiveMembers(Integer activeMembers) {
|
||||
this.activeMembers = activeMembers;
|
||||
}
|
||||
|
||||
public Integer getRetainedMembers() {
|
||||
return retainedMembers;
|
||||
}
|
||||
|
||||
public void setRetainedMembers(Integer retainedMembers) {
|
||||
this.retainedMembers = retainedMembers;
|
||||
}
|
||||
|
||||
public Integer getTotalMembers() {
|
||||
return totalMembers;
|
||||
}
|
||||
|
||||
public void setTotalMembers(Integer totalMembers) {
|
||||
this.totalMembers = totalMembers;
|
||||
}
|
||||
|
||||
public Integer getMaleMembers() {
|
||||
return maleMembers;
|
||||
}
|
||||
|
||||
public void setMaleMembers(Integer maleMembers) {
|
||||
this.maleMembers = maleMembers;
|
||||
}
|
||||
|
||||
public Integer getFemaleMembers() {
|
||||
return femaleMembers;
|
||||
}
|
||||
|
||||
public void setFemaleMembers(Integer femaleMembers) {
|
||||
this.femaleMembers = femaleMembers;
|
||||
}
|
||||
|
||||
public Integer getCardPurchaseCount() {
|
||||
return cardPurchaseCount;
|
||||
}
|
||||
|
||||
public void setCardPurchaseCount(Integer cardPurchaseCount) {
|
||||
this.cardPurchaseCount = cardPurchaseCount;
|
||||
}
|
||||
|
||||
public Double getAverageAge() {
|
||||
return averageAge;
|
||||
}
|
||||
|
||||
public void setAverageAge(Double averageAge) {
|
||||
this.averageAge = averageAge;
|
||||
}
|
||||
|
||||
public LocalDate getStartDate() {
|
||||
return startDate;
|
||||
}
|
||||
|
||||
public void setStartDate(LocalDate startDate) {
|
||||
this.startDate = startDate;
|
||||
}
|
||||
|
||||
public LocalDate getEndDate() {
|
||||
return endDate;
|
||||
}
|
||||
|
||||
public void setEndDate(LocalDate endDate) {
|
||||
this.endDate = endDate;
|
||||
}
|
||||
}
|
||||
-64
@@ -1,64 +0,0 @@
|
||||
package cn.novalon.gym.manage.datacount.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 签到数据统计结果
|
||||
*
|
||||
* @author system
|
||||
* @date 2026-06-09
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class SignInStatistics {
|
||||
|
||||
/**
|
||||
* 统计日期
|
||||
*/
|
||||
private String statDate;
|
||||
|
||||
/**
|
||||
* 签到总次数
|
||||
*/
|
||||
private Long totalSignIns;
|
||||
|
||||
/**
|
||||
* 成功签到次数
|
||||
*/
|
||||
private Long successSignIns;
|
||||
|
||||
/**
|
||||
* 失败签到次数
|
||||
*/
|
||||
private Long failedSignIns;
|
||||
|
||||
/**
|
||||
* 签到成功率
|
||||
*/
|
||||
private Double successRate;
|
||||
|
||||
/**
|
||||
* 签到人数(独立会员数)
|
||||
*/
|
||||
private Long signInMembers;
|
||||
|
||||
/**
|
||||
* 扫码签到次数
|
||||
*/
|
||||
private Long qrCodeSignIns;
|
||||
|
||||
/**
|
||||
* 手动签到次数
|
||||
*/
|
||||
private Long manualSignIns;
|
||||
|
||||
/**
|
||||
* 人脸识别签到次数
|
||||
*/
|
||||
private Long faceSignIns;
|
||||
}
|
||||
+90
@@ -0,0 +1,90 @@
|
||||
package cn.novalon.gym.manage.datacount.domain;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
@Schema(description = "统计数据导出DTO")
|
||||
public class StatisticsExportDTO {
|
||||
|
||||
@Schema(description = "导出文件名", example = "statistics_report_20260101")
|
||||
private String fileName;
|
||||
|
||||
@Schema(description = "导出格式", example = "EXCEL")
|
||||
private String format;
|
||||
|
||||
@Schema(description = "开始日期", example = "2026-01-01")
|
||||
private LocalDate startDate;
|
||||
|
||||
@Schema(description = "结束日期", example = "2026-01-31")
|
||||
private LocalDate endDate;
|
||||
|
||||
@Schema(description = "导出类型", example = "MEMBER")
|
||||
private String exportType;
|
||||
|
||||
@Schema(description = "会员统计数据")
|
||||
private List<MemberStatistics> memberStatisticsList;
|
||||
|
||||
@Schema(description = "预约统计数据")
|
||||
private List<BookingStatistics> bookingStatisticsList;
|
||||
|
||||
public StatisticsExportDTO() {
|
||||
}
|
||||
|
||||
public String getFileName() {
|
||||
return fileName;
|
||||
}
|
||||
|
||||
public void setFileName(String fileName) {
|
||||
this.fileName = fileName;
|
||||
}
|
||||
|
||||
public String getFormat() {
|
||||
return format;
|
||||
}
|
||||
|
||||
public void setFormat(String format) {
|
||||
this.format = format;
|
||||
}
|
||||
|
||||
public LocalDate getStartDate() {
|
||||
return startDate;
|
||||
}
|
||||
|
||||
public void setStartDate(LocalDate startDate) {
|
||||
this.startDate = startDate;
|
||||
}
|
||||
|
||||
public LocalDate getEndDate() {
|
||||
return endDate;
|
||||
}
|
||||
|
||||
public void setEndDate(LocalDate endDate) {
|
||||
this.endDate = endDate;
|
||||
}
|
||||
|
||||
public String getExportType() {
|
||||
return exportType;
|
||||
}
|
||||
|
||||
public void setExportType(String exportType) {
|
||||
this.exportType = exportType;
|
||||
}
|
||||
|
||||
public List<MemberStatistics> getMemberStatisticsList() {
|
||||
return memberStatisticsList;
|
||||
}
|
||||
|
||||
public void setMemberStatisticsList(List<MemberStatistics> memberStatisticsList) {
|
||||
this.memberStatisticsList = memberStatisticsList;
|
||||
}
|
||||
|
||||
public List<BookingStatistics> getBookingStatisticsList() {
|
||||
return bookingStatisticsList;
|
||||
}
|
||||
|
||||
public void setBookingStatisticsList(List<BookingStatistics> bookingStatisticsList) {
|
||||
this.bookingStatisticsList = bookingStatisticsList;
|
||||
}
|
||||
}
|
||||
-52
@@ -1,52 +0,0 @@
|
||||
package cn.novalon.gym.manage.datacount.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 统计数据查询请求
|
||||
*
|
||||
* @author system
|
||||
* @date 2026-06-09
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class StatisticsQuery {
|
||||
|
||||
/**
|
||||
* 统计类型:MEMBER-会员统计,BOOKING-预约统计,SIGN_IN-签到统计
|
||||
* 空表示所有类型
|
||||
*/
|
||||
private String statType;
|
||||
|
||||
/**
|
||||
* 统计周期:DAY-日统计,WEEK-周统计,MONTH-月统计
|
||||
*/
|
||||
private String periodType;
|
||||
|
||||
/**
|
||||
* 开始时间
|
||||
*/
|
||||
private LocalDateTime startTime;
|
||||
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
private LocalDateTime endTime;
|
||||
|
||||
/**
|
||||
* 分页页码
|
||||
*/
|
||||
private Integer page;
|
||||
|
||||
/**
|
||||
* 每页大小
|
||||
*/
|
||||
private Integer size;
|
||||
}
|
||||
-44
@@ -1,44 +0,0 @@
|
||||
package cn.novalon.gym.manage.datacount.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 统计数据汇总
|
||||
*
|
||||
* @author system
|
||||
* @date 2026-06-09
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class StatisticsSummary {
|
||||
|
||||
/**
|
||||
* 统计日期
|
||||
*/
|
||||
private String statDate;
|
||||
|
||||
/**
|
||||
* 会员统计数据
|
||||
*/
|
||||
private MemberStatistics memberStatistics;
|
||||
|
||||
/**
|
||||
* 预约统计数据
|
||||
*/
|
||||
private BookingStatistics bookingStatistics;
|
||||
|
||||
/**
|
||||
* 签到统计数据
|
||||
*/
|
||||
private SignInStatistics signInStatistics;
|
||||
|
||||
/**
|
||||
* 统计数据生成时间
|
||||
*/
|
||||
private String generatedAt;
|
||||
}
|
||||
+204
@@ -0,0 +1,204 @@
|
||||
package cn.novalon.gym.manage.datacount.handler;
|
||||
|
||||
import cn.novalon.gym.manage.datacount.domain.BookingStatistics;
|
||||
import cn.novalon.gym.manage.datacount.domain.MemberStatistics;
|
||||
import cn.novalon.gym.manage.datacount.service.IDataCountService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.reactive.function.server.ServerRequest;
|
||||
import org.springframework.web.reactive.function.server.ServerResponse;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
@Tag(name = "数据统计", description = "数据统计相关操作")
|
||||
public class DataCountHandler {
|
||||
|
||||
private final IDataCountService dataCountService;
|
||||
|
||||
private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
|
||||
public DataCountHandler(IDataCountService dataCountService) {
|
||||
this.dataCountService = dataCountService;
|
||||
}
|
||||
|
||||
@Operation(summary = "获取会员数据统计(按日期)", description = "获取指定日期的会员数据统计")
|
||||
public Mono<ServerResponse> getMemberStatisticsByDate(ServerRequest request) {
|
||||
String dateStr = request.pathVariable("date");
|
||||
LocalDate date = LocalDate.parse(dateStr, DATE_FORMATTER);
|
||||
|
||||
return dataCountService.getMemberStatisticsByDate(date)
|
||||
.flatMap(stats -> ServerResponse.ok().bodyValue(stats))
|
||||
.switchIfEmpty(ServerResponse.notFound().build())
|
||||
.onErrorResume(error -> {
|
||||
Map<String, Object> response = new HashMap<>();
|
||||
response.put("success", false);
|
||||
response.put("message", error.getMessage());
|
||||
return ServerResponse.badRequest().bodyValue(response);
|
||||
});
|
||||
}
|
||||
|
||||
@Operation(summary = "获取会员数据统计(按日期范围)", description = "获取指定日期范围内的会员数据统计")
|
||||
public Mono<ServerResponse> getMemberStatisticsByDateRange(ServerRequest request) {
|
||||
String startDateStr = request.queryParam("startDate").orElseThrow(() -> new IllegalArgumentException("startDate必填"));
|
||||
String endDateStr = request.queryParam("endDate").orElseThrow(() -> new IllegalArgumentException("endDate必填"));
|
||||
|
||||
LocalDate startDate = LocalDate.parse(startDateStr, DATE_FORMATTER);
|
||||
LocalDate endDate = LocalDate.parse(endDateStr, DATE_FORMATTER);
|
||||
|
||||
return dataCountService.getMemberStatisticsByDateRange(startDate, endDate)
|
||||
.collectList()
|
||||
.flatMap(list -> ServerResponse.ok().bodyValue(list))
|
||||
.onErrorResume(error -> {
|
||||
Map<String, Object> response = new HashMap<>();
|
||||
response.put("success", false);
|
||||
response.put("message", error.getMessage());
|
||||
return ServerResponse.badRequest().bodyValue(response);
|
||||
});
|
||||
}
|
||||
|
||||
@Operation(summary = "获取会员数据统计汇总", description = "获取指定日期范围内的会员数据统计汇总")
|
||||
public Mono<ServerResponse> getMemberStatisticsSummary(ServerRequest request) {
|
||||
String startDateStr = request.queryParam("startDate").orElseThrow(() -> new IllegalArgumentException("startDate必填"));
|
||||
String endDateStr = request.queryParam("endDate").orElseThrow(() -> new IllegalArgumentException("endDate必填"));
|
||||
|
||||
LocalDate startDate = LocalDate.parse(startDateStr, DATE_FORMATTER);
|
||||
LocalDate endDate = LocalDate.parse(endDateStr, DATE_FORMATTER);
|
||||
|
||||
return dataCountService.getMemberStatisticsSummary(startDate, endDate)
|
||||
.flatMap(summary -> ServerResponse.ok().bodyValue(summary))
|
||||
.onErrorResume(error -> {
|
||||
Map<String, Object> response = new HashMap<>();
|
||||
response.put("success", false);
|
||||
response.put("message", error.getMessage());
|
||||
return ServerResponse.badRequest().bodyValue(response);
|
||||
});
|
||||
}
|
||||
|
||||
@Operation(summary = "获取预约数据统计(按日期)", description = "获取指定日期的预约数据统计")
|
||||
public Mono<ServerResponse> getBookingStatisticsByDate(ServerRequest request) {
|
||||
String dateStr = request.pathVariable("date");
|
||||
LocalDate date = LocalDate.parse(dateStr, DATE_FORMATTER);
|
||||
|
||||
return dataCountService.getBookingStatisticsByDate(date)
|
||||
.flatMap(stats -> ServerResponse.ok().bodyValue(stats))
|
||||
.switchIfEmpty(ServerResponse.notFound().build())
|
||||
.onErrorResume(error -> {
|
||||
Map<String, Object> response = new HashMap<>();
|
||||
response.put("success", false);
|
||||
response.put("message", error.getMessage());
|
||||
return ServerResponse.badRequest().bodyValue(response);
|
||||
});
|
||||
}
|
||||
|
||||
@Operation(summary = "获取预约数据统计(按日期范围)", description = "获取指定日期范围内的预约数据统计")
|
||||
public Mono<ServerResponse> getBookingStatisticsByDateRange(ServerRequest request) {
|
||||
String startDateStr = request.queryParam("startDate").orElseThrow(() -> new IllegalArgumentException("startDate必填"));
|
||||
String endDateStr = request.queryParam("endDate").orElseThrow(() -> new IllegalArgumentException("endDate必填"));
|
||||
|
||||
LocalDate startDate = LocalDate.parse(startDateStr, DATE_FORMATTER);
|
||||
LocalDate endDate = LocalDate.parse(endDateStr, DATE_FORMATTER);
|
||||
|
||||
return dataCountService.getBookingStatisticsByDateRange(startDate, endDate)
|
||||
.collectList()
|
||||
.flatMap(list -> ServerResponse.ok().bodyValue(list))
|
||||
.onErrorResume(error -> {
|
||||
Map<String, Object> response = new HashMap<>();
|
||||
response.put("success", false);
|
||||
response.put("message", error.getMessage());
|
||||
return ServerResponse.badRequest().bodyValue(response);
|
||||
});
|
||||
}
|
||||
|
||||
@Operation(summary = "获取预约数据统计汇总", description = "获取指定日期范围内的预约数据统计汇总")
|
||||
public Mono<ServerResponse> getBookingStatisticsSummary(ServerRequest request) {
|
||||
String startDateStr = request.queryParam("startDate").orElseThrow(() -> new IllegalArgumentException("startDate必填"));
|
||||
String endDateStr = request.queryParam("endDate").orElseThrow(() -> new IllegalArgumentException("endDate必填"));
|
||||
|
||||
LocalDate startDate = LocalDate.parse(startDateStr, DATE_FORMATTER);
|
||||
LocalDate endDate = LocalDate.parse(endDateStr, DATE_FORMATTER);
|
||||
|
||||
return dataCountService.getBookingStatisticsSummary(startDate, endDate)
|
||||
.flatMap(summary -> ServerResponse.ok().bodyValue(summary))
|
||||
.onErrorResume(error -> {
|
||||
Map<String, Object> response = new HashMap<>();
|
||||
response.put("success", false);
|
||||
response.put("message", error.getMessage());
|
||||
return ServerResponse.badRequest().bodyValue(response);
|
||||
});
|
||||
}
|
||||
|
||||
@Operation(summary = "导出会员数据统计", description = "导出指定日期范围内的会员数据统计为CSV文件")
|
||||
public Mono<ServerResponse> exportMemberStatistics(ServerRequest request) {
|
||||
String startDateStr = request.queryParam("startDate").orElseThrow(() -> new IllegalArgumentException("startDate必填"));
|
||||
String endDateStr = request.queryParam("endDate").orElseThrow(() -> new IllegalArgumentException("endDate必填"));
|
||||
|
||||
LocalDate startDate = LocalDate.parse(startDateStr, DATE_FORMATTER);
|
||||
LocalDate endDate = LocalDate.parse(endDateStr, DATE_FORMATTER);
|
||||
|
||||
String fileName = "member_statistics_" + startDateStr + "_" + endDateStr + ".csv";
|
||||
|
||||
return dataCountService.exportMemberStatistics(startDate, endDate)
|
||||
.flatMap(data -> ServerResponse.ok()
|
||||
.header("Content-Disposition", "attachment; filename=" + fileName)
|
||||
.header("Content-Type", "text/csv; charset=UTF-8")
|
||||
.bodyValue(data))
|
||||
.onErrorResume(error -> {
|
||||
Map<String, Object> response = new HashMap<>();
|
||||
response.put("success", false);
|
||||
response.put("message", error.getMessage());
|
||||
return ServerResponse.badRequest().bodyValue(response);
|
||||
});
|
||||
}
|
||||
|
||||
@Operation(summary = "导出预约数据统计", description = "导出指定日期范围内的预约数据统计为CSV文件")
|
||||
public Mono<ServerResponse> exportBookingStatistics(ServerRequest request) {
|
||||
String startDateStr = request.queryParam("startDate").orElseThrow(() -> new IllegalArgumentException("startDate必填"));
|
||||
String endDateStr = request.queryParam("endDate").orElseThrow(() -> new IllegalArgumentException("endDate必填"));
|
||||
|
||||
LocalDate startDate = LocalDate.parse(startDateStr, DATE_FORMATTER);
|
||||
LocalDate endDate = LocalDate.parse(endDateStr, DATE_FORMATTER);
|
||||
|
||||
String fileName = "booking_statistics_" + startDateStr + "_" + endDateStr + ".csv";
|
||||
|
||||
return dataCountService.exportBookingStatistics(startDate, endDate)
|
||||
.flatMap(data -> ServerResponse.ok()
|
||||
.header("Content-Disposition", "attachment; filename=" + fileName)
|
||||
.header("Content-Type", "text/csv; charset=UTF-8")
|
||||
.bodyValue(data))
|
||||
.onErrorResume(error -> {
|
||||
Map<String, Object> response = new HashMap<>();
|
||||
response.put("success", false);
|
||||
response.put("message", error.getMessage());
|
||||
return ServerResponse.badRequest().bodyValue(response);
|
||||
});
|
||||
}
|
||||
|
||||
@Operation(summary = "导出全部统计数据", description = "导出指定日期范围内的会员和预约数据统计为CSV文件")
|
||||
public Mono<ServerResponse> exportAllStatistics(ServerRequest request) {
|
||||
String startDateStr = request.queryParam("startDate").orElseThrow(() -> new IllegalArgumentException("startDate必填"));
|
||||
String endDateStr = request.queryParam("endDate").orElseThrow(() -> new IllegalArgumentException("endDate必填"));
|
||||
|
||||
LocalDate startDate = LocalDate.parse(startDateStr, DATE_FORMATTER);
|
||||
LocalDate endDate = LocalDate.parse(endDateStr, DATE_FORMATTER);
|
||||
|
||||
String fileName = "all_statistics_" + startDateStr + "_" + endDateStr + ".csv";
|
||||
|
||||
return dataCountService.exportAllStatistics(startDate, endDate)
|
||||
.flatMap(data -> ServerResponse.ok()
|
||||
.header("Content-Disposition", "attachment; filename=" + fileName)
|
||||
.header("Content-Type", "text/csv; charset=UTF-8")
|
||||
.bodyValue(data))
|
||||
.onErrorResume(error -> {
|
||||
Map<String, Object> response = new HashMap<>();
|
||||
response.put("success", false);
|
||||
response.put("message", error.getMessage());
|
||||
return ServerResponse.badRequest().bodyValue(response);
|
||||
});
|
||||
}
|
||||
}
|
||||
-125
@@ -1,125 +0,0 @@
|
||||
package cn.novalon.gym.manage.datacount.handler;
|
||||
|
||||
import cn.novalon.gym.manage.datacount.domain.*;
|
||||
import cn.novalon.gym.manage.datacount.service.IDataStatisticsService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.reactive.function.server.ServerRequest;
|
||||
import org.springframework.web.reactive.function.server.ServerResponse;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
/**
|
||||
* 数据统计 Handler
|
||||
*
|
||||
* @author system
|
||||
* @date 2026-06-09
|
||||
*/
|
||||
@Component
|
||||
@Tag(name = "数据统计", description = "数据统计相关操作")
|
||||
public class DataStatisticsHandler {
|
||||
|
||||
@Autowired
|
||||
private IDataStatisticsService dataStatisticsService;
|
||||
|
||||
@Operation(summary = "获取综合统计数据", description = "获取会员、预约、签到综合统计数据")
|
||||
public Mono<ServerResponse> getStatisticsSummary(ServerRequest request) {
|
||||
StatisticsQuery query = buildQueryFromRequest(request);
|
||||
|
||||
return dataStatisticsService.getStatisticsSummaryWithCache(query)
|
||||
.flatMap(summary -> ServerResponse.ok().bodyValue(summary))
|
||||
.onErrorResume(e -> {
|
||||
StatisticsSummary errorSummary = StatisticsSummary.builder()
|
||||
.statDate(LocalDateTime.now().toLocalDate().toString())
|
||||
.generatedAt(LocalDateTime.now().format(DateTimeFormatter.ISO_LOCAL_DATE_TIME))
|
||||
.build();
|
||||
return ServerResponse.ok().bodyValue(errorSummary);
|
||||
});
|
||||
}
|
||||
|
||||
@Operation(summary = "获取会员统计数据", description = "获取会员统计数据")
|
||||
public Mono<ServerResponse> getMemberStatistics(ServerRequest request) {
|
||||
StatisticsQuery query = buildQueryFromRequest(request);
|
||||
|
||||
return dataStatisticsService.getMemberStatistics(query)
|
||||
.flatMap(stats -> ServerResponse.ok().bodyValue(stats))
|
||||
.onErrorResume(e -> ServerResponse.ok().bodyValue(MemberStatistics.builder().statDate(query.getStartTime() != null ? query.getStartTime().toLocalDate().toString() : LocalDateTime.now().toLocalDate().toString()).build()));
|
||||
}
|
||||
|
||||
@Operation(summary = "获取预约统计数据", description = "获取预约统计数据")
|
||||
public Mono<ServerResponse> getBookingStatistics(ServerRequest request) {
|
||||
StatisticsQuery query = buildQueryFromRequest(request);
|
||||
|
||||
return dataStatisticsService.getBookingStatistics(query)
|
||||
.flatMap(stats -> ServerResponse.ok().bodyValue(stats))
|
||||
.onErrorResume(e -> ServerResponse.ok().bodyValue(BookingStatistics.builder().statDate(query.getStartTime() != null ? query.getStartTime().toLocalDate().toString() : LocalDateTime.now().toLocalDate().toString()).build()));
|
||||
}
|
||||
|
||||
@Operation(summary = "获取签到统计数据", description = "获取签到统计数据")
|
||||
public Mono<ServerResponse> getSignInStatistics(ServerRequest request) {
|
||||
StatisticsQuery query = buildQueryFromRequest(request);
|
||||
|
||||
return dataStatisticsService.getSignInStatistics(query)
|
||||
.flatMap(stats -> ServerResponse.ok().bodyValue(stats))
|
||||
.onErrorResume(e -> ServerResponse.ok().bodyValue(SignInStatistics.builder().statDate(query.getStartTime() != null ? query.getStartTime().toLocalDate().toString() : LocalDateTime.now().toLocalDate().toString()).build()));
|
||||
}
|
||||
|
||||
@Operation(summary = "查询历史统计数据", description = "查询历史统计数据")
|
||||
public Mono<ServerResponse> queryHistoricalStatistics(ServerRequest request) {
|
||||
StatisticsQuery query = buildQueryFromRequest(request);
|
||||
|
||||
return dataStatisticsService.queryHistoricalStatistics(query)
|
||||
.collectList()
|
||||
.flatMap(stats -> ServerResponse.ok().bodyValue(stats));
|
||||
}
|
||||
|
||||
@Operation(summary = "导出统计数据", description = "导出统计数据为Excel文件")
|
||||
public Mono<ServerResponse> exportStatistics(ServerRequest request) {
|
||||
StatisticsQuery query = buildQueryFromRequest(request);
|
||||
|
||||
return dataStatisticsService.exportStatistics(query)
|
||||
.flatMap(bytes -> {
|
||||
String filename = "statistics_" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss")) + ".xlsx";
|
||||
return ServerResponse.ok()
|
||||
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + filename + "\"")
|
||||
.contentType(MediaType.parseMediaType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"))
|
||||
.bodyValue(bytes);
|
||||
})
|
||||
.onErrorResume(e -> ServerResponse.ok().bodyValue("导出失败: " + e.getMessage()));
|
||||
}
|
||||
|
||||
private StatisticsQuery buildQueryFromRequest(ServerRequest request) {
|
||||
StatisticsQuery.StatisticsQueryBuilder builder = StatisticsQuery.builder();
|
||||
|
||||
request.queryParam("statType").ifPresent(builder::statType);
|
||||
request.queryParam("periodType").ifPresent(builder::periodType);
|
||||
request.queryParam("startTime").ifPresent(startTimeStr -> {
|
||||
try {
|
||||
builder.startTime(LocalDateTime.parse(startTimeStr, DateTimeFormatter.ISO_LOCAL_DATE_TIME));
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
builder.startTime(LocalDateTime.parse(startTimeStr));
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
});
|
||||
request.queryParam("endTime").ifPresent(endTimeStr -> {
|
||||
try {
|
||||
builder.endTime(LocalDateTime.parse(endTimeStr, DateTimeFormatter.ISO_LOCAL_DATE_TIME));
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
builder.endTime(LocalDateTime.parse(endTimeStr));
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return builder.build();
|
||||
}
|
||||
}
|
||||
-109
@@ -1,109 +0,0 @@
|
||||
package cn.novalon.gym.manage.datacount.scheduler;
|
||||
|
||||
import cn.novalon.gym.manage.datacount.domain.DataStatistics;
|
||||
import cn.novalon.gym.manage.datacount.service.IDataStatisticsService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
/**
|
||||
* 数据统计定时任务
|
||||
* 每日凌晨执行统计数据更新
|
||||
*
|
||||
* @author system
|
||||
* @date 2026-06-09
|
||||
*/
|
||||
@Component
|
||||
public class DataStatisticsScheduler {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(DataStatisticsScheduler.class);
|
||||
|
||||
@Autowired
|
||||
private IDataStatisticsService dataStatisticsService;
|
||||
|
||||
/**
|
||||
* 每日凌晨2点执行前一天的日统计数据
|
||||
* 使用cron表达式: 0 0 2 * * ?
|
||||
*/
|
||||
@Scheduled(cron = "0 0 2 * * ?")
|
||||
public void executeDailyStatistics() {
|
||||
LocalDate yesterday = LocalDate.now().minusDays(1);
|
||||
log.info("Starting daily statistics task for date: {}", yesterday);
|
||||
|
||||
dataStatisticsService.executeDailyStatistics(yesterday)
|
||||
.subscribe(
|
||||
null,
|
||||
error -> log.error("Daily statistics task failed for date: {}", yesterday, error),
|
||||
() -> log.info("Daily statistics task completed for date: {}", yesterday)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 每周一凌晨3点执行上周的周统计数据
|
||||
* 使用cron表达式: 0 0 3 ? * MON
|
||||
*/
|
||||
@Scheduled(cron = "0 0 3 ? * MON")
|
||||
public void executeWeeklyStatistics() {
|
||||
LocalDate lastWeek = LocalDate.now().minusWeeks(1);
|
||||
log.info("Starting weekly statistics task for week of: {}", lastWeek);
|
||||
|
||||
// 执行上周每天的统计数据汇总
|
||||
LocalDate weekStart = lastWeek.with(java.time.temporal.TemporalAdjusters.previousOrSame(java.time.DayOfWeek.MONDAY));
|
||||
LocalDate weekEnd = lastWeek.with(java.time.temporal.TemporalAdjusters.nextOrSame(java.time.DayOfWeek.SUNDAY));
|
||||
|
||||
for (LocalDate date = weekStart; !date.isAfter(weekEnd); date = date.plusDays(1)) {
|
||||
final LocalDate statDate = date;
|
||||
dataStatisticsService.executeDailyStatistics(statDate)
|
||||
.block();
|
||||
}
|
||||
|
||||
log.info("Weekly statistics task completed for week: {} - {}", weekStart, weekEnd);
|
||||
}
|
||||
|
||||
/**
|
||||
* 每月1日凌晨3点执行上个月的月统计数据
|
||||
* 使用cron表达式: 0 0 3 1 * ?
|
||||
*/
|
||||
@Scheduled(cron = "0 0 3 1 * ?")
|
||||
public void executeMonthlyStatistics() {
|
||||
LocalDate lastMonth = LocalDate.now().minusMonths(1);
|
||||
log.info("Starting monthly statistics task for month: {}", lastMonth.getMonth());
|
||||
|
||||
// 执行上个月每天的统计数据补全
|
||||
LocalDate startOfMonth = lastMonth.withDayOfMonth(1);
|
||||
LocalDate endOfMonth = lastMonth.with(java.time.temporal.TemporalAdjusters.lastDayOfMonth());
|
||||
|
||||
for (LocalDate date = startOfMonth; !date.isAfter(endOfMonth); date = date.plusDays(1)) {
|
||||
final LocalDate statDate = date;
|
||||
dataStatisticsService.executeDailyStatistics(statDate)
|
||||
.block();
|
||||
}
|
||||
|
||||
log.info("Monthly statistics task completed for month: {}", lastMonth.getMonth());
|
||||
}
|
||||
|
||||
/**
|
||||
* 每月15日凌晨4点清理30天前的旧统计数据
|
||||
* 使用cron表达式: 0 0 4 15 * ?
|
||||
*/
|
||||
@Scheduled(cron = "0 0 4 15 * ?")
|
||||
public void cleanupOldStatistics() {
|
||||
LocalDate cutoffDate = LocalDate.now().minusDays(30);
|
||||
log.info("Starting cleanup old statistics task, removing data before: {}", cutoffDate);
|
||||
|
||||
// 清理Redis中的旧统计数据
|
||||
String pattern = "datacount:statistics:*:" + cutoffDate.toString();
|
||||
cn.novalon.gym.manage.common.util.RedisUtil redisUtil = null;
|
||||
try {
|
||||
// 这里可以通过注入的service来清理,但当前实现使用Redis缓存30天自动过期
|
||||
log.info("Old statistics cleanup completed, cutoff date: {}", cutoffDate);
|
||||
} catch (Exception e) {
|
||||
log.error("Failed to cleanup old statistics", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
package cn.novalon.gym.manage.datacount.scheduler;
|
||||
|
||||
import cn.novalon.gym.manage.datacount.service.IDataCountService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
/**
|
||||
* 数据统计定时任务
|
||||
*
|
||||
* 功能:每日凌晨1点自动计算前一天的数据统计并缓存到Redis
|
||||
*
|
||||
* @author 数据统计模块
|
||||
* @date 2026-06-06
|
||||
*/
|
||||
@Component
|
||||
public class StatisticsDailyScheduler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(StatisticsDailyScheduler.class);
|
||||
|
||||
private final IDataCountService dataCountService;
|
||||
|
||||
public StatisticsDailyScheduler(IDataCountService dataCountService) {
|
||||
this.dataCountService = dataCountService;
|
||||
}
|
||||
|
||||
/**
|
||||
* 每日凌晨1点执行前一天的统计数据计算并缓存
|
||||
* cron表达式:秒 分 时 日 月 周
|
||||
*/
|
||||
@Scheduled(cron = "0 0 1 * * ?")
|
||||
public void calculateDailyStatistics() {
|
||||
LocalDate yesterday = LocalDate.now().minusDays(1);
|
||||
logger.info("定时任务开始计算 {} 的数据统计", yesterday);
|
||||
|
||||
dataCountService.getMemberStatisticsByDate(yesterday)
|
||||
.doOnSuccess(stats -> logger.info("会员统计计算完成: date={}, newMembers={}, totalMembers={}",
|
||||
yesterday, stats.getNewMembers(), stats.getTotalMembers()))
|
||||
.doOnError(error -> logger.error("会员统计计算失败: date={}", yesterday, error))
|
||||
.subscribe();
|
||||
|
||||
dataCountService.getBookingStatisticsByDate(yesterday)
|
||||
.doOnSuccess(stats -> logger.info("预约统计计算完成: date={}, totalBookings={}, attendanceRate={}%",
|
||||
yesterday, stats.getTotalBookings(), stats.getAttendanceRate()))
|
||||
.doOnError(error -> logger.error("预约统计计算失败: date={}", yesterday, error))
|
||||
.subscribe();
|
||||
}
|
||||
|
||||
/**
|
||||
* 每周一凌晨2点执行上周的数据汇总统计
|
||||
*/
|
||||
@Scheduled(cron = "0 0 2 * * 1")
|
||||
public void calculateWeeklyStatistics() {
|
||||
LocalDate lastWeekEnd = LocalDate.now().minusDays(1);
|
||||
LocalDate lastWeekStart = lastWeekEnd.minusDays(6);
|
||||
logger.info("定时任务开始计算上周汇总统计: {} ~ {}", lastWeekStart, lastWeekEnd);
|
||||
|
||||
dataCountService.getMemberStatisticsSummary(lastWeekStart, lastWeekEnd)
|
||||
.doOnSuccess(stats -> logger.info("上周会员汇总统计完成: newMembers={}", stats.getNewMembers()))
|
||||
.doOnError(error -> logger.error("上周会员汇总统计失败", error))
|
||||
.subscribe();
|
||||
|
||||
dataCountService.getBookingStatisticsSummary(lastWeekStart, lastWeekEnd)
|
||||
.doOnSuccess(stats -> logger.info("上周预约汇总统计完成: totalBookings={}", stats.getTotalBookings()))
|
||||
.doOnError(error -> logger.error("上周预约汇总统计失败", error))
|
||||
.subscribe();
|
||||
}
|
||||
|
||||
/**
|
||||
* 每月1号凌晨3点执行上月的数据汇总统计
|
||||
*/
|
||||
@Scheduled(cron = "0 0 3 1 * ?")
|
||||
public void calculateMonthlyStatistics() {
|
||||
LocalDate lastMonthEnd = LocalDate.now().minusDays(1);
|
||||
LocalDate lastMonthStart = lastMonthEnd.withDayOfMonth(1);
|
||||
logger.info("定时任务开始计算上月汇总统计: {} ~ {}", lastMonthStart, lastMonthEnd);
|
||||
|
||||
dataCountService.getMemberStatisticsSummary(lastMonthStart, lastMonthEnd)
|
||||
.doOnSuccess(stats -> logger.info("上月会员汇总统计完成: newMembers={}", stats.getNewMembers()))
|
||||
.doOnError(error -> logger.error("上月会员汇总统计失败", error))
|
||||
.subscribe();
|
||||
|
||||
dataCountService.getBookingStatisticsSummary(lastMonthStart, lastMonthEnd)
|
||||
.doOnSuccess(stats -> logger.info("上月预约汇总统计完成: totalBookings={}", stats.getTotalBookings()))
|
||||
.doOnError(error -> logger.error("上月预约汇总统计失败", error))
|
||||
.subscribe();
|
||||
}
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
package cn.novalon.gym.manage.datacount.service;
|
||||
|
||||
import cn.novalon.gym.manage.datacount.domain.BookingStatistics;
|
||||
import cn.novalon.gym.manage.datacount.domain.MemberStatistics;
|
||||
import cn.novalon.gym.manage.datacount.domain.StatisticsExportDTO;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
public interface IDataCountService {
|
||||
|
||||
Mono<MemberStatistics> getMemberStatisticsByDate(LocalDate date);
|
||||
|
||||
Flux<MemberStatistics> getMemberStatisticsByDateRange(LocalDate startDate, LocalDate endDate);
|
||||
|
||||
Mono<MemberStatistics> getMemberStatisticsSummary(LocalDate startDate, LocalDate endDate);
|
||||
|
||||
Mono<BookingStatistics> getBookingStatisticsByDate(LocalDate date);
|
||||
|
||||
Flux<BookingStatistics> getBookingStatisticsByDateRange(LocalDate startDate, LocalDate endDate);
|
||||
|
||||
Mono<BookingStatistics> getBookingStatisticsSummary(LocalDate startDate, LocalDate endDate);
|
||||
|
||||
Mono<byte[]> exportMemberStatistics(LocalDate startDate, LocalDate endDate);
|
||||
|
||||
Mono<byte[]> exportBookingStatistics(LocalDate startDate, LocalDate endDate);
|
||||
|
||||
Mono<byte[]> exportAllStatistics(LocalDate startDate, LocalDate endDate);
|
||||
}
|
||||
-78
@@ -1,78 +0,0 @@
|
||||
package cn.novalon.gym.manage.datacount.service;
|
||||
|
||||
import cn.novalon.gym.manage.datacount.domain.*;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
/**
|
||||
* 数据统计服务接口
|
||||
*
|
||||
* @author system
|
||||
* @date 2026-06-09
|
||||
*/
|
||||
public interface IDataStatisticsService {
|
||||
|
||||
/**
|
||||
* 获取会员统计数据
|
||||
*
|
||||
* @param query 查询条件
|
||||
* @return 会员统计数据
|
||||
*/
|
||||
Mono<MemberStatistics> getMemberStatistics(StatisticsQuery query);
|
||||
|
||||
/**
|
||||
* 获取预约统计数据
|
||||
*
|
||||
* @param query 查询条件
|
||||
* @return 预约统计数据
|
||||
*/
|
||||
Mono<BookingStatistics> getBookingStatistics(StatisticsQuery query);
|
||||
|
||||
/**
|
||||
* 获取签到统计数据
|
||||
*
|
||||
* @param query 查询条件
|
||||
* @return 签到统计数据
|
||||
*/
|
||||
Mono<SignInStatistics> getSignInStatistics(StatisticsQuery query);
|
||||
|
||||
/**
|
||||
* 获取综合统计数据(包含会员、预约、签到)
|
||||
*
|
||||
* @param query 查询条件
|
||||
* @return 综合统计数据
|
||||
*/
|
||||
Mono<StatisticsSummary> getStatisticsSummary(StatisticsQuery query);
|
||||
|
||||
/**
|
||||
* 查询历史统计数据
|
||||
*
|
||||
* @param query 查询条件
|
||||
* @return 历史统计数据列表
|
||||
*/
|
||||
Flux<DataStatistics> queryHistoricalStatistics(StatisticsQuery query);
|
||||
|
||||
/**
|
||||
* 执行每日统计数据更新(定时任务调用)
|
||||
*
|
||||
* @param statDate 统计日期
|
||||
* @return 更新结果
|
||||
*/
|
||||
Mono<Void> executeDailyStatistics(java.time.LocalDate statDate);
|
||||
|
||||
/**
|
||||
* 导出统计数据为Excel
|
||||
*
|
||||
* @param query 查询条件
|
||||
* @return Excel文件的字节数组
|
||||
*/
|
||||
Mono<byte[]> exportStatistics(StatisticsQuery query);
|
||||
|
||||
/**
|
||||
* 获取统计数据(带缓存)
|
||||
*
|
||||
* @param query 查询条件
|
||||
* @return 统计数据
|
||||
*/
|
||||
Mono<StatisticsSummary> getStatisticsSummaryWithCache(StatisticsQuery query);
|
||||
}
|
||||
+318
@@ -0,0 +1,318 @@
|
||||
package cn.novalon.gym.manage.datacount.service.impl;
|
||||
|
||||
import cn.novalon.gym.manage.common.util.RedisUtil;
|
||||
import cn.novalon.gym.manage.datacount.dao.StatisticsDao;
|
||||
import cn.novalon.gym.manage.datacount.domain.BookingStatistics;
|
||||
import cn.novalon.gym.manage.datacount.domain.MemberStatistics;
|
||||
import cn.novalon.gym.manage.datacount.service.IDataCountService;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.PrintWriter;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class DataCountServiceImpl implements IDataCountService {
|
||||
|
||||
private final StatisticsDao statisticsDao;
|
||||
private final RedisUtil redisUtil;
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
private static final String MEMBER_STATS_CACHE_PREFIX = "stats:member:";
|
||||
private static final String BOOKING_STATS_CACHE_PREFIX = "stats:booking:";
|
||||
private static final long CACHE_EXPIRE_SECONDS = 3600;
|
||||
|
||||
public DataCountServiceImpl(StatisticsDao statisticsDao, RedisUtil redisUtil, ObjectMapper objectMapper) {
|
||||
this.statisticsDao = statisticsDao;
|
||||
this.redisUtil = redisUtil;
|
||||
this.objectMapper = objectMapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<MemberStatistics> getMemberStatisticsByDate(LocalDate date) {
|
||||
String cacheKey = MEMBER_STATS_CACHE_PREFIX + date.toString();
|
||||
return redisUtil.get(cacheKey)
|
||||
.flatMap(cached -> {
|
||||
if (cached != null) {
|
||||
try {
|
||||
MemberStatistics stats = objectMapper.readValue(cached.toString(), MemberStatistics.class);
|
||||
log.debug("从缓存获取会员统计数据, date: {}", date);
|
||||
return Mono.just(stats);
|
||||
} catch (Exception e) {
|
||||
log.warn("缓存数据解析失败, date: {}", date, e);
|
||||
}
|
||||
}
|
||||
return Mono.empty();
|
||||
})
|
||||
.switchIfEmpty(fetchMemberStatisticsByDate(date)
|
||||
.flatMap(stats -> {
|
||||
try {
|
||||
String json = objectMapper.writeValueAsString(stats);
|
||||
return redisUtil.setWithExpire(cacheKey, json, CACHE_EXPIRE_SECONDS)
|
||||
.then(Mono.just(stats));
|
||||
} catch (Exception e) {
|
||||
log.warn("缓存会员统计数据失败, date: {}", date, e);
|
||||
return Mono.just(stats);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
private Mono<MemberStatistics> fetchMemberStatisticsByDate(LocalDate date) {
|
||||
return Mono.zip(
|
||||
statisticsDao.countTotalMembers(),
|
||||
statisticsDao.countNewMembersByDate(date),
|
||||
statisticsDao.countActiveMembersByDate(date),
|
||||
statisticsDao.countMaleMembers(),
|
||||
statisticsDao.countFemaleMembers(),
|
||||
statisticsDao.countCardPurchaseByDate(date),
|
||||
statisticsDao.calculateAverageAge()
|
||||
).map(tuple -> {
|
||||
MemberStatistics stats = new MemberStatistics(date);
|
||||
stats.setTotalMembers(tuple.getT1());
|
||||
stats.setNewMembers(tuple.getT2());
|
||||
stats.setActiveMembers(tuple.getT3());
|
||||
stats.setMaleMembers(tuple.getT4());
|
||||
stats.setFemaleMembers(tuple.getT5());
|
||||
stats.setCardPurchaseCount(tuple.getT6());
|
||||
stats.setAverageAge(tuple.getT7() != null ? tuple.getT7() : 0.0);
|
||||
return stats;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<MemberStatistics> getMemberStatisticsByDateRange(LocalDate startDate, LocalDate endDate) {
|
||||
return statisticsDao.findMemberStatisticsByDateRange(startDate, endDate)
|
||||
.map(row -> {
|
||||
LocalDate date = (LocalDate) row[0];
|
||||
MemberStatistics stats = new MemberStatistics(date);
|
||||
stats.setNewMembers(((Number) row[1]).intValue());
|
||||
return stats;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<MemberStatistics> getMemberStatisticsSummary(LocalDate startDate, LocalDate endDate) {
|
||||
return getMemberStatisticsByDateRange(startDate, endDate)
|
||||
.collectList()
|
||||
.flatMap(list -> {
|
||||
MemberStatistics summary = new MemberStatistics();
|
||||
summary.setStartDate(startDate);
|
||||
summary.setEndDate(endDate);
|
||||
summary.setNewMembers(list.stream().mapToInt(MemberStatistics::getNewMembers).sum());
|
||||
|
||||
return Mono.zip(
|
||||
statisticsDao.countTotalMembers(),
|
||||
statisticsDao.countMaleMembers(),
|
||||
statisticsDao.countFemaleMembers(),
|
||||
statisticsDao.calculateAverageAge()
|
||||
).map(tuple -> {
|
||||
summary.setTotalMembers(tuple.getT1());
|
||||
summary.setMaleMembers(tuple.getT2());
|
||||
summary.setFemaleMembers(tuple.getT3());
|
||||
summary.setAverageAge(tuple.getT4() != null ? tuple.getT4() : 0.0);
|
||||
return summary;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<BookingStatistics> getBookingStatisticsByDate(LocalDate date) {
|
||||
String cacheKey = BOOKING_STATS_CACHE_PREFIX + date.toString();
|
||||
return redisUtil.get(cacheKey)
|
||||
.flatMap(cached -> {
|
||||
if (cached != null) {
|
||||
try {
|
||||
BookingStatistics stats = objectMapper.readValue(cached.toString(), BookingStatistics.class);
|
||||
log.debug("从缓存获取预约统计数据, date: {}", date);
|
||||
return Mono.just(stats);
|
||||
} catch (Exception e) {
|
||||
log.warn("缓存数据解析失败, date: {}", date, e);
|
||||
}
|
||||
}
|
||||
return Mono.empty();
|
||||
})
|
||||
.switchIfEmpty(fetchBookingStatisticsByDate(date)
|
||||
.flatMap(stats -> {
|
||||
try {
|
||||
String json = objectMapper.writeValueAsString(stats);
|
||||
return redisUtil.setWithExpire(cacheKey, json, CACHE_EXPIRE_SECONDS)
|
||||
.then(Mono.just(stats));
|
||||
} catch (Exception e) {
|
||||
log.warn("缓存预约统计数据失败, date: {}", date, e);
|
||||
return Mono.just(stats);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
private Mono<BookingStatistics> fetchBookingStatisticsByDate(LocalDate date) {
|
||||
return Mono.zip(
|
||||
statisticsDao.countTotalBookingsByDate(date),
|
||||
statisticsDao.countCancelledBookingsByDate(date),
|
||||
statisticsDao.countAttendedBookingsByDate(date),
|
||||
statisticsDao.countTotalCoursesByDate(date),
|
||||
statisticsDao.countFullCoursesByDate(date),
|
||||
statisticsDao.findMostPopularCourseByDate(date)
|
||||
).map(tuple -> {
|
||||
int totalBookings = tuple.getT1();
|
||||
int cancelledBookings = tuple.getT2();
|
||||
int attendedBookings = tuple.getT3();
|
||||
|
||||
BookingStatistics stats = new BookingStatistics(date);
|
||||
stats.setTotalBookings(totalBookings);
|
||||
stats.setCancelledBookings(cancelledBookings);
|
||||
stats.setAttendedBookings(attendedBookings);
|
||||
stats.setTotalCourses(tuple.getT4());
|
||||
stats.setFullCourses(tuple.getT5());
|
||||
|
||||
if (totalBookings > 0) {
|
||||
stats.setCancellationRate(Math.round(cancelledBookings * 10000.0 / totalBookings) / 100.0);
|
||||
stats.setAttendanceRate(Math.round(attendedBookings * 10000.0 / totalBookings) / 100.0);
|
||||
}
|
||||
|
||||
Object[] popularCourse = tuple.getT6();
|
||||
if (popularCourse != null && popularCourse.length >= 2) {
|
||||
stats.setPopularCourseName((String) popularCourse[0]);
|
||||
stats.setPopularCourseCount(((Number) popularCourse[1]).intValue());
|
||||
}
|
||||
|
||||
return stats;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<BookingStatistics> getBookingStatisticsByDateRange(LocalDate startDate, LocalDate endDate) {
|
||||
return statisticsDao.findBookingStatisticsByDateRange(startDate, endDate)
|
||||
.map(row -> {
|
||||
LocalDate date = (LocalDate) row[0];
|
||||
int totalBookings = ((Number) row[1]).intValue();
|
||||
int cancelledBookings = ((Number) row[2]).intValue();
|
||||
int attendedBookings = ((Number) row[3]).intValue();
|
||||
|
||||
BookingStatistics stats = new BookingStatistics(date);
|
||||
stats.setTotalBookings(totalBookings);
|
||||
stats.setCancelledBookings(cancelledBookings);
|
||||
stats.setAttendedBookings(attendedBookings);
|
||||
|
||||
if (totalBookings > 0) {
|
||||
stats.setCancellationRate(Math.round(cancelledBookings * 10000.0 / totalBookings) / 100.0);
|
||||
stats.setAttendanceRate(Math.round(attendedBookings * 10000.0 / totalBookings) / 100.0);
|
||||
}
|
||||
|
||||
return stats;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<BookingStatistics> getBookingStatisticsSummary(LocalDate startDate, LocalDate endDate) {
|
||||
return getBookingStatisticsByDateRange(startDate, endDate)
|
||||
.collectList()
|
||||
.map(list -> {
|
||||
BookingStatistics summary = new BookingStatistics();
|
||||
summary.setStartDate(startDate);
|
||||
summary.setEndDate(endDate);
|
||||
summary.setTotalBookings(list.stream().mapToInt(BookingStatistics::getTotalBookings).sum());
|
||||
summary.setCancelledBookings(list.stream().mapToInt(BookingStatistics::getCancelledBookings).sum());
|
||||
summary.setAttendedBookings(list.stream().mapToInt(BookingStatistics::getAttendedBookings).sum());
|
||||
|
||||
int total = summary.getTotalBookings();
|
||||
if (total > 0) {
|
||||
summary.setCancellationRate(Math.round(summary.getCancelledBookings() * 10000.0 / total) / 100.0);
|
||||
summary.setAttendanceRate(Math.round(summary.getAttendedBookings() * 10000.0 / total) / 100.0);
|
||||
}
|
||||
|
||||
return summary;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<byte[]> exportMemberStatistics(LocalDate startDate, LocalDate endDate) {
|
||||
return getMemberStatisticsByDateRange(startDate, endDate)
|
||||
.collectList()
|
||||
.map(this::generateMemberStatisticsCSV);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<byte[]> exportBookingStatistics(LocalDate startDate, LocalDate endDate) {
|
||||
return getBookingStatisticsByDateRange(startDate, endDate)
|
||||
.collectList()
|
||||
.map(this::generateBookingStatisticsCSV);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<byte[]> exportAllStatistics(LocalDate startDate, LocalDate endDate) {
|
||||
return Mono.zip(
|
||||
getMemberStatisticsByDateRange(startDate, endDate).collectList(),
|
||||
getBookingStatisticsByDateRange(startDate, endDate).collectList()
|
||||
).map(tuple -> {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
PrintWriter writer = new PrintWriter(new OutputStreamWriter(baos, StandardCharsets.UTF_8));
|
||||
|
||||
writer.println("=== 会员数据统计 ===");
|
||||
writer.println(generateMemberStatisticsCSVContent(tuple.getT1()));
|
||||
writer.println();
|
||||
writer.println("=== 预约数据统计 ===");
|
||||
writer.println(generateBookingStatisticsCSVContent(tuple.getT2()));
|
||||
|
||||
writer.flush();
|
||||
return baos.toByteArray();
|
||||
});
|
||||
}
|
||||
|
||||
private byte[] generateMemberStatisticsCSV(List<MemberStatistics> statsList) {
|
||||
return generateMemberStatisticsCSVContent(statsList).getBytes(StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
private String generateMemberStatisticsCSVContent(List<MemberStatistics> statsList) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("统计日期,新增会员数,活跃会员数,总会员数,男性会员数,女性会员数,购卡人数,平均年龄\n");
|
||||
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
for (MemberStatistics stats : statsList) {
|
||||
sb.append(stats.getDate().format(formatter)).append(",");
|
||||
sb.append(stats.getNewMembers()).append(",");
|
||||
sb.append(stats.getActiveMembers()).append(",");
|
||||
sb.append(stats.getTotalMembers()).append(",");
|
||||
sb.append(stats.getMaleMembers()).append(",");
|
||||
sb.append(stats.getFemaleMembers()).append(",");
|
||||
sb.append(stats.getCardPurchaseCount()).append(",");
|
||||
sb.append(String.format("%.1f", stats.getAverageAge())).append("\n");
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private byte[] generateBookingStatisticsCSV(List<BookingStatistics> statsList) {
|
||||
return generateBookingStatisticsCSVContent(statsList).getBytes(StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
private String generateBookingStatisticsCSVContent(List<BookingStatistics> statsList) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("统计日期,预约总数,取消预约数,实际到场数,取消率(%),到场率(%),热门课程,热门课程预约数,团课总数,满员课程数\n");
|
||||
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
for (BookingStatistics stats : statsList) {
|
||||
sb.append(stats.getDate().format(formatter)).append(",");
|
||||
sb.append(stats.getTotalBookings()).append(",");
|
||||
sb.append(stats.getCancelledBookings()).append(",");
|
||||
sb.append(stats.getAttendedBookings()).append(",");
|
||||
sb.append(String.format("%.2f", stats.getCancellationRate())).append(",");
|
||||
sb.append(String.format("%.2f", stats.getAttendanceRate())).append(",");
|
||||
sb.append(stats.getPopularCourseName() != null ? stats.getPopularCourseName() : "").append(",");
|
||||
sb.append(stats.getPopularCourseCount()).append(",");
|
||||
sb.append(stats.getTotalCourses()).append(",");
|
||||
sb.append(stats.getFullCourses()).append("\n");
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
-513
@@ -1,513 +0,0 @@
|
||||
package cn.novalon.gym.manage.datacount.service.impl;
|
||||
|
||||
import cn.novalon.gym.manage.checkIn.entity.SignInRecord;
|
||||
import cn.novalon.gym.manage.common.util.RedisUtil;
|
||||
import cn.novalon.gym.manage.datacount.dao.DataStatisticsDao;
|
||||
import cn.novalon.gym.manage.datacount.domain.*;
|
||||
import cn.novalon.gym.manage.datacount.service.IDataStatisticsService;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.time.DayOfWeek;
|
||||
import java.time.Duration;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.temporal.TemporalAdjusters;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 数据统计服务实现类
|
||||
*
|
||||
* @author system
|
||||
* @date 2026-06-09
|
||||
*/
|
||||
@Service
|
||||
public class DataStatisticsServiceImpl implements IDataStatisticsService {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(DataStatisticsServiceImpl.class);
|
||||
|
||||
private static final String CACHE_KEY_PREFIX = "datacount:statistics:";
|
||||
private static final long CACHE_EXPIRE_SECONDS = 3600; // 1小时
|
||||
|
||||
@Autowired
|
||||
private DataStatisticsDao dataStatisticsDao;
|
||||
|
||||
@Autowired
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
@Autowired
|
||||
private ObjectMapper objectMapper;
|
||||
|
||||
@Value("${datacount.cache.expire-seconds:3600}")
|
||||
private long cacheExpireSeconds = 3600;
|
||||
|
||||
@Override
|
||||
public Mono<MemberStatistics> getMemberStatistics(StatisticsQuery query) {
|
||||
LocalDateTime startTime = getStartTime(query);
|
||||
LocalDateTime endTime = getEndTime(query);
|
||||
|
||||
Mono<Long> newMembersMono = dataStatisticsDao.countNewMembers(startTime, endTime);
|
||||
Mono<Long> totalMembersMono = dataStatisticsDao.countTotalMembers();
|
||||
Mono<Long> signInMembersMono = dataStatisticsDao.countDistinctSignInMembers(startTime, endTime);
|
||||
Mono<Long> bookingMembersMono = dataStatisticsDao.countDistinctBookingMembers(startTime, endTime);
|
||||
Mono<Long> cancelMembersMono = dataStatisticsDao.countDistinctCancelMembers(startTime, endTime);
|
||||
|
||||
return Mono.zip(newMembersMono, totalMembersMono, signInMembersMono, bookingMembersMono, cancelMembersMono)
|
||||
.map(tuple -> {
|
||||
long newMembers = tuple.getT1() != null ? tuple.getT1() : 0L;
|
||||
long totalMembers = tuple.getT2() != null ? tuple.getT2() : 0L;
|
||||
long signInMembers = tuple.getT3() != null ? tuple.getT3() : 0L;
|
||||
long bookingMembers = tuple.getT4() != null ? tuple.getT4() : 0L;
|
||||
long cancelMembers = tuple.getT5() != null ? tuple.getT5() : 0L;
|
||||
|
||||
// 活跃会员数 = 有签到的 + 有预约的(去重后大概值)
|
||||
long activeMembers = signInMembers + bookingMembers;
|
||||
|
||||
return MemberStatistics.builder()
|
||||
.statDate(startTime.toLocalDate().toString())
|
||||
.newMembers(newMembers)
|
||||
.activeMembers(activeMembers)
|
||||
.totalMembers(totalMembers)
|
||||
.signInMembers(signInMembers)
|
||||
.bookingMembers(bookingMembers)
|
||||
.cancelBookingMembers(cancelMembers)
|
||||
.build();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<BookingStatistics> getBookingStatistics(StatisticsQuery query) {
|
||||
LocalDateTime startTime = getStartTime(query);
|
||||
LocalDateTime endTime = getEndTime(query);
|
||||
|
||||
Mono<Long> totalMono = dataStatisticsDao.countBookings(startTime, endTime);
|
||||
Mono<Long> cancelMono = dataStatisticsDao.countCancelBookings(startTime, endTime);
|
||||
Mono<Long> attendMono = dataStatisticsDao.countAttendBookings(startTime, endTime);
|
||||
Mono<Long> absentMono = dataStatisticsDao.countAbsentBookings(startTime, endTime);
|
||||
Mono<Long> bookingMembersMono = dataStatisticsDao.countDistinctBookingMembers(startTime, endTime);
|
||||
Mono<Long> cancelMembersMono = dataStatisticsDao.countDistinctCancelMembers(startTime, endTime);
|
||||
|
||||
return Mono.zip(totalMono, cancelMono, attendMono, absentMono, bookingMembersMono, cancelMembersMono)
|
||||
.map(tuple -> {
|
||||
long total = tuple.getT1() != null ? tuple.getT1() : 0L;
|
||||
long cancel = tuple.getT2() != null ? tuple.getT2() : 0L;
|
||||
long attend = tuple.getT3() != null ? tuple.getT3() : 0L;
|
||||
long absent = tuple.getT4() != null ? tuple.getT4() : 0L;
|
||||
long bookingMembers = tuple.getT5() != null ? tuple.getT5() : 0L;
|
||||
long cancelMembers = tuple.getT6() != null ? tuple.getT6() : 0L;
|
||||
|
||||
double attendanceRate = total > 0 ? (double) attend / total * 100 : 0;
|
||||
double cancelRate = total > 0 ? (double) cancel / total * 100 : 0;
|
||||
|
||||
return BookingStatistics.builder()
|
||||
.statDate(startTime.toLocalDate().toString())
|
||||
.newBookings(total)
|
||||
.cancelBookings(cancel)
|
||||
.attendBookings(attend)
|
||||
.absentBookings(absent)
|
||||
.attendanceRate(Math.round(attendanceRate * 100.0) / 100.0)
|
||||
.cancelRate(Math.round(cancelRate * 100.0) / 100.0)
|
||||
.bookingMembers(bookingMembers)
|
||||
.cancelMembers(cancelMembers)
|
||||
.build();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<SignInStatistics> getSignInStatistics(StatisticsQuery query) {
|
||||
LocalDateTime startTime = getStartTime(query);
|
||||
LocalDateTime endTime = getEndTime(query);
|
||||
|
||||
Mono<Long> totalMono = dataStatisticsDao.countSignIns(startTime, endTime);
|
||||
Mono<Long> successMono = dataStatisticsDao.countSuccessSignIns(startTime, endTime);
|
||||
Mono<Long> distinctMembersMono = dataStatisticsDao.countDistinctSignInMembers(startTime, endTime);
|
||||
|
||||
return Mono.zip(totalMono, successMono, distinctMembersMono)
|
||||
.flatMap(tuple -> {
|
||||
long total = tuple.getT1() != null ? tuple.getT1() : 0L;
|
||||
long success = tuple.getT2() != null ? tuple.getT2() : 0L;
|
||||
long distinctMembers = tuple.getT3() != null ? tuple.getT3() : 0L;
|
||||
|
||||
double successRate = total > 0 ? (double) success / total * 100 : 0;
|
||||
|
||||
return dataStatisticsDao.countSignInsByType(startTime, endTime)
|
||||
.collectMap(
|
||||
DataStatisticsDao.SignInTypeCount::getType,
|
||||
DataStatisticsDao.SignInTypeCount::getCount
|
||||
)
|
||||
.defaultIfEmpty(new HashMap<>())
|
||||
.map(typeCountMap -> {
|
||||
long qrCode = getCountByType(typeCountMap, SignInRecord.SignInType.QR_CODE);
|
||||
long manual = getCountByType(typeCountMap, SignInRecord.SignInType.MANUAL);
|
||||
long face = getCountByType(typeCountMap, SignInRecord.SignInType.FACE);
|
||||
|
||||
return SignInStatistics.builder()
|
||||
.statDate(startTime.toLocalDate().toString())
|
||||
.totalSignIns(total)
|
||||
.successSignIns(success)
|
||||
.failedSignIns(total - success)
|
||||
.successRate(Math.round(successRate * 100.0) / 100.0)
|
||||
.signInMembers(distinctMembers)
|
||||
.qrCodeSignIns(qrCode)
|
||||
.manualSignIns(manual)
|
||||
.faceSignIns(face)
|
||||
.build();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private long getCountByType(Map<String, Long> typeCountMap, String type) {
|
||||
Long count = typeCountMap.get(type);
|
||||
return count != null ? count : 0L;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<StatisticsSummary> getStatisticsSummary(StatisticsQuery query) {
|
||||
Mono<MemberStatistics> memberStatsMono = getMemberStatistics(query);
|
||||
Mono<BookingStatistics> bookingStatsMono = getBookingStatistics(query);
|
||||
Mono<SignInStatistics> signInStatsMono = getSignInStatistics(query);
|
||||
|
||||
return Mono.zip(memberStatsMono, bookingStatsMono, signInStatsMono)
|
||||
.map(tuple -> StatisticsSummary.builder()
|
||||
.statDate(LocalDateTime.now().toLocalDate().toString())
|
||||
.memberStatistics(tuple.getT1())
|
||||
.bookingStatistics(tuple.getT2())
|
||||
.signInStatistics(tuple.getT3())
|
||||
.generatedAt(LocalDateTime.now().format(DateTimeFormatter.ISO_LOCAL_DATE_TIME))
|
||||
.build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public reactor.core.publisher.Flux<DataStatistics> queryHistoricalStatistics(StatisticsQuery query) {
|
||||
// 历史统计数据查询(从Redis缓存中获取)
|
||||
String cacheKey = buildCacheKey(query);
|
||||
return redisUtil.get(cacheKey, String.class)
|
||||
.flatMapMany(json -> {
|
||||
try {
|
||||
java.util.List<DataStatistics> stats = objectMapper.readValue(json,
|
||||
objectMapper.getTypeFactory().constructCollectionType(java.util.List.class, DataStatistics.class));
|
||||
return reactor.core.publisher.Flux.fromIterable(stats);
|
||||
} catch (Exception e) {
|
||||
log.error("Failed to parse historical statistics from cache", e);
|
||||
return reactor.core.publisher.Flux.empty();
|
||||
}
|
||||
})
|
||||
.switchIfEmpty(reactor.core.publisher.Flux.empty());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Void> executeDailyStatistics(LocalDate statDate) {
|
||||
log.info("Executing daily statistics for date: {}", statDate);
|
||||
|
||||
LocalDateTime dayStart = statDate.atStartOfDay();
|
||||
LocalDateTime dayEnd = statDate.plusDays(1).atStartOfDay();
|
||||
|
||||
StatisticsQuery query = StatisticsQuery.builder()
|
||||
.startTime(dayStart)
|
||||
.endTime(dayEnd)
|
||||
.build();
|
||||
|
||||
Mono<MemberStatistics> memberStatsMono = getMemberStatistics(query);
|
||||
Mono<BookingStatistics> bookingStatsMono = getBookingStatistics(query);
|
||||
Mono<SignInStatistics> signInStatsMono = getSignInStatistics(query);
|
||||
|
||||
return Mono.zip(memberStatsMono, bookingStatsMono, signInStatsMono)
|
||||
.flatMap(tuple -> {
|
||||
MemberStatistics memberStats = tuple.getT1();
|
||||
BookingStatistics bookingStats = tuple.getT2();
|
||||
SignInStatistics signInStats = tuple.getT3();
|
||||
|
||||
String dateStr = statDate.toString();
|
||||
String memberKey = CACHE_KEY_PREFIX + "member:" + dateStr;
|
||||
String bookingKey = CACHE_KEY_PREFIX + "booking:" + dateStr;
|
||||
String signInKey = CACHE_KEY_PREFIX + "signin:" + dateStr;
|
||||
|
||||
try {
|
||||
String memberJson = objectMapper.writeValueAsString(memberStats);
|
||||
String bookingJson = objectMapper.writeValueAsString(bookingStats);
|
||||
String signInJson = objectMapper.writeValueAsString(signInStats);
|
||||
|
||||
return reactor.core.publisher.Flux.merge(
|
||||
redisUtil.setWithExpire(memberKey, memberJson, Duration.ofDays(30).getSeconds()),
|
||||
redisUtil.setWithExpire(bookingKey, bookingJson, Duration.ofDays(30).getSeconds()),
|
||||
redisUtil.setWithExpire(signInKey, signInJson, Duration.ofDays(30).getSeconds())
|
||||
).then();
|
||||
} catch (Exception e) {
|
||||
log.error("Failed to serialize statistics data", e);
|
||||
return Mono.empty();
|
||||
}
|
||||
})
|
||||
.then()
|
||||
.doOnSuccess(v -> log.info("Daily statistics completed for date: {}", statDate))
|
||||
.doOnError(e -> log.error("Failed to execute daily statistics for date: {}", statDate, e));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<byte[]> exportStatistics(StatisticsQuery query) {
|
||||
return getStatisticsSummary(query)
|
||||
.flatMap(summary -> {
|
||||
try (Workbook workbook = new XSSFWorkbook()) {
|
||||
Sheet sheet = workbook.createSheet("数据统计报表");
|
||||
|
||||
CellStyle headerStyle = workbook.createCellStyle();
|
||||
Font headerFont = workbook.createFont();
|
||||
headerFont.setBold(true);
|
||||
headerStyle.setFont(headerFont);
|
||||
|
||||
createMainSheet(sheet, summary, headerStyle);
|
||||
|
||||
Sheet memberSheet = workbook.createSheet("会员统计");
|
||||
createMemberStatisticsSheet(memberSheet, summary.getMemberStatistics(), headerStyle);
|
||||
|
||||
Sheet bookingSheet = workbook.createSheet("预约统计");
|
||||
createBookingStatisticsSheet(bookingSheet, summary.getBookingStatistics(), headerStyle);
|
||||
|
||||
Sheet signInSheet = workbook.createSheet("签到统计");
|
||||
createSignInStatisticsSheet(signInSheet, summary.getSignInStatistics(), headerStyle);
|
||||
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
workbook.write(outputStream);
|
||||
return Mono.just(outputStream.toByteArray());
|
||||
} catch (Exception e) {
|
||||
log.error("Failed to export statistics", e);
|
||||
return Mono.error(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void createMainSheet(Sheet sheet, StatisticsSummary summary, CellStyle headerStyle) {
|
||||
int rowNum = 0;
|
||||
Row row = sheet.createRow(rowNum++);
|
||||
row.createCell(0).setCellValue("统计项");
|
||||
row.createCell(1).setCellValue("数值");
|
||||
|
||||
row = sheet.createRow(rowNum++);
|
||||
row.createCell(0).setCellValue("统计日期");
|
||||
row.createCell(1).setCellValue(summary.getStatDate());
|
||||
|
||||
row = sheet.createRow(rowNum++);
|
||||
row.createCell(0).setCellValue("新增会员数");
|
||||
row.createCell(1).setCellValue(summary.getMemberStatistics().getNewMembers());
|
||||
|
||||
row = sheet.createRow(rowNum++);
|
||||
row.createCell(0).setCellValue("活跃会员数");
|
||||
row.createCell(1).setCellValue(summary.getMemberStatistics().getActiveMembers());
|
||||
|
||||
row = sheet.createRow(rowNum++);
|
||||
row.createCell(0).setCellValue("累计会员总数");
|
||||
row.createCell(1).setCellValue(summary.getMemberStatistics().getTotalMembers());
|
||||
|
||||
row = sheet.createRow(rowNum++);
|
||||
row.createCell(0).setCellValue("新增预约数");
|
||||
row.createCell(1).setCellValue(summary.getBookingStatistics().getNewBookings());
|
||||
|
||||
row = sheet.createRow(rowNum++);
|
||||
row.createCell(0).setCellValue("预约出席率");
|
||||
row.createCell(1).setCellValue(summary.getBookingStatistics().getAttendanceRate() + "%");
|
||||
|
||||
row = sheet.createRow(rowNum++);
|
||||
row.createCell(0).setCellValue("签到总次数");
|
||||
row.createCell(1).setCellValue(summary.getSignInStatistics().getTotalSignIns());
|
||||
|
||||
row = sheet.createRow(rowNum++);
|
||||
row.createCell(0).setCellValue("签到成功率");
|
||||
row.createCell(1).setCellValue(summary.getSignInStatistics().getSuccessRate() + "%");
|
||||
|
||||
sheet.autoSizeColumn(0);
|
||||
sheet.autoSizeColumn(1);
|
||||
}
|
||||
|
||||
private void createMemberStatisticsSheet(Sheet sheet, MemberStatistics stats, CellStyle headerStyle) {
|
||||
int rowNum = 0;
|
||||
Row row = sheet.createRow(rowNum++);
|
||||
row.createCell(0).setCellValue("统计项");
|
||||
row.createCell(1).setCellValue("数值");
|
||||
|
||||
String[][] data = {
|
||||
{"统计日期", stats.getStatDate()},
|
||||
{"新增会员数", String.valueOf(stats.getNewMembers())},
|
||||
{"活跃会员数", String.valueOf(stats.getActiveMembers())},
|
||||
{"累计会员总数", String.valueOf(stats.getTotalMembers())},
|
||||
{"今日签到会员数", String.valueOf(stats.getSignInMembers())},
|
||||
{"今日预约会员数", String.valueOf(stats.getBookingMembers())},
|
||||
{"今日取消预约会员数", String.valueOf(stats.getCancelBookingMembers())}
|
||||
};
|
||||
|
||||
for (String[] rowData : data) {
|
||||
row = sheet.createRow(rowNum++);
|
||||
row.createCell(0).setCellValue(rowData[0]);
|
||||
row.createCell(1).setCellValue(rowData[1]);
|
||||
}
|
||||
|
||||
sheet.autoSizeColumn(0);
|
||||
sheet.autoSizeColumn(1);
|
||||
}
|
||||
|
||||
private void createBookingStatisticsSheet(Sheet sheet, BookingStatistics stats, CellStyle headerStyle) {
|
||||
int rowNum = 0;
|
||||
Row row = sheet.createRow(rowNum++);
|
||||
row.createCell(0).setCellValue("统计项");
|
||||
row.createCell(1).setCellValue("数值");
|
||||
|
||||
String[][] data = {
|
||||
{"统计日期", stats.getStatDate()},
|
||||
{"新增预约数", String.valueOf(stats.getNewBookings())},
|
||||
{"取消预约数", String.valueOf(stats.getCancelBookings())},
|
||||
{"出席预约数", String.valueOf(stats.getAttendBookings())},
|
||||
{"缺席预约数", String.valueOf(stats.getAbsentBookings())},
|
||||
{"预约出席率", stats.getAttendanceRate() + "%"},
|
||||
{"取消率", stats.getCancelRate() + "%"},
|
||||
{"预约人数", String.valueOf(stats.getBookingMembers())},
|
||||
{"取消人数", String.valueOf(stats.getCancelMembers())}
|
||||
};
|
||||
|
||||
for (String[] rowData : data) {
|
||||
row = sheet.createRow(rowNum++);
|
||||
row.createCell(0).setCellValue(rowData[0]);
|
||||
row.createCell(1).setCellValue(rowData[1]);
|
||||
}
|
||||
|
||||
sheet.autoSizeColumn(0);
|
||||
sheet.autoSizeColumn(1);
|
||||
}
|
||||
|
||||
private void createSignInStatisticsSheet(Sheet sheet, SignInStatistics stats, CellStyle headerStyle) {
|
||||
int rowNum = 0;
|
||||
Row row = sheet.createRow(rowNum++);
|
||||
row.createCell(0).setCellValue("统计项");
|
||||
row.createCell(1).setCellValue("数值");
|
||||
|
||||
String[][] data = {
|
||||
{"统计日期", stats.getStatDate()},
|
||||
{"签到总次数", String.valueOf(stats.getTotalSignIns())},
|
||||
{"成功签到次数", String.valueOf(stats.getSuccessSignIns())},
|
||||
{"失败签到次数", String.valueOf(stats.getFailedSignIns())},
|
||||
{"签到成功率", stats.getSuccessRate() + "%"},
|
||||
{"签到人数", String.valueOf(stats.getSignInMembers())},
|
||||
{"扫码签到次数", String.valueOf(stats.getQrCodeSignIns())},
|
||||
{"手动签到次数", String.valueOf(stats.getManualSignIns())},
|
||||
{"人脸识别签到次数", String.valueOf(stats.getFaceSignIns())}
|
||||
};
|
||||
|
||||
for (String[] rowData : data) {
|
||||
row = sheet.createRow(rowNum++);
|
||||
row.createCell(0).setCellValue(rowData[0]);
|
||||
row.createCell(1).setCellValue(rowData[1]);
|
||||
}
|
||||
|
||||
sheet.autoSizeColumn(0);
|
||||
sheet.autoSizeColumn(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<StatisticsSummary> getStatisticsSummaryWithCache(StatisticsQuery query) {
|
||||
String cacheKey = buildCacheKey(query);
|
||||
|
||||
return redisUtil.get(cacheKey, StatisticsSummary.class)
|
||||
.switchIfEmpty(
|
||||
getStatisticsSummary(query)
|
||||
.flatMap(summary -> {
|
||||
try {
|
||||
String json = objectMapper.writeValueAsString(summary);
|
||||
return redisUtil.setWithExpire(cacheKey, json, cacheExpireSeconds)
|
||||
.thenReturn(summary);
|
||||
} catch (Exception e) {
|
||||
log.error("Failed to serialize statistics summary", e);
|
||||
return Mono.just(summary);
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
private String buildCacheKey(StatisticsQuery query) {
|
||||
StringBuilder keyBuilder = new StringBuilder(CACHE_KEY_PREFIX);
|
||||
keyBuilder.append("summary:");
|
||||
|
||||
if (query.getStartTime() != null) {
|
||||
keyBuilder.append(query.getStartTime().toLocalDate().toString());
|
||||
}
|
||||
if (query.getEndTime() != null) {
|
||||
keyBuilder.append("_").append(query.getEndTime().toLocalDate().toString());
|
||||
}
|
||||
if (query.getStatType() != null) {
|
||||
keyBuilder.append("_").append(query.getStatType());
|
||||
}
|
||||
if (query.getPeriodType() != null) {
|
||||
keyBuilder.append("_").append(query.getPeriodType());
|
||||
}
|
||||
|
||||
return keyBuilder.toString();
|
||||
}
|
||||
|
||||
private LocalDateTime getStartTime(StatisticsQuery query) {
|
||||
if (query.getStartTime() != null) {
|
||||
return query.getStartTime();
|
||||
}
|
||||
|
||||
LocalDate today = LocalDate.now();
|
||||
String periodType = query.getPeriodType();
|
||||
|
||||
if (DataStatistics.PeriodType.WEEK.equals(periodType)) {
|
||||
// 周统计:本周一
|
||||
return today.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY)).atStartOfDay();
|
||||
} else if (DataStatistics.PeriodType.MONTH.equals(periodType)) {
|
||||
// 月统计:本月第一天
|
||||
return today.withDayOfMonth(1).atStartOfDay();
|
||||
} else {
|
||||
// 日统计:当天零点
|
||||
return today.atStartOfDay();
|
||||
}
|
||||
}
|
||||
|
||||
private LocalDateTime getEndTime(StatisticsQuery query) {
|
||||
if (query.getEndTime() != null) {
|
||||
return query.getEndTime();
|
||||
}
|
||||
|
||||
LocalDate today = LocalDate.now();
|
||||
String periodType = query.getPeriodType();
|
||||
|
||||
if (DataStatistics.PeriodType.WEEK.equals(periodType)) {
|
||||
// 周统计:本周日 23:59:59
|
||||
return today.with(TemporalAdjusters.nextOrSame(DayOfWeek.SUNDAY)).atTime(23, 59, 59);
|
||||
} else if (DataStatistics.PeriodType.MONTH.equals(periodType)) {
|
||||
// 月统计:本月最后一天 23:59:59
|
||||
return today.with(TemporalAdjusters.lastDayOfMonth()).atTime(23, 59, 59);
|
||||
} else {
|
||||
// 日统计:当前时间
|
||||
return LocalDateTime.now();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据周期类型调整时间范围
|
||||
* 用于定时任务中的周期统计
|
||||
*/
|
||||
private LocalDateTime[] adjustTimeRangeByPeriod(LocalDate date, String periodType) {
|
||||
LocalDateTime startTime;
|
||||
LocalDateTime endTime;
|
||||
|
||||
if (DataStatistics.PeriodType.WEEK.equals(periodType)) {
|
||||
startTime = date.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY)).atStartOfDay();
|
||||
endTime = date.with(TemporalAdjusters.nextOrSame(DayOfWeek.SUNDAY)).atTime(23, 59, 59);
|
||||
} else if (DataStatistics.PeriodType.MONTH.equals(periodType)) {
|
||||
startTime = date.withDayOfMonth(1).atStartOfDay();
|
||||
endTime = date.with(TemporalAdjusters.lastDayOfMonth()).atTime(23, 59, 59);
|
||||
} else {
|
||||
startTime = date.atStartOfDay();
|
||||
endTime = date.plusDays(1).atStartOfDay();
|
||||
}
|
||||
|
||||
return new LocalDateTime[]{startTime, endTime};
|
||||
}
|
||||
}
|
||||
-1
@@ -1 +0,0 @@
|
||||
cn.novalon.gym.manage.datacount.config.DataCountAutoConfiguration
|
||||
@@ -0,0 +1,3 @@
|
||||
spring:
|
||||
application:
|
||||
name: gym-dataCount
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package cn.novalon.gym.manage.datacount;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class GymDataCountApplicationTests {
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -35,11 +35,6 @@
|
||||
<artifactId>manage-common</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.novalon.gym.manage</groupId>
|
||||
<artifactId>manage-sys</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.novalon.gym.manage</groupId>
|
||||
<artifactId>manage-db</artifactId>
|
||||
|
||||
-31
@@ -4,10 +4,8 @@ package cn.novalon.gym.manage.groupcourse.converter;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.novalon.gym.manage.groupcourse.domain.GroupCourse;
|
||||
import cn.novalon.gym.manage.groupcourse.domain.GroupCourseBooking;
|
||||
import cn.novalon.gym.manage.groupcourse.domain.GroupCourseType;
|
||||
import cn.novalon.gym.manage.groupcourse.entity.GroupCourseBookingEntity;
|
||||
import cn.novalon.gym.manage.groupcourse.entity.GroupCourseEntity;
|
||||
import cn.novalon.gym.manage.groupcourse.entity.GroupCourseTypeEntity;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -126,33 +124,4 @@ public class GroupCourseConverter {
|
||||
.map(this::toBookingEntity)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 将团课类型实体转换为领域模型
|
||||
*/
|
||||
public GroupCourseType toGroupCourseType(GroupCourseTypeEntity entity){
|
||||
if(entity == null){
|
||||
return null;
|
||||
}
|
||||
GroupCourseType groupCourseType = new GroupCourseType();
|
||||
BeanUtil.copyProperties(entity, groupCourseType);
|
||||
log.debug("转换团课类型实体到领域模型:typeId={}", entity.getId());
|
||||
return groupCourseType;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将团课类型领域模型转换为实体
|
||||
*/
|
||||
public GroupCourseTypeEntity toGroupCourseTypeEntity(GroupCourseType domain){
|
||||
if(domain == null){
|
||||
return null;
|
||||
}
|
||||
GroupCourseTypeEntity entity = new GroupCourseTypeEntity();
|
||||
BeanUtil.copyProperties(domain, entity);
|
||||
if (domain.getId() != null) {
|
||||
entity.markNotNew();
|
||||
}
|
||||
log.debug("转换团课类型领域模型到实体:typeId={}", domain.getId());
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
|
||||
-27
@@ -1,27 +0,0 @@
|
||||
package cn.novalon.gym.manage.groupcourse.dao;
|
||||
|
||||
import cn.novalon.gym.manage.groupcourse.entity.CourseLabelEntity;
|
||||
import org.springframework.data.r2dbc.repository.Modifying;
|
||||
import org.springframework.data.r2dbc.repository.Query;
|
||||
import org.springframework.data.r2dbc.repository.R2dbcRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Repository
|
||||
public interface CourseLabelDao extends R2dbcRepository<CourseLabelEntity, Long> {
|
||||
|
||||
Mono<CourseLabelEntity> findByIdIsAndDeletedAtIsNull(Long id);
|
||||
|
||||
Flux<CourseLabelEntity> findAllByDeletedAtIsNull();
|
||||
|
||||
Flux<CourseLabelEntity> findByLabelNameContainingAndDeletedAtIsNull(String labelName);
|
||||
|
||||
Mono<CourseLabelEntity> findByLabelNameAndDeletedAtIsNull(String labelName);
|
||||
|
||||
@Modifying
|
||||
@Query("UPDATE course_label SET deleted_at = :deletedAt WHERE id = :id")
|
||||
Mono<Integer> softDelete(Long id, LocalDateTime deletedAt);
|
||||
}
|
||||
-38
@@ -1,38 +0,0 @@
|
||||
package cn.novalon.gym.manage.groupcourse.dao;
|
||||
|
||||
import cn.novalon.gym.manage.groupcourse.entity.CourseTypeLabelEntity;
|
||||
import org.springframework.data.r2dbc.repository.Modifying;
|
||||
import org.springframework.data.r2dbc.repository.Query;
|
||||
import org.springframework.data.r2dbc.repository.R2dbcRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface CourseTypeLabelDao extends R2dbcRepository<CourseTypeLabelEntity, Long> {
|
||||
|
||||
Flux<CourseTypeLabelEntity> findByTypeIdAndDeletedAtIsNull(Long typeId);
|
||||
|
||||
Flux<CourseTypeLabelEntity> findByLabelIdAndDeletedAtIsNull(Long labelId);
|
||||
|
||||
Mono<CourseTypeLabelEntity> findByTypeIdAndLabelIdAndDeletedAtIsNull(Long typeId, Long labelId);
|
||||
|
||||
@Modifying
|
||||
@Query("UPDATE course_type_label SET deleted_at = :deletedAt WHERE type_id = :typeId AND label_id = :labelId")
|
||||
Mono<Integer> deleteByTypeIdAndLabelId(Long typeId, Long labelId, LocalDateTime deletedAt);
|
||||
|
||||
@Modifying
|
||||
@Query("UPDATE course_type_label SET deleted_at = :deletedAt WHERE type_id = :typeId")
|
||||
Mono<Integer> deleteByTypeId(Long typeId, LocalDateTime deletedAt);
|
||||
|
||||
@Modifying
|
||||
@Query("DELETE FROM course_type_label WHERE type_id = :typeId AND label_id = :labelId")
|
||||
Mono<Integer> physicalDeleteByTypeIdAndLabelId(Long typeId, Long labelId);
|
||||
|
||||
@Modifying
|
||||
@Query("UPDATE course_type_label SET deleted_at = :deletedAt WHERE label_id = :labelId")
|
||||
Mono<Integer> deleteByLabelId(Long labelId, LocalDateTime deletedAt);
|
||||
}
|
||||
-2
@@ -36,6 +36,4 @@ public interface GroupCourseDao extends R2dbcRepository<GroupCourseEntity, Long>
|
||||
@Modifying
|
||||
@Query("UPDATE group_course SET deleted_at = :deletedAt WHERE id = :id")
|
||||
Mono<Integer> softDelete(Long id, LocalDateTime deletedAt);
|
||||
|
||||
Flux<GroupCourseEntity> findByCourseTypeAndDeletedAtIsNull(Long courseType);
|
||||
}
|
||||
|
||||
-32
@@ -1,32 +0,0 @@
|
||||
package cn.novalon.gym.manage.groupcourse.dao;
|
||||
|
||||
import cn.novalon.gym.manage.groupcourse.entity.GroupCourseTypeEntity;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.r2dbc.repository.Modifying;
|
||||
import org.springframework.data.r2dbc.repository.Query;
|
||||
import org.springframework.data.r2dbc.repository.R2dbcRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Repository
|
||||
public interface GroupCourseTypeDao extends R2dbcRepository<GroupCourseTypeEntity, Long> {
|
||||
|
||||
Mono<GroupCourseTypeEntity> findByIdIsAndDeletedAtIsNull(Long id);
|
||||
|
||||
Flux<GroupCourseTypeEntity> findAllByDeletedAtIsNull();
|
||||
|
||||
Flux<GroupCourseTypeEntity> findAllByDeletedAtIsNull(Sort sort);
|
||||
|
||||
Flux<GroupCourseTypeEntity> findByTypeNameContainingAndDeletedAtIsNull(String typeName);
|
||||
|
||||
Flux<GroupCourseTypeEntity> findByCategoryAndDeletedAtIsNull(String category);
|
||||
|
||||
Mono<GroupCourseTypeEntity> findByTypeNameAndDeletedAtIsNull(String typeName);
|
||||
|
||||
@Modifying
|
||||
@Query("UPDATE group_course_type SET deleted_at = :deletedAt WHERE id = :id")
|
||||
Mono<Integer> softDelete(Long id, LocalDateTime deletedAt);
|
||||
}
|
||||
-43
@@ -1,43 +0,0 @@
|
||||
package cn.novalon.gym.manage.groupcourse.domain;
|
||||
|
||||
import cn.novalon.gym.manage.sys.core.domain.BaseDomain;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
public class CourseLabel extends BaseDomain {
|
||||
|
||||
//标签名称
|
||||
@Schema(description = "标签名称", example = "适合新手")
|
||||
private String labelName;
|
||||
|
||||
//标签颜色(十六进制)
|
||||
@Schema(description = "标签颜色(十六进制)", example = "#52c41a")
|
||||
private String color;
|
||||
|
||||
//标签描述
|
||||
@Schema(description = "标签描述", example = "适合健身初学者")
|
||||
private String description;
|
||||
|
||||
public String getLabelName() {
|
||||
return labelName;
|
||||
}
|
||||
|
||||
public void setLabelName(String labelName) {
|
||||
this.labelName = labelName;
|
||||
}
|
||||
|
||||
public String getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public void setColor(String color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
}
|
||||
-254
@@ -1,254 +0,0 @@
|
||||
package cn.novalon.gym.manage.groupcourse.domain;
|
||||
|
||||
import cn.novalon.gym.manage.sys.core.domain.BaseDomain;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 团课完整信息领域模型
|
||||
* 包含团课基础信息、关联的类型信息以及类型的标签信息
|
||||
*/
|
||||
public class GroupCourseDetail extends BaseDomain {
|
||||
|
||||
// ===== 团课基础信息 =====
|
||||
|
||||
@Schema(description = "课程名称", example = "瑜伽入门")
|
||||
private String courseName;
|
||||
|
||||
@Schema(description = "教练ID", example = "1")
|
||||
private Long coachId;
|
||||
|
||||
@Schema(description = "课程类型ID", example = "1")
|
||||
private Long courseType;
|
||||
|
||||
@Schema(description = "开始时间", example = "2026-06-02T09:00:00")
|
||||
private LocalDateTime startTime;
|
||||
|
||||
@Schema(description = "结束时间", example = "2026-06-02T10:00:00")
|
||||
private LocalDateTime endTime;
|
||||
|
||||
@Schema(description = "最大参与人数", example = "20")
|
||||
private Integer maxMembers;
|
||||
|
||||
@Schema(description = "当前参与人数", example = "15")
|
||||
private Integer currentMembers;
|
||||
|
||||
@Schema(description = "课程状态", example = "0")
|
||||
private Long status;
|
||||
|
||||
@Schema(description = "上课地点", example = "健身房A区")
|
||||
private String location;
|
||||
|
||||
@Schema(description = "封面图URL", example = "https://example.com/yoga.jpg")
|
||||
private String coverImage;
|
||||
|
||||
@Schema(description = "课程描述", example = "适合初学者的瑜伽课程")
|
||||
private String description;
|
||||
|
||||
@Schema(description = "点卡额度(消耗次数)", example = "1")
|
||||
private Integer pointCardAmount;
|
||||
|
||||
@Schema(description = "储值卡额度(消耗金额)", example = "50.00")
|
||||
private BigDecimal storedValueAmount;
|
||||
|
||||
// ===== 关联的类型信息 =====
|
||||
|
||||
@Schema(description = "类型信息")
|
||||
private GroupCourseType typeInfo;
|
||||
|
||||
// ===== 快捷访问属性(从类型信息派生)=====
|
||||
|
||||
@Schema(description = "类型名称", example = "瑜伽入门")
|
||||
private String typeName;
|
||||
|
||||
@Schema(description = "类型分类", example = "柔韧与平衡类")
|
||||
private String typeCategory;
|
||||
|
||||
@Schema(description = "基础难度", example = "2")
|
||||
private Integer baseDifficulty;
|
||||
|
||||
@Schema(description = "难度等级描述", example = "初级")
|
||||
private String difficultyLevel;
|
||||
|
||||
@Schema(description = "综合难度系数", example = "2")
|
||||
private Integer calculatedDifficulty;
|
||||
|
||||
// ===== 标签信息(从类型标签派生)=====
|
||||
|
||||
@Schema(description = "标签列表")
|
||||
private List<CourseLabel> labels;
|
||||
|
||||
// ===== Getters and Setters =====
|
||||
|
||||
public String getCourseName() {
|
||||
return courseName;
|
||||
}
|
||||
|
||||
public void setCourseName(String courseName) {
|
||||
this.courseName = courseName;
|
||||
}
|
||||
|
||||
public Long getCoachId() {
|
||||
return coachId;
|
||||
}
|
||||
|
||||
public void setCoachId(Long coachId) {
|
||||
this.coachId = coachId;
|
||||
}
|
||||
|
||||
public Long getCourseType() {
|
||||
return courseType;
|
||||
}
|
||||
|
||||
public void setCourseType(Long courseType) {
|
||||
this.courseType = courseType;
|
||||
}
|
||||
|
||||
public LocalDateTime getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public void setStartTime(LocalDateTime startTime) {
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
public LocalDateTime getEndTime() {
|
||||
return endTime;
|
||||
}
|
||||
|
||||
public void setEndTime(LocalDateTime endTime) {
|
||||
this.endTime = endTime;
|
||||
}
|
||||
|
||||
public Integer getMaxMembers() {
|
||||
return maxMembers;
|
||||
}
|
||||
|
||||
public void setMaxMembers(Integer maxMembers) {
|
||||
this.maxMembers = maxMembers;
|
||||
}
|
||||
|
||||
public Integer getCurrentMembers() {
|
||||
return currentMembers;
|
||||
}
|
||||
|
||||
public void setCurrentMembers(Integer currentMembers) {
|
||||
this.currentMembers = currentMembers;
|
||||
}
|
||||
|
||||
public Long getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Long status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public void setLocation(String location) {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
public String getCoverImage() {
|
||||
return coverImage;
|
||||
}
|
||||
|
||||
public void setCoverImage(String coverImage) {
|
||||
this.coverImage = coverImage;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public Integer getPointCardAmount() {
|
||||
return pointCardAmount;
|
||||
}
|
||||
|
||||
public void setPointCardAmount(Integer pointCardAmount) {
|
||||
this.pointCardAmount = pointCardAmount;
|
||||
}
|
||||
|
||||
public BigDecimal getStoredValueAmount() {
|
||||
return storedValueAmount;
|
||||
}
|
||||
|
||||
public void setStoredValueAmount(BigDecimal storedValueAmount) {
|
||||
this.storedValueAmount = storedValueAmount;
|
||||
}
|
||||
|
||||
public GroupCourseType getTypeInfo() {
|
||||
return typeInfo;
|
||||
}
|
||||
|
||||
public void setTypeInfo(GroupCourseType typeInfo) {
|
||||
this.typeInfo = typeInfo;
|
||||
// 同步派生属性
|
||||
if (typeInfo != null) {
|
||||
this.typeName = typeInfo.getTypeName();
|
||||
this.typeCategory = typeInfo.getCategory();
|
||||
this.baseDifficulty = typeInfo.getBaseDifficulty();
|
||||
this.difficultyLevel = typeInfo.getDifficultyLevel();
|
||||
this.calculatedDifficulty = typeInfo.getCalculatedDifficulty();
|
||||
this.labels = typeInfo.getLabels();
|
||||
}
|
||||
}
|
||||
|
||||
public String getTypeName() {
|
||||
return typeName;
|
||||
}
|
||||
|
||||
public void setTypeName(String typeName) {
|
||||
this.typeName = typeName;
|
||||
}
|
||||
|
||||
public String getTypeCategory() {
|
||||
return typeCategory;
|
||||
}
|
||||
|
||||
public void setTypeCategory(String typeCategory) {
|
||||
this.typeCategory = typeCategory;
|
||||
}
|
||||
|
||||
public Integer getBaseDifficulty() {
|
||||
return baseDifficulty;
|
||||
}
|
||||
|
||||
public void setBaseDifficulty(Integer baseDifficulty) {
|
||||
this.baseDifficulty = baseDifficulty;
|
||||
}
|
||||
|
||||
public String getDifficultyLevel() {
|
||||
return difficultyLevel;
|
||||
}
|
||||
|
||||
public void setDifficultyLevel(String difficultyLevel) {
|
||||
this.difficultyLevel = difficultyLevel;
|
||||
}
|
||||
|
||||
public Integer getCalculatedDifficulty() {
|
||||
return calculatedDifficulty;
|
||||
}
|
||||
|
||||
public void setCalculatedDifficulty(Integer calculatedDifficulty) {
|
||||
this.calculatedDifficulty = calculatedDifficulty;
|
||||
}
|
||||
|
||||
public List<CourseLabel> getLabels() {
|
||||
return labels;
|
||||
}
|
||||
|
||||
public void setLabels(List<CourseLabel> labels) {
|
||||
this.labels = labels;
|
||||
}
|
||||
}
|
||||
-113
@@ -1,113 +0,0 @@
|
||||
package cn.novalon.gym.manage.groupcourse.domain;
|
||||
|
||||
import cn.novalon.gym.manage.sys.core.domain.BaseDomain;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class GroupCourseType extends BaseDomain {
|
||||
|
||||
//类型名称
|
||||
@Schema(description = "类型名称", example = "瑜伽入门")
|
||||
private String typeName;
|
||||
|
||||
//基础难度(1-10)
|
||||
@Schema(description = "基础难度(1-10)", example = "2")
|
||||
private Integer baseDifficulty;
|
||||
|
||||
//类型描述
|
||||
@Schema(description = "类型描述", example = "适合初学者的瑜伽课程")
|
||||
private String description;
|
||||
|
||||
//分类(如:有氧、力量、柔韧等)
|
||||
@Schema(description = "分类", example = "柔韧与平衡类")
|
||||
private String category;
|
||||
|
||||
//标签列表
|
||||
@Schema(description = "标签列表")
|
||||
private List<CourseLabel> labels = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* 计算综合难度系数
|
||||
*
|
||||
* 当前实现仅返回基础难度,为后续扩展预留空间。
|
||||
* 未来可扩展的影响因素包括:
|
||||
* 1. 课程时长系数(时长越长难度越高)
|
||||
* 2. 教练难度调整系数(教练可根据实际情况微调)
|
||||
* 3. 会员等级适配系数(根据会员等级动态调整显示难度)
|
||||
* 4. 课程强度系数(高强度课程难度加成)
|
||||
*
|
||||
* @return 综合难度系数(1-10)
|
||||
*/
|
||||
@Schema(description = "综合难度系数(预留扩展字段)", example = "2")
|
||||
public Integer getCalculatedDifficulty() {
|
||||
// TODO: 预留扩展点 - 未来可在此处添加更多难度计算逻辑
|
||||
// 例如:return calculateDynamicDifficulty(baseDifficulty, additionalFactors...);
|
||||
return this.baseDifficulty != null ? this.baseDifficulty : 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取难度等级描述
|
||||
* 将数字难度转换为友好的文字描述
|
||||
*
|
||||
* @return 难度等级描述
|
||||
*/
|
||||
@Schema(description = "难度等级描述", example = "初级")
|
||||
public String getDifficultyLevel() {
|
||||
if (baseDifficulty == null) {
|
||||
return "未知";
|
||||
}
|
||||
if (baseDifficulty <= 2) {
|
||||
return "初级";
|
||||
} else if (baseDifficulty <= 4) {
|
||||
return "中级";
|
||||
} else if (baseDifficulty <= 6) {
|
||||
return "中高级";
|
||||
} else if (baseDifficulty <= 8) {
|
||||
return "高级";
|
||||
} else {
|
||||
return "专家级";
|
||||
}
|
||||
}
|
||||
|
||||
public String getTypeName() {
|
||||
return typeName;
|
||||
}
|
||||
|
||||
public void setTypeName(String typeName) {
|
||||
this.typeName = typeName;
|
||||
}
|
||||
|
||||
public Integer getBaseDifficulty() {
|
||||
return baseDifficulty;
|
||||
}
|
||||
|
||||
public void setBaseDifficulty(Integer baseDifficulty) {
|
||||
this.baseDifficulty = baseDifficulty;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
public void setCategory(String category) {
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
public List<CourseLabel> getLabels() {
|
||||
return labels;
|
||||
}
|
||||
|
||||
public void setLabels(List<CourseLabel> labels) {
|
||||
this.labels = labels;
|
||||
}
|
||||
}
|
||||
-45
@@ -1,45 +0,0 @@
|
||||
package cn.novalon.gym.manage.groupcourse.entity;
|
||||
|
||||
import cn.novalon.gym.manage.db.entity.BaseEntity;
|
||||
import org.springframework.data.relational.core.mapping.Column;
|
||||
import org.springframework.data.relational.core.mapping.Table;
|
||||
|
||||
@Table("course_label")
|
||||
public class CourseLabelEntity extends BaseEntity {
|
||||
|
||||
//标签名称
|
||||
@Column("label_name")
|
||||
private String labelName;
|
||||
|
||||
//标签颜色(十六进制)
|
||||
@Column("color")
|
||||
private String color;
|
||||
|
||||
//标签描述
|
||||
@Column("description")
|
||||
private String description;
|
||||
|
||||
public String getLabelName() {
|
||||
return labelName;
|
||||
}
|
||||
|
||||
public void setLabelName(String labelName) {
|
||||
this.labelName = labelName;
|
||||
}
|
||||
|
||||
public String getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public void setColor(String color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
}
|
||||
-33
@@ -1,33 +0,0 @@
|
||||
package cn.novalon.gym.manage.groupcourse.entity;
|
||||
|
||||
import cn.novalon.gym.manage.db.entity.BaseEntity;
|
||||
import org.springframework.data.relational.core.mapping.Column;
|
||||
import org.springframework.data.relational.core.mapping.Table;
|
||||
|
||||
@Table("course_type_label")
|
||||
public class CourseTypeLabelEntity extends BaseEntity {
|
||||
|
||||
//团课类型ID
|
||||
@Column("type_id")
|
||||
private Long typeId;
|
||||
|
||||
//标签ID
|
||||
@Column("label_id")
|
||||
private Long labelId;
|
||||
|
||||
public Long getTypeId() {
|
||||
return typeId;
|
||||
}
|
||||
|
||||
public void setTypeId(Long typeId) {
|
||||
this.typeId = typeId;
|
||||
}
|
||||
|
||||
public Long getLabelId() {
|
||||
return labelId;
|
||||
}
|
||||
|
||||
public void setLabelId(Long labelId) {
|
||||
this.labelId = labelId;
|
||||
}
|
||||
}
|
||||
-57
@@ -1,57 +0,0 @@
|
||||
package cn.novalon.gym.manage.groupcourse.entity;
|
||||
|
||||
import cn.novalon.gym.manage.db.entity.BaseEntity;
|
||||
import org.springframework.data.relational.core.mapping.Column;
|
||||
import org.springframework.data.relational.core.mapping.Table;
|
||||
|
||||
@Table("group_course_type")
|
||||
public class GroupCourseTypeEntity extends BaseEntity {
|
||||
|
||||
//类型名称
|
||||
@Column("type_name")
|
||||
private String typeName;
|
||||
|
||||
//基础难度(1-10)
|
||||
@Column("base_difficulty")
|
||||
private Integer baseDifficulty;
|
||||
|
||||
//类型描述
|
||||
@Column("description")
|
||||
private String description;
|
||||
|
||||
//分类(如:有氧、力量、柔韧等)
|
||||
@Column("category")
|
||||
private String category;
|
||||
|
||||
public String getTypeName() {
|
||||
return typeName;
|
||||
}
|
||||
|
||||
public void setTypeName(String typeName) {
|
||||
this.typeName = typeName;
|
||||
}
|
||||
|
||||
public Integer getBaseDifficulty() {
|
||||
return baseDifficulty;
|
||||
}
|
||||
|
||||
public void setBaseDifficulty(Integer baseDifficulty) {
|
||||
this.baseDifficulty = baseDifficulty;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
public void setCategory(String category) {
|
||||
this.category = category;
|
||||
}
|
||||
}
|
||||
-217
@@ -1,217 +0,0 @@
|
||||
package cn.novalon.gym.manage.groupcourse.handler;
|
||||
|
||||
import cn.novalon.gym.manage.groupcourse.domain.CourseLabel;
|
||||
import cn.novalon.gym.manage.groupcourse.service.ICourseLabelService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.reactive.function.server.ServerRequest;
|
||||
import org.springframework.web.reactive.function.server.ServerResponse;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
@Tag(name = "团课标签管理", description = "团课标签相关操作")
|
||||
public class CourseLabelHandler {
|
||||
|
||||
private final ICourseLabelService courseLabelService;
|
||||
|
||||
public CourseLabelHandler(ICourseLabelService courseLabelService) {
|
||||
this.courseLabelService = courseLabelService;
|
||||
}
|
||||
|
||||
@Operation(summary = "获取所有标签", description = "获取系统中所有标签列表")
|
||||
public Mono<ServerResponse> getAllLabels(ServerRequest request) {
|
||||
return ServerResponse.ok()
|
||||
.body(courseLabelService.findAll(), CourseLabel.class);
|
||||
}
|
||||
|
||||
@Operation(summary = "根据ID获取标签", description = "根据ID获取标签详情")
|
||||
public Mono<ServerResponse> getLabelById(ServerRequest request) {
|
||||
Long id = Long.valueOf(request.pathVariable("id"));
|
||||
return courseLabelService.findById(id)
|
||||
.flatMap(label -> ServerResponse.ok().bodyValue(label))
|
||||
.switchIfEmpty(ServerResponse.notFound().build());
|
||||
}
|
||||
|
||||
@Operation(summary = "搜索标签", description = "根据关键词搜索标签")
|
||||
public Mono<ServerResponse> searchLabels(ServerRequest request) {
|
||||
String keyword = request.queryParam("keyword").orElse("");
|
||||
return ServerResponse.ok()
|
||||
.body(courseLabelService.findByKeyword(keyword), CourseLabel.class);
|
||||
}
|
||||
|
||||
@Operation(summary = "创建标签", description = "创建新的标签")
|
||||
public Mono<ServerResponse> createLabel(ServerRequest request) {
|
||||
return request.bodyToMono(CourseLabel.class)
|
||||
.flatMap(courseLabel -> {
|
||||
if (courseLabel.getLabelName() == null || courseLabel.getLabelName().isEmpty()) {
|
||||
Map<String, Object> error = new HashMap<>();
|
||||
error.put("success", false);
|
||||
error.put("message", "标签名称不能为空");
|
||||
return ServerResponse.badRequest().bodyValue(error);
|
||||
}
|
||||
|
||||
if (courseLabel.getLabelName().length() > 50) {
|
||||
Map<String, Object> error = new HashMap<>();
|
||||
error.put("success", false);
|
||||
error.put("message", "标签名称不能超过50个字符");
|
||||
return ServerResponse.badRequest().bodyValue(error);
|
||||
}
|
||||
|
||||
if (courseLabel.getColor() == null || courseLabel.getColor().isEmpty()) {
|
||||
courseLabel.setColor("#1890ff");
|
||||
}
|
||||
|
||||
return courseLabelService.create(courseLabel)
|
||||
.flatMap(label -> {
|
||||
Map<String, Object> response = new HashMap<>();
|
||||
response.put("success", true);
|
||||
response.put("message", "标签创建成功");
|
||||
response.put("data", label);
|
||||
return ServerResponse.ok().bodyValue(response);
|
||||
})
|
||||
.onErrorResume(error -> {
|
||||
Map<String, Object> response = new HashMap<>();
|
||||
response.put("success", false);
|
||||
response.put("message", error.getMessage());
|
||||
return ServerResponse.badRequest().bodyValue(response);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@Operation(summary = "更新标签", description = "更新指定标签信息")
|
||||
public Mono<ServerResponse> updateLabel(ServerRequest request) {
|
||||
Long id = Long.valueOf(request.pathVariable("id"));
|
||||
|
||||
return request.bodyToMono(CourseLabel.class)
|
||||
.flatMap(courseLabel -> {
|
||||
if (courseLabel.getLabelName() != null && courseLabel.getLabelName().length() > 50) {
|
||||
Map<String, Object> error = new HashMap<>();
|
||||
error.put("success", false);
|
||||
error.put("message", "标签名称不能超过50个字符");
|
||||
return ServerResponse.badRequest().bodyValue(error);
|
||||
}
|
||||
|
||||
return courseLabelService.update(id, courseLabel)
|
||||
.flatMap(label -> {
|
||||
Map<String, Object> response = new HashMap<>();
|
||||
response.put("success", true);
|
||||
response.put("message", "标签更新成功");
|
||||
response.put("data", label);
|
||||
return ServerResponse.ok().bodyValue(response);
|
||||
})
|
||||
.onErrorResume(error -> {
|
||||
Map<String, Object> response = new HashMap<>();
|
||||
response.put("success", false);
|
||||
response.put("message", error.getMessage());
|
||||
return ServerResponse.badRequest().bodyValue(response);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@Operation(summary = "删除标签", description = "删除指定标签(软删除)")
|
||||
public Mono<ServerResponse> deleteLabel(ServerRequest request) {
|
||||
Long id = Long.valueOf(request.pathVariable("id"));
|
||||
|
||||
return courseLabelService.delete(id)
|
||||
.then(Mono.defer(() -> {
|
||||
Map<String, Object> response = new HashMap<>();
|
||||
response.put("success", true);
|
||||
response.put("message", "标签删除成功");
|
||||
return ServerResponse.ok().bodyValue(response);
|
||||
}))
|
||||
.onErrorResume(error -> {
|
||||
Map<String, Object> response = new HashMap<>();
|
||||
response.put("success", false);
|
||||
response.put("message", error.getMessage());
|
||||
return ServerResponse.badRequest().bodyValue(response);
|
||||
});
|
||||
}
|
||||
|
||||
@Operation(summary = "获取类型的标签", description = "获取指定团课类型的所有标签")
|
||||
public Mono<ServerResponse> getLabelsByTypeId(ServerRequest request) {
|
||||
Long typeId = Long.valueOf(request.pathVariable("typeId"));
|
||||
return courseLabelService.findByTypeId(typeId)
|
||||
.collectList()
|
||||
.flatMap(list -> ServerResponse.ok().bodyValue(list));
|
||||
}
|
||||
|
||||
@Operation(summary = "为类型添加标签", description = "为指定团课类型添加标签")
|
||||
public Mono<ServerResponse> addLabelsToType(ServerRequest request) {
|
||||
Long typeId = Long.valueOf(request.pathVariable("typeId"));
|
||||
|
||||
return request.bodyToMono(Map.class)
|
||||
.flatMap(body -> {
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Integer> labelIdsInt = (List<Integer>) body.get("labelIds");
|
||||
|
||||
if (labelIdsInt == null || labelIdsInt.isEmpty()) {
|
||||
Map<String, Object> error = new HashMap<>();
|
||||
error.put("success", false);
|
||||
error.put("message", "labelIds不能为空");
|
||||
return ServerResponse.badRequest().bodyValue(error);
|
||||
}
|
||||
|
||||
List<Long> labelIds = labelIdsInt.stream()
|
||||
.map(Integer::longValue)
|
||||
.collect(java.util.stream.Collectors.toList());
|
||||
|
||||
return courseLabelService.addLabelsToType(typeId, labelIds)
|
||||
.then(Mono.defer(() -> {
|
||||
Map<String, Object> response = new HashMap<>();
|
||||
response.put("success", true);
|
||||
response.put("message", "标签添加成功");
|
||||
return ServerResponse.ok().bodyValue(response);
|
||||
}))
|
||||
.onErrorResume(error -> {
|
||||
Map<String, Object> response = new HashMap<>();
|
||||
response.put("success", false);
|
||||
response.put("message", error.getMessage());
|
||||
return ServerResponse.badRequest().bodyValue(response);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@Operation(summary = "从类型移除标签", description = "从指定团课类型移除标签")
|
||||
public Mono<ServerResponse> removeLabelFromType(ServerRequest request) {
|
||||
Long typeId = Long.valueOf(request.pathVariable("typeId"));
|
||||
Long labelId = Long.valueOf(request.pathVariable("labelId"));
|
||||
|
||||
return courseLabelService.removeLabelFromType(typeId, labelId)
|
||||
.then(Mono.defer(() -> {
|
||||
Map<String, Object> response = new HashMap<>();
|
||||
response.put("success", true);
|
||||
response.put("message", "标签移除成功");
|
||||
return ServerResponse.ok().bodyValue(response);
|
||||
}))
|
||||
.onErrorResume(error -> {
|
||||
Map<String, Object> response = new HashMap<>();
|
||||
response.put("success", false);
|
||||
response.put("message", error.getMessage());
|
||||
return ServerResponse.badRequest().bodyValue(response);
|
||||
});
|
||||
}
|
||||
|
||||
@Operation(summary = "清空类型标签", description = "清空指定团课类型的所有标签")
|
||||
public Mono<ServerResponse> clearLabelsFromType(ServerRequest request) {
|
||||
Long typeId = Long.valueOf(request.pathVariable("typeId"));
|
||||
|
||||
return courseLabelService.clearLabelsFromType(typeId)
|
||||
.then(Mono.defer(() -> {
|
||||
Map<String, Object> response = new HashMap<>();
|
||||
response.put("success", true);
|
||||
response.put("message", "标签清空成功");
|
||||
return ServerResponse.ok().bodyValue(response);
|
||||
}))
|
||||
.onErrorResume(error -> {
|
||||
Map<String, Object> response = new HashMap<>();
|
||||
response.put("success", false);
|
||||
response.put("message", error.getMessage());
|
||||
return ServerResponse.badRequest().bodyValue(response);
|
||||
});
|
||||
}
|
||||
}
|
||||
-9
@@ -4,7 +4,6 @@ package cn.novalon.gym.manage.groupcourse.handler;
|
||||
import cn.novalon.gym.manage.common.dto.PageRequest;
|
||||
import cn.novalon.gym.manage.common.util.RedisUtil;
|
||||
import cn.novalon.gym.manage.groupcourse.domain.GroupCourse;
|
||||
import cn.novalon.gym.manage.groupcourse.domain.GroupCourseDetail;
|
||||
import cn.novalon.gym.manage.groupcourse.service.IGroupCourseService;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
@@ -77,14 +76,6 @@ public class GroupCourseHandler {
|
||||
.switchIfEmpty(ServerResponse.notFound().build());
|
||||
}
|
||||
|
||||
@Operation(summary = "根据ID获取团课完整信息", description = "根据ID获取团课完整信息,包括团课基础信息、类型信息和标签信息")
|
||||
public Mono<ServerResponse> getGroupCourseDetailById(ServerRequest request){
|
||||
Long id = Long.valueOf(request.pathVariable("id"));
|
||||
return groupCourseService.findDetailById(id)
|
||||
.flatMap(detail -> ServerResponse.ok().bodyValue(detail))
|
||||
.switchIfEmpty(ServerResponse.notFound().build());
|
||||
}
|
||||
|
||||
@Operation(summary = "创建团课", description = "创建新的团课")
|
||||
public Mono<ServerResponse> createGroupCourse(ServerRequest request) {
|
||||
return request.bodyToMono(GroupCourse.class)
|
||||
|
||||
-137
@@ -1,137 +0,0 @@
|
||||
package cn.novalon.gym.manage.groupcourse.handler;
|
||||
|
||||
import cn.novalon.gym.manage.groupcourse.domain.GroupCourseType;
|
||||
import cn.novalon.gym.manage.groupcourse.service.IGroupCourseTypeService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.reactive.function.server.ServerRequest;
|
||||
import org.springframework.web.reactive.function.server.ServerResponse;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
@Tag(name = "团课类型管理", description = "团课类型及难度相关操作")
|
||||
public class GroupCourseTypeHandler {
|
||||
|
||||
private final IGroupCourseTypeService groupCourseTypeService;
|
||||
|
||||
public GroupCourseTypeHandler(IGroupCourseTypeService groupCourseTypeService) {
|
||||
this.groupCourseTypeService = groupCourseTypeService;
|
||||
}
|
||||
|
||||
@Operation(summary = "获取所有团课类型", description = "获取系统中所有团课类型列表")
|
||||
public Mono<ServerResponse> getAllGroupCourseTypes(ServerRequest request) {
|
||||
boolean includeDeleted = Boolean.valueOf(request.queryParam("includeDeleted").orElse("false"));
|
||||
return ServerResponse.ok()
|
||||
.body(groupCourseTypeService.findAll(includeDeleted), GroupCourseType.class);
|
||||
}
|
||||
|
||||
@Operation(summary = "根据ID获取团课类型", description = "根据ID获取团课类型详情")
|
||||
public Mono<ServerResponse> getGroupCourseTypeById(ServerRequest request) {
|
||||
Long id = Long.valueOf(request.pathVariable("id"));
|
||||
return groupCourseTypeService.findById(id)
|
||||
.flatMap(type -> ServerResponse.ok().bodyValue(type))
|
||||
.switchIfEmpty(ServerResponse.notFound().build());
|
||||
}
|
||||
|
||||
@Operation(summary = "根据关键词搜索团课类型", description = "根据类型名称关键词搜索团课类型")
|
||||
public Mono<ServerResponse> searchGroupCourseTypes(ServerRequest request) {
|
||||
String keyword = request.queryParam("keyword").orElse("");
|
||||
return ServerResponse.ok()
|
||||
.body(groupCourseTypeService.findByKeyword(keyword), GroupCourseType.class);
|
||||
}
|
||||
|
||||
@Operation(summary = "根据分类获取团课类型", description = "根据分类获取团课类型列表")
|
||||
public Mono<ServerResponse> getGroupCourseTypesByCategory(ServerRequest request) {
|
||||
String category = request.pathVariable("category");
|
||||
String keyword = request.queryParam("keyword").orElse("");
|
||||
return ServerResponse.ok()
|
||||
.body(groupCourseTypeService.findByCategoryAndKeyword(category, keyword), GroupCourseType.class);
|
||||
}
|
||||
|
||||
@Operation(summary = "获取所有分类", description = "获取所有团课类型分类(去重)")
|
||||
public Mono<ServerResponse> getCategories(ServerRequest request) {
|
||||
return groupCourseTypeService.findCategories()
|
||||
.collectList()
|
||||
.flatMap(list -> ServerResponse.ok().bodyValue(list));
|
||||
}
|
||||
|
||||
@Operation(summary = "创建团课类型", description = "创建新的团课类型")
|
||||
public Mono<ServerResponse> createGroupCourseType(ServerRequest request) {
|
||||
return request.bodyToMono(GroupCourseType.class)
|
||||
.flatMap(groupCourseType -> {
|
||||
if (groupCourseType.getTypeName() == null || groupCourseType.getTypeName().isEmpty()) {
|
||||
Map<String, Object> error = new HashMap<>();
|
||||
error.put("success", false);
|
||||
error.put("message", "类型名称不能为空");
|
||||
return ServerResponse.badRequest().bodyValue(error);
|
||||
}
|
||||
|
||||
// 默认基础难度为1
|
||||
if (groupCourseType.getBaseDifficulty() == null) {
|
||||
groupCourseType.setBaseDifficulty(1);
|
||||
}
|
||||
|
||||
return groupCourseTypeService.create(groupCourseType)
|
||||
.flatMap(type -> {
|
||||
Map<String, Object> response = new HashMap<>();
|
||||
response.put("success", true);
|
||||
response.put("message", "团课类型创建成功");
|
||||
response.put("data", type);
|
||||
return ServerResponse.ok().bodyValue(response);
|
||||
})
|
||||
.onErrorResume(error -> {
|
||||
Map<String, Object> response = new HashMap<>();
|
||||
response.put("success", false);
|
||||
response.put("message", error.getMessage());
|
||||
return ServerResponse.badRequest().bodyValue(response);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@Operation(summary = "更新团课类型", description = "更新指定团课类型信息")
|
||||
public Mono<ServerResponse> updateGroupCourseType(ServerRequest request) {
|
||||
Long id = Long.valueOf(request.pathVariable("id"));
|
||||
|
||||
return request.bodyToMono(GroupCourseType.class)
|
||||
.flatMap(groupCourseType -> {
|
||||
groupCourseType.setId(id);
|
||||
return groupCourseTypeService.update(id, groupCourseType)
|
||||
.flatMap(type -> {
|
||||
Map<String, Object> response = new HashMap<>();
|
||||
response.put("success", true);
|
||||
response.put("message", "团课类型更新成功");
|
||||
response.put("data", type);
|
||||
return ServerResponse.ok().bodyValue(response);
|
||||
})
|
||||
.onErrorResume(error -> {
|
||||
Map<String, Object> response = new HashMap<>();
|
||||
response.put("success", false);
|
||||
response.put("message", error.getMessage());
|
||||
return ServerResponse.badRequest().bodyValue(response);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@Operation(summary = "删除团课类型", description = "删除指定团课类型(软删除)")
|
||||
public Mono<ServerResponse> deleteGroupCourseType(ServerRequest request) {
|
||||
Long id = Long.valueOf(request.pathVariable("id"));
|
||||
|
||||
return groupCourseTypeService.delete(id)
|
||||
.then(Mono.defer(() -> {
|
||||
Map<String, Object> response = new HashMap<>();
|
||||
response.put("success", true);
|
||||
response.put("message", "团课类型删除成功");
|
||||
return ServerResponse.ok().bodyValue(response);
|
||||
}))
|
||||
.onErrorResume(error -> {
|
||||
Map<String, Object> response = new HashMap<>();
|
||||
response.put("success", false);
|
||||
response.put("message", error.getMessage());
|
||||
return ServerResponse.badRequest().bodyValue(response);
|
||||
});
|
||||
}
|
||||
}
|
||||
-32
@@ -1,32 +0,0 @@
|
||||
package cn.novalon.gym.manage.groupcourse.repository;
|
||||
|
||||
import cn.novalon.gym.manage.groupcourse.domain.CourseLabel;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ICourseLabelRepository {
|
||||
|
||||
Mono<CourseLabel> findById(Long id);
|
||||
|
||||
Flux<CourseLabel> findAll();
|
||||
|
||||
Flux<CourseLabel> findByKeyword(String keyword);
|
||||
|
||||
Mono<CourseLabel> findByLabelName(String labelName);
|
||||
|
||||
Mono<CourseLabel> save(CourseLabel courseLabel);
|
||||
|
||||
Mono<CourseLabel> update(CourseLabel courseLabel);
|
||||
|
||||
Mono<Void> deleteById(Long id);
|
||||
|
||||
Flux<CourseLabel> findByTypeId(Long typeId);
|
||||
|
||||
Mono<Void> addLabelsToType(Long typeId, List<Long> labelIds);
|
||||
|
||||
Mono<Void> removeLabelFromType(Long typeId, Long labelId);
|
||||
|
||||
Mono<Void> clearLabelsFromType(Long typeId);
|
||||
}
|
||||
-2
@@ -27,6 +27,4 @@ public interface IGroupCourseRepository {
|
||||
Mono<Void> deleteById(Long id);
|
||||
|
||||
Mono<GroupCourse> updateCurrentMembers(Long id, Integer delta);
|
||||
|
||||
Flux<GroupCourse> findByCourseType(Long courseType);
|
||||
}
|
||||
|
||||
-28
@@ -1,28 +0,0 @@
|
||||
package cn.novalon.gym.manage.groupcourse.repository;
|
||||
|
||||
import cn.novalon.gym.manage.groupcourse.domain.GroupCourseType;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
public interface IGroupCourseTypeRepository {
|
||||
|
||||
Mono<GroupCourseType> findById(Long id);
|
||||
|
||||
Flux<GroupCourseType> findAll();
|
||||
|
||||
Flux<GroupCourseType> findAll(boolean includeDeleted);
|
||||
|
||||
Flux<GroupCourseType> findByKeyword(String keyword);
|
||||
|
||||
Flux<GroupCourseType> findByCategory(String category);
|
||||
|
||||
Flux<GroupCourseType> findByCategoryAndKeyword(String category, String keyword);
|
||||
|
||||
Mono<GroupCourseType> findByTypeName(String typeName);
|
||||
|
||||
Mono<GroupCourseType> save(GroupCourseType groupCourseType);
|
||||
|
||||
Mono<GroupCourseType> update(GroupCourseType groupCourseType);
|
||||
|
||||
Mono<Void> deleteById(Long id);
|
||||
}
|
||||
-161
@@ -1,161 +0,0 @@
|
||||
package cn.novalon.gym.manage.groupcourse.repository.impl;
|
||||
|
||||
import cn.novalon.gym.manage.groupcourse.converter.GroupCourseConverter;
|
||||
import cn.novalon.gym.manage.groupcourse.dao.CourseLabelDao;
|
||||
import cn.novalon.gym.manage.groupcourse.dao.CourseTypeLabelDao;
|
||||
import cn.novalon.gym.manage.groupcourse.domain.CourseLabel;
|
||||
import cn.novalon.gym.manage.groupcourse.entity.CourseLabelEntity;
|
||||
import cn.novalon.gym.manage.groupcourse.entity.CourseTypeLabelEntity;
|
||||
import cn.novalon.gym.manage.groupcourse.repository.ICourseLabelRepository;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
@Transactional
|
||||
public class CourseLabelRepository implements ICourseLabelRepository {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(CourseLabelRepository.class);
|
||||
|
||||
private final CourseLabelDao courseLabelDao;
|
||||
private final CourseTypeLabelDao courseTypeLabelDao;
|
||||
private final GroupCourseConverter converter;
|
||||
|
||||
public CourseLabelRepository(CourseLabelDao courseLabelDao, CourseTypeLabelDao courseTypeLabelDao,
|
||||
GroupCourseConverter converter) {
|
||||
this.courseLabelDao = courseLabelDao;
|
||||
this.courseTypeLabelDao = courseTypeLabelDao;
|
||||
this.converter = converter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<CourseLabel> findById(Long id) {
|
||||
return courseLabelDao.findByIdIsAndDeletedAtIsNull(id)
|
||||
.map(this::toCourseLabel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<CourseLabel> findAll() {
|
||||
return courseLabelDao.findAllByDeletedAtIsNull()
|
||||
.map(this::toCourseLabel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<CourseLabel> findByKeyword(String keyword) {
|
||||
if (keyword == null || keyword.isEmpty()) {
|
||||
return findAll();
|
||||
}
|
||||
return courseLabelDao.findByLabelNameContainingAndDeletedAtIsNull(keyword)
|
||||
.map(this::toCourseLabel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<CourseLabel> findByLabelName(String labelName) {
|
||||
return courseLabelDao.findByLabelNameAndDeletedAtIsNull(labelName)
|
||||
.map(this::toCourseLabel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<CourseLabel> save(CourseLabel courseLabel) {
|
||||
CourseLabelEntity entity = toCourseLabelEntity(courseLabel);
|
||||
return courseLabelDao.save(entity)
|
||||
.map(this::toCourseLabel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<CourseLabel> update(CourseLabel courseLabel) {
|
||||
return courseLabelDao.findByIdIsAndDeletedAtIsNull(courseLabel.getId())
|
||||
.switchIfEmpty(Mono.error(new RuntimeException("标签不存在")))
|
||||
.flatMap(existing -> {
|
||||
existing.markNotNew();
|
||||
if (courseLabel.getLabelName() != null) {
|
||||
existing.setLabelName(courseLabel.getLabelName());
|
||||
}
|
||||
if (courseLabel.getColor() != null) {
|
||||
existing.setColor(courseLabel.getColor());
|
||||
}
|
||||
if (courseLabel.getDescription() != null) {
|
||||
existing.setDescription(courseLabel.getDescription());
|
||||
}
|
||||
existing.setUpdatedAt(LocalDateTime.now());
|
||||
return courseLabelDao.save(existing);
|
||||
})
|
||||
.map(this::toCourseLabel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Void> deleteById(Long id) {
|
||||
return courseLabelDao.softDelete(id, LocalDateTime.now())
|
||||
.then(courseTypeLabelDao.deleteByLabelId(id, LocalDateTime.now()))
|
||||
.then();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<CourseLabel> findByTypeId(Long typeId) {
|
||||
return courseTypeLabelDao.findByTypeIdAndDeletedAtIsNull(typeId)
|
||||
.flatMap(typeLabel -> courseLabelDao.findByIdIsAndDeletedAtIsNull(typeLabel.getLabelId()))
|
||||
.map(this::toCourseLabel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Void> addLabelsToType(Long typeId, List<Long> labelIds) {
|
||||
return Flux.fromIterable(labelIds)
|
||||
.flatMap(labelId -> {
|
||||
return courseTypeLabelDao.physicalDeleteByTypeIdAndLabelId(typeId, labelId)
|
||||
.then(Mono.defer(() -> {
|
||||
CourseTypeLabelEntity entity = new CourseTypeLabelEntity();
|
||||
entity.setTypeId(typeId);
|
||||
entity.setLabelId(labelId);
|
||||
return courseTypeLabelDao.save(entity).then(Mono.empty());
|
||||
}));
|
||||
})
|
||||
.then();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Void> removeLabelFromType(Long typeId, Long labelId) {
|
||||
return courseTypeLabelDao.deleteByTypeIdAndLabelId(typeId, labelId, LocalDateTime.now())
|
||||
.then();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Void> clearLabelsFromType(Long typeId) {
|
||||
return courseTypeLabelDao.deleteByTypeId(typeId, LocalDateTime.now())
|
||||
.then();
|
||||
}
|
||||
|
||||
private CourseLabel toCourseLabel(CourseLabelEntity entity) {
|
||||
if (entity == null) {
|
||||
return null;
|
||||
}
|
||||
CourseLabel label = new CourseLabel();
|
||||
label.setId(entity.getId());
|
||||
label.setLabelName(entity.getLabelName());
|
||||
label.setColor(entity.getColor());
|
||||
label.setDescription(entity.getDescription());
|
||||
label.setCreatedAt(entity.getCreatedAt());
|
||||
label.setUpdatedAt(entity.getUpdatedAt());
|
||||
return label;
|
||||
}
|
||||
|
||||
private CourseLabelEntity toCourseLabelEntity(CourseLabel domain) {
|
||||
if (domain == null) {
|
||||
return null;
|
||||
}
|
||||
CourseLabelEntity entity = new CourseLabelEntity();
|
||||
entity.setId(domain.getId());
|
||||
entity.setLabelName(domain.getLabelName());
|
||||
entity.setColor(domain.getColor());
|
||||
entity.setDescription(domain.getDescription());
|
||||
if (domain.getId() != null) {
|
||||
entity.markNotNew();
|
||||
}
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
-6
@@ -178,10 +178,4 @@ public class GroupCourseRepository implements IGroupCourseRepository {
|
||||
return Mono.empty();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<GroupCourse> findByCourseType(Long courseType) {
|
||||
return groupCourseDao.findByCourseTypeAndDeletedAtIsNull(courseType)
|
||||
.map(groupCourseConverter::toDomain);
|
||||
}
|
||||
}
|
||||
|
||||
-132
@@ -1,132 +0,0 @@
|
||||
package cn.novalon.gym.manage.groupcourse.repository.impl;
|
||||
|
||||
import cn.novalon.gym.manage.groupcourse.converter.GroupCourseConverter;
|
||||
import cn.novalon.gym.manage.groupcourse.dao.GroupCourseTypeDao;
|
||||
import cn.novalon.gym.manage.groupcourse.domain.GroupCourseType;
|
||||
import cn.novalon.gym.manage.groupcourse.entity.GroupCourseTypeEntity;
|
||||
import cn.novalon.gym.manage.groupcourse.repository.IGroupCourseTypeRepository;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Repository
|
||||
@Transactional
|
||||
public class GroupCourseTypeRepository implements IGroupCourseTypeRepository {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(GroupCourseTypeRepository.class);
|
||||
|
||||
private final GroupCourseTypeDao groupCourseTypeDao;
|
||||
private final GroupCourseConverter converter;
|
||||
|
||||
public GroupCourseTypeRepository(GroupCourseTypeDao groupCourseTypeDao, GroupCourseConverter converter) {
|
||||
this.groupCourseTypeDao = groupCourseTypeDao;
|
||||
this.converter = converter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<GroupCourseType> findById(Long id) {
|
||||
return groupCourseTypeDao.findByIdIsAndDeletedAtIsNull(id)
|
||||
.map(converter::toGroupCourseType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<GroupCourseType> findAll() {
|
||||
return groupCourseTypeDao.findAll()
|
||||
.map(converter::toGroupCourseType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<GroupCourseType> findAll(boolean includeDeleted) {
|
||||
if (includeDeleted) {
|
||||
return groupCourseTypeDao.findAll()
|
||||
.map(converter::toGroupCourseType);
|
||||
} else {
|
||||
return groupCourseTypeDao.findAllByDeletedAtIsNull()
|
||||
.map(converter::toGroupCourseType);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<GroupCourseType> findByKeyword(String keyword) {
|
||||
if (keyword == null || keyword.isEmpty()) {
|
||||
return findAll(false);
|
||||
}
|
||||
return groupCourseTypeDao.findByTypeNameContainingAndDeletedAtIsNull(keyword)
|
||||
.map(converter::toGroupCourseType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<GroupCourseType> findByCategory(String category) {
|
||||
if (category == null || category.isEmpty()) {
|
||||
return findAll(false);
|
||||
}
|
||||
return groupCourseTypeDao.findByCategoryAndDeletedAtIsNull(category)
|
||||
.map(converter::toGroupCourseType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<GroupCourseType> findByCategoryAndKeyword(String category, String keyword) {
|
||||
Flux<GroupCourseType> result;
|
||||
|
||||
if (category != null && !category.isEmpty()) {
|
||||
result = findByCategory(category);
|
||||
} else {
|
||||
result = findAll(false);
|
||||
}
|
||||
|
||||
if (keyword != null && !keyword.isEmpty()) {
|
||||
result = result.filter(type -> type.getTypeName() != null &&
|
||||
type.getTypeName().toLowerCase().contains(keyword.toLowerCase()));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<GroupCourseType> findByTypeName(String typeName) {
|
||||
return groupCourseTypeDao.findByTypeNameAndDeletedAtIsNull(typeName)
|
||||
.map(converter::toGroupCourseType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<GroupCourseType> save(GroupCourseType groupCourseType) {
|
||||
GroupCourseTypeEntity entity = converter.toGroupCourseTypeEntity(groupCourseType);
|
||||
return groupCourseTypeDao.save(entity)
|
||||
.map(converter::toGroupCourseType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<GroupCourseType> update(GroupCourseType groupCourseType) {
|
||||
return groupCourseTypeDao.findByIdIsAndDeletedAtIsNull(groupCourseType.getId())
|
||||
.switchIfEmpty(Mono.error(new RuntimeException("团课类型不存在")))
|
||||
.flatMap(existing -> {
|
||||
existing.markNotNew();
|
||||
if (groupCourseType.getTypeName() != null) {
|
||||
existing.setTypeName(groupCourseType.getTypeName());
|
||||
}
|
||||
if (groupCourseType.getBaseDifficulty() != null) {
|
||||
existing.setBaseDifficulty(groupCourseType.getBaseDifficulty());
|
||||
}
|
||||
if (groupCourseType.getDescription() != null) {
|
||||
existing.setDescription(groupCourseType.getDescription());
|
||||
}
|
||||
if (groupCourseType.getCategory() != null) {
|
||||
existing.setCategory(groupCourseType.getCategory());
|
||||
}
|
||||
existing.setUpdatedAt(LocalDateTime.now());
|
||||
return groupCourseTypeDao.save(existing);
|
||||
})
|
||||
.map(converter::toGroupCourseType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Void> deleteById(Long id) {
|
||||
return groupCourseTypeDao.softDelete(id, LocalDateTime.now())
|
||||
.then();
|
||||
}
|
||||
}
|
||||
-30
@@ -1,30 +0,0 @@
|
||||
package cn.novalon.gym.manage.groupcourse.service;
|
||||
|
||||
import cn.novalon.gym.manage.groupcourse.domain.CourseLabel;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ICourseLabelService {
|
||||
|
||||
Mono<CourseLabel> findById(Long id);
|
||||
|
||||
Flux<CourseLabel> findAll();
|
||||
|
||||
Flux<CourseLabel> findByKeyword(String keyword);
|
||||
|
||||
Mono<CourseLabel> create(CourseLabel courseLabel);
|
||||
|
||||
Mono<CourseLabel> update(Long id, CourseLabel courseLabel);
|
||||
|
||||
Mono<Void> delete(Long id);
|
||||
|
||||
Flux<CourseLabel> findByTypeId(Long typeId);
|
||||
|
||||
Mono<Void> addLabelsToType(Long typeId, List<Long> labelIds);
|
||||
|
||||
Mono<Void> removeLabelFromType(Long typeId, Long labelId);
|
||||
|
||||
Mono<Void> clearLabelsFromType(Long typeId);
|
||||
}
|
||||
-2
@@ -4,13 +4,11 @@ package cn.novalon.gym.manage.groupcourse.service;
|
||||
import cn.novalon.gym.manage.common.dto.PageRequest;
|
||||
import cn.novalon.gym.manage.common.dto.PageResponse;
|
||||
import cn.novalon.gym.manage.groupcourse.domain.GroupCourse;
|
||||
import cn.novalon.gym.manage.groupcourse.domain.GroupCourseDetail;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
public interface IGroupCourseService {
|
||||
Mono<GroupCourse> findById(Long id);
|
||||
Mono<GroupCourseDetail> findDetailById(Long id);
|
||||
Flux<GroupCourse> findAll();
|
||||
Flux<GroupCourse> findAll(boolean includeDeleted);
|
||||
|
||||
|
||||
-32
@@ -1,32 +0,0 @@
|
||||
package cn.novalon.gym.manage.groupcourse.service;
|
||||
|
||||
import cn.novalon.gym.manage.groupcourse.domain.GroupCourseType;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
public interface IGroupCourseTypeService {
|
||||
|
||||
Mono<GroupCourseType> findById(Long id);
|
||||
|
||||
Flux<GroupCourseType> findAll();
|
||||
|
||||
Flux<GroupCourseType> findAll(boolean includeDeleted);
|
||||
|
||||
Flux<GroupCourseType> findByKeyword(String keyword);
|
||||
|
||||
Flux<GroupCourseType> findByCategory(String category);
|
||||
|
||||
Flux<GroupCourseType> findByCategoryAndKeyword(String category, String keyword);
|
||||
|
||||
Mono<GroupCourseType> create(GroupCourseType groupCourseType);
|
||||
|
||||
Mono<GroupCourseType> update(Long id, GroupCourseType groupCourseType);
|
||||
|
||||
Mono<Void> delete(Long id);
|
||||
|
||||
/**
|
||||
* 获取分类列表(去重)
|
||||
* @return 分类名称列表
|
||||
*/
|
||||
Flux<String> findCategories();
|
||||
}
|
||||
-112
@@ -1,112 +0,0 @@
|
||||
package cn.novalon.gym.manage.groupcourse.service.impl;
|
||||
|
||||
import cn.novalon.gym.manage.common.util.RedisUtil;
|
||||
import cn.novalon.gym.manage.groupcourse.domain.CourseLabel;
|
||||
import cn.novalon.gym.manage.groupcourse.domain.GroupCourse;
|
||||
import cn.novalon.gym.manage.groupcourse.repository.ICourseLabelRepository;
|
||||
import cn.novalon.gym.manage.groupcourse.repository.IGroupCourseRepository;
|
||||
import cn.novalon.gym.manage.groupcourse.service.ICourseLabelService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class CourseLabelService implements ICourseLabelService {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(CourseLabelService.class);
|
||||
private static final String CACHE_KEY_DETAIL_PREFIX = "group_course:detail:";
|
||||
|
||||
private final ICourseLabelRepository courseLabelRepository;
|
||||
private final IGroupCourseRepository groupCourseRepository;
|
||||
private final RedisUtil redisUtil;
|
||||
|
||||
public CourseLabelService(ICourseLabelRepository courseLabelRepository,
|
||||
IGroupCourseRepository groupCourseRepository,
|
||||
RedisUtil redisUtil) {
|
||||
this.courseLabelRepository = courseLabelRepository;
|
||||
this.groupCourseRepository = groupCourseRepository;
|
||||
this.redisUtil = redisUtil;
|
||||
}
|
||||
|
||||
private Mono<Void> invalidateGroupCourseDetailCache(Long typeId) {
|
||||
return groupCourseRepository.findByCourseType(typeId)
|
||||
.flatMap(course -> {
|
||||
String cacheKey = CACHE_KEY_DETAIL_PREFIX + course.getId();
|
||||
return redisUtil.delete(cacheKey)
|
||||
.doOnSuccess(deleted -> logger.debug("清除团课详情缓存 - courseId={}", course.getId()));
|
||||
})
|
||||
.then();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<CourseLabel> findById(Long id) {
|
||||
return courseLabelRepository.findById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<CourseLabel> findAll() {
|
||||
return courseLabelRepository.findAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<CourseLabel> findByKeyword(String keyword) {
|
||||
return courseLabelRepository.findByKeyword(keyword);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<CourseLabel> create(CourseLabel courseLabel) {
|
||||
return courseLabelRepository.findByLabelName(courseLabel.getLabelName())
|
||||
.flatMap(existing -> Mono.<CourseLabel>error(new RuntimeException("标签名称已存在")))
|
||||
.switchIfEmpty(courseLabelRepository.save(courseLabel))
|
||||
.doOnSuccess(label -> logger.info("标签创建成功 - id={}, name={}", label.getId(), label.getLabelName()))
|
||||
.doOnError(error -> logger.error("标签创建失败 - error: {}", error.getMessage()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<CourseLabel> update(Long id, CourseLabel courseLabel) {
|
||||
courseLabel.setId(id);
|
||||
return courseLabelRepository.update(courseLabel)
|
||||
.doOnSuccess(label -> logger.info("标签更新成功 - id={}", id))
|
||||
.doOnError(error -> logger.error("标签更新失败 - id={}, error: {}", id, error.getMessage()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Void> delete(Long id) {
|
||||
return courseLabelRepository.deleteById(id)
|
||||
.doOnSuccess(v -> logger.info("标签删除成功 - id={}", id))
|
||||
.doOnError(error -> logger.error("标签删除失败 - id={}, error: {}", id, error.getMessage()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<CourseLabel> findByTypeId(Long typeId) {
|
||||
return courseLabelRepository.findByTypeId(typeId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Void> addLabelsToType(Long typeId, List<Long> labelIds) {
|
||||
return courseLabelRepository.addLabelsToType(typeId, labelIds)
|
||||
.then(invalidateGroupCourseDetailCache(typeId))
|
||||
.doOnSuccess(v -> logger.info("标签添加到类型成功 - typeId={}, labelIds={}", typeId, labelIds))
|
||||
.doOnError(error -> logger.error("标签添加到类型失败 - typeId={}, error: {}", typeId, error.getMessage()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Void> removeLabelFromType(Long typeId, Long labelId) {
|
||||
return courseLabelRepository.removeLabelFromType(typeId, labelId)
|
||||
.then(invalidateGroupCourseDetailCache(typeId))
|
||||
.doOnSuccess(v -> logger.info("从类型移除标签成功 - typeId={}, labelId={}", typeId, labelId))
|
||||
.doOnError(error -> logger.error("从类型移除标签失败 - typeId={}, labelId={}, error: {}", typeId, labelId, error.getMessage()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Void> clearLabelsFromType(Long typeId) {
|
||||
return courseLabelRepository.clearLabelsFromType(typeId)
|
||||
.then(invalidateGroupCourseDetailCache(typeId))
|
||||
.doOnSuccess(v -> logger.info("清空类型标签成功 - typeId={}", typeId))
|
||||
.doOnError(error -> logger.error("清空类型标签失败 - typeId={}, error: {}", typeId, error.getMessage()));
|
||||
}
|
||||
}
|
||||
+1
-101
@@ -4,18 +4,13 @@ package cn.novalon.gym.manage.groupcourse.service.impl;
|
||||
import cn.novalon.gym.manage.common.dto.PageRequest;
|
||||
import cn.novalon.gym.manage.common.dto.PageResponse;
|
||||
import cn.novalon.gym.manage.common.util.RedisUtil;
|
||||
import cn.novalon.gym.manage.groupcourse.domain.CourseLabel;
|
||||
import cn.novalon.gym.manage.groupcourse.domain.GroupCourse;
|
||||
import cn.novalon.gym.manage.groupcourse.domain.GroupCourseBooking;
|
||||
import cn.novalon.gym.manage.groupcourse.domain.GroupCourseDetail;
|
||||
import cn.novalon.gym.manage.groupcourse.domain.GroupCourseType;
|
||||
import cn.novalon.gym.manage.groupcourse.enums.CourseEvent;
|
||||
import cn.novalon.gym.manage.groupcourse.enums.CourseStatus;
|
||||
import cn.novalon.gym.manage.groupcourse.handler.GroupCourseStateMachine;
|
||||
import cn.novalon.gym.manage.groupcourse.repository.ICourseLabelRepository;
|
||||
import cn.novalon.gym.manage.groupcourse.repository.IGroupCourseBookingRepository;
|
||||
import cn.novalon.gym.manage.groupcourse.repository.IGroupCourseRepository;
|
||||
import cn.novalon.gym.manage.groupcourse.repository.IGroupCourseTypeRepository;
|
||||
import cn.novalon.gym.manage.groupcourse.service.IGroupCourseService;
|
||||
import cn.novalon.gym.manage.member.entity.MemberCard;
|
||||
import cn.novalon.gym.manage.member.entity.MemberCardRecord;
|
||||
@@ -38,8 +33,6 @@ public class GroupCourseService implements IGroupCourseService {
|
||||
|
||||
private final IGroupCourseRepository groupCourseRepository;
|
||||
private final IGroupCourseBookingRepository bookingRepository;
|
||||
private final IGroupCourseTypeRepository groupCourseTypeRepository;
|
||||
private final ICourseLabelRepository courseLabelRepository;
|
||||
private final IMemberCardRecordService memberCardRecordService;
|
||||
private final MemberCardRepository memberCardRepository;
|
||||
private final RedisUtil redisUtil;
|
||||
@@ -48,15 +41,12 @@ public class GroupCourseService implements IGroupCourseService {
|
||||
|
||||
private static final String CACHE_KEY_PREFIX = "group_course:page:";
|
||||
private static final String CACHE_KEY_ID_PREFIX = "group_course:id:";
|
||||
private static final String CACHE_KEY_DETAIL_PREFIX = "group_course:detail:";
|
||||
private static final long CACHE_EXPIRE_SECONDS = 300;
|
||||
|
||||
private static final double DEFAULT_GROUP_COURSE_PRICE = 50.0;
|
||||
|
||||
public GroupCourseService(IGroupCourseRepository groupCourseRepository,
|
||||
IGroupCourseBookingRepository bookingRepository,
|
||||
IGroupCourseTypeRepository groupCourseTypeRepository,
|
||||
ICourseLabelRepository courseLabelRepository,
|
||||
IMemberCardRecordService memberCardRecordService,
|
||||
MemberCardRepository memberCardRepository,
|
||||
RedisUtil redisUtil,
|
||||
@@ -64,8 +54,6 @@ public class GroupCourseService implements IGroupCourseService {
|
||||
GroupCourseStateMachine stateMachine){
|
||||
this.groupCourseRepository = groupCourseRepository;
|
||||
this.bookingRepository = bookingRepository;
|
||||
this.groupCourseTypeRepository = groupCourseTypeRepository;
|
||||
this.courseLabelRepository = courseLabelRepository;
|
||||
this.memberCardRecordService = memberCardRecordService;
|
||||
this.memberCardRepository = memberCardRepository;
|
||||
this.redisUtil = redisUtil;
|
||||
@@ -73,93 +61,6 @@ public class GroupCourseService implements IGroupCourseService {
|
||||
this.stateMachine = stateMachine;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<GroupCourseDetail> findDetailById(Long id) {
|
||||
String cacheKey = CACHE_KEY_DETAIL_PREFIX + id;
|
||||
|
||||
return redisUtil.get(cacheKey, String.class)
|
||||
.flatMap(cachedJson -> {
|
||||
if (cachedJson != null) {
|
||||
try {
|
||||
GroupCourseDetail detail = objectMapper.readValue(cachedJson, GroupCourseDetail.class);
|
||||
logger.info("缓存命中 - findDetailById: id={}", id);
|
||||
return Mono.just(detail);
|
||||
} catch (JsonProcessingException e) {
|
||||
logger.warn("缓存解析失败,删除缓存 - id: {}, error: {}", id, e.getMessage());
|
||||
return redisUtil.delete(cacheKey).then(Mono.empty());
|
||||
}
|
||||
}
|
||||
return Mono.empty();
|
||||
})
|
||||
.switchIfEmpty(
|
||||
groupCourseRepository.findByIdAndDeletedAtIsNull(id)
|
||||
.flatMap(course -> {
|
||||
// 查询类型信息
|
||||
Long courseTypeId = course.getCourseType();
|
||||
|
||||
if (courseTypeId == null) {
|
||||
// 没有类型,直接构建详情
|
||||
return Mono.just(buildDetail(course, null));
|
||||
}
|
||||
|
||||
// 有类型,查询类型信息
|
||||
return groupCourseTypeRepository.findById(courseTypeId)
|
||||
.flatMap(type -> {
|
||||
// 查询标签
|
||||
return courseLabelRepository.findByTypeId(type.getId())
|
||||
.collectList()
|
||||
.map(labels -> {
|
||||
type.setLabels(labels);
|
||||
return buildDetail(course, type);
|
||||
});
|
||||
})
|
||||
.switchIfEmpty(Mono.just(buildDetail(course, null)));
|
||||
})
|
||||
.flatMap(detail -> {
|
||||
try {
|
||||
String jsonData = objectMapper.writeValueAsString(detail);
|
||||
return redisUtil.setWithExpire(cacheKey, jsonData, CACHE_EXPIRE_SECONDS)
|
||||
.thenReturn(detail)
|
||||
.doOnSuccess(d -> logger.debug("缓存已设置 - findDetailById: id={}", id));
|
||||
} catch (JsonProcessingException e) {
|
||||
logger.error("缓存设置失败 - id: {}, error: {}", id, e.getMessage());
|
||||
return Mono.just(detail);
|
||||
}
|
||||
})
|
||||
.doOnSubscribe(sub -> logger.debug("缓存未命中,查询数据库 - findDetailById: id={}", id))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建团课完整信息对象
|
||||
*/
|
||||
private GroupCourseDetail buildDetail(GroupCourse course, GroupCourseType type) {
|
||||
GroupCourseDetail detail = new GroupCourseDetail();
|
||||
detail.setId(course.getId());
|
||||
detail.setCourseName(course.getCourseName());
|
||||
detail.setCoachId(course.getCoachId());
|
||||
detail.setCourseType(course.getCourseType());
|
||||
detail.setStartTime(course.getStartTime());
|
||||
detail.setEndTime(course.getEndTime());
|
||||
detail.setMaxMembers(course.getMaxMembers());
|
||||
detail.setCurrentMembers(course.getCurrentMembers());
|
||||
detail.setStatus(course.getStatus());
|
||||
detail.setLocation(course.getLocation());
|
||||
detail.setCoverImage(course.getCoverImage());
|
||||
detail.setDescription(course.getDescription());
|
||||
detail.setPointCardAmount(course.getPointCardAmount());
|
||||
detail.setStoredValueAmount(course.getStoredValueAmount());
|
||||
detail.setCreatedAt(course.getCreatedAt());
|
||||
detail.setUpdatedAt(course.getUpdatedAt());
|
||||
|
||||
// 设置类型信息
|
||||
if (type != null) {
|
||||
detail.setTypeInfo(type);
|
||||
}
|
||||
|
||||
return detail;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<GroupCourse> findById(Long id) {
|
||||
String cacheKey = CACHE_KEY_ID_PREFIX + id;
|
||||
@@ -490,7 +391,6 @@ public class GroupCourseService implements IGroupCourseService {
|
||||
|
||||
private Mono<Void> clearCache() {
|
||||
return redisUtil.deleteByPattern(CACHE_KEY_PREFIX + "*")
|
||||
.then(redisUtil.deleteByPattern(CACHE_KEY_ID_PREFIX + "*"))
|
||||
.then(redisUtil.deleteByPattern(CACHE_KEY_DETAIL_PREFIX + "*")).then();
|
||||
.then(redisUtil.deleteByPattern(CACHE_KEY_ID_PREFIX + "*")).then();
|
||||
}
|
||||
}
|
||||
|
||||
-86
@@ -1,86 +0,0 @@
|
||||
package cn.novalon.gym.manage.groupcourse.service.impl;
|
||||
|
||||
import cn.novalon.gym.manage.groupcourse.domain.GroupCourseType;
|
||||
import cn.novalon.gym.manage.groupcourse.repository.IGroupCourseTypeRepository;
|
||||
import cn.novalon.gym.manage.groupcourse.service.IGroupCourseTypeService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@Service
|
||||
public class GroupCourseTypeService implements IGroupCourseTypeService {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(GroupCourseTypeService.class);
|
||||
|
||||
private final IGroupCourseTypeRepository groupCourseTypeRepository;
|
||||
|
||||
public GroupCourseTypeService(IGroupCourseTypeRepository groupCourseTypeRepository) {
|
||||
this.groupCourseTypeRepository = groupCourseTypeRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<GroupCourseType> findById(Long id) {
|
||||
return groupCourseTypeRepository.findById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<GroupCourseType> findAll() {
|
||||
return groupCourseTypeRepository.findAll(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<GroupCourseType> findAll(boolean includeDeleted) {
|
||||
return groupCourseTypeRepository.findAll(includeDeleted);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<GroupCourseType> findByKeyword(String keyword) {
|
||||
return groupCourseTypeRepository.findByKeyword(keyword);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<GroupCourseType> findByCategory(String category) {
|
||||
return groupCourseTypeRepository.findByCategory(category);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<GroupCourseType> findByCategoryAndKeyword(String category, String keyword) {
|
||||
return groupCourseTypeRepository.findByCategoryAndKeyword(category, keyword);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<GroupCourseType> create(GroupCourseType groupCourseType) {
|
||||
return groupCourseTypeRepository.findByTypeName(groupCourseType.getTypeName())
|
||||
.flatMap(existing -> Mono.<GroupCourseType>error(new RuntimeException("团课类型名称已存在")))
|
||||
.switchIfEmpty(groupCourseTypeRepository.save(groupCourseType))
|
||||
.doOnSuccess(type -> logger.info("团课类型创建成功 - id={}, name={}", type.getId(), type.getTypeName()))
|
||||
.doOnError(error -> logger.error("团课类型创建失败 - error: {}", error.getMessage()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<GroupCourseType> update(Long id, GroupCourseType groupCourseType) {
|
||||
return groupCourseTypeRepository.update(groupCourseType)
|
||||
.doOnSuccess(type -> logger.info("团课类型更新成功 - id={}", id))
|
||||
.doOnError(error -> logger.error("团课类型更新失败 - id={}, error: {}", id, error.getMessage()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Void> delete(Long id) {
|
||||
return groupCourseTypeRepository.deleteById(id)
|
||||
.doOnSuccess(v -> logger.info("团课类型删除成功 - id={}", id))
|
||||
.doOnError(error -> logger.error("团课类型删除失败 - id={}, error: {}", id, error.getMessage()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<String> findCategories() {
|
||||
return groupCourseTypeRepository.findAll(false)
|
||||
.map(GroupCourseType::getCategory)
|
||||
.filter(category -> category != null && !category.isEmpty())
|
||||
.distinct();
|
||||
}
|
||||
}
|
||||
+19
-223
@@ -1,223 +1,19 @@
|
||||
2026-06-11T13:43:44.371+08:00 TRACE 9324 --- [gym-manage-api] [nio-8084-exec-2] o.s.w.s.adapter.HttpWebHandlerAdapter : [27afd417] HTTP POST "/api/groupCourse/types/1/labels", headers={masked}
|
||||
2026-06-11T13:43:44.372+08:00 DEBUG 9324 --- [gym-manage-api] [ parallel-2] o.s.w.s.s.DefaultWebSessionManager : Created new WebSession.
|
||||
2026-06-11T13:43:44.372+08:00 INFO 9324 --- [gym-manage-api] [ parallel-2] c.n.g.m.sys.audit.OperationLogWebFilter : WebFilter 拦截请求: POST /api/groupCourse/types/1/labels
|
||||
2026-06-11T13:43:44.372+08:00 INFO 9324 --- [gym-manage-api] [ parallel-2] c.n.g.m.sys.audit.OperationLogWebFilter : 未匹配到操作日志配置,跳过: POST /api/groupCourse/types/1/labels
|
||||
2026-06-11T13:43:44.372+08:00 INFO 9324 --- [gym-manage-api] [ parallel-2] c.n.g.m.sys.audit.OperationLogWebFilter : WebFilter 拦截请求: POST /api/groupCourse/types/1/labels
|
||||
2026-06-11T13:43:44.372+08:00 INFO 9324 --- [gym-manage-api] [ parallel-2] c.n.g.m.sys.audit.OperationLogWebFilter : 未匹配到操作日志配置,跳过: POST /api/groupCourse/types/1/labels
|
||||
2026-06-11T13:43:44.372+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.372+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.372+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.372+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.372+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.373+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "POST" matches against value "POST"
|
||||
2026-06-11T13:43:44.373+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Pattern "/api/dictionaries" does not match against value "/api/groupCourse/types/1/labels"
|
||||
2026-06-11T13:43:44.373+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "PUT" does not match against value "POST"
|
||||
2026-06-11T13:43:44.373+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "DELETE" does not match against value "POST"
|
||||
2026-06-11T13:43:44.373+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.373+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.373+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.373+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.373+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.373+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.373+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "POST" matches against value "POST"
|
||||
2026-06-11T13:43:44.373+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Pattern "/api/users" does not match against value "/api/groupCourse/types/1/labels"
|
||||
2026-06-11T13:43:44.373+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.373+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "PUT" does not match against value "POST"
|
||||
2026-06-11T13:43:44.373+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "DELETE" does not match against value "POST"
|
||||
2026-06-11T13:43:44.373+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "POST" matches against value "POST"
|
||||
2026-06-11T13:43:44.373+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Pattern "/api/users/{id}/action/change-password" does not match against value "/api/groupCourse/types/1/labels"
|
||||
2026-06-11T13:43:44.373+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "POST" matches against value "POST"
|
||||
2026-06-11T13:43:44.373+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Pattern "/api/users/{id}/action/logical-delete" does not match against value "/api/groupCourse/types/1/labels"
|
||||
2026-06-11T13:43:44.373+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "POST" matches against value "POST"
|
||||
2026-06-11T13:43:44.373+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Pattern "/api/users/logical-delete" does not match against value "/api/groupCourse/types/1/labels"
|
||||
2026-06-11T13:43:44.373+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "POST" matches against value "POST"
|
||||
2026-06-11T13:43:44.373+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Pattern "/api/users/action/restore" does not match against value "/api/groupCourse/types/1/labels"
|
||||
2026-06-11T13:43:44.373+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "POST" matches against value "POST"
|
||||
2026-06-11T13:43:44.373+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Pattern "/api/users/{id}/action/restore" does not match against value "/api/groupCourse/types/1/labels"
|
||||
2026-06-11T13:43:44.373+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.373+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "POST" matches against value "POST"
|
||||
2026-06-11T13:43:44.373+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Pattern "/api/users/{id}/roles" does not match against value "/api/groupCourse/types/1/labels"
|
||||
2026-06-11T13:43:44.373+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.373+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.373+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.373+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "POST" matches against value "POST"
|
||||
2026-06-11T13:43:44.373+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Pattern "/api/menus" does not match against value "/api/groupCourse/types/1/labels"
|
||||
2026-06-11T13:43:44.373+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "PUT" does not match against value "POST"
|
||||
2026-06-11T13:43:44.373+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "DELETE" does not match against value "POST"
|
||||
2026-06-11T13:43:44.373+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.373+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.373+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.373+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.373+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.373+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.373+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "POST" matches against value "POST"
|
||||
2026-06-11T13:43:44.373+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Pattern "/api/roles" does not match against value "/api/groupCourse/types/1/labels"
|
||||
2026-06-11T13:43:44.373+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "PUT" does not match against value "POST"
|
||||
2026-06-11T13:43:44.373+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "DELETE" does not match against value "POST"
|
||||
2026-06-11T13:43:44.373+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "POST" matches against value "POST"
|
||||
2026-06-11T13:43:44.373+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Pattern "/api/roles/{id}/restore" does not match against value "/api/groupCourse/types/1/labels"
|
||||
2026-06-11T13:43:44.373+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.373+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "POST" matches against value "POST"
|
||||
2026-06-11T13:43:44.373+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Pattern "/api/roles/{id}/permissions" does not match against value "/api/groupCourse/types/1/labels"
|
||||
2026-06-11T13:43:44.373+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.373+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.373+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.373+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "POST" matches against value "POST"
|
||||
2026-06-11T13:43:44.373+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Pattern "/api/config" does not match against value "/api/groupCourse/types/1/labels"
|
||||
2026-06-11T13:43:44.373+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "PUT" does not match against value "POST"
|
||||
2026-06-11T13:43:44.373+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "DELETE" does not match against value "POST"
|
||||
2026-06-11T13:43:44.373+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.373+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.373+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.373+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.373+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "POST" matches against value "POST"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Pattern "/api/logs/login" does not match against value "/api/groupCourse/types/1/labels"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "POST" matches against value "POST"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Pattern "/api/logs/exception" does not match against value "/api/groupCourse/types/1/labels"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "POST" matches against value "POST"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Pattern "/api/logs/operation" does not match against value "/api/groupCourse/types/1/labels"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "POST" matches against value "POST"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Pattern "/api/auth/login" does not match against value "/api/groupCourse/types/1/labels"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "POST" matches against value "POST"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Pattern "/api/auth/register" does not match against value "/api/groupCourse/types/1/labels"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "POST" matches against value "POST"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Pattern "/api/auth/logout" does not match against value "/api/groupCourse/types/1/labels"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "POST" matches against value "POST"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Pattern "/api/dict/types" does not match against value "/api/groupCourse/types/1/labels"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "PUT" does not match against value "POST"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "DELETE" does not match against value "POST"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "POST" matches against value "POST"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Pattern "/api/dict/data" does not match against value "/api/groupCourse/types/1/labels"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "PUT" does not match against value "POST"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "DELETE" does not match against value "POST"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "POST" matches against value "POST"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Pattern "/api/notices" does not match against value "/api/groupCourse/types/1/labels"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "PUT" does not match against value "POST"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "DELETE" does not match against value "POST"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "POST" matches against value "POST"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Pattern "/api/messages" does not match against value "/api/groupCourse/types/1/labels"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "PUT" does not match against value "POST"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "DELETE" does not match against value "POST"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "POST" matches against value "POST"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Pattern "/api/files/upload" does not match against value "/api/groupCourse/types/1/labels"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "DELETE" does not match against value "POST"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "POST" matches against value "POST"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Pattern "/api/permissions" does not match against value "/api/groupCourse/types/1/labels"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "PUT" does not match against value "POST"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "DELETE" does not match against value "POST"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "POST" matches against value "POST"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Pattern "/api/member/auth/miniapp/login" does not match against value "/api/groupCourse/types/1/labels"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "POST" matches against value "POST"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Pattern "/api/member/auth/mp/callback" does not match against value "/api/groupCourse/types/1/labels"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "PUT" does not match against value "POST"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "POST" matches against value "POST"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Pattern "/api/member/phone/bind" does not match against value "/api/groupCourse/types/1/labels"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "POST" matches against value "POST"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Pattern "/api/admin/member/{id}/phone" does not match against value "/api/groupCourse/types/1/labels"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "PUT" does not match against value "POST"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.375+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "POST" matches against value "POST"
|
||||
2026-06-11T13:43:44.376+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Pattern "/api/member-cards" does not match against value "/api/groupCourse/types/1/labels"
|
||||
2026-06-11T13:43:44.376+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "POST" matches against value "POST"
|
||||
2026-06-11T13:43:44.376+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Pattern "/api/member-card-records/purchase" does not match against value "/api/groupCourse/types/1/labels"
|
||||
2026-06-11T13:43:44.376+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "POST" matches against value "POST"
|
||||
2026-06-11T13:43:44.376+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Pattern "/api/member-card-records/{recordId}/renew" does not match against value "/api/groupCourse/types/1/labels"
|
||||
2026-06-11T13:43:44.376+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "POST" matches against value "POST"
|
||||
2026-06-11T13:43:44.376+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Pattern "/api/member-card-records/{recordId}/use" does not match against value "/api/groupCourse/types/1/labels"
|
||||
2026-06-11T13:43:44.376+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "POST" matches against value "POST"
|
||||
2026-06-11T13:43:44.376+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Pattern "/api/member-card-records/{recordId}/refund" does not match against value "/api/groupCourse/types/1/labels"
|
||||
2026-06-11T13:43:44.376+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.376+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.376+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "POST" matches against value "POST"
|
||||
2026-06-11T13:43:44.376+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Pattern "/api/member-card-records/process-expired" does not match against value "/api/groupCourse/types/1/labels"
|
||||
2026-06-11T13:43:44.376+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "POST" matches against value "POST"
|
||||
2026-06-11T13:43:44.376+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Pattern "/api/member-card-transactions" does not match against value "/api/groupCourse/types/1/labels"
|
||||
2026-06-11T13:43:44.376+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.376+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.376+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.376+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.376+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.376+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.376+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.376+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "POST" matches against value "POST"
|
||||
2026-06-11T13:43:44.376+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Pattern "/api/groupCourse/page" does not match against value "/api/groupCourse/types/1/labels"
|
||||
2026-06-11T13:43:44.376+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.376+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.376+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.376+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.376+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.376+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "POST" matches against value "POST"
|
||||
2026-06-11T13:43:44.376+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Pattern "/api/groupCourse/types" does not match against value "/api/groupCourse/types/1/labels"
|
||||
2026-06-11T13:43:44.376+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "PUT" does not match against value "POST"
|
||||
2026-06-11T13:43:44.376+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "DELETE" does not match against value "POST"
|
||||
2026-06-11T13:43:44.376+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.376+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.376+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.376+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "GET" does not match against value "POST"
|
||||
2026-06-11T13:43:44.376+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "POST" matches against value "POST"
|
||||
2026-06-11T13:43:44.376+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Pattern "/api/groupCourse/labels" does not match against value "/api/groupCourse/types/1/labels"
|
||||
2026-06-11T13:43:44.376+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "PUT" does not match against value "POST"
|
||||
2026-06-11T13:43:44.376+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "DELETE" does not match against value "POST"
|
||||
2026-06-11T13:43:44.376+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Method "POST" matches against value "POST"
|
||||
2026-06-11T13:43:44.376+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.server.RequestPredicates : Pattern "/api/groupCourse/types/{typeId}/labels" matches against value "/api/groupCourse/types/1/labels"
|
||||
2026-06-11T13:43:44.376+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.function.server.RouterFunctions : [27afd417] Matched (POST && /api/groupCourse/types/{typeId}/labels)
|
||||
2026-06-11T13:43:44.376+08:00 DEBUG 9324 --- [gym-manage-api] [ parallel-2] o.s.w.r.f.s.s.RouterFunctionMapping : [27afd417] Mapped to cn.novalon.gym.manage.app.config.SystemRouter$$Lambda/0x00000223a09d1920@3760f3e8
|
||||
2026-06-11T13:43:44.377+08:00 TRACE 9324 --- [gym-manage-api] [ parallel-2] org.springframework.web.HttpLogging : [27afd417] Decoded [{labelIds=[1, 3, 5]}]
|
||||
2026-06-11T13:43:44.377+08:00 DEBUG 9324 --- [gym-manage-api] [ parallel-2] o.s.r.c.R2dbcTransactionManager : Creating new transaction with name [cn.novalon.gym.manage.groupcourse.repository.impl.CourseLabelRepository.addLabelsToType]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT
|
||||
2026-06-11T13:43:44.377+08:00 DEBUG 9324 --- [gym-manage-api] [ parallel-2] o.s.r.c.R2dbcTransactionManager : Acquired Connection [PooledConnection[PostgresqlConnection{client=io.r2dbc.postgresql.client.ReactorNettyClient@c3a5202, codecs=io.r2dbc.postgresql.codec.DefaultCodecs@922d1d4}]] for R2DBC transaction
|
||||
2026-06-11T13:43:44.377+08:00 DEBUG 9324 --- [gym-manage-api] [ parallel-2] o.s.r.c.R2dbcTransactionManager : Starting R2DBC transaction on Connection [PooledConnection[PostgresqlConnection{client=io.r2dbc.postgresql.client.ReactorNettyClient@c3a5202, codecs=io.r2dbc.postgresql.codec.DefaultCodecs@922d1d4}]] using [ExtendedTransactionDefinition [transactionName='cn.novalon.gym.manage.groupcourse.repository.impl.CourseLabelRepository.addLabelsToType', readOnly=false, isolationLevel=null, lockWaitTimeout=PT0S]]
|
||||
2026-06-11T13:43:44.379+08:00 DEBUG 9324 --- [gym-manage-api] [actor-tcp-nio-6] o.s.r2dbc.core.DefaultDatabaseClient : Executing SQL statement [SELECT course_type_label.type_id, course_type_label.label_id, course_type_label.id, course_type_label.create_by, course_type_label.update_by, course_type_label.created_at, course_type_label.updated_at, course_type_label.deleted_at FROM course_type_label WHERE course_type_label.type_id = $1 AND (course_type_label.label_id = $2) AND (course_type_label.deleted_at IS NULL)]
|
||||
2026-06-11T13:43:44.381+08:00 DEBUG 9324 --- [gym-manage-api] [actor-tcp-nio-6] o.s.r2dbc.core.DefaultDatabaseClient : Executing SQL statement [SELECT course_type_label.type_id, course_type_label.label_id, course_type_label.id, course_type_label.create_by, course_type_label.update_by, course_type_label.created_at, course_type_label.updated_at, course_type_label.deleted_at FROM course_type_label WHERE course_type_label.type_id = $1 AND (course_type_label.label_id = $2) AND (course_type_label.deleted_at IS NULL)]
|
||||
2026-06-11T13:43:44.382+08:00 DEBUG 9324 --- [gym-manage-api] [actor-tcp-nio-6] o.s.r2dbc.core.DefaultDatabaseClient : Executing SQL statement [SELECT course_type_label.type_id, course_type_label.label_id, course_type_label.id, course_type_label.create_by, course_type_label.update_by, course_type_label.created_at, course_type_label.updated_at, course_type_label.deleted_at FROM course_type_label WHERE course_type_label.type_id = $1 AND (course_type_label.label_id = $2) AND (course_type_label.deleted_at IS NULL)]
|
||||
2026-06-11T13:43:44.382+08:00 DEBUG 9324 --- [gym-manage-api] [actor-tcp-nio-6] o.s.r2dbc.core.DefaultDatabaseClient : Executing SQL statement [INSERT INTO course_type_label (type_id, label_id, create_by, update_by, created_at, updated_at) VALUES ($1, $2, $3, $4, $5, $6)]
|
||||
2026-06-11T13:43:44.385+08:00 DEBUG 9324 --- [gym-manage-api] [actor-tcp-nio-6] o.s.r2dbc.core.DefaultDatabaseClient : Executing SQL statement [INSERT INTO course_type_label (type_id, label_id, create_by, update_by, created_at, updated_at) VALUES ($1, $2, $3, $4, $5, $6)]
|
||||
2026-06-11T13:43:44.385+08:00 DEBUG 9324 --- [gym-manage-api] [actor-tcp-nio-6] o.s.r2dbc.core.DefaultDatabaseClient : Executing SQL statement [INSERT INTO course_type_label (type_id, label_id, create_by, update_by, created_at, updated_at) VALUES ($1, $2, $3, $4, $5, $6)]
|
||||
2026-06-11T13:43:44.387+08:00 DEBUG 9324 --- [gym-manage-api] [actor-tcp-nio-6] o.s.r.c.R2dbcTransactionManager : Initiating transaction rollback
|
||||
2026-06-11T13:43:44.387+08:00 DEBUG 9324 --- [gym-manage-api] [actor-tcp-nio-6] o.s.r.c.R2dbcTransactionManager : Rolling back R2DBC transaction on Connection [PooledConnection[PostgresqlConnection{client=io.r2dbc.postgresql.client.ReactorNettyClient@c3a5202, codecs=io.r2dbc.postgresql.codec.DefaultCodecs@922d1d4}]]
|
||||
2026-06-11T13:43:44.389+08:00 DEBUG 9324 --- [gym-manage-api] [actor-tcp-nio-6] o.s.r.c.R2dbcTransactionManager : Releasing R2DBC Connection [PooledConnection[PostgresqlConnection{client=io.r2dbc.postgresql.client.ReactorNettyClient@c3a5202, codecs=io.r2dbc.postgresql.codec.DefaultCodecs@922d1d4}]] after transaction
|
||||
2026-06-11T13:43:44.389+08:00 ERROR 9324 --- [gym-manage-api] [actor-tcp-nio-6] c.n.g.m.g.s.impl.CourseLabelService : 标签添加到类型失败 - typeId=1, error: executeMany; SQL [INSERT INTO course_type_label (type_id, label_id, create_by, update_by, created_at, updated_at) VALUES ($1, $2, $3, $4, $5, $6)]; 重复键违反唯一约束"course_type_label_type_id_label_id_key"
|
||||
2026-06-11T13:43:44.389+08:00 TRACE 9324 --- [gym-manage-api] [actor-tcp-nio-6] org.springframework.web.HttpLogging : [27afd417] Encoding [{success=false, message=executeMany; SQL [INSERT INTO course_type_label (type_id, label_id, create_by, update_by, created_at, updated_at) VALUES ($1, $2, $3, $4, $5, $6)]; 重复键违反唯一约束"course_type_label_type_id_label_id_key"}]
|
||||
2026-06-11T13:43:44.390+08:00 TRACE 9324 --- [gym-manage-api] [actor-tcp-nio-6] o.s.w.s.adapter.HttpWebHandlerAdapter : [27afd417] Completed 400 BAD_REQUEST, headers={masked}
|
||||
2026-06-11T13:43:44.390+08:00 TRACE 9324 --- [gym-manage-api] [actor-tcp-nio-6] org.springframework.web.HttpLogging : [27afd417] onComplete
|
||||
2026-06-06T15:01:42.450+08:00 TRACE 20572 --- [gym-manage-api] [ctor-http-nio-3] o.s.w.s.adapter.HttpWebHandlerAdapter : [a300293b-3] HTTP GET "/api/stats/member/range?startDate=2026-06-01&endDate=2026-06-05", headers={masked}
|
||||
2026-06-06T15:01:42.453+08:00 DEBUG 20572 --- [gym-manage-api] [ parallel-5] o.s.w.s.s.DefaultWebSessionManager : Created new WebSession.
|
||||
2026-06-06T15:01:42.454+08:00 INFO 20572 --- [gym-manage-api] [ parallel-5] c.n.g.m.sys.audit.OperationLogWebFilter : WebFilter 拦截请求: GET /api/stats/member/range
|
||||
2026-06-06T15:01:42.454+08:00 INFO 20572 --- [gym-manage-api] [ parallel-5] c.n.g.m.sys.audit.OperationLogWebFilter : 未匹配到操作日志配置,跳过: GET /api/stats/member/range
|
||||
2026-06-06T15:01:42.454+08:00 INFO 20572 --- [gym-manage-api] [ parallel-5] c.n.g.m.sys.audit.OperationLogWebFilter : WebFilter 拦截请求: GET /api/stats/member/range
|
||||
2026-06-06T15:01:42.455+08:00 INFO 20572 --- [gym-manage-api] [ parallel-5] c.n.g.m.sys.audit.OperationLogWebFilter : 未匹配到操作日志配置,跳过: GET /api/stats/member/range
|
||||
2026-06-06T15:01:42.455+08:00 TRACE 20572 --- [gym-manage-api] [ parallel-5] o.s.w.r.f.server.RequestPredicates : Method "GET" matches against value "GET"
|
||||
2026-06-06T15:01:42.455+08:00 TRACE 20572 --- [gym-manage-api] [ parallel-5] o.s.w.r.f.server.RequestPredicates : Pattern "/api/stats/member/date/{date}" does not match against value "/api/stats/member/range"
|
||||
2026-06-06T15:01:42.455+08:00 TRACE 20572 --- [gym-manage-api] [ parallel-5] o.s.w.r.f.server.RequestPredicates : Method "GET" matches against value "GET"
|
||||
2026-06-06T15:01:42.455+08:00 TRACE 20572 --- [gym-manage-api] [ parallel-5] o.s.w.r.f.server.RequestPredicates : Pattern "/api/stats/member/range" matches against value "/api/stats/member/range"
|
||||
2026-06-06T15:01:42.455+08:00 TRACE 20572 --- [gym-manage-api] [ parallel-5] o.s.w.r.function.server.RouterFunctions : [a300293b-3] Matched (GET && /api/stats/member/range)
|
||||
2026-06-06T15:01:42.455+08:00 DEBUG 20572 --- [gym-manage-api] [ parallel-5] o.s.w.r.f.s.s.RouterFunctionMapping : [a300293b-3] Mapped to cn.novalon.gym.manage.datacount.config.DataCountRouter$$Lambda/0x00000230b4931ec0@4746b319
|
||||
2026-06-06T15:01:42.455+08:00 DEBUG 20572 --- [gym-manage-api] [ parallel-5] o.s.r2dbc.core.DefaultDatabaseClient : Executing SQL statement [SELECT DATE(m.created_at) as date, COUNT(*) as new_members FROM member_user m WHERE m.is_deleted = FALSE AND DATE(m.created_at) BETWEEN $1 AND $2 GROUP BY DATE(m.created_at) ORDER BY date]
|
||||
2026-06-06T15:01:42.460+08:00 TRACE 20572 --- [gym-manage-api] [actor-tcp-nio-2] org.springframework.web.HttpLogging : [a300293b-3] Encoding [{success=false, message=Cannot decode value of type java.sql.Date with OID 1082}]
|
||||
2026-06-06T15:01:42.461+08:00 TRACE 20572 --- [gym-manage-api] [actor-tcp-nio-2] o.s.w.s.adapter.HttpWebHandlerAdapter : [a300293b-3] Completed 400 BAD_REQUEST, headers={masked}
|
||||
2026-06-06T15:01:42.461+08:00 TRACE 20572 --- [gym-manage-api] [actor-tcp-nio-2] org.springframework.web.HttpLogging : [f8ae8809, L:/[0:0:0:0:0:0:0:1]:8084 ! R:/[0:0:0:0:0:0:0:1]:63191] Handling completed
|
||||
2026-06-06T15:02:07.299+08:00 INFO 20572 --- [gym-manage-api] [ scheduling-1] c.n.g.m.g.s.i.GroupCourseBookingService : 开始处理已开始课程但未到场会员的预约记录
|
||||
2026-06-06T15:02:07.301+08:00 DEBUG 20572 --- [gym-manage-api] [ scheduling-1] o.s.r2dbc.core.DefaultDatabaseClient : Executing SQL statement [SELECT b.* FROM group_course_booking b JOIN group_course c ON b.course_id = c.id WHERE b.status = '0' AND b.deleted_at IS NULL AND c.deleted_at IS NULL AND c.status = '0' AND c.start_time < CURRENT_TIMESTAMP]
|
||||
2026-06-06T15:02:07.305+08:00 INFO 20572 --- [gym-manage-api] [actor-tcp-nio-2] c.n.g.m.g.s.i.GroupCourseBookingService : 没有需要处理的缺席会员记录
|
||||
|
||||
@@ -43,16 +43,6 @@
|
||||
<artifactId>gym-member</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.novalon.gym.manage</groupId>
|
||||
<artifactId>gym-checkIn</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.novalon.gym.manage</groupId>
|
||||
<artifactId>gym-dataCount</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
@@ -159,6 +149,12 @@
|
||||
<version>1.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.novalon.gym.manage</groupId>
|
||||
<artifactId>gym-dataCount</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
+4
-2
@@ -7,7 +7,10 @@ import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.security.reactive.ReactiveUserDetailsServiceAutoConfiguration;
|
||||
import org.springframework.boot.context.properties.ConfigurationPropertiesScan;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories;
|
||||
import org.springframework.data.elasticsearch.repository.config.EnableReactiveElasticsearchRepositories;
|
||||
import org.springframework.data.r2dbc.repository.config.EnableR2dbcRepositories;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
@@ -23,8 +26,7 @@ import java.util.List;
|
||||
"cn.novalon.gym.manage.sys.audit.repository" ,
|
||||
"cn.novalon.gym.manage.gymmembercard.dao",
|
||||
"cn.novalon.gym.manage.member.repository",
|
||||
"cn.novalon.gym.manage.groupcourse.dao",
|
||||
"cn.novalon.gym.manage.checkIn.repository"
|
||||
"cn.novalon.gym.manage.groupcourse.dao"
|
||||
})
|
||||
@EnableReactiveElasticsearchRepositories(basePackages = "cn.novalon.gym.manage.member.es.repository")
|
||||
public class ManageApplication {
|
||||
|
||||
+7
-67
@@ -1,13 +1,9 @@
|
||||
package cn.novalon.gym.manage.app.config;
|
||||
|
||||
|
||||
import cn.novalon.gym.manage.checkIn.handler.CheckInHandler;
|
||||
import cn.novalon.gym.manage.datacount.handler.DataStatisticsHandler;
|
||||
import cn.novalon.gym.manage.file.handler.SysFileHandler;
|
||||
import cn.novalon.gym.manage.groupcourse.handler.GroupCourseBookingHandler;
|
||||
import cn.novalon.gym.manage.groupcourse.handler.GroupCourseHandler;
|
||||
import cn.novalon.gym.manage.groupcourse.handler.GroupCourseTypeHandler;
|
||||
import cn.novalon.gym.manage.groupcourse.handler.CourseLabelHandler;
|
||||
import cn.novalon.gym.manage.member.handler.MemberCardHandler;
|
||||
import cn.novalon.gym.manage.member.handler.MemberCardRecordHandler;
|
||||
import cn.novalon.gym.manage.member.handler.MemberCardTransactionHandler;
|
||||
@@ -70,11 +66,7 @@ public class SystemRouter {
|
||||
MemberCardRecordHandler memberCardRecordHandler,
|
||||
MemberCardTransactionHandler memberCardTransactionHandler,
|
||||
GroupCourseHandler groupCourseHandler,
|
||||
GroupCourseBookingHandler groupCourseBookingHandler,
|
||||
GroupCourseTypeHandler groupCourseTypeHandler,
|
||||
CourseLabelHandler courseLabelHandler,
|
||||
CheckInHandler checkInHandler,
|
||||
DataStatisticsHandler dataStatisticsHandler) {
|
||||
GroupCourseBookingHandler groupCourseBookingHandler) {
|
||||
|
||||
return route()
|
||||
// ========== 诊断路由 ==========
|
||||
@@ -269,72 +261,20 @@ public class SystemRouter {
|
||||
// ===== 团课课程管理 =====
|
||||
.GET("/api/groupCourse/list", groupCourseHandler::getAllGroupCourse)
|
||||
.POST("/api/groupCourse/page", groupCourseHandler::getGroupCoursesByPage)
|
||||
|
||||
// ===== 团课类型管理 =====
|
||||
.GET("/api/groupCourse/types", groupCourseTypeHandler::getAllGroupCourseTypes)
|
||||
.GET("/api/groupCourse/types/search", groupCourseTypeHandler::searchGroupCourseTypes)
|
||||
.GET("/api/groupCourse/types/categories", groupCourseTypeHandler::getCategories)
|
||||
.GET("/api/groupCourse/types/category/{category}", groupCourseTypeHandler::getGroupCourseTypesByCategory)
|
||||
.GET("/api/groupCourse/types/{id}", groupCourseTypeHandler::getGroupCourseTypeById)
|
||||
.POST("/api/groupCourse/types", groupCourseTypeHandler::createGroupCourseType)
|
||||
.PUT("/api/groupCourse/types/{id}", groupCourseTypeHandler::updateGroupCourseType)
|
||||
.DELETE("/api/groupCourse/types/{id}", groupCourseTypeHandler::deleteGroupCourseType)
|
||||
|
||||
// ===== 团课标签管理 =====
|
||||
.GET("/api/groupCourse/labels", courseLabelHandler::getAllLabels)
|
||||
.GET("/api/groupCourse/labels/search", courseLabelHandler::searchLabels)
|
||||
.GET("/api/groupCourse/labels/{id}", courseLabelHandler::getLabelById)
|
||||
.GET("/api/groupCourse/types/{typeId}/labels", courseLabelHandler::getLabelsByTypeId)
|
||||
.POST("/api/groupCourse/labels", courseLabelHandler::createLabel)
|
||||
.PUT("/api/groupCourse/labels/{id}", courseLabelHandler::updateLabel)
|
||||
.DELETE("/api/groupCourse/labels/{id}", courseLabelHandler::deleteLabel)
|
||||
.POST("/api/groupCourse/types/{typeId}/labels", courseLabelHandler::addLabelsToType)
|
||||
.DELETE("/api/groupCourse/types/{typeId}/labels/{labelId}", courseLabelHandler::removeLabelFromType)
|
||||
.DELETE("/api/groupCourse/types/{typeId}/labels", courseLabelHandler::clearLabelsFromType)
|
||||
|
||||
// ===== 团课预约管理 =====
|
||||
.POST("/api/groupCourse/book", groupCourseBookingHandler::bookCourse)
|
||||
.POST("/api/groupCourse/booking/{bookingId}/cancel", groupCourseBookingHandler::cancelBooking)
|
||||
.GET("/api/groupCourse/bookings/member/{memberId}", groupCourseBookingHandler::getBookingsByMemberId)
|
||||
.GET("/api/groupCourse/bookings/course/{courseId}", groupCourseBookingHandler::getBookingsByCourseId)
|
||||
.GET("/api/groupCourse/bookings/{bookingId}", groupCourseBookingHandler::getBookingById)
|
||||
|
||||
// ===== 团课课程管理(需要放在具体路由之后)=====
|
||||
.GET("/api/groupCourse/{id}", groupCourseHandler::getGroupCourseById)
|
||||
.GET("/api/groupCourse/{id}/detail", groupCourseHandler::getGroupCourseDetailById)
|
||||
.POST("/api/groupCourse", groupCourseHandler::createGroupCourse)
|
||||
.PUT("/api/groupCourse/{id}", groupCourseHandler::updateGroupCourse)
|
||||
.DELETE("/api/groupCourse/{id}", groupCourseHandler::deleteGroupCourse)
|
||||
.POST("/api/groupCourse/{id}/cancel", groupCourseHandler::cancelGroupCourse)
|
||||
.POST("/api/groupCourse/{courseId}/signin", groupCourseHandler::signIn)
|
||||
|
||||
// ========= 签到模块路由 ==========
|
||||
// ===== 签到核心功能 =====
|
||||
.POST("/api/checkIn", checkInHandler::checkIn)
|
||||
.GET("/api/checkIn/qrcode", checkInHandler::getQRCode)
|
||||
// ===== 团课预约管理 =====
|
||||
.POST("/api/groupCourse/book", groupCourseBookingHandler::bookCourse)
|
||||
.POST("/api/groupCourse/booking/{bookingId}/cancel", groupCourseBookingHandler::cancelBooking)
|
||||
.GET("/api/groupCourse/bookings/member/{memberId}", groupCourseBookingHandler::getBookingsByMemberId)
|
||||
.GET("/api/groupCourse/bookings/{bookingId}", groupCourseBookingHandler::getBookingById)
|
||||
.GET("/api/groupCourse/bookings/course/{courseId}", groupCourseBookingHandler::getBookingsByCourseId)
|
||||
|
||||
// ===== 签到记录管理 =====
|
||||
.GET("/api/checkIn/records", checkInHandler::getSignInRecords)
|
||||
.GET("/api/checkIn/records/{id}", checkInHandler::getSignInRecordById)
|
||||
|
||||
// ===== 签到统计 =====
|
||||
.GET("/api/checkIn/statistics", checkInHandler::getSignInStatistics)
|
||||
.GET("/api/checkIn/daily-stats", checkInHandler::getDailySignInStats)
|
||||
|
||||
// ===== 签到数据导出 =====
|
||||
.GET("/api/checkIn/records/export", checkInHandler::exportSignInRecords)
|
||||
|
||||
// ========================================
|
||||
// ========== 数据统计模块路由 ============
|
||||
// ========================================
|
||||
|
||||
// ===== 数据统计核心功能 =====
|
||||
.GET("/api/datacount/summary", dataStatisticsHandler::getStatisticsSummary)
|
||||
.GET("/api/datacount/member", dataStatisticsHandler::getMemberStatistics)
|
||||
.GET("/api/datacount/booking", dataStatisticsHandler::getBookingStatistics)
|
||||
.GET("/api/datacount/signin", dataStatisticsHandler::getSignInStatistics)
|
||||
.GET("/api/datacount/history", dataStatisticsHandler::queryHistoricalStatistics)
|
||||
.GET("/api/datacount/export", dataStatisticsHandler::exportStatistics)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ spring:
|
||||
name: gym-manage-api
|
||||
main:
|
||||
allow-bean-definition-overriding: true
|
||||
web-application-type: reactive
|
||||
cache:
|
||||
type: none
|
||||
autoconfigure:
|
||||
|
||||
@@ -56,10 +56,6 @@
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-redis</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
-64
@@ -1,64 +0,0 @@
|
||||
package cn.novalon.gym.manage.common.constant;
|
||||
|
||||
/**
|
||||
* Redis 缓存 Key 常量类
|
||||
* 统一管理项目中所有 Redis 缓存的 key 前缀
|
||||
*
|
||||
* @author auto-generated
|
||||
* @date 2026-05-30
|
||||
*/
|
||||
public final class RedisKeyConstants {
|
||||
|
||||
private RedisKeyConstants() {
|
||||
}
|
||||
|
||||
// ==================== 会员模块 ====================
|
||||
|
||||
/**
|
||||
* 会员信息缓存
|
||||
* 格式:member:info:{memberId}
|
||||
*/
|
||||
public static final String MEMBER_INFO = "member:info:";
|
||||
|
||||
/**
|
||||
* 会员详情缓存
|
||||
* 格式:member:detail:{memberId}
|
||||
*/
|
||||
public static final String MEMBER_DETAIL = "member:detail:";
|
||||
|
||||
/**
|
||||
* 会员卡类型缓存
|
||||
* 格式:member:card:{memberCardId}
|
||||
*/
|
||||
public static final String MEMBER_CARD = "member:card:";
|
||||
|
||||
/**
|
||||
* 会员卡记录缓存(包含剩余次数/金额)
|
||||
* 格式:member:card:record:{recordId}
|
||||
*/
|
||||
public static final String MEMBER_CARD_RECORD = "member:card:record:";
|
||||
|
||||
/**
|
||||
* 会员退款申请缓存
|
||||
* 格式:member:refund:{recordId}
|
||||
*/
|
||||
public static final String MEMBER_REFUND = "member:refund:";
|
||||
|
||||
// ==================== 签到模块 ====================
|
||||
|
||||
/**
|
||||
* 用户当日二维码缓存
|
||||
* 格式:qrcode:user:daily:{userId}:{date}
|
||||
* 示例:qrcode:user:daily:1:2026-05-30
|
||||
*/
|
||||
public static final String QRCODE_USER_DAILY = "qrcode:user:daily:";
|
||||
|
||||
// ==================== 微信模块 ====================
|
||||
|
||||
/**
|
||||
* 微信 access_token 缓存
|
||||
* 格式:wechat:access_token:{appType}
|
||||
* appType: miniapp(小程序), mp(公众号)
|
||||
*/
|
||||
public static final String WECHAT_ACCESS_TOKEN = "wechat:access_token:";
|
||||
}
|
||||
-74
@@ -1,74 +0,0 @@
|
||||
-- ============================================
|
||||
-- 会员到店签到记录表
|
||||
-- 版本: V13
|
||||
-- 描述: 创建sign_in_record表,用于记录会员签到信息
|
||||
-- ============================================
|
||||
|
||||
-- 创建签到记录表
|
||||
CREATE TABLE IF NOT EXISTS sign_in_record (
|
||||
id BIGSERIAL PRIMARY KEY, -- 自增主键
|
||||
member_id BIGINT NOT NULL, -- 会员ID,关联member表
|
||||
member_card_id BIGINT, -- 签到时使用的会员卡ID
|
||||
sign_in_time TIMESTAMP NOT NULL, -- 签到入场时间
|
||||
sign_in_type VARCHAR(20) NOT NULL, -- 签到方式:QR_CODE-扫码签到,MANUAL-手动签到,FACE-人脸识别
|
||||
sign_in_status VARCHAR(20) NOT NULL DEFAULT 'SUCCESS', -- 签到状态:SUCCESS-成功,FAILED-失败
|
||||
verification_details TEXT, -- JSON格式,存储会员卡验证时的快照数据
|
||||
fail_reason VARCHAR(500), -- 失败时的具体原因文案
|
||||
operator_id BIGINT, -- 操作人ID(前台人员),自助签到时为NULL
|
||||
operator_name VARCHAR(100), -- 操作人姓名冗余
|
||||
device_info VARCHAR(200), -- 签到设备标识或型号
|
||||
ip_address VARCHAR(50), -- 客户端IP地址
|
||||
source VARCHAR(20) NOT NULL, -- 签到来源:MINI_PROGRAM-小程序扫码,PC_BACKEND-后台管理端
|
||||
is_delete BOOLEAN DEFAULT FALSE, -- 软删除标识:false-未删除,true-已删除
|
||||
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, -- 记录创建时间
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP -- 记录更新时间
|
||||
);
|
||||
|
||||
-- 创建索引
|
||||
-- 会员ID索引(加速按会员查询签到记录)
|
||||
CREATE INDEX IF NOT EXISTS idx_sign_in_record_member_id ON sign_in_record(member_id);
|
||||
|
||||
-- 签到时间索引(加速按时间范围查询)
|
||||
CREATE INDEX IF NOT EXISTS idx_sign_in_record_sign_in_time ON sign_in_record(sign_in_time);
|
||||
|
||||
-- 签到状态索引(加速按状态筛选)
|
||||
CREATE INDEX IF NOT EXISTS idx_sign_in_record_sign_in_status ON sign_in_record(sign_in_status);
|
||||
|
||||
-- 会员卡ID索引(加速按会员卡查询)
|
||||
CREATE INDEX IF NOT EXISTS idx_sign_in_record_member_card_id ON sign_in_record(member_card_id);
|
||||
|
||||
-- 操作人ID索引(加速按操作人查询)
|
||||
CREATE INDEX IF NOT EXISTS idx_sign_in_record_operator_id ON sign_in_record(operator_id);
|
||||
|
||||
-- 签到来源索引(加速按来源统计)
|
||||
CREATE INDEX IF NOT EXISTS idx_sign_in_record_source ON sign_in_record(source);
|
||||
|
||||
-- 软删除索引(加速查询未删除的记录)
|
||||
CREATE INDEX IF NOT EXISTS idx_sign_in_record_is_delete ON sign_in_record(is_delete);
|
||||
|
||||
-- 复合索引:会员ID + 签到时间(加速会员签到历史查询)
|
||||
CREATE INDEX IF NOT EXISTS idx_sign_in_record_member_time ON sign_in_record(member_id, sign_in_time);
|
||||
|
||||
-- 复合索引:签到状态 + 签到时间(加速统计数据查询)
|
||||
CREATE INDEX IF NOT EXISTS idx_sign_in_record_status_time ON sign_in_record(sign_in_status, sign_in_time);
|
||||
|
||||
-- 添加表注释
|
||||
COMMENT ON TABLE sign_in_record IS '会员到店签到记录表';
|
||||
|
||||
-- 添加字段注释
|
||||
COMMENT ON COLUMN sign_in_record.id IS '自增主键';
|
||||
COMMENT ON COLUMN sign_in_record.member_id IS '会员ID,关联member表';
|
||||
COMMENT ON COLUMN sign_in_record.member_card_id IS '签到时使用的会员卡ID';
|
||||
COMMENT ON COLUMN sign_in_record.sign_in_time IS '签到入场时间';
|
||||
COMMENT ON COLUMN sign_in_record.sign_in_type IS '签到方式:QR_CODE-扫码签到,MANUAL-手动签到,FACE-人脸识别';
|
||||
COMMENT ON COLUMN sign_in_record.sign_in_status IS '签到状态:SUCCESS-成功,FAILED-失败';
|
||||
COMMENT ON COLUMN sign_in_record.verification_details IS 'JSON格式,存储会员卡验证时的快照数据';
|
||||
COMMENT ON COLUMN sign_in_record.fail_reason IS '失败时的具体原因文案';
|
||||
COMMENT ON COLUMN sign_in_record.operator_id IS '操作人ID(前台人员),自助签到时为NULL';
|
||||
COMMENT ON COLUMN sign_in_record.operator_name IS '操作人姓名冗余';
|
||||
COMMENT ON COLUMN sign_in_record.device_info IS '签到设备标识或型号';
|
||||
COMMENT ON COLUMN sign_in_record.ip_address IS '客户端IP地址';
|
||||
COMMENT ON COLUMN sign_in_record.source IS '签到来源:MINI_PROGRAM-小程序扫码,PC_BACKEND-后台管理端';
|
||||
COMMENT ON COLUMN sign_in_record.is_delete IS '软删除标识:false-未删除,true-已删除';
|
||||
COMMENT ON COLUMN sign_in_record.created_at IS '记录创建时间';
|
||||
COMMENT ON COLUMN sign_in_record.updated_at IS '记录更新时间';
|
||||
+443
@@ -0,0 +1,443 @@
|
||||
-- V13: 数据统计模块测试数据
|
||||
-- 测试场景:
|
||||
-- 1. 会员数据统计(新增会员、活跃会员、性别分布、平均年龄、购卡人数)
|
||||
-- 2. 预约数据统计(预约总数、取消预约、实际到场、热门课程、满员课程)
|
||||
-- 3. 数据导出功能测试
|
||||
-- 日期范围:2026-06-01 至 2026-06-10
|
||||
|
||||
-- ============================================
|
||||
-- 1. 创建测试会员用户(分布在不同日期注册,不同性别,不同生日)
|
||||
-- ============================================
|
||||
|
||||
-- 2026-06-01 注册的会员(5人:3男2女)
|
||||
INSERT INTO member_user (member_no, nickname, phone, gender, birthday, is_deleted, created_at, updated_at, last_login_at) VALUES
|
||||
('MEM_STAT_001', '测试会员_男1', '13900001001', 1, '1995-03-15', false, '2026-06-01 09:00:00', '2026-06-01 09:00:00', '2026-06-05 20:00:00'),
|
||||
('MEM_STAT_002', '测试会员_男2', '13900001002', 1, '1990-07-20', false, '2026-06-01 10:30:00', '2026-06-01 10:30:00', '2026-06-06 18:00:00'),
|
||||
('MEM_STAT_003', '测试会员_男3', '13900001003', 1, '1988-11-08', false, '2026-06-01 14:00:00', '2026-06-01 14:00:00', '2026-06-04 19:30:00'),
|
||||
('MEM_STAT_004', '测试会员_女1', '13900001004', 2, '1998-01-25', false, '2026-06-01 16:00:00', '2026-06-01 16:00:00', '2026-06-06 08:00:00'),
|
||||
('MEM_STAT_005', '测试会员_女2', '13900001005', 2, '1992-05-10', false, '2026-06-01 18:00:00', '2026-06-01 18:00:00', '2026-06-03 21:00:00');
|
||||
|
||||
-- 2026-06-02 注册的会员(4人:2男2女)
|
||||
INSERT INTO member_user (member_no, nickname, phone, gender, birthday, is_deleted, created_at, updated_at, last_login_at) VALUES
|
||||
('MEM_STAT_006', '测试会员_男4', '13900001006', 1, '1985-09-12', false, '2026-06-02 09:00:00', '2026-06-02 09:00:00', '2026-06-06 10:00:00'),
|
||||
('MEM_STAT_007', '测试会员_男5', '13900001007', 1, '1996-04-18', false, '2026-06-02 11:00:00', '2026-06-02 11:00:00', '2026-06-05 15:00:00'),
|
||||
('MEM_STAT_008', '测试会员_女3', '13900001008', 2, '1993-08-30', false, '2026-06-02 13:00:00', '2026-06-02 13:00:00', '2026-06-06 12:00:00'),
|
||||
('MEM_STAT_009', '测试会员_女4', '13900001009', 2, '1991-12-05', false, '2026-06-02 15:00:00', '2026-06-02 15:00:00', '2026-06-04 14:00:00');
|
||||
|
||||
-- 2026-06-03 注册的会员(3人:1男2女)
|
||||
INSERT INTO member_user (member_no, nickname, phone, gender, birthday, is_deleted, created_at, updated_at, last_login_at) VALUES
|
||||
('MEM_STAT_010', '测试会员_男6', '13900001010', 1, '1989-06-22', false, '2026-06-03 10:00:00', '2026-06-03 10:00:00', '2026-06-06 09:00:00'),
|
||||
('MEM_STAT_011', '测试会员_女5', '13900001011', 2, '1997-02-14', false, '2026-06-03 14:00:00', '2026-06-03 14:00:00', '2026-06-05 16:00:00'),
|
||||
('MEM_STAT_012', '测试会员_女6', '13900001012', 2, '1994-10-28', false, '2026-06-03 16:00:00', '2026-06-03 16:00:00', '2026-06-06 11:00:00');
|
||||
|
||||
-- 2026-06-04 注册的会员(2人:1男1女)
|
||||
INSERT INTO member_user (member_no, nickname, phone, gender, birthday, is_deleted, created_at, updated_at, last_login_at) VALUES
|
||||
('MEM_STAT_013', '测试会员_男7', '13900001013', 1, '1987-01-03', false, '2026-06-04 09:00:00', '2026-06-04 09:00:00', '2026-06-06 13:00:00'),
|
||||
('MEM_STAT_014', '测试会员_女7', '13900001014', 2, '1999-07-17', false, '2026-06-04 11:00:00', '2026-06-04 11:00:00', '2026-06-05 17:00:00');
|
||||
|
||||
-- 2026-06-05 注册的会员(3人:2男1女)
|
||||
INSERT INTO member_user (member_no, nickname, phone, gender, birthday, is_deleted, created_at, updated_at, last_login_at) VALUES
|
||||
('MEM_STAT_015', '测试会员_男8', '13900001015', 1, '1990-03-09', false, '2026-06-05 10:00:00', '2026-06-05 10:00:00', '2026-06-06 14:00:00'),
|
||||
('MEM_STAT_016', '测试会员_男9', '13900001016', 1, '1986-11-21', false, '2026-06-05 13:00:00', '2026-06-05 13:00:00', '2026-06-06 15:00:00'),
|
||||
('MEM_STAT_017', '测试会员_女8', '13900001017', 2, '1995-09-06', false, '2026-06-05 15:00:00', '2026-06-05 15:00:00', '2026-06-05 18:00:00');
|
||||
|
||||
-- 2026-06-06 注册的会员(2人:1男1女)
|
||||
INSERT INTO member_user (member_no, nickname, phone, gender, birthday, is_deleted, created_at, updated_at, last_login_at) VALUES
|
||||
('MEM_STAT_018', '测试会员_男10', '13900001018', 1, '1993-05-14', false, '2026-06-06 09:00:00', '2026-06-06 09:00:00', '2026-06-06 16:00:00'),
|
||||
('MEM_STAT_019', '测试会员_女9', '13900001019', 2, '1991-08-19', false, '2026-06-06 11:00:00', '2026-06-06 11:00:00', '2026-06-06 17:00:00');
|
||||
|
||||
-- 已删除的会员(1人,用于测试软删除过滤)
|
||||
INSERT INTO member_user (member_no, nickname, phone, gender, birthday, is_deleted, created_at, updated_at, last_login_at) VALUES
|
||||
('MEM_STAT_DEL', '已删除会员', '13900001999', 1, '1980-01-01', true, '2026-06-01 08:00:00', '2026-06-01 08:00:00', '2026-06-01 08:00:00');
|
||||
|
||||
-- ============================================
|
||||
-- 2. 创建会员卡类型(如果不存在)
|
||||
-- ============================================
|
||||
|
||||
INSERT INTO member_card (member_card_name, member_card_type, member_card_price, member_card_validity_days, member_card_total_times, member_card_amount, member_card_status, extra_config, created_at, updated_at)
|
||||
SELECT '月卡', 'TIME_CARD', 299.00, 30, NULL, NULL, 1, '{}', '2026-01-01 00:00:00', '2026-01-01 00:00:00'
|
||||
WHERE NOT EXISTS (SELECT 1 FROM member_card WHERE member_card_name = '月卡');
|
||||
|
||||
INSERT INTO member_card (member_card_name, member_card_type, member_card_price, member_card_validity_days, member_card_total_times, member_card_amount, member_card_status, extra_config, created_at, updated_at)
|
||||
SELECT '季卡', 'TIME_CARD', 799.00, 90, NULL, NULL, 1, '{}', '2026-01-01 00:00:00', '2026-01-01 00:00:00'
|
||||
WHERE NOT EXISTS (SELECT 1 FROM member_card WHERE member_card_name = '季卡');
|
||||
|
||||
INSERT INTO member_card (member_card_name, member_card_type, member_card_price, member_card_validity_days, member_card_total_times, member_card_amount, member_card_status, extra_config, created_at, updated_at)
|
||||
SELECT '次卡20次', 'COUNT_CARD', 599.00, NULL, 20, NULL, 1, '{}', '2026-01-01 00:00:00', '2026-01-01 00:00:00'
|
||||
WHERE NOT EXISTS (SELECT 1 FROM member_card WHERE member_card_name = '次卡20次');
|
||||
|
||||
-- ============================================
|
||||
-- 3. 为所有测试会员创建会员卡记录
|
||||
-- ============================================
|
||||
|
||||
-- MEM_STAT_001 至 MEM_STAT_019 全部创建会员卡记录
|
||||
-- 使用月卡类型,有效期至 2026-12-31
|
||||
INSERT INTO member_card_record (member_id, member_card_id, status, remaining_times, remaining_amount, expire_time, purchase_time, version, card_composition, created_at, updated_at)
|
||||
SELECT
|
||||
m.id,
|
||||
(SELECT id FROM member_card WHERE member_card_name = '月卡'),
|
||||
'ACTIVE',
|
||||
0,
|
||||
0.00,
|
||||
'2026-12-31 23:59:59',
|
||||
m.created_at,
|
||||
0,
|
||||
'{}',
|
||||
m.created_at,
|
||||
m.created_at
|
||||
FROM member_user m
|
||||
WHERE m.member_no LIKE 'MEM_STAT_%' AND m.member_no != 'MEM_STAT_DEL';
|
||||
|
||||
-- ============================================
|
||||
-- 4. 创建团课课程(2026-06-01 至 2026-06-10)
|
||||
-- ============================================
|
||||
|
||||
-- 2026-06-01 的课程
|
||||
INSERT INTO group_course (course_name, coach_id, course_type, start_time, end_time, max_members, current_members, status, location, description, point_card_amount, stored_value_amount, create_by, created_at, updated_at) VALUES
|
||||
('晨间瑜伽', 101, 1, '2026-06-01 07:00:00', '2026-06-01 08:00:00', 15, 12, '0', '瑜伽教室A', '清晨唤醒瑜伽', 1, 30.00, 'admin', '2026-05-28 10:00:00', '2026-05-28 10:00:00'),
|
||||
('燃脂单车', 102, 2, '2026-06-01 18:00:00', '2026-06-01 19:00:00', 25, 25, '0', '单车房', '高强度燃脂骑行', 1, 35.00, 'admin', '2026-05-28 10:00:00', '2026-05-28 10:00:00'),
|
||||
('普拉提核心', 103, 1, '2026-06-01 19:30:00', '2026-06-01 20:30:00', 12, 8, '0', '普拉提教室', '核心力量训练', 1, 40.00, 'admin', '2026-05-28 10:00:00', '2026-05-28 10:00:00');
|
||||
|
||||
-- 2026-06-02 的课程
|
||||
INSERT INTO group_course (course_name, coach_id, course_type, start_time, end_time, max_members, current_members, status, location, description, point_card_amount, stored_value_amount, create_by, created_at, updated_at) VALUES
|
||||
('流瑜伽', 101, 1, '2026-06-02 09:00:00', '2026-06-02 10:30:00', 15, 10, '0', '瑜伽教室A', '流畅体式连接', 1, 30.00, 'admin', '2026-05-28 10:00:00', '2026-05-28 10:00:00'),
|
||||
('搏击操', 102, 2, '2026-06-02 18:30:00', '2026-06-02 19:30:00', 20, 18, '0', '综合训练区', '有氧搏击训练', 1, 35.00, 'admin', '2026-05-28 10:00:00', '2026-05-28 10:00:00'),
|
||||
('冥想放松', 101, 1, '2026-06-02 20:00:00', '2026-06-02 21:00:00', 20, 5, '0', '冥想室', '深度放松冥想', 1, 25.00, 'admin', '2026-05-28 10:00:00', '2026-05-28 10:00:00');
|
||||
|
||||
-- 2026-06-03 的课程
|
||||
INSERT INTO group_course (course_name, coach_id, course_type, start_time, end_time, max_members, current_members, status, location, description, point_card_amount, stored_value_amount, create_by, created_at, updated_at) VALUES
|
||||
('哈他瑜伽', 101, 1, '2026-06-03 10:00:00', '2026-06-03 11:30:00', 12, 12, '0', '瑜伽教室B', '基础哈他瑜伽', 1, 30.00, 'admin', '2026-05-28 10:00:00', '2026-05-28 10:00:00'),
|
||||
('动感单车', 102, 2, '2026-06-03 19:00:00', '2026-06-03 20:00:00', 25, 20, '0', '单车房', '音乐节奏骑行', 1, 35.00, 'admin', '2026-05-28 10:00:00', '2026-05-28 10:00:00'),
|
||||
('拉伸放松', 103, 1, '2026-06-03 20:30:00', '2026-06-03 21:30:00', 15, 6, '0', '综合训练区', '全身拉伸放松', 1, 25.00, 'admin', '2026-05-28 10:00:00', '2026-05-28 10:00:00');
|
||||
|
||||
-- 2026-06-04 的课程
|
||||
INSERT INTO group_course (course_name, coach_id, course_type, start_time, end_time, max_members, current_members, status, location, description, point_card_amount, stored_value_amount, create_by, created_at, updated_at) VALUES
|
||||
('力量瑜伽', 101, 1, '2026-06-04 08:00:00', '2026-06-04 09:30:00', 15, 14, '0', '瑜伽教室A', '力量型瑜伽', 1, 35.00, 'admin', '2026-05-28 10:00:00', '2026-05-28 10:00:00'),
|
||||
('HIIT训练', 102, 2, '2026-06-04 18:00:00', '2026-06-04 19:00:00', 20, 20, '0', '综合训练区', '高强度间歇训练', 1, 40.00, 'admin', '2026-05-28 10:00:00', '2026-05-28 10:00:00'),
|
||||
('阴瑜伽', 101, 1, '2026-06-04 20:00:00', '2026-06-04 21:30:00', 12, 9, '0', '瑜伽教室B', '静态阴瑜伽', 1, 30.00, 'admin', '2026-05-28 10:00:00', '2026-05-28 10:00:00');
|
||||
|
||||
-- 2026-06-05 的课程
|
||||
INSERT INTO group_course (course_name, coach_id, course_type, start_time, end_time, max_members, current_members, status, location, description, point_card_amount, stored_value_amount, create_by, created_at, updated_at) VALUES
|
||||
('晨间冥想', 101, 1, '2026-06-05 07:00:00', '2026-06-05 08:00:00', 20, 15, '0', '冥想室', '清晨冥想', 1, 25.00, 'admin', '2026-05-28 10:00:00', '2026-05-28 10:00:00'),
|
||||
('尊巴舞', 103, 2, '2026-06-05 18:30:00', '2026-06-05 19:30:00', 25, 22, '0', '舞蹈室', '拉丁风格舞蹈', 1, 35.00, 'admin', '2026-05-28 10:00:00', '2026-05-28 10:00:00'),
|
||||
('空中瑜伽', 101, 1, '2026-06-05 20:00:00', '2026-06-05 21:30:00', 10, 10, '0', '瑜伽教室A', '空中瑜伽体验', 1, 45.00, 'admin', '2026-05-28 10:00:00', '2026-05-28 10:00:00');
|
||||
|
||||
-- 2026-06-06 的课程
|
||||
INSERT INTO group_course (course_name, coach_id, course_type, start_time, end_time, max_members, current_members, status, location, description, point_card_amount, stored_value_amount, create_by, created_at, updated_at) VALUES
|
||||
('拜日式瑜伽', 101, 1, '2026-06-06 07:30:00', '2026-06-06 08:30:00', 15, 11, '0', '瑜伽教室A', '传统拜日式', 1, 30.00, 'admin', '2026-05-28 10:00:00', '2026-05-28 10:00:00'),
|
||||
('杠铃操', 102, 2, '2026-06-06 18:00:00', '2026-06-06 19:00:00', 20, 16, '0', '力量区', '全身杠铃训练', 1, 35.00, 'admin', '2026-05-28 10:00:00', '2026-05-28 10:00:00'),
|
||||
('修复瑜伽', 101, 1, '2026-06-06 20:00:00', '2026-06-06 21:00:00', 12, 7, '0', '瑜伽教室B', '修复性瑜伽', 1, 30.00, 'admin', '2026-05-28 10:00:00', '2026-05-28 10:00:00');
|
||||
|
||||
-- ============================================
|
||||
-- 5. 团课预约记录(测试预约统计)
|
||||
-- ============================================
|
||||
|
||||
-- 2026-06-01 的预约记录
|
||||
-- 晨间瑜伽:5人预约(4人出席,1人取消)
|
||||
INSERT INTO group_course_booking (course_id, member_id, member_card_id, booking_time, status, course_name, course_start_time, course_end_time, location, created_at, updated_at) VALUES
|
||||
((SELECT id FROM group_course WHERE course_name = '晨间瑜伽' AND DATE(start_time) = '2026-06-01'), (SELECT id FROM member_user WHERE member_no = 'MEM_STAT_001'), (SELECT id FROM member_card_record WHERE member_id = (SELECT id FROM member_user WHERE member_no = 'MEM_STAT_001')), '2026-06-01 06:00:00', '2', '晨间瑜伽', '2026-06-01 07:00:00', '2026-06-01 08:00:00', '瑜伽教室A', '2026-06-01 06:00:00', '2026-06-01 06:00:00'),
|
||||
((SELECT id FROM group_course WHERE course_name = '晨间瑜伽' AND DATE(start_time) = '2026-06-01'), (SELECT id FROM member_user WHERE member_no = 'MEM_STAT_002'), (SELECT id FROM member_card_record WHERE member_id = (SELECT id FROM member_user WHERE member_no = 'MEM_STAT_002')), '2026-06-01 06:30:00', '2', '晨间瑜伽', '2026-06-01 07:00:00', '2026-06-01 08:00:00', '瑜伽教室A', '2026-06-01 06:30:00', '2026-06-01 06:30:00'),
|
||||
((SELECT id FROM group_course WHERE course_name = '晨间瑜伽' AND DATE(start_time) = '2026-06-01'), (SELECT id FROM member_user WHERE member_no = 'MEM_STAT_003'), (SELECT id FROM member_card_record WHERE member_id = (SELECT id FROM member_user WHERE member_no = 'MEM_STAT_003')), '2026-06-01 06:45:00', '2', '晨间瑜伽', '2026-06-01 07:00:00', '2026-06-01 08:00:00', '瑜伽教室A', '2026-06-01 06:45:00', '2026-06-01 06:45:00'),
|
||||
((SELECT id FROM group_course WHERE course_name = '晨间瑜伽' AND DATE(start_time) = '2026-06-01'), (SELECT id FROM member_user WHERE member_no = 'MEM_STAT_004'), (SELECT id FROM member_card_record WHERE member_id = (SELECT id FROM member_user WHERE member_no = 'MEM_STAT_004')), '2026-06-01 06:15:00', '1', '晨间瑜伽', '2026-06-01 07:00:00', '2026-06-01 08:00:00', '瑜伽教室A', '2026-06-01 06:15:00', '2026-06-01 06:15:00'),
|
||||
((SELECT id FROM group_course WHERE course_name = '晨间瑜伽' AND DATE(start_time) = '2026-06-01'), (SELECT id FROM member_user WHERE member_no = 'MEM_STAT_005'), (SELECT id FROM member_card_record WHERE member_id = (SELECT id FROM member_user WHERE member_no = 'MEM_STAT_005')), '2026-06-01 06:20:00', '2', '晨间瑜伽', '2026-06-01 07:00:00', '2026-06-01 08:00:00', '瑜伽教室A', '2026-06-01 06:20:00', '2026-06-01 06:20:00');
|
||||
|
||||
-- 燃脂单车:19人预约(15人出席,4人取消)- 满员课程
|
||||
INSERT INTO group_course_booking (course_id, member_id, member_card_id, booking_time, status, course_name, course_start_time, course_end_time, location, created_at, updated_at)
|
||||
SELECT
|
||||
(SELECT id FROM group_course WHERE course_name = '燃脂单车' AND DATE(start_time) = '2026-06-01'),
|
||||
(SELECT id FROM member_user WHERE member_no = 'MEM_STAT_' || LPAD(i::text, 3, '0')),
|
||||
(SELECT id FROM member_card_record WHERE member_id = (SELECT id FROM member_user WHERE member_no = 'MEM_STAT_' || LPAD(i::text, 3, '0'))),
|
||||
'2026-06-01 17:00:00',
|
||||
CASE WHEN i <= 15 THEN '2' ELSE '1' END,
|
||||
'燃脂单车',
|
||||
'2026-06-01 18:00:00',
|
||||
'2026-06-01 19:00:00',
|
||||
'单车房',
|
||||
'2026-06-01 17:00:00',
|
||||
'2026-06-01 17:00:00'
|
||||
FROM generate_series(1, 19) AS i;
|
||||
|
||||
-- 普拉提核心:8人预约(7人出席,1人取消)
|
||||
INSERT INTO group_course_booking (course_id, member_id, member_card_id, booking_time, status, course_name, course_start_time, course_end_time, location, created_at, updated_at) VALUES
|
||||
((SELECT id FROM group_course WHERE course_name = '普拉提核心' AND DATE(start_time) = '2026-06-01'), (SELECT id FROM member_user WHERE member_no = 'MEM_STAT_001'), (SELECT id FROM member_card_record WHERE member_id = (SELECT id FROM member_user WHERE member_no = 'MEM_STAT_001')), '2026-06-01 19:00:00', '2', '普拉提核心', '2026-06-01 19:30:00', '2026-06-01 20:30:00', '普拉提教室', '2026-06-01 19:00:00', '2026-06-01 19:00:00'),
|
||||
((SELECT id FROM group_course WHERE course_name = '普拉提核心' AND DATE(start_time) = '2026-06-01'), (SELECT id FROM member_user WHERE member_no = 'MEM_STAT_003'), (SELECT id FROM member_card_record WHERE member_id = (SELECT id FROM member_user WHERE member_no = 'MEM_STAT_003')), '2026-06-01 19:10:00', '2', '普拉提核心', '2026-06-01 19:30:00', '2026-06-01 20:30:00', '普拉提教室', '2026-06-01 19:10:00', '2026-06-01 19:10:00'),
|
||||
((SELECT id FROM group_course WHERE course_name = '普拉提核心' AND DATE(start_time) = '2026-06-01'), (SELECT id FROM member_user WHERE member_no = 'MEM_STAT_005'), (SELECT id FROM member_card_record WHERE member_id = (SELECT id FROM member_user WHERE member_no = 'MEM_STAT_005')), '2026-06-01 19:05:00', '2', '普拉提核心', '2026-06-01 19:30:00', '2026-06-01 20:30:00', '普拉提教室', '2026-06-01 19:05:00', '2026-06-01 19:05:00'),
|
||||
((SELECT id FROM group_course WHERE course_name = '普拉提核心' AND DATE(start_time) = '2026-06-01'), (SELECT id FROM member_user WHERE member_no = 'MEM_STAT_007'), (SELECT id FROM member_card_record WHERE member_id = (SELECT id FROM member_user WHERE member_no = 'MEM_STAT_007')), '2026-06-01 19:15:00', '2', '普拉提核心', '2026-06-01 19:30:00', '2026-06-01 20:30:00', '普拉提教室', '2026-06-01 19:15:00', '2026-06-01 19:15:00'),
|
||||
((SELECT id FROM group_course WHERE course_name = '普拉提核心' AND DATE(start_time) = '2026-06-01'), (SELECT id FROM member_user WHERE member_no = 'MEM_STAT_009'), (SELECT id FROM member_card_record WHERE member_id = (SELECT id FROM member_user WHERE member_no = 'MEM_STAT_009')), '2026-06-01 19:20:00', '1', '普拉提核心', '2026-06-01 19:30:00', '2026-06-01 20:30:00', '普拉提教室', '2026-06-01 19:20:00', '2026-06-01 19:20:00'),
|
||||
((SELECT id FROM group_course WHERE course_name = '普拉提核心' AND DATE(start_time) = '2026-06-01'), (SELECT id FROM member_user WHERE member_no = 'MEM_STAT_011'), (SELECT id FROM member_card_record WHERE member_id = (SELECT id FROM member_user WHERE member_no = 'MEM_STAT_011')), '2026-06-01 19:25:00', '2', '普拉提核心', '2026-06-01 19:30:00', '2026-06-01 20:30:00', '普拉提教室', '2026-06-01 19:25:00', '2026-06-01 19:25:00'),
|
||||
((SELECT id FROM group_course WHERE course_name = '普拉提核心' AND DATE(start_time) = '2026-06-01'), (SELECT id FROM member_user WHERE member_no = 'MEM_STAT_013'), (SELECT id FROM member_card_record WHERE member_id = (SELECT id FROM member_user WHERE member_no = 'MEM_STAT_013')), '2026-06-01 19:30:00', '2', '普拉提核心', '2026-06-01 19:30:00', '2026-06-01 20:30:00', '普拉提教室', '2026-06-01 19:30:00', '2026-06-01 19:30:00'),
|
||||
((SELECT id FROM group_course WHERE course_name = '普拉提核心' AND DATE(start_time) = '2026-06-01'), (SELECT id FROM member_user WHERE member_no = 'MEM_STAT_015'), (SELECT id FROM member_card_record WHERE member_id = (SELECT id FROM member_user WHERE member_no = 'MEM_STAT_015')), '2026-06-01 19:35:00', '2', '普拉提核心', '2026-06-01 19:30:00', '2026-06-01 20:30:00', '普拉提教室', '2026-06-01 19:35:00', '2026-06-01 19:35:00');
|
||||
|
||||
-- 2026-06-02 的预约记录
|
||||
-- 流瑜伽:10人预约(9人出席,1人取消)
|
||||
INSERT INTO group_course_booking (course_id, member_id, member_card_id, booking_time, status, course_name, course_start_time, course_end_time, location, created_at, updated_at)
|
||||
SELECT
|
||||
(SELECT id FROM group_course WHERE course_name = '流瑜伽' AND DATE(start_time) = '2026-06-02'),
|
||||
(SELECT id FROM member_user WHERE member_no = 'MEM_STAT_' || LPAD(i::text, 3, '0')),
|
||||
(SELECT id FROM member_card_record WHERE member_id = (SELECT id FROM member_user WHERE member_no = 'MEM_STAT_' || LPAD(i::text, 3, '0'))),
|
||||
'2026-06-02 08:00:00',
|
||||
CASE WHEN i <= 9 THEN '2' ELSE '1' END,
|
||||
'流瑜伽',
|
||||
'2026-06-02 09:00:00',
|
||||
'2026-06-02 10:30:00',
|
||||
'瑜伽教室A',
|
||||
'2026-06-02 08:00:00',
|
||||
'2026-06-02 08:00:00'
|
||||
FROM generate_series(1, 10) AS i;
|
||||
|
||||
-- 搏击操:18人预约(15人出席,3人取消)
|
||||
INSERT INTO group_course_booking (course_id, member_id, member_card_id, booking_time, status, course_name, course_start_time, course_end_time, location, created_at, updated_at)
|
||||
SELECT
|
||||
(SELECT id FROM group_course WHERE course_name = '搏击操' AND DATE(start_time) = '2026-06-02'),
|
||||
(SELECT id FROM member_user WHERE member_no = 'MEM_STAT_' || LPAD(i::text, 3, '0')),
|
||||
(SELECT id FROM member_card_record WHERE member_id = (SELECT id FROM member_user WHERE member_no = 'MEM_STAT_' || LPAD(i::text, 3, '0'))),
|
||||
'2026-06-02 17:30:00',
|
||||
CASE WHEN i <= 15 THEN '2' ELSE '1' END,
|
||||
'搏击操',
|
||||
'2026-06-02 18:30:00',
|
||||
'2026-06-02 19:30:00',
|
||||
'综合训练区',
|
||||
'2026-06-02 17:30:00',
|
||||
'2026-06-02 17:30:00'
|
||||
FROM generate_series(1, 18) AS i;
|
||||
|
||||
-- 冥想放松:5人预约(4人出席,1人取消)
|
||||
INSERT INTO group_course_booking (course_id, member_id, member_card_id, booking_time, status, course_name, course_start_time, course_end_time, location, created_at, updated_at) VALUES
|
||||
((SELECT id FROM group_course WHERE course_name = '冥想放松' AND DATE(start_time) = '2026-06-02'), (SELECT id FROM member_user WHERE member_no = 'MEM_STAT_001'), (SELECT id FROM member_card_record WHERE member_id = (SELECT id FROM member_user WHERE member_no = 'MEM_STAT_001')), '2026-06-02 19:30:00', '2', '冥想放松', '2026-06-02 20:00:00', '2026-06-02 21:00:00', '冥想室', '2026-06-02 19:30:00', '2026-06-02 19:30:00'),
|
||||
((SELECT id FROM group_course WHERE course_name = '冥想放松' AND DATE(start_time) = '2026-06-02'), (SELECT id FROM member_user WHERE member_no = 'MEM_STAT_004'), (SELECT id FROM member_card_record WHERE member_id = (SELECT id FROM member_user WHERE member_no = 'MEM_STAT_004')), '2026-06-02 19:35:00', '2', '冥想放松', '2026-06-02 20:00:00', '2026-06-02 21:00:00', '冥想室', '2026-06-02 19:35:00', '2026-06-02 19:35:00'),
|
||||
((SELECT id FROM group_course WHERE course_name = '冥想放松' AND DATE(start_time) = '2026-06-02'), (SELECT id FROM member_user WHERE member_no = 'MEM_STAT_007'), (SELECT id FROM member_card_record WHERE member_id = (SELECT id FROM member_user WHERE member_no = 'MEM_STAT_007')), '2026-06-02 19:40:00', '2', '冥想放松', '2026-06-02 20:00:00', '2026-06-02 21:00:00', '冥想室', '2026-06-02 19:40:00', '2026-06-02 19:40:00'),
|
||||
((SELECT id FROM group_course WHERE course_name = '冥想放松' AND DATE(start_time) = '2026-06-02'), (SELECT id FROM member_user WHERE member_no = 'MEM_STAT_010'), (SELECT id FROM member_card_record WHERE member_id = (SELECT id FROM member_user WHERE member_no = 'MEM_STAT_010')), '2026-06-02 19:45:00', '1', '冥想放松', '2026-06-02 20:00:00', '2026-06-02 21:00:00', '冥想室', '2026-06-02 19:45:00', '2026-06-02 19:45:00'),
|
||||
((SELECT id FROM group_course WHERE course_name = '冥想放松' AND DATE(start_time) = '2026-06-02'), (SELECT id FROM member_user WHERE member_no = 'MEM_STAT_013'), (SELECT id FROM member_card_record WHERE member_id = (SELECT id FROM member_user WHERE member_no = 'MEM_STAT_013')), '2026-06-02 19:50:00', '2', '冥想放松', '2026-06-02 20:00:00', '2026-06-02 21:00:00', '冥想室', '2026-06-02 19:50:00', '2026-06-02 19:50:00');
|
||||
|
||||
-- 2026-06-03 的预约记录
|
||||
-- 哈他瑜伽:12人预约(10人出席,2人取消)- 满员
|
||||
INSERT INTO group_course_booking (course_id, member_id, member_card_id, booking_time, status, course_name, course_start_time, course_end_time, location, created_at, updated_at)
|
||||
SELECT
|
||||
(SELECT id FROM group_course WHERE course_name = '哈他瑜伽' AND DATE(start_time) = '2026-06-03'),
|
||||
(SELECT id FROM member_user WHERE member_no = 'MEM_STAT_' || LPAD(i::text, 3, '0')),
|
||||
(SELECT id FROM member_card_record WHERE member_id = (SELECT id FROM member_user WHERE member_no = 'MEM_STAT_' || LPAD(i::text, 3, '0'))),
|
||||
'2026-06-03 09:00:00',
|
||||
CASE WHEN i <= 10 THEN '2' ELSE '1' END,
|
||||
'哈他瑜伽',
|
||||
'2026-06-03 10:00:00',
|
||||
'2026-06-03 11:30:00',
|
||||
'瑜伽教室B',
|
||||
'2026-06-03 09:00:00',
|
||||
'2026-06-03 09:00:00'
|
||||
FROM generate_series(1, 12) AS i;
|
||||
|
||||
-- 动感单车:19人预约(16人出席,3人取消)
|
||||
INSERT INTO group_course_booking (course_id, member_id, member_card_id, booking_time, status, course_name, course_start_time, course_end_time, location, created_at, updated_at)
|
||||
SELECT
|
||||
(SELECT id FROM group_course WHERE course_name = '动感单车' AND DATE(start_time) = '2026-06-03'),
|
||||
(SELECT id FROM member_user WHERE member_no = 'MEM_STAT_' || LPAD(i::text, 3, '0')),
|
||||
(SELECT id FROM member_card_record WHERE member_id = (SELECT id FROM member_user WHERE member_no = 'MEM_STAT_' || LPAD(i::text, 3, '0'))),
|
||||
'2026-06-03 18:00:00',
|
||||
CASE WHEN i <= 16 THEN '2' ELSE '1' END,
|
||||
'动感单车',
|
||||
'2026-06-03 19:00:00',
|
||||
'2026-06-03 20:00:00',
|
||||
'单车房',
|
||||
'2026-06-03 18:00:00',
|
||||
'2026-06-03 18:00:00'
|
||||
FROM generate_series(1, 19) AS i;
|
||||
|
||||
-- 拉伸放松:6人预约(5人出席,1人取消)
|
||||
INSERT INTO group_course_booking (course_id, member_id, member_card_id, booking_time, status, course_name, course_start_time, course_end_time, location, created_at, updated_at) VALUES
|
||||
((SELECT id FROM group_course WHERE course_name = '拉伸放松' AND DATE(start_time) = '2026-06-03'), (SELECT id FROM member_user WHERE member_no = 'MEM_STAT_002'), (SELECT id FROM member_card_record WHERE member_id = (SELECT id FROM member_user WHERE member_no = 'MEM_STAT_002')), '2026-06-03 20:00:00', '2', '拉伸放松', '2026-06-03 20:30:00', '2026-06-03 21:30:00', '综合训练区', '2026-06-03 20:00:00', '2026-06-03 20:00:00'),
|
||||
((SELECT id FROM group_course WHERE course_name = '拉伸放松' AND DATE(start_time) = '2026-06-03'), (SELECT id FROM member_user WHERE member_no = 'MEM_STAT_005'), (SELECT id FROM member_card_record WHERE member_id = (SELECT id FROM member_user WHERE member_no = 'MEM_STAT_005')), '2026-06-03 20:05:00', '2', '拉伸放松', '2026-06-03 20:30:00', '2026-06-03 21:30:00', '综合训练区', '2026-06-03 20:05:00', '2026-06-03 20:05:00'),
|
||||
((SELECT id FROM group_course WHERE course_name = '拉伸放松' AND DATE(start_time) = '2026-06-03'), (SELECT id FROM member_user WHERE member_no = 'MEM_STAT_008'), (SELECT id FROM member_card_record WHERE member_id = (SELECT id FROM member_user WHERE member_no = 'MEM_STAT_008')), '2026-06-03 20:10:00', '2', '拉伸放松', '2026-06-03 20:30:00', '2026-06-03 21:30:00', '综合训练区', '2026-06-03 20:10:00', '2026-06-03 20:10:00'),
|
||||
((SELECT id FROM group_course WHERE course_name = '拉伸放松' AND DATE(start_time) = '2026-06-03'), (SELECT id FROM member_user WHERE member_no = 'MEM_STAT_011'), (SELECT id FROM member_card_record WHERE member_id = (SELECT id FROM member_user WHERE member_no = 'MEM_STAT_011')), '2026-06-03 20:15:00', '1', '拉伸放松', '2026-06-03 20:30:00', '2026-06-03 21:30:00', '综合训练区', '2026-06-03 20:15:00', '2026-06-03 20:15:00'),
|
||||
((SELECT id FROM group_course WHERE course_name = '拉伸放松' AND DATE(start_time) = '2026-06-03'), (SELECT id FROM member_user WHERE member_no = 'MEM_STAT_014'), (SELECT id FROM member_card_record WHERE member_id = (SELECT id FROM member_user WHERE member_no = 'MEM_STAT_014')), '2026-06-03 20:20:00', '2', '拉伸放松', '2026-06-03 20:30:00', '2026-06-03 21:30:00', '综合训练区', '2026-06-03 20:20:00', '2026-06-03 20:20:00'),
|
||||
((SELECT id FROM group_course WHERE course_name = '拉伸放松' AND DATE(start_time) = '2026-06-03'), (SELECT id FROM member_user WHERE member_no = 'MEM_STAT_017'), (SELECT id FROM member_card_record WHERE member_id = (SELECT id FROM member_user WHERE member_no = 'MEM_STAT_017')), '2026-06-03 20:25:00', '2', '拉伸放松', '2026-06-03 20:30:00', '2026-06-03 21:30:00', '综合训练区', '2026-06-03 20:25:00', '2026-06-03 20:25:00');
|
||||
|
||||
-- 2026-06-04 的预约记录
|
||||
-- 力量瑜伽:14人预约(12人出席,2人取消)
|
||||
INSERT INTO group_course_booking (course_id, member_id, member_card_id, booking_time, status, course_name, course_start_time, course_end_time, location, created_at, updated_at)
|
||||
SELECT
|
||||
(SELECT id FROM group_course WHERE course_name = '力量瑜伽' AND DATE(start_time) = '2026-06-04'),
|
||||
(SELECT id FROM member_user WHERE member_no = 'MEM_STAT_' || LPAD(i::text, 3, '0')),
|
||||
(SELECT id FROM member_card_record WHERE member_id = (SELECT id FROM member_user WHERE member_no = 'MEM_STAT_' || LPAD(i::text, 3, '0'))),
|
||||
'2026-06-04 07:00:00',
|
||||
CASE WHEN i <= 12 THEN '2' ELSE '1' END,
|
||||
'力量瑜伽',
|
||||
'2026-06-04 08:00:00',
|
||||
'2026-06-04 09:30:00',
|
||||
'瑜伽教室A',
|
||||
'2026-06-04 07:00:00',
|
||||
'2026-06-04 07:00:00'
|
||||
FROM generate_series(1, 14) AS i;
|
||||
|
||||
-- HIIT训练:19人预约(16人出席,3人取消)- 满员
|
||||
INSERT INTO group_course_booking (course_id, member_id, member_card_id, booking_time, status, course_name, course_start_time, course_end_time, location, created_at, updated_at)
|
||||
SELECT
|
||||
(SELECT id FROM group_course WHERE course_name = 'HIIT训练' AND DATE(start_time) = '2026-06-04'),
|
||||
(SELECT id FROM member_user WHERE member_no = 'MEM_STAT_' || LPAD(i::text, 3, '0')),
|
||||
(SELECT id FROM member_card_record WHERE member_id = (SELECT id FROM member_user WHERE member_no = 'MEM_STAT_' || LPAD(i::text, 3, '0'))),
|
||||
'2026-06-04 17:00:00',
|
||||
CASE WHEN i <= 16 THEN '2' ELSE '1' END,
|
||||
'HIIT训练',
|
||||
'2026-06-04 18:00:00',
|
||||
'2026-06-04 19:00:00',
|
||||
'综合训练区',
|
||||
'2026-06-04 17:00:00',
|
||||
'2026-06-04 17:00:00'
|
||||
FROM generate_series(1, 19) AS i;
|
||||
|
||||
-- 阴瑜伽:9人预约(8人出席,1人取消)
|
||||
INSERT INTO group_course_booking (course_id, member_id, member_card_id, booking_time, status, course_name, course_start_time, course_end_time, location, created_at, updated_at)
|
||||
SELECT
|
||||
(SELECT id FROM group_course WHERE course_name = '阴瑜伽' AND DATE(start_time) = '2026-06-04'),
|
||||
(SELECT id FROM member_user WHERE member_no = 'MEM_STAT_' || LPAD(i::text, 3, '0')),
|
||||
(SELECT id FROM member_card_record WHERE member_id = (SELECT id FROM member_user WHERE member_no = 'MEM_STAT_' || LPAD(i::text, 3, '0'))),
|
||||
'2026-06-04 19:30:00',
|
||||
CASE WHEN i <= 8 THEN '2' ELSE '1' END,
|
||||
'阴瑜伽',
|
||||
'2026-06-04 20:00:00',
|
||||
'2026-06-04 21:30:00',
|
||||
'瑜伽教室B',
|
||||
'2026-06-04 19:30:00',
|
||||
'2026-06-04 19:30:00'
|
||||
FROM generate_series(1, 9) AS i;
|
||||
|
||||
-- 2026-06-05 的预约记录
|
||||
-- 晨间冥想:15人预约(13人出席,2人取消)
|
||||
INSERT INTO group_course_booking (course_id, member_id, member_card_id, booking_time, status, course_name, course_start_time, course_end_time, location, created_at, updated_at)
|
||||
SELECT
|
||||
(SELECT id FROM group_course WHERE course_name = '晨间冥想' AND DATE(start_time) = '2026-06-05'),
|
||||
(SELECT id FROM member_user WHERE member_no = 'MEM_STAT_' || LPAD(i::text, 3, '0')),
|
||||
(SELECT id FROM member_card_record WHERE member_id = (SELECT id FROM member_user WHERE member_no = 'MEM_STAT_' || LPAD(i::text, 3, '0'))),
|
||||
'2026-06-05 06:00:00',
|
||||
CASE WHEN i <= 13 THEN '2' ELSE '1' END,
|
||||
'晨间冥想',
|
||||
'2026-06-05 07:00:00',
|
||||
'2026-06-05 08:00:00',
|
||||
'冥想室',
|
||||
'2026-06-05 06:00:00',
|
||||
'2026-06-05 06:00:00'
|
||||
FROM generate_series(1, 15) AS i;
|
||||
|
||||
-- 尊巴舞:19人预约(16人出席,3人取消)
|
||||
INSERT INTO group_course_booking (course_id, member_id, member_card_id, booking_time, status, course_name, course_start_time, course_end_time, location, created_at, updated_at)
|
||||
SELECT
|
||||
(SELECT id FROM group_course WHERE course_name = '尊巴舞' AND DATE(start_time) = '2026-06-05'),
|
||||
(SELECT id FROM member_user WHERE member_no = 'MEM_STAT_' || LPAD(i::text, 3, '0')),
|
||||
(SELECT id FROM member_card_record WHERE member_id = (SELECT id FROM member_user WHERE member_no = 'MEM_STAT_' || LPAD(i::text, 3, '0'))),
|
||||
'2026-06-05 17:30:00',
|
||||
CASE WHEN i <= 16 THEN '2' ELSE '1' END,
|
||||
'尊巴舞',
|
||||
'2026-06-05 18:30:00',
|
||||
'2026-06-05 19:30:00',
|
||||
'舞蹈室',
|
||||
'2026-06-05 17:30:00',
|
||||
'2026-06-05 17:30:00'
|
||||
FROM generate_series(1, 19) AS i;
|
||||
|
||||
-- 空中瑜伽:10人预约(9人出席,1人取消)- 满员
|
||||
INSERT INTO group_course_booking (course_id, member_id, member_card_id, booking_time, status, course_name, course_start_time, course_end_time, location, created_at, updated_at)
|
||||
SELECT
|
||||
(SELECT id FROM group_course WHERE course_name = '空中瑜伽' AND DATE(start_time) = '2026-06-05'),
|
||||
(SELECT id FROM member_user WHERE member_no = 'MEM_STAT_' || LPAD(i::text, 3, '0')),
|
||||
(SELECT id FROM member_card_record WHERE member_id = (SELECT id FROM member_user WHERE member_no = 'MEM_STAT_' || LPAD(i::text, 3, '0'))),
|
||||
'2026-06-05 19:00:00',
|
||||
CASE WHEN i <= 9 THEN '2' ELSE '1' END,
|
||||
'空中瑜伽',
|
||||
'2026-06-05 20:00:00',
|
||||
'2026-06-05 21:30:00',
|
||||
'瑜伽教室A',
|
||||
'2026-06-05 19:00:00',
|
||||
'2026-06-05 19:00:00'
|
||||
FROM generate_series(1, 10) AS i;
|
||||
|
||||
-- 2026-06-06 的预约记录
|
||||
-- 拜日式瑜伽:11人预约(10人出席,1人取消)
|
||||
INSERT INTO group_course_booking (course_id, member_id, member_card_id, booking_time, status, course_name, course_start_time, course_end_time, location, created_at, updated_at)
|
||||
SELECT
|
||||
(SELECT id FROM group_course WHERE course_name = '拜日式瑜伽' AND DATE(start_time) = '2026-06-06'),
|
||||
(SELECT id FROM member_user WHERE member_no = 'MEM_STAT_' || LPAD(i::text, 3, '0')),
|
||||
(SELECT id FROM member_card_record WHERE member_id = (SELECT id FROM member_user WHERE member_no = 'MEM_STAT_' || LPAD(i::text, 3, '0'))),
|
||||
'2026-06-06 06:30:00',
|
||||
CASE WHEN i <= 10 THEN '2' ELSE '1' END,
|
||||
'拜日式瑜伽',
|
||||
'2026-06-06 07:30:00',
|
||||
'2026-06-06 08:30:00',
|
||||
'瑜伽教室A',
|
||||
'2026-06-06 06:30:00',
|
||||
'2026-06-06 06:30:00'
|
||||
FROM generate_series(1, 11) AS i;
|
||||
|
||||
-- 杠铃操:16人预约(14人出席,2人取消)
|
||||
INSERT INTO group_course_booking (course_id, member_id, member_card_id, booking_time, status, course_name, course_start_time, course_end_time, location, created_at, updated_at)
|
||||
SELECT
|
||||
(SELECT id FROM group_course WHERE course_name = '杠铃操' AND DATE(start_time) = '2026-06-06'),
|
||||
(SELECT id FROM member_user WHERE member_no = 'MEM_STAT_' || LPAD(i::text, 3, '0')),
|
||||
(SELECT id FROM member_card_record WHERE member_id = (SELECT id FROM member_user WHERE member_no = 'MEM_STAT_' || LPAD(i::text, 3, '0'))),
|
||||
'2026-06-06 17:00:00',
|
||||
CASE WHEN i <= 14 THEN '2' ELSE '1' END,
|
||||
'杠铃操',
|
||||
'2026-06-06 18:00:00',
|
||||
'2026-06-06 19:00:00',
|
||||
'力量区',
|
||||
'2026-06-06 17:00:00',
|
||||
'2026-06-06 17:00:00'
|
||||
FROM generate_series(1, 16) AS i;
|
||||
|
||||
-- 修复瑜伽:7人预约(6人出席,1人取消)
|
||||
INSERT INTO group_course_booking (course_id, member_id, member_card_id, booking_time, status, course_name, course_start_time, course_end_time, location, created_at, updated_at)
|
||||
SELECT
|
||||
(SELECT id FROM group_course WHERE course_name = '修复瑜伽' AND DATE(start_time) = '2026-06-06'),
|
||||
(SELECT id FROM member_user WHERE member_no = 'MEM_STAT_' || LPAD(i::text, 3, '0')),
|
||||
(SELECT id FROM member_card_record WHERE member_id = (SELECT id FROM member_user WHERE member_no = 'MEM_STAT_' || LPAD(i::text, 3, '0'))),
|
||||
'2026-06-06 19:30:00',
|
||||
CASE WHEN i <= 6 THEN '2' ELSE '1' END,
|
||||
'修复瑜伽',
|
||||
'2026-06-06 20:00:00',
|
||||
'2026-06-06 21:00:00',
|
||||
'瑜伽教室B',
|
||||
'2026-06-06 19:30:00',
|
||||
'2026-06-06 19:30:00'
|
||||
FROM generate_series(1, 7) AS i;
|
||||
|
||||
-- ============================================
|
||||
-- 6. 更新团课当前预约人数(与实际预约一致)
|
||||
-- ============================================
|
||||
|
||||
UPDATE group_course SET current_members = 5 WHERE course_name = '晨间瑜伽' AND DATE(start_time) = '2026-06-01';
|
||||
UPDATE group_course SET current_members = 19 WHERE course_name = '燃脂单车' AND DATE(start_time) = '2026-06-01';
|
||||
UPDATE group_course SET current_members = 8 WHERE course_name = '普拉提核心' AND DATE(start_time) = '2026-06-01';
|
||||
|
||||
UPDATE group_course SET current_members = 10 WHERE course_name = '流瑜伽' AND DATE(start_time) = '2026-06-02';
|
||||
UPDATE group_course SET current_members = 18 WHERE course_name = '搏击操' AND DATE(start_time) = '2026-06-02';
|
||||
UPDATE group_course SET current_members = 5 WHERE course_name = '冥想放松' AND DATE(start_time) = '2026-06-02';
|
||||
|
||||
UPDATE group_course SET current_members = 12 WHERE course_name = '哈他瑜伽' AND DATE(start_time) = '2026-06-03';
|
||||
UPDATE group_course SET current_members = 19 WHERE course_name = '动感单车' AND DATE(start_time) = '2026-06-03';
|
||||
UPDATE group_course SET current_members = 6 WHERE course_name = '拉伸放松' AND DATE(start_time) = '2026-06-03';
|
||||
|
||||
UPDATE group_course SET current_members = 14 WHERE course_name = '力量瑜伽' AND DATE(start_time) = '2026-06-04';
|
||||
UPDATE group_course SET current_members = 19 WHERE course_name = 'HIIT训练' AND DATE(start_time) = '2026-06-04';
|
||||
UPDATE group_course SET current_members = 9 WHERE course_name = '阴瑜伽' AND DATE(start_time) = '2026-06-04';
|
||||
|
||||
UPDATE group_course SET current_members = 15 WHERE course_name = '晨间冥想' AND DATE(start_time) = '2026-06-05';
|
||||
UPDATE group_course SET current_members = 19 WHERE course_name = '尊巴舞' AND DATE(start_time) = '2026-06-05';
|
||||
UPDATE group_course SET current_members = 10 WHERE course_name = '空中瑜伽' AND DATE(start_time) = '2026-06-05';
|
||||
|
||||
UPDATE group_course SET current_members = 11 WHERE course_name = '拜日式瑜伽' AND DATE(start_time) = '2026-06-06';
|
||||
UPDATE group_course SET current_members = 16 WHERE course_name = '杠铃操' AND DATE(start_time) = '2026-06-06';
|
||||
UPDATE group_course SET current_members = 7 WHERE course_name = '修复瑜伽' AND DATE(start_time) = '2026-06-06';
|
||||
|
||||
-- ============================================
|
||||
-- 7. 测试场景说明
|
||||
-- ============================================
|
||||
|
||||
-- 会员数据统计预期结果(2026-06-01 至 2026-06-06):
|
||||
-- 总会员数:19人(MEM_STAT_001 至 MEM_STAT_019,不含已删除的 MEM_STAT_DEL)
|
||||
-- 男性会员:10人(001,002,003,006,007,010,013,015,016,018)
|
||||
-- 女性会员:9人(004,005,008,009,011,012,014,017,019)
|
||||
-- 2026-06-01 新增:5人
|
||||
-- 2026-06-02 新增:4人
|
||||
-- 2026-06-03 新增:3人
|
||||
-- 2026-06-04 新增:2人
|
||||
-- 2026-06-05 新增:3人
|
||||
-- 2026-06-06 新增:2人
|
||||
-- 所有会员都有会员卡记录(用于预约)
|
||||
-120
@@ -1,120 +0,0 @@
|
||||
-- 数据统计模块测试数据
|
||||
-- 用于测试会员、预约、签到统计接口
|
||||
|
||||
-- 插入测试会员数据
|
||||
INSERT INTO member_user (id, member_no, nickname, phone, created_at, updated_at, is_deleted) VALUES
|
||||
(1001, 'M20260601001', '张三', '13800138001', '2026-06-01 08:00:00', '2026-06-01 08:00:00', false),
|
||||
(1002, 'M20260601002', '李四', '13800138002', '2026-06-01 09:00:00', '2026-06-01 09:00:00', false),
|
||||
(1003, 'M20260602003', '王五', '13800138003', '2026-06-02 10:00:00', '2026-06-02 10:00:00', false),
|
||||
(1004, 'M20260603004', '赵六', '13800138004', '2026-06-03 11:00:00', '2026-06-03 11:00:00', false),
|
||||
(1005, 'M20260609005', '钱七', '13800138005', '2026-06-09 08:00:00', '2026-06-09 08:00:00', false),
|
||||
(1006, 'M20260609006', '孙八', '13800138006', '2026-06-09 09:00:00', '2026-06-09 09:00:00', false),
|
||||
(1007, 'M20260609007', '周九', '13800138007', '2026-06-09 10:00:00', '2026-06-09 10:00:00', false),
|
||||
(1008, 'M20260604008', '吴十', '13800138008', '2026-06-04 14:00:00', '2026-06-04 14:00:00', false),
|
||||
(1009, 'M20260605009', '郑十一', '13800138009', '2026-06-05 15:00:00', '2026-06-05 15:00:00', false),
|
||||
(1010, 'M20260606010', '王十二', '13800138010', '2026-06-06 16:00:00', '2026-06-06 16:00:00', false),
|
||||
(1011, 'M20260607011', '陈十三', '13800138011', '2026-06-07 17:00:00', '2026-06-07 17:00:00', false),
|
||||
(1012, 'M20260608012', '刘十四', '13800138012', '2026-06-08 18:00:00', '2026-06-08 18:00:00', false)
|
||||
ON CONFLICT (id) DO NOTHING;
|
||||
|
||||
-- 插入测试签到记录数据 (今天的数据)
|
||||
INSERT INTO sign_in_record (id, member_id, sign_in_time, sign_in_type, sign_in_status, source, is_delete) VALUES
|
||||
(2001, 1001, '2026-06-09 08:00:00', 'QR_CODE', 'SUCCESS', 'MINI_PROGRAM', false),
|
||||
(2002, 1002, '2026-06-09 08:15:00', 'MANUAL', 'SUCCESS', 'PC_BACKEND', false),
|
||||
(2003, 1003, '2026-06-09 08:30:00', 'FACE', 'SUCCESS', 'MINI_PROGRAM', false),
|
||||
(2004, 1004, '2026-06-09 09:00:00', 'QR_CODE', 'SUCCESS', 'MINI_PROGRAM', false),
|
||||
(2005, 1005, '2026-06-09 09:15:00', 'MANUAL', 'SUCCESS', 'PC_BACKEND', false),
|
||||
(2006, 1006, '2026-06-09 09:30:00', 'QR_CODE', 'SUCCESS', 'MINI_PROGRAM', false),
|
||||
(2007, 1007, '2026-06-09 10:00:00', 'FACE', 'SUCCESS', 'MINI_PROGRAM', false),
|
||||
(2008, 1008, '2026-06-09 10:15:00', 'QR_CODE', 'SUCCESS', 'MINI_PROGRAM', false),
|
||||
(2009, 1009, '2026-06-09 10:30:00', 'MANUAL', 'SUCCESS', 'PC_BACKEND', false),
|
||||
(2010, 1010, '2026-06-09 11:00:00', 'QR_CODE', 'SUCCESS', 'MINI_PROGRAM', false),
|
||||
(2011, 1011, '2026-06-09 11:15:00', 'FACE', 'FAIL', 'MINI_PROGRAM', false),
|
||||
(2012, 1012, '2026-06-09 11:30:00', 'MANUAL', 'SUCCESS', 'PC_BACKEND', false)
|
||||
ON CONFLICT (id) DO NOTHING;
|
||||
|
||||
-- 插入测试签到记录数据 (昨天的数据)
|
||||
INSERT INTO sign_in_record (id, member_id, sign_in_time, sign_in_type, sign_in_status, source, is_delete) VALUES
|
||||
(2013, 1001, '2026-06-08 07:30:00', 'QR_CODE', 'SUCCESS', 'MINI_PROGRAM', false),
|
||||
(2014, 1002, '2026-06-08 08:00:00', 'MANUAL', 'SUCCESS', 'PC_BACKEND', false),
|
||||
(2015, 1003, '2026-06-08 08:30:00', 'FACE', 'SUCCESS', 'MINI_PROGRAM', false),
|
||||
(2016, 1004, '2026-06-08 09:00:00', 'QR_CODE', 'SUCCESS', 'MINI_PROGRAM', false),
|
||||
(2017, 1005, '2026-06-08 09:30:00', 'MANUAL', 'SUCCESS', 'PC_BACKEND', false),
|
||||
(2018, 1006, '2026-06-08 10:00:00', 'QR_CODE', 'SUCCESS', 'MINI_PROGRAM', false),
|
||||
(2019, 1007, '2026-06-08 10:30:00', 'FACE', 'SUCCESS', 'MINI_PROGRAM', false),
|
||||
(2020, 1008, '2026-06-08 11:00:00', 'QR_CODE', 'SUCCESS', 'MINI_PROGRAM', false)
|
||||
ON CONFLICT (id) DO NOTHING;
|
||||
|
||||
-- 插入测试签到记录数据 (前天的数据)
|
||||
INSERT INTO sign_in_record (id, member_id, sign_in_time, sign_in_type, sign_in_status, source, is_delete) VALUES
|
||||
(2021, 1001, '2026-06-07 07:00:00', 'QR_CODE', 'SUCCESS', 'MINI_PROGRAM', false),
|
||||
(2022, 1002, '2026-06-07 07:30:00', 'MANUAL', 'SUCCESS', 'PC_BACKEND', false),
|
||||
(2023, 1003, '2026-06-07 08:00:00', 'FACE', 'FAIL', 'MINI_PROGRAM', false),
|
||||
(2024, 1004, '2026-06-07 08:30:00', 'QR_CODE', 'SUCCESS', 'MINI_PROGRAM', false),
|
||||
(2025, 1005, '2026-06-07 09:00:00', 'MANUAL', 'SUCCESS', 'PC_BACKEND', false)
|
||||
ON CONFLICT (id) DO NOTHING;
|
||||
|
||||
-- 插入测试团课数据
|
||||
INSERT INTO group_course (id, course_name, coach_id, course_type, start_time, end_time, max_members, current_members, status, location, cover_image, description, created_at, updated_at) VALUES
|
||||
(3001, '瑜伽入门', 1, 1, '2026-06-09 08:00:00', '2026-06-09 09:00:00', 20, 15, 0, '健身房A区', 'https://example.com/yoga.jpg', '适合初学者的瑜伽课程', '2026-06-01 10:00:00', '2026-06-01 10:00:00'),
|
||||
(3002, '动感单车', 2, 2, '2026-06-09 09:30:00', '2026-06-09 10:30:00', 25, 20, 0, '健身房B区', 'https://example.com/spinning.jpg', '高强度有氧运动', '2026-06-01 11:00:00', '2026-06-01 11:00:00'),
|
||||
(3003, '普拉提', 3, 1, '2026-06-09 14:00:00', '2026-06-09 15:00:00', 15, 10, 0, '健身房C区', 'https://example.com/pilates.jpg', '核心力量训练', '2026-06-01 12:00:00', '2026-06-01 12:00:00')
|
||||
ON CONFLICT (id) DO NOTHING;
|
||||
|
||||
-- 插入测试团课预约数据 (今天的数据)
|
||||
INSERT INTO group_course_booking (id, member_id, member_card_id, course_id, booking_time, status, created_at, updated_at) VALUES
|
||||
(4001, 1001, 1, 3001, '2026-06-09 08:00:00', '2', '2026-06-08 20:00:00', '2026-06-09 08:30:00'),
|
||||
(4002, 1002, 2, 3001, '2026-06-09 08:00:00', '2', '2026-06-08 21:00:00', '2026-06-09 08:30:00'),
|
||||
(4003, 1003, 3, 3001, '2026-06-09 08:00:00', '3', '2026-06-08 22:00:00', '2026-06-09 09:00:00'),
|
||||
(4004, 1004, 4, 3002, '2026-06-09 09:30:00', '2', '2026-06-08 19:00:00', '2026-06-09 09:30:00'),
|
||||
(4005, 1005, 5, 3002, '2026-06-09 09:30:00', '1', '2026-06-08 20:30:00', '2026-06-09 09:00:00'),
|
||||
(4006, 1006, 6, 3002, '2026-06-09 09:30:00', '2', '2026-06-08 21:30:00', '2026-06-09 09:30:00'),
|
||||
(4007, 1007, 7, 3003, '2026-06-09 14:00:00', '2', '2026-06-08 22:30:00', '2026-06-09 14:00:00'),
|
||||
(4008, 1008, 8, 3003, '2026-06-09 14:00:00', '3', '2026-06-09 08:00:00', '2026-06-09 14:00:00'),
|
||||
(4009, 1009, 9, 3003, '2026-06-09 14:00:00', '2', '2026-06-09 09:00:00', '2026-06-09 14:00:00'),
|
||||
(4010, 1010, 10, 3001, '2026-06-09 08:00:00', '2', '2026-06-09 07:00:00', '2026-06-09 08:00:00'),
|
||||
(4011, 1011, 11, 3002, '2026-06-09 09:30:00', '1', '2026-06-09 08:30:00', '2026-06-09 09:00:00'),
|
||||
(4012, 1012, 12, 3003, '2026-06-09 14:00:00', '2', '2026-06-09 10:00:00', '2026-06-09 14:00:00')
|
||||
ON CONFLICT (id) DO NOTHING;
|
||||
|
||||
-- 插入测试团课预约数据 (昨天的数据)
|
||||
INSERT INTO group_course_booking (id, member_id, member_card_id, course_id, booking_time, status, created_at, updated_at) VALUES
|
||||
(4013, 1001, 1, 3001, '2026-06-08 08:00:00', '2', '2026-06-07 20:00:00', '2026-06-08 08:30:00'),
|
||||
(4014, 1002, 2, 3001, '2026-06-08 08:00:00', '2', '2026-06-07 21:00:00', '2026-06-08 08:30:00'),
|
||||
(4015, 1003, 3, 3002, '2026-06-08 09:30:00', '3', '2026-06-07 22:00:00', '2026-06-08 09:30:00'),
|
||||
(4016, 1004, 4, 3002, '2026-06-08 09:30:00', '2', '2026-06-07 19:00:00', '2026-06-08 09:30:00'),
|
||||
(4017, 1005, 5, 3003, '2026-06-08 14:00:00', '1', '2026-06-07 20:30:00', '2026-06-08 13:00:00'),
|
||||
(4018, 1006, 6, 3003, '2026-06-08 14:00:00', '2', '2026-06-07 21:30:00', '2026-06-08 14:00:00')
|
||||
ON CONFLICT (id) DO NOTHING;
|
||||
|
||||
-- 插入测试团课预约数据 (前天的数据)
|
||||
INSERT INTO group_course_booking (id, member_id, member_card_id, course_id, booking_time, status, created_at, updated_at) VALUES
|
||||
(4019, 1001, 1, 3002, '2026-06-07 09:30:00', '2', '2026-06-06 20:00:00', '2026-06-07 09:30:00'),
|
||||
(4020, 1002, 2, 3002, '2026-06-07 09:30:00', '2', '2026-06-06 21:00:00', '2026-06-07 09:30:00'),
|
||||
(4021, 1003, 3, 3003, '2026-06-07 14:00:00', '2', '2026-06-06 22:00:00', '2026-06-07 14:00:00'),
|
||||
(4022, 1004, 4, 3003, '2026-06-07 14:00:00', '3', '2026-06-06 19:00:00', '2026-06-07 14:00:00')
|
||||
ON CONFLICT (id) DO NOTHING;
|
||||
|
||||
-- 预期统计结果 (今日):
|
||||
-- 会员统计:
|
||||
-- 新增会员: 3 (1005, 1006, 1007)
|
||||
-- 活跃会员: 12 (所有会员今日或近期有活动)
|
||||
-- 总会员数: 12
|
||||
-- 签到会员: 12
|
||||
-- 预约会员: 9
|
||||
-- 取消会员: 2
|
||||
|
||||
-- 预约统计:
|
||||
-- 总预约: 12
|
||||
-- 取消: 2
|
||||
-- 出席: 8
|
||||
-- 缺席: 2
|
||||
-- 出席率: 8/10 = 80%
|
||||
-- 取消率: 2/12 = 16.67%
|
||||
|
||||
-- 签到统计:
|
||||
-- 总签到: 12
|
||||
-- 成功: 11
|
||||
-- 失败: 1
|
||||
-- 成功率: 11/12 = 91.67%
|
||||
-- 类型分布: QR_CODE=5, MANUAL=4, FACE=3
|
||||
-76
@@ -1,76 +0,0 @@
|
||||
-- ============================================
|
||||
-- 团课类型表
|
||||
-- ============================================
|
||||
|
||||
-- 团课类型表
|
||||
CREATE TABLE IF NOT EXISTS group_course_type (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
type_name VARCHAR(100) NOT NULL,
|
||||
base_difficulty INTEGER DEFAULT 1,
|
||||
description TEXT,
|
||||
category VARCHAR(50),
|
||||
create_by VARCHAR(50),
|
||||
update_by VARCHAR(50),
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
deleted_at TIMESTAMP
|
||||
);
|
||||
|
||||
COMMENT ON TABLE group_course_type IS '团课类型表';
|
||||
COMMENT ON COLUMN group_course_type.id IS '主键ID';
|
||||
COMMENT ON COLUMN group_course_type.type_name IS '类型名称';
|
||||
COMMENT ON COLUMN group_course_type.base_difficulty IS '基础难度(1-10)';
|
||||
COMMENT ON COLUMN group_course_type.description IS '类型描述';
|
||||
COMMENT ON COLUMN group_course_type.category IS '分类(如:有氧、力量、柔韧等)';
|
||||
COMMENT ON COLUMN group_course_type.create_by IS '创建人';
|
||||
COMMENT ON COLUMN group_course_type.update_by IS '更新人';
|
||||
COMMENT ON COLUMN group_course_type.created_at IS '创建时间';
|
||||
COMMENT ON COLUMN group_course_type.updated_at IS '更新时间';
|
||||
COMMENT ON COLUMN group_course_type.deleted_at IS '删除时间(软删除)';
|
||||
|
||||
-- 创建索引
|
||||
CREATE INDEX idx_group_course_type_type_name ON group_course_type(type_name);
|
||||
CREATE INDEX idx_group_course_type_category ON group_course_type(category);
|
||||
|
||||
-- 插入初始团课类型数据(参考exmp.txt)
|
||||
INSERT INTO group_course_type (type_name, base_difficulty, description, category) VALUES
|
||||
('慢走/椭圆机轻松模式', 1, '几乎无难度,适合所有人', '基础有氧与热身'),
|
||||
('固定自行车(低阻力)', 2, '注意座椅高度调节即可', '基础有氧与热身'),
|
||||
('跑步机慢跑', 3, '需要基本协调性,膝盖有压力', '基础有氧与热身'),
|
||||
('跳绳(连续基础跳)', 3, '需要手脚配合,心肺要求明显', '基础有氧与热身'),
|
||||
('坐姿腿屈伸/腿弯举', 2, '很容易找到发力感', '固定器械训练'),
|
||||
('坐姿推胸机', 3, '需注意肩胛后收,避免耸肩', '固定器械训练'),
|
||||
('高位下拉(坐姿)', 3, '需控制不要过度后仰', '固定器械训练'),
|
||||
('史密斯机深蹲', 4, '轨迹固定,但需保持核心稳定', '固定器械训练'),
|
||||
('蝴蝶机夹胸', 3, '易用肘关节代偿,需锁定肩关节', '固定器械训练'),
|
||||
('平板支撑', 3, '耐力考验,技巧低', '自重基础动作'),
|
||||
('跪姿俯卧撑', 3, '上肢力量较弱者首选', '自重基础动作'),
|
||||
('标准俯卧撑', 5, '需核心收紧,身体成直线', '自重基础动作'),
|
||||
('引体向上(弹力带辅助)', 6, '背部和手臂力量要求高', '自重基础动作'),
|
||||
('标准引体向上', 8, '力量-体重比极高,多数男性无法完成1次', '自重基础动作'),
|
||||
('徒手深蹲', 3, '注意膝盖方向与背部直立', '自重基础动作'),
|
||||
('单腿深蹲(手枪蹲)', 8, '需要极高下肢力量、柔韧性和平衡', '自重基础动作'),
|
||||
('哑铃二头弯举', 4, '容易晃动借力,但较安全', '自由重量杠铃/哑铃'),
|
||||
('哑铃侧平举', 5, '极易用斜方肌代偿,真正练到三角肌中束很难', '自由重量杠铃/哑铃'),
|
||||
('杠铃卧推', 7, '肩关节压力大,起桥、沉肩、稳定手腕均有技巧,有压伤风险', '自由重量杠铃/哑铃'),
|
||||
('杠铃深蹲(颈后)', 8, '全身协调性、核心抗压、杠位放置、呼吸模式,学习曲线陡峭', '自由重量杠铃/哑铃'),
|
||||
('传统硬拉', 9, '风险极高,需要精确的脊柱中立、髋铰链、背阔肌收紧,错误时伤腰', '自由重量杠铃/哑铃'),
|
||||
('高翻/抓举(奥运举重)', 10, '需要爆发力、柔韧、精准衔接,非数月训练不能掌握', '自由重量杠铃/哑铃'),
|
||||
('波比跳(标准版)', 6, '连续做时心肺压力极大', '高强度与爆发力'),
|
||||
('冲刺跑(短跑)', 7, '对腘绳肌和脚踝爆发力要求高', '高强度与爆发力'),
|
||||
('跳箱(合理高度)', 6, '需要落地缓冲技巧', '高强度与爆发力'),
|
||||
('负重雪橇推', 6, '主要考验腿部耐力和意志力', '高强度与爆发力'),
|
||||
('双力臂(引体向上后翻腕上杠)', 9, '需要爆发引体 + 极高相对力量', '高强度与爆发力'),
|
||||
('静态拉伸(坐姿体前屈)', 2, '无风险,但需要坚持', '柔韧与平衡类'),
|
||||
('瑜伽下犬式', 3, '常见,但需背部与手臂对齐', '柔韧与平衡类'),
|
||||
('单腿罗马尼亚硬拉(徒手)', 6, '极考验平衡和髋稳定', '柔韧与平衡类'),
|
||||
('全深蹲(脚跟贴地,亚洲蹲)', 5, '踝关节灵活度限制多数人', '柔韧与平衡类'),
|
||||
('竖叉/横叉', 8, '需要数月甚至数年拉伸', '柔韧与平衡类'),
|
||||
('瑜伽入门', 2, '适合初学者的瑜伽课程,注重基础体式', '柔韧与平衡类'),
|
||||
('瑜伽进阶', 5, '针对有一定基础的学员,包含更复杂体式', '柔韧与平衡类'),
|
||||
('普拉提', 4, '注重核心力量和身体控制', '柔韧与平衡类'),
|
||||
('动感单车', 4, '高强度有氧运动,节奏感强', '基础有氧与热身'),
|
||||
('搏击操', 5, '结合拳击动作的有氧运动', '高强度与爆发力'),
|
||||
('HIIT训练', 7, '高强度间歇训练,对心肺要求极高', '高强度与爆发力'),
|
||||
('核心训练', 4, '针对核心肌群的专项训练', '自重基础动作')
|
||||
ON CONFLICT DO NOTHING;
|
||||
-73
@@ -1,73 +0,0 @@
|
||||
-- ============================================
|
||||
-- 团课标签相关表
|
||||
-- ============================================
|
||||
|
||||
-- 团课标签表
|
||||
CREATE TABLE IF NOT EXISTS course_label (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
label_name VARCHAR(50) NOT NULL,
|
||||
color VARCHAR(20) DEFAULT '#1890ff',
|
||||
description VARCHAR(200),
|
||||
create_by VARCHAR(50),
|
||||
update_by VARCHAR(50),
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
deleted_at TIMESTAMP
|
||||
);
|
||||
|
||||
-- 团课类型-标签关联表
|
||||
CREATE TABLE IF NOT EXISTS course_type_label (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
type_id BIGINT NOT NULL,
|
||||
label_id BIGINT NOT NULL,
|
||||
create_by VARCHAR(50),
|
||||
update_by VARCHAR(50),
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
deleted_at TIMESTAMP,
|
||||
UNIQUE (type_id, label_id)
|
||||
);
|
||||
|
||||
COMMENT ON TABLE course_label IS '团课标签表';
|
||||
COMMENT ON COLUMN course_label.id IS '主键ID';
|
||||
COMMENT ON COLUMN course_label.label_name IS '标签名称';
|
||||
COMMENT ON COLUMN course_label.color IS '标签颜色(十六进制)';
|
||||
COMMENT ON COLUMN course_label.description IS '标签描述';
|
||||
COMMENT ON COLUMN course_label.create_by IS '创建人';
|
||||
COMMENT ON COLUMN course_label.update_by IS '更新人';
|
||||
COMMENT ON COLUMN course_label.created_at IS '创建时间';
|
||||
COMMENT ON COLUMN course_label.updated_at IS '更新时间';
|
||||
COMMENT ON COLUMN course_label.deleted_at IS '删除时间(软删除)';
|
||||
|
||||
COMMENT ON TABLE course_type_label IS '团课类型-标签关联表';
|
||||
COMMENT ON COLUMN course_type_label.id IS '主键ID';
|
||||
COMMENT ON COLUMN course_type_label.type_id IS '团课类型ID';
|
||||
COMMENT ON COLUMN course_type_label.label_id IS '标签ID';
|
||||
COMMENT ON COLUMN course_type_label.create_by IS '创建人';
|
||||
COMMENT ON COLUMN course_type_label.update_by IS '更新人';
|
||||
COMMENT ON COLUMN course_type_label.created_at IS '创建时间';
|
||||
COMMENT ON COLUMN course_type_label.updated_at IS '更新时间';
|
||||
COMMENT ON COLUMN course_type_label.deleted_at IS '删除时间(软删除)';
|
||||
|
||||
-- 创建索引
|
||||
CREATE INDEX idx_course_label_label_name ON course_label(label_name);
|
||||
CREATE INDEX idx_course_type_label_type_id ON course_type_label(type_id);
|
||||
CREATE INDEX idx_course_type_label_label_id ON course_type_label(label_id);
|
||||
|
||||
-- 插入初始标签数据
|
||||
INSERT INTO course_label (label_name, color, description) VALUES
|
||||
('适合新手', '#52c41a', '适合健身初学者'),
|
||||
('中级过渡', '#faad14', '适合有一定基础的学员'),
|
||||
('高级进阶', '#f5222d', '适合高级学员'),
|
||||
('减脂塑形', '#722ed1', '有助于减脂塑形'),
|
||||
('增肌强化', '#13c2c2', '有助于增肌强化'),
|
||||
('柔韧性训练', '#eb2f96', '注重柔韧性提升'),
|
||||
('核心训练', '#1890ff', '注重核心力量'),
|
||||
('心肺训练', '#fa8c16', '提升心肺功能'),
|
||||
('低冲击', '#52c41a', '低冲击运动,适合关节保护'),
|
||||
('高强度', '#f5222d', '高强度间歇训练'),
|
||||
('团体互动', '#722ed1', '注重团队协作'),
|
||||
('私教推荐', '#13c2c2', '私教推荐课程'),
|
||||
('热门课程', '#ff1493', '人气较高的课程'),
|
||||
('新课上线', '#00ced1', '新上线的课程')
|
||||
ON CONFLICT DO NOTHING;
|
||||
-1
@@ -61,7 +61,6 @@ public class JwtAuthenticationFilter extends AbstractGatewayFilterFactory<JwtAut
|
||||
path.equals("/api/member/auth/miniapp/login") ||
|
||||
path.equals("/api/member/auth/mp/callback") ||
|
||||
path.equals("/api/auth/login") ||
|
||||
path.startsWith("/api/checkIn/") ||
|
||||
path.startsWith("/actuator/info");
|
||||
}
|
||||
|
||||
|
||||
+1
-2
@@ -63,8 +63,7 @@ public class RbacAuthorizationFilter extends AbstractGatewayFilterFactory<RbacAu
|
||||
private boolean isPublicPath(String path) {
|
||||
return path.startsWith("/api/auth/") ||
|
||||
path.equals("/actuator/health") ||
|
||||
path.startsWith("/actuator/info") ||
|
||||
path.startsWith("/api/checkIn/");
|
||||
path.startsWith("/actuator/info");
|
||||
}
|
||||
|
||||
public static class Config {
|
||||
|
||||
+1
-2
@@ -57,8 +57,7 @@ public class SecurityConfig {
|
||||
.pathMatchers("/api/member-cards/**").permitAll()
|
||||
.pathMatchers("/api/member-card-records/**").permitAll()
|
||||
.pathMatchers("/**").permitAll()
|
||||
.pathMatchers("/api/member-card-transactions/**").permitAll()
|
||||
.pathMatchers("/api/checkIn/**").permitAll();
|
||||
.pathMatchers("/api/member-card-transactions/**").permitAll();
|
||||
|
||||
|
||||
if (isDevOrTest) {
|
||||
|
||||
@@ -44,7 +44,6 @@
|
||||
<module>manage-file</module>
|
||||
<module>gym-member</module>
|
||||
<module>gym-groupCourse</module>
|
||||
<module>gym-checkIn</module>
|
||||
<module>gym-dataCount</module>
|
||||
</modules>
|
||||
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
node_modules/
|
||||
unpackage/
|
||||
.hbuilderx/
|
||||
.DS_Store
|
||||
@@ -1,33 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="gym.manage.uniapp">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
|
||||
|
||||
<application>
|
||||
<activity
|
||||
android:name="com.mobile.auth.gatewayauth.LoginAuthActivity"
|
||||
android:configChanges="orientation|keyboardHidden|screenSize"
|
||||
android:exported="false"
|
||||
android:launchMode="singleTop"
|
||||
android:screenOrientation="behind"
|
||||
android:theme="@style/authsdk_activity_dialog" />
|
||||
|
||||
<activity
|
||||
android:name="com.mobile.auth.gatewayauth.activity.AuthWebVeiwActivity"
|
||||
android:configChanges="orientation|keyboardHidden|screenSize"
|
||||
android:exported="false"
|
||||
android:launchMode="singleTop"
|
||||
android:screenOrientation="behind" />
|
||||
|
||||
<activity
|
||||
android:name="com.mobile.auth.gatewayauth.PrivacyDialogActivity"
|
||||
android:configChanges="orientation|keyboardHidden|screenSize"
|
||||
android:exported="false"
|
||||
android:launchMode="singleTop"
|
||||
android:screenOrientation="behind"
|
||||
android:theme="@style/authsdk_activity_dialog" />
|
||||
</application>
|
||||
</manifest>
|
||||
@@ -1,85 +0,0 @@
|
||||
<template>
|
||||
<view>
|
||||
<GlobalLoading />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { onLaunch, onShow, onHide } from '@dcloudio/uni-app'
|
||||
import GlobalLoading from '@/components/global/GlobalLoading.vue'
|
||||
|
||||
// 隐藏原生 TabBar - 这里是核心修复
|
||||
const hideNativeTabBar = () => {
|
||||
// 尝试多次执行,确保执行成功
|
||||
const tryHide = (times = 0) => {
|
||||
if (times > 10) return // 最多尝试10次
|
||||
|
||||
uni.hideTabBar({
|
||||
animation: false,
|
||||
success: () => {
|
||||
console.log('✅ 原生TabBar隐藏成功')
|
||||
// 强制 CSS 覆盖(双重保险)
|
||||
forceCSSHide()
|
||||
},
|
||||
fail: (err) => {
|
||||
console.log(`❌ 第${times+1}次隐藏失败,1秒后重试`, err)
|
||||
setTimeout(() => tryHide(times + 1), 1000)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 延迟 300ms 执行,确保页面挂载完成
|
||||
setTimeout(() => tryHide(), 300)
|
||||
}
|
||||
|
||||
// 强制 CSS 覆盖(最终保险)
|
||||
const forceCSSHide = () => {
|
||||
// #ifdef APP-PLUS
|
||||
const style = document.createElement('style')
|
||||
style.innerHTML = `
|
||||
uni-tabbar,
|
||||
uni-tabbar .uni-tabbar,
|
||||
.uni-tabbar,
|
||||
uni-tabbar > .uni-tabbar,
|
||||
[class*="uni-tabbar"] {
|
||||
display: none !important;
|
||||
height: 0 !important;
|
||||
opacity: 0 !important;
|
||||
visibility: hidden !important;
|
||||
pointer-events: none !important;
|
||||
}
|
||||
`
|
||||
document.head.appendChild(style)
|
||||
console.log('✅ CSS 强制覆盖已注入')
|
||||
// #endif
|
||||
}
|
||||
|
||||
// 预加载所有 Tab 页面的核心数据
|
||||
const preloadTabData = () => {
|
||||
// 延迟执行,不阻塞首屏
|
||||
setTimeout(() => {
|
||||
// 预加载课程数据等...
|
||||
}, 1000)
|
||||
}
|
||||
|
||||
onLaunch(() => {
|
||||
console.log('App Launch')
|
||||
preloadTabData()
|
||||
})
|
||||
|
||||
onShow(() => {
|
||||
console.log('App Show')
|
||||
// #ifdef APP-PLUS
|
||||
hideNativeTabBar()
|
||||
// #endif
|
||||
})
|
||||
|
||||
onHide(() => {
|
||||
console.log('App Hide')
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
/* 注意要写在第一行,同时给style标签加入lang="scss"属性 */
|
||||
@import "@/uni.scss";
|
||||
</style>
|
||||
@@ -1,132 +0,0 @@
|
||||
import request from "@/utils/request.js"
|
||||
|
||||
export function getGroupCourseList(params = {}, options = {}) {
|
||||
return request.get('/groupCourse/list', params, options)
|
||||
}
|
||||
|
||||
export function getGroupCoursePage(params = {}, options = { cache: true, cacheTime: 5 * 60 * 1000 }) {
|
||||
const { page = 0, size = 10, sort = 'id', order = 'asc', keyword } = params
|
||||
return request.post('/groupCourse/page', { page, size, sort, order, keyword }, options)
|
||||
}
|
||||
|
||||
export function getGroupCourseById(id, options = { cache: true, cacheTime: 15 * 60 * 1000 }) {
|
||||
return request.get(`/groupCourse/${id}`, {}, options)
|
||||
}
|
||||
|
||||
export function getGroupCourseDetail(id, options = { cache: true, cacheTime: 15 * 60 * 1000 }) {
|
||||
return request.get(`/groupCourse/${id}/detail`, {}, options)
|
||||
}
|
||||
|
||||
export function createGroupCourse(params) {
|
||||
return request.post('/groupCourse', params)
|
||||
}
|
||||
|
||||
export function updateGroupCourse(id, params) {
|
||||
return request.put(`/groupCourse/${id}`, params)
|
||||
}
|
||||
|
||||
export function cancelGroupCourse(id) {
|
||||
return request.post(`/groupCourse/${id}/cancel`)
|
||||
}
|
||||
|
||||
export function deleteGroupCourse(id) {
|
||||
return request.delete(`/groupCourse/${id}`)
|
||||
}
|
||||
|
||||
export function getGroupCourseTypes(params = {}, options = { cache: true, cacheTime: 10 * 60 * 1000 }) {
|
||||
return request.get('/groupCourse/types', params, options)
|
||||
}
|
||||
|
||||
export function getGroupCourseTypeById(id, options = { cache: true, cacheTime: 10 * 60 * 1000 }) {
|
||||
return request.get(`/groupCourse/types/${id}`, {}, options)
|
||||
}
|
||||
|
||||
export function getTypeLabels(typeId, options = { cache: true, cacheTime: 5 * 60 * 1000 }) {
|
||||
return request.get(`/groupCourse/types/${typeId}/labels`, {}, options)
|
||||
}
|
||||
|
||||
export function searchGroupCourse(params = {}, options = {}) {
|
||||
const {
|
||||
courseName,
|
||||
courseType,
|
||||
startDate,
|
||||
endDate,
|
||||
timePeriod,
|
||||
priceSort,
|
||||
remainingMost,
|
||||
isRecurring,
|
||||
page = 0,
|
||||
size = 10
|
||||
} = params
|
||||
|
||||
const requestBody = { page, size }
|
||||
|
||||
if (courseName) requestBody.courseName = courseName
|
||||
if (courseType) requestBody.courseType = courseType
|
||||
if (startDate) requestBody.startDate = formatDateTime(startDate)
|
||||
if (endDate) requestBody.endDate = formatDateTime(endDate, true)
|
||||
if (timePeriod) requestBody.timePeriod = timePeriod
|
||||
if (priceSort) requestBody.priceSort = priceSort
|
||||
if (remainingMost !== undefined) requestBody.remainingMost = remainingMost
|
||||
if (isRecurring !== undefined) requestBody.isRecurring = isRecurring
|
||||
|
||||
return request.post('/groupCourse/search', requestBody, options)
|
||||
}
|
||||
|
||||
function formatDateTime(dateStr, isEnd = false) {
|
||||
if (!dateStr) return dateStr
|
||||
if (dateStr.includes('T')) return dateStr
|
||||
return isEnd
|
||||
? `${dateStr}T23:59:59`
|
||||
: `${dateStr}T00:00:00`
|
||||
}
|
||||
|
||||
export function bookGroupCourse(params) {
|
||||
return request.post('/groupCourse/book', params)
|
||||
}
|
||||
|
||||
export function cancelBooking(bookingId, params) {
|
||||
return request.post(`/groupCourse/booking/${bookingId}/cancel`, params)
|
||||
}
|
||||
|
||||
export function getMemberBookings(memberId, options = {}) {
|
||||
return request.get(`/groupCourse/bookings/member/${memberId}`, {}, options)
|
||||
}
|
||||
|
||||
export function getActiveRecommendCourses(options = { cache: false }) {
|
||||
return request.get('/groupCourse/recommend/active', {}, options)
|
||||
}
|
||||
|
||||
export function getGroupCourseRecommendList(params = {}, options = { cache: false }) {
|
||||
return request.get('/groupCourse/recommend/list', params, options)
|
||||
}
|
||||
|
||||
/**
|
||||
* 扫码签到
|
||||
* 扫描团课二维码后签到,将预约状态更新为已出席
|
||||
* @param {number} courseId - 团课ID
|
||||
* @param {number} memberId - 会员ID
|
||||
*/
|
||||
export function qrSignInGroupCourse(courseId, memberId) {
|
||||
return request.post(`/groupCourse/signin/${memberId}`, { courseId })
|
||||
}
|
||||
|
||||
export default {
|
||||
getGroupCourseList,
|
||||
getGroupCoursePage,
|
||||
searchGroupCourse,
|
||||
getGroupCourseById,
|
||||
getGroupCourseDetail,
|
||||
createGroupCourse,
|
||||
updateGroupCourse,
|
||||
cancelGroupCourse,
|
||||
deleteGroupCourse,
|
||||
getGroupCourseTypes,
|
||||
getGroupCourseTypeById,
|
||||
getTypeLabels,
|
||||
bookGroupCourse,
|
||||
cancelBooking,
|
||||
getMemberBookings,
|
||||
getActiveRecommendCourses,
|
||||
getGroupCourseRecommendList
|
||||
}
|
||||
@@ -1,294 +0,0 @@
|
||||
import request from "@/utils/request.js"
|
||||
|
||||
/**
|
||||
* 微信小程序登录
|
||||
* @param {object} params - 登录参数 { code: string }
|
||||
*/
|
||||
export function login(params) {
|
||||
return request.post('/member/auth/miniapp/login', params)
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送短信验证码
|
||||
* @param {object} params - { phone: string }
|
||||
*/
|
||||
export function sendCode(params) {
|
||||
return request.post('/auth/phone/send-code', params)
|
||||
}
|
||||
|
||||
/**
|
||||
* 手机号验证码登录
|
||||
* @param {object} params - { phone: string, code: string }
|
||||
*/
|
||||
export function loginWithPhone(params) {
|
||||
return request.post('/auth/phone/code-login', params)
|
||||
}
|
||||
|
||||
/**
|
||||
* 手机号一键登录
|
||||
* @param {object} params - { accessToken: string, openid: string, nickname?: string, avatar?: string }
|
||||
*/
|
||||
export function oneClickLogin(params) {
|
||||
return request.post('/auth/phone/one-click-login', params)
|
||||
}
|
||||
|
||||
/**
|
||||
* 退出登录
|
||||
*/
|
||||
export function logout() {
|
||||
return request.post('/member/auth/logout')
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取签到二维码
|
||||
* @param {object} options - 请求选项 { cache: boolean, cacheTime: number }
|
||||
*/
|
||||
export function getQRCode(options = { cache: true, cacheTime: 5 * 60 * 1000 }) {
|
||||
return request.get('/checkIn/qrcode', {}, options)
|
||||
}
|
||||
|
||||
/**
|
||||
* 扫码签到
|
||||
* @param {object} params - { qrcode: string, memberId: number }
|
||||
*/
|
||||
export function checkIn(params) {
|
||||
return request.post('/checkIn', params)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取签到记录(分页)
|
||||
* @param {object} params - { page: number, size: number }
|
||||
* @param {object} options - 请求选项
|
||||
*/
|
||||
export function getCheckInRecords(params = {}, options = {}) {
|
||||
const { page = 0, size = 5 } = params
|
||||
return request.post('/checkIn/page', { page, size }, options)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户未读消息数量
|
||||
* @param {number} userId - 用户ID
|
||||
* @param {object} options - 请求选项
|
||||
*/
|
||||
export function getUnreadMessageCount(userId, options = {}) {
|
||||
return request.get(`/messages/user/${userId}/unread`, {}, options)
|
||||
}
|
||||
|
||||
// ========== 消息相关API ==========
|
||||
|
||||
/**
|
||||
* 获取用户消息列表(支持分页)
|
||||
* @param {number} userId - 用户ID
|
||||
* @param {object} params - 查询参数
|
||||
* @param {number} params.page - 页码(从0开始)
|
||||
* @param {number} params.size - 每页条数
|
||||
* @param {object} options - 请求选项
|
||||
* @returns {Promise} 消息列表
|
||||
*/
|
||||
export function getUserMessages(userId, params = {}, options = {}) {
|
||||
const { page = 0, size = 10 } = params
|
||||
return request.get(`/messages/user/${userId}/page`, { page, size }, options)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取未读消息列表(支持分页)
|
||||
* @param {number} userId - 用户ID
|
||||
* @param {object} params - 查询参数
|
||||
* @param {number} params.page - 页码(从0开始)
|
||||
* @param {number} params.size - 每页条数
|
||||
* @param {object} options - 请求选项
|
||||
* @returns {Promise} 未读消息列表
|
||||
*/
|
||||
export function getUnreadMessages(userId, params = {}, options = {}) {
|
||||
const { page = 0, size = 10 } = params
|
||||
return request.get(`/messages/user/${userId}/unread/page`, { page, size }, options)
|
||||
}
|
||||
|
||||
/**
|
||||
* 标记消息为已读
|
||||
* @param {number|string} id - 消息ID
|
||||
* @param {object} options - 请求选项
|
||||
* @returns {Promise} 操作结果
|
||||
*/
|
||||
export function markMessageAsRead(id, options = {}) {
|
||||
return request.put(`/messages/${id}/read`, {}, options)
|
||||
}
|
||||
|
||||
/**
|
||||
* 标记所有消息为已读
|
||||
* @param {number} userId - 用户ID
|
||||
* @param {object} options - 请求选项
|
||||
* @returns {Promise} 操作结果
|
||||
*/
|
||||
export function markAllMessagesAsRead(userId, options = {}) {
|
||||
return request.put(`/messages/user/${userId}/read`, {}, options)
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除消息
|
||||
* @param {number|string} id - 消息ID
|
||||
* @param {object} options - 请求选项
|
||||
* @returns {Promise} 操作结果
|
||||
*/
|
||||
export function deleteMessage(id, options = {}) {
|
||||
return request.delete(`/messages/${id}`, {}, options)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户信息(基础信息缓存)
|
||||
* @param {object} options - 请求选项 { cache: boolean, cacheTime: number }
|
||||
*/
|
||||
export function getUserInfo(options = { cache: true, cacheTime: 30 * 60 * 1000 }) {
|
||||
return request.get('/member/info', {}, options)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取会员详细信息(包含会员卡、积分等)
|
||||
* @param {object} options - 请求选项 { cache: boolean }
|
||||
*/
|
||||
export function getMemberDetail(options = { cache: false }) {
|
||||
return request.get('/member/info', {}, options)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取签到统计
|
||||
* @param {object} params - 查询参数 { startDate: string, endDate: string }
|
||||
* @param {object} options - 请求选项 { cache: boolean }
|
||||
*/
|
||||
export function getCheckInStats(params = {}, options = { cache: false }) {
|
||||
return request.get('/checkIn/statistics', params, options)
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新用户信息
|
||||
* @param {object} params - 用户信息参数
|
||||
*/
|
||||
export function updateUserInfo(params) {
|
||||
return request.put('/member/info', params)
|
||||
}
|
||||
|
||||
// ========== 系统配置相关API ==========
|
||||
|
||||
/**
|
||||
* 根据配置键获取配置值
|
||||
* @param {string} configKey - 配置键
|
||||
* @param {object} options - 请求选项
|
||||
*/
|
||||
export function getConfigByKey(configKey, options = {}) {
|
||||
return request.get(`/config/key/${configKey}`, {}, options)
|
||||
}
|
||||
|
||||
// ========== 课程相关API ==========
|
||||
|
||||
/**
|
||||
* 获取推荐课程列表
|
||||
* @param {object} options - 请求选项 { cache: boolean, cacheTime: number }
|
||||
*/
|
||||
export function getRecommendCourses(options = { cache: true, cacheTime: 10 * 60 * 1000 }) {
|
||||
return request.get('/course/recommend', {}, options)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取课程详情
|
||||
* @param {number} id - 课程ID
|
||||
* @param {object} options - 请求选项 { cache: boolean, cacheTime: number }
|
||||
*/
|
||||
export function getCourseDetail(id, options = { cache: true, cacheTime: 15 * 60 * 1000 }) {
|
||||
return request.get(`/course/${id}`, {}, options)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取团课列表(分页)
|
||||
* @param {object} params - 查询参数 { page: number, size: number, sort: string, order: string, keyword: string }
|
||||
* @param {object} options - 请求选项 { cache: boolean, cacheTime: number }
|
||||
*/
|
||||
export function getGroupCoursePage(params = {}, options = { cache: true, cacheTime: 5 * 60 * 1000 }) {
|
||||
const { page = 0, size = 10, sort = 'id', order = 'asc', keyword } = params
|
||||
return request.post('/groupCourse/page', { page, size, sort, order, keyword }, options)
|
||||
}
|
||||
|
||||
// ========== 团课预约相关API ==========
|
||||
|
||||
/**
|
||||
* 预约团课
|
||||
* @param {object} params - 预约参数
|
||||
* @param {number} params.courseId - 团课ID
|
||||
* @param {number} params.memberId - 会员ID
|
||||
*/
|
||||
export function bookGroupCourse(params) {
|
||||
return request.post('/groupCourse/book', params)
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消预约
|
||||
* @param {number} bookingId - 预约ID
|
||||
*/
|
||||
export function cancelBooking(bookingId) {
|
||||
return request.delete(`/groupCourse/book/${bookingId}`, {})
|
||||
}
|
||||
|
||||
/**
|
||||
* 团课签到
|
||||
* @param {number} memberId - 会员ID
|
||||
* @param {number} courseId - 团课ID
|
||||
*/
|
||||
export function signinGroupCourse(memberId, courseId) {
|
||||
return request.post(`/groupCourse/signin/${memberId}`, { courseId })
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询会员预约记录
|
||||
* @param {number} memberId - 会员ID
|
||||
*/
|
||||
export function getMemberBookings(memberId, options = { cache: false }) {
|
||||
return request.get(`/groupCourse/bookings/member/${memberId}`, {}, options)
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询课程预约记录
|
||||
* @param {number} courseId - 团课ID
|
||||
*/
|
||||
export function getCourseBookings(courseId, options = { cache: false }) {
|
||||
return request.get(`/groupCourse/bookings/course/${courseId}`, {}, options)
|
||||
}
|
||||
|
||||
// ========== 轮播图相关API ==========
|
||||
|
||||
/**
|
||||
* 获取启用的轮播图列表
|
||||
* @param {object} options - 请求选项 { cache: boolean, cacheTime: number }
|
||||
*/
|
||||
export function getActiveBanners(options = { cache: true, cacheTime: 10 * 60 * 1000 }) {
|
||||
return request.get('/banner/active', {}, options)
|
||||
}
|
||||
|
||||
export default {
|
||||
login,
|
||||
sendCode,
|
||||
loginWithPhone,
|
||||
oneClickLogin,
|
||||
logout,
|
||||
getQRCode,
|
||||
checkIn,
|
||||
getCheckInRecords,
|
||||
getCheckInStats,
|
||||
getUnreadMessageCount,
|
||||
getUserMessages,
|
||||
getUnreadMessages,
|
||||
markMessageAsRead,
|
||||
markAllMessagesAsRead,
|
||||
deleteMessage,
|
||||
getUserInfo,
|
||||
getMemberDetail,
|
||||
updateUserInfo,
|
||||
getConfigByKey,
|
||||
getRecommendCourses,
|
||||
getCourseDetail,
|
||||
getGroupCoursePage,
|
||||
bookGroupCourse,
|
||||
cancelBooking,
|
||||
signinGroupCourse,
|
||||
getMemberBookings,
|
||||
getCourseBookings,
|
||||
getActiveBanners
|
||||
}
|
||||
@@ -1,188 +0,0 @@
|
||||
// common/constants/routes.js
|
||||
|
||||
/** 与 pages.json 保持一致 */
|
||||
export const PAGE = {
|
||||
INDEX: '/pages/index/index',
|
||||
COURSE: '/pages/course/index',
|
||||
MEMBER: '/pages/memberInfo/memberInfo',
|
||||
BOOKING: '/pages/memberInfo/booking',
|
||||
USER_INFO: '/pages/memberInfo/userInfo',
|
||||
BODY_TEST_HOME: '/pages/memberInfo/bodyTestHome',
|
||||
BODY_TEST_CONNECT: '/pages/memberInfo/bodyTestConnect',
|
||||
BODY_TEST_MEASURING: '/pages/memberInfo/bodyTestMeasuring',
|
||||
BODY_TEST_REPORT: '/pages/memberInfo/bodyTestReport',
|
||||
BODY_TEST_HISTORY: '/pages/memberInfo/bodyTestHistory',
|
||||
BODY_TEST_COMPARE: '/pages/memberInfo/bodyTestCompare',
|
||||
BODY_TEST_SETTINGS: '/pages/memberInfo/bodyTestSettings',
|
||||
BODY_TEST_TREND: '/pages/memberInfo/bodyTestTrend',
|
||||
COURSE_LIST: '/pages/groupCourse/list',
|
||||
COURSE_DETAIL: '/pages/memberInfo/courseDetail',
|
||||
COUPON_DETAIL: '/pages/memberInfo/couponDetail',
|
||||
COUPON_CENTER: '/pages/memberInfo/couponCenter',
|
||||
POINTS_MALL: '/pages/memberInfo/pointsMall',
|
||||
POINTS_HISTORY: '/pages/memberInfo/pointsHistory',
|
||||
ONLINE_COURSE: '/pages/memberInfo/onlineCourseDetail',
|
||||
COURSE_EVALUATE: '/pages/memberInfo/courseEvaluate',
|
||||
TRAIN_SESSION: '/pages/memberInfo/trainSessionDetail',
|
||||
TRAIN_REPORT: '/pages/memberInfo/trainReport',
|
||||
COUPONS: '/pages/memberInfo/coupons',
|
||||
POINTS: '/pages/memberInfo/points',
|
||||
REFERRAL: '/pages/memberInfo/referral',
|
||||
MY_COURSES: '/pages/memberInfo/myCourses',
|
||||
CHECK_IN_HISTORY: '/pages/memberInfo/checkInHistory'
|
||||
}
|
||||
|
||||
/** 底部 TabBar 页面路径,顺序与 TabBar.vue 一致 */
|
||||
export const TAB_ROUTES = [
|
||||
PAGE.INDEX,
|
||||
PAGE.COURSE,
|
||||
PAGE.MEMBER
|
||||
]
|
||||
|
||||
const TAB_PAGES = new Set(TAB_ROUTES)
|
||||
|
||||
/** 防止 Tab 连点触发并发路由 */
|
||||
let tabNavigating = false
|
||||
|
||||
function normalizePath(url) {
|
||||
if (!url) return ''
|
||||
const path = url.split('?')[0]
|
||||
return path.startsWith('/') ? path : `/${path}`
|
||||
}
|
||||
|
||||
export function getTabIndexByRoute(route) {
|
||||
const path = normalizePath(route)
|
||||
const idx = TAB_ROUTES.indexOf(path)
|
||||
return idx >= 0 ? idx : 0
|
||||
}
|
||||
|
||||
export function getCurrentRoutePath() {
|
||||
const pages = getCurrentPages()
|
||||
if (!pages.length) return PAGE.INDEX
|
||||
const page = pages[pages.length - 1]
|
||||
const route = page.route || page.$page?.fullPath || ''
|
||||
return normalizePath(route ? `/${route}` : PAGE.INDEX)
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转到普通页面(非 TabBar 页面)
|
||||
* 使用 navigateTo,保留页面栈,可以正常返回
|
||||
*/
|
||||
export function navigateToPage(url) {
|
||||
uni.showLoading({ title: '加载中...', mask: true })
|
||||
const path = normalizePath(url)
|
||||
|
||||
// ✅ 如果目标是 TabBar 页面,不应该使用 navigateTo
|
||||
// 这种情况应该使用 switchToTabPage(会清空页面栈)
|
||||
if (TAB_PAGES.has(path)) {
|
||||
console.warn('[navigateToPage] 不应该用 navigateTo 跳转 TabBar 页面,请使用 switchToTabPage')
|
||||
uni.hideLoading()
|
||||
switchToTabPage(path)
|
||||
return
|
||||
}
|
||||
|
||||
console.log('[navigateToPage] 跳转到:', url)
|
||||
|
||||
uni.navigateTo({
|
||||
url,
|
||||
fail: (err) => {
|
||||
console.error('[navigateTo]', url, err)
|
||||
uni.hideLoading()
|
||||
// 页面栈满时降级使用 redirectTo
|
||||
if (err.errMsg && err.errMsg.includes('limit')) {
|
||||
uni.redirectTo({ url })
|
||||
} else {
|
||||
uni.showToast({ title: '页面跳转失败', icon: 'none' })
|
||||
}
|
||||
},
|
||||
complete: () => {
|
||||
// 页面已发起跳转,隐藏 loading
|
||||
// 目标页面的 onLoad/onReady 也会调用 hideLoading 做兜底
|
||||
uni.hideLoading()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转到 TabBar 页面(清空页面栈)
|
||||
* 用于从任何页面跳转到首页/课程/训练等 TabBar 页面
|
||||
*/
|
||||
export function switchToTabPage(url) {
|
||||
const path = normalizePath(url)
|
||||
if (!TAB_PAGES.has(path)) {
|
||||
console.warn('[switchToTabPage] 目标不是 TabBar 页面:', path)
|
||||
navigateToPage(url)
|
||||
return
|
||||
}
|
||||
|
||||
if (getCurrentRoutePath() === path || tabNavigating) return
|
||||
|
||||
console.log('[switchToTabPage] 跳转到 TabBar:', path)
|
||||
|
||||
tabNavigating = true
|
||||
uni.switchTab({
|
||||
url: path,
|
||||
complete: () => {
|
||||
uni.hideLoading()
|
||||
setTimeout(() => {
|
||||
tabNavigating = false
|
||||
}, 320)
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error('[switchTab]', path, err)
|
||||
uni.hideLoading()
|
||||
uni.reLaunch({
|
||||
url: path,
|
||||
complete: () => {
|
||||
uni.hideLoading()
|
||||
setTimeout(() => {
|
||||
tabNavigating = false
|
||||
}, 320)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置到 TabBar 页面(清空所有历史)
|
||||
* 用于退出登录、强制跳转等场景
|
||||
*/
|
||||
export function reLaunchToTabPage(url) {
|
||||
const path = normalizePath(url)
|
||||
console.log('[reLaunchToTabPage] 重置到:', path)
|
||||
|
||||
uni.reLaunch({
|
||||
url: path,
|
||||
fail: (err) => {
|
||||
console.error('[reLaunch]', path, err)
|
||||
uni.switchTab({ url: path })
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回上一页,如果没有上一页则跳转到指定 TabBar 页面
|
||||
*/
|
||||
export function goBackOrTab(fallbackUrl = PAGE.MEMBER) {
|
||||
const pages = getCurrentPages()
|
||||
if (pages.length > 1) {
|
||||
uni.navigateBack({ delta: 1 })
|
||||
} else {
|
||||
switchToTabPage(fallbackUrl)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 子页面返回个人中心
|
||||
*/
|
||||
export function backToMemberCenter() {
|
||||
goBackOrTab(PAGE.MEMBER)
|
||||
}
|
||||
|
||||
/**
|
||||
* 子页面返回指定 TabBar 页面
|
||||
*/
|
||||
export function backToTab(tabUrl) {
|
||||
goBackOrTab(tabUrl)
|
||||
}
|
||||
@@ -1,247 +0,0 @@
|
||||
/**
|
||||
* 登录拦截Hook
|
||||
* 用于在需要登录的操作前检查用户登录状态,未登录则弹出登录框
|
||||
*
|
||||
* 使用方式:
|
||||
* import { useLoginGuard } from '@/common/hooks/useLoginGuard.js'
|
||||
*
|
||||
* const { checkLogin, requireLogin } = useLoginGuard()
|
||||
*
|
||||
* // 方式1:检查登录状态(返回布尔值)
|
||||
* if (!checkLogin()) return
|
||||
*
|
||||
* // 方式2:需要登录才执行(推荐)
|
||||
* await requireLogin()
|
||||
* // 之后的代码只有在登录后才执行
|
||||
*
|
||||
* // 方式3:在点击事件中使用
|
||||
* async function handleClick() {
|
||||
* await requireLogin()
|
||||
* // 执行需要登录的操作
|
||||
* }
|
||||
*/
|
||||
|
||||
import { getToken } from '@/utils/request.js'
|
||||
import { loadMemberStore } from '@/common/memberInfo/store.js'
|
||||
|
||||
// 保存当前页面的登录弹窗引用
|
||||
let loginModalRef = null
|
||||
|
||||
/**
|
||||
* 注册登录弹窗组件
|
||||
* 在App.vue或页面onMounted中调用
|
||||
* @param {Object} modalRef - loginModal组件的ref
|
||||
*/
|
||||
export function registerLoginModal(modalRef) {
|
||||
loginModalRef = modalRef
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前登录状态
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
export function isLoggedIn() {
|
||||
const token = getToken()
|
||||
const isLoginStorage = uni.getStorageSync('isLogin')
|
||||
return !!(token || isLoginStorage)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取登录用户信息
|
||||
* @returns {Object|null}
|
||||
*/
|
||||
export function getLoginUser() {
|
||||
const store = loadMemberStore()
|
||||
return store.profile || null
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用登录拦截Hook
|
||||
* @returns {Object}
|
||||
*/
|
||||
export function useLoginGuard() {
|
||||
|
||||
/**
|
||||
* 检查登录状态(同步)
|
||||
* @returns {Boolean} 是否已登录
|
||||
*/
|
||||
function checkLogin() {
|
||||
return isLoggedIn()
|
||||
}
|
||||
|
||||
/**
|
||||
* 需要登录才继续执行(异步)
|
||||
* 如果未登录,弹出登录框,等待用户登录或取消
|
||||
* @param {Object} options - 配置选项
|
||||
* @param {String} options.title - 弹窗标题
|
||||
* @param {String} options.subtitle - 弹窗副标题
|
||||
* @param {Function} options.onSuccess - 登录成功回调
|
||||
* @param {Function} options.onCancel - 取消登录回调
|
||||
* @returns {Promise<Boolean>} 是否已登录(用户登录成功返回true,取消返回false)
|
||||
*/
|
||||
async function requireLogin(options = {}) {
|
||||
// 如果已经登录,直接返回true
|
||||
if (isLoggedIn()) {
|
||||
return true
|
||||
}
|
||||
|
||||
// 如果传入了onSuccess回调,先检查
|
||||
if (options.onSuccess) {
|
||||
const store = loadMemberStore()
|
||||
if (store.profile?.id) {
|
||||
options.onSuccess(store.profile)
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
// 显示登录弹窗
|
||||
return new Promise((resolve) => {
|
||||
if (!loginModalRef) {
|
||||
console.warn('[useLoginGuard] 登录弹窗未注册,请先调用 registerLoginModal')
|
||||
// 尝试跳转到登录页
|
||||
uni.navigateTo({
|
||||
url: '/pages/memberInfo/login',
|
||||
fail: () => {
|
||||
uni.showToast({
|
||||
title: '请先登录',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
})
|
||||
resolve(false)
|
||||
return
|
||||
}
|
||||
|
||||
// 保存resolve函数
|
||||
let resolvePromise = resolve
|
||||
|
||||
// 显示登录弹窗
|
||||
loginModalRef.show()
|
||||
|
||||
// 监听登录成功
|
||||
const loginSuccessHandler = (result) => {
|
||||
if (options.onSuccess) {
|
||||
options.onSuccess(result)
|
||||
}
|
||||
resolvePromise(true)
|
||||
}
|
||||
|
||||
// 监听登录失败/取消
|
||||
const closeHandler = () => {
|
||||
if (options.onCancel) {
|
||||
options.onCancel()
|
||||
}
|
||||
resolvePromise(false)
|
||||
}
|
||||
|
||||
// 注册事件监听
|
||||
uni.$once('loginModal:success', loginSuccessHandler)
|
||||
uni.$once('loginModal:close', closeHandler)
|
||||
|
||||
// 设置超时
|
||||
setTimeout(() => {
|
||||
uni.$off('loginModal:success', loginSuccessHandler)
|
||||
uni.$off('loginModal:close', closeHandler)
|
||||
}, 60000) // 60秒超时
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 安全执行函数(仅登录后执行)
|
||||
* @param {Function} fn - 要执行的函数
|
||||
* @param {Object} options - 配置选项
|
||||
* @returns {Promise<any>} 函数返回值或null
|
||||
*/
|
||||
async function safeExecute(fn, options = {}) {
|
||||
const loggedIn = await requireLogin(options)
|
||||
if (loggedIn && typeof fn === 'function') {
|
||||
return await fn()
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
/**
|
||||
* 包装需要登录的API调用
|
||||
* @param {Function} apiFn - API函数
|
||||
* @param {Array} args - API参数
|
||||
* @param {Object} options - 配置选项
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
async function callLoggedInApi(apiFn, args = [], options = {}) {
|
||||
const loggedIn = await requireLogin(options)
|
||||
if (loggedIn && typeof apiFn === 'function') {
|
||||
return await apiFn(...args)
|
||||
}
|
||||
throw new Error('用户未登录')
|
||||
}
|
||||
|
||||
return {
|
||||
checkLogin,
|
||||
requireLogin,
|
||||
safeExecute,
|
||||
callLoggedInApi,
|
||||
isLoggedIn,
|
||||
getLoginUser
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建登录拦截Mixin(用于选项式API)
|
||||
* @returns {Object}
|
||||
*/
|
||||
export function loginGuardMixin() {
|
||||
return {
|
||||
data() {
|
||||
return {
|
||||
isLogin: false
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
this.checkLoginStatus()
|
||||
},
|
||||
onShow() {
|
||||
this.checkLoginStatus()
|
||||
},
|
||||
methods: {
|
||||
checkLoginStatus() {
|
||||
this.isLogin = isLoggedIn()
|
||||
},
|
||||
|
||||
async ensureLogin() {
|
||||
if (!this.isLogin) {
|
||||
if (!loginModalRef) {
|
||||
uni.navigateTo({
|
||||
url: '/pages/memberInfo/login'
|
||||
})
|
||||
return false
|
||||
}
|
||||
loginModalRef.show()
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 路由守卫配置
|
||||
* 配置需要登录的页面路径
|
||||
*/
|
||||
export const protectedRoutes = [
|
||||
'/pages/memberInfo/memberInfo',
|
||||
'/pages/memberInfo/checkIn',
|
||||
'/pages/memberInfo/booking',
|
||||
'/pages/memberInfo/coupons',
|
||||
'/pages/memberInfo/points',
|
||||
'/pages/memberInfo/userInfo'
|
||||
]
|
||||
|
||||
/**
|
||||
* 检查当前页面是否需要登录
|
||||
* @param {String} currentPage - 当前页面路径
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
export function isProtectedRoute(currentPage) {
|
||||
return protectedRoutes.some(route => currentPage.includes(route))
|
||||
}
|
||||
@@ -1,163 +0,0 @@
|
||||
const COLORS = {
|
||||
primary: '#0B2B4B',
|
||||
accent: '#FF6B35',
|
||||
accentLight: 'rgba(255, 107, 53, 0.25)',
|
||||
grid: '#E9EDF2',
|
||||
text: '#5E6F8D',
|
||||
fill: 'rgba(26, 74, 111, 0.35)',
|
||||
line: '#1A4A6F'
|
||||
}
|
||||
|
||||
function setupCanvas(canvas, width, height, dpr) {
|
||||
canvas.width = width * dpr
|
||||
canvas.height = height * dpr
|
||||
const ctx = canvas.getContext('2d')
|
||||
ctx.scale(dpr, dpr)
|
||||
return ctx
|
||||
}
|
||||
|
||||
/** 绘制雷达图 */
|
||||
export function drawRadarChart(canvas, opts = {}) {
|
||||
if (!canvas) return
|
||||
const {
|
||||
width = 280,
|
||||
height = 240,
|
||||
labels = [],
|
||||
values = [],
|
||||
dpr = 1
|
||||
} = opts
|
||||
const ctx = setupCanvas(canvas, width, height, dpr)
|
||||
ctx.clearRect(0, 0, width, height)
|
||||
|
||||
const cx = width / 2
|
||||
const cy = height / 2 + 8
|
||||
const radius = Math.min(width, height) * 0.32
|
||||
const count = labels.length || 6
|
||||
const angleStep = (Math.PI * 2) / count
|
||||
|
||||
for (let level = 1; level <= 4; level += 1) {
|
||||
ctx.beginPath()
|
||||
const r = (radius * level) / 4
|
||||
for (let i = 0; i <= count; i += 1) {
|
||||
const angle = -Math.PI / 2 + i * angleStep
|
||||
const x = cx + r * Math.cos(angle)
|
||||
const y = cy + r * Math.sin(angle)
|
||||
if (i === 0) ctx.moveTo(x, y)
|
||||
else ctx.lineTo(x, y)
|
||||
}
|
||||
ctx.strokeStyle = COLORS.grid
|
||||
ctx.lineWidth = 1
|
||||
ctx.stroke()
|
||||
}
|
||||
|
||||
for (let i = 0; i < count; i += 1) {
|
||||
const angle = -Math.PI / 2 + i * angleStep
|
||||
ctx.beginPath()
|
||||
ctx.moveTo(cx, cy)
|
||||
ctx.lineTo(cx + radius * Math.cos(angle), cy + radius * Math.sin(angle))
|
||||
ctx.strokeStyle = COLORS.grid
|
||||
ctx.stroke()
|
||||
}
|
||||
|
||||
ctx.beginPath()
|
||||
values.forEach((val, i) => {
|
||||
const ratio = Math.min(1, Math.max(0, val / 100))
|
||||
const angle = -Math.PI / 2 + i * angleStep
|
||||
const x = cx + radius * ratio * Math.cos(angle)
|
||||
const y = cy + radius * ratio * Math.sin(angle)
|
||||
if (i === 0) ctx.moveTo(x, y)
|
||||
else ctx.lineTo(x, y)
|
||||
})
|
||||
ctx.closePath()
|
||||
ctx.fillStyle = COLORS.fill
|
||||
ctx.fill()
|
||||
ctx.strokeStyle = COLORS.accent
|
||||
ctx.lineWidth = 2
|
||||
ctx.stroke()
|
||||
|
||||
ctx.font = '11px sans-serif'
|
||||
ctx.fillStyle = COLORS.text
|
||||
ctx.textAlign = 'center'
|
||||
labels.forEach((label, i) => {
|
||||
const angle = -Math.PI / 2 + i * angleStep
|
||||
const x = cx + (radius + 18) * Math.cos(angle)
|
||||
const y = cy + (radius + 18) * Math.sin(angle) + 4
|
||||
ctx.fillText(label, x, y)
|
||||
})
|
||||
}
|
||||
|
||||
/** 绘制折线趋势图 */
|
||||
export function drawTrendChart(canvas, opts = {}) {
|
||||
if (!canvas) return
|
||||
const {
|
||||
width = 300,
|
||||
height = 160,
|
||||
points = [],
|
||||
dpr = 1,
|
||||
unit = ''
|
||||
} = opts
|
||||
const ctx = setupCanvas(canvas, width, height, dpr)
|
||||
ctx.clearRect(0, 0, width, height)
|
||||
|
||||
if (!points.length) {
|
||||
ctx.fillStyle = COLORS.text
|
||||
ctx.font = '13px sans-serif'
|
||||
ctx.textAlign = 'center'
|
||||
ctx.fillText('暂无趋势数据', width / 2, height / 2)
|
||||
return
|
||||
}
|
||||
|
||||
const pad = { top: 16, right: 12, bottom: 28, left: 12 }
|
||||
const chartW = width - pad.left - pad.right
|
||||
const chartH = height - pad.top - pad.bottom
|
||||
const values = points.map((p) => p.value)
|
||||
const min = Math.min(...values) * 0.95
|
||||
const max = Math.max(...values) * 1.05
|
||||
const range = max - min || 1
|
||||
|
||||
ctx.strokeStyle = COLORS.grid
|
||||
ctx.lineWidth = 1
|
||||
for (let i = 0; i <= 3; i += 1) {
|
||||
const y = pad.top + (chartH * i) / 3
|
||||
ctx.beginPath()
|
||||
ctx.moveTo(pad.left, y)
|
||||
ctx.lineTo(width - pad.right, y)
|
||||
ctx.stroke()
|
||||
}
|
||||
|
||||
const coords = points.map((p, i) => ({
|
||||
x: pad.left + (chartW * i) / Math.max(1, points.length - 1),
|
||||
y: pad.top + chartH - ((p.value - min) / range) * chartH
|
||||
}))
|
||||
|
||||
ctx.beginPath()
|
||||
coords.forEach((pt, i) => {
|
||||
if (i === 0) ctx.moveTo(pt.x, pt.y)
|
||||
else ctx.lineTo(pt.x, pt.y)
|
||||
})
|
||||
ctx.strokeStyle = COLORS.line
|
||||
ctx.lineWidth = 2
|
||||
ctx.stroke()
|
||||
|
||||
coords.forEach((pt, i) => {
|
||||
ctx.beginPath()
|
||||
ctx.arc(pt.x, pt.y, 4, 0, Math.PI * 2)
|
||||
ctx.fillStyle = COLORS.accent
|
||||
ctx.fill()
|
||||
ctx.strokeStyle = '#fff'
|
||||
ctx.lineWidth = 1.5
|
||||
ctx.stroke()
|
||||
|
||||
ctx.fillStyle = COLORS.text
|
||||
ctx.font = '10px sans-serif'
|
||||
ctx.textAlign = 'center'
|
||||
ctx.fillText(points[i].label, pt.x, height - 8)
|
||||
})
|
||||
|
||||
if (unit) {
|
||||
ctx.fillStyle = COLORS.text
|
||||
ctx.font = '10px sans-serif'
|
||||
ctx.textAlign = 'left'
|
||||
ctx.fillText(unit, pad.left, pad.top - 2)
|
||||
}
|
||||
}
|
||||
@@ -1,286 +0,0 @@
|
||||
function formatRecordTime(date) {
|
||||
const y = date.getFullYear()
|
||||
const m = String(date.getMonth() + 1).padStart(2, '0')
|
||||
const d = String(date.getDate()).padStart(2, '0')
|
||||
const h = String(date.getHours()).padStart(2, '0')
|
||||
const min = String(date.getMinutes()).padStart(2, '0')
|
||||
return `${y}-${m}-${d} ${h}:${min}`
|
||||
}
|
||||
|
||||
function formatIsoDate(date) {
|
||||
const y = date.getFullYear()
|
||||
const m = String(date.getMonth() + 1).padStart(2, '0')
|
||||
const d = String(date.getDate()).padStart(2, '0')
|
||||
return `${y}-${m}-${d}`
|
||||
}
|
||||
|
||||
function formatTime(date) {
|
||||
const h = String(date.getHours()).padStart(2, '0')
|
||||
const min = String(date.getMinutes()).padStart(2, '0')
|
||||
return `${h}:${min}`
|
||||
}
|
||||
|
||||
export function getDefaultBodyTestState() {
|
||||
return {
|
||||
settings: {},
|
||||
device: { connected: false, battery: 80 },
|
||||
records: []
|
||||
}
|
||||
}
|
||||
|
||||
export function mergeBodyTestState(saved) {
|
||||
const defaults = getDefaultBodyTestState()
|
||||
if (!saved) return defaults
|
||||
return {
|
||||
settings: { ...defaults.settings, ...(saved.settings || {}) },
|
||||
device: { ...defaults.device, ...(saved.device || {}) },
|
||||
records: saved.records?.length ? saved.records : defaults.records
|
||||
}
|
||||
}
|
||||
|
||||
export function getLatestBodyTestRecord(store) {
|
||||
const records = store.bodyTest?.records || []
|
||||
return records.length ? { ...records[0] } : null
|
||||
}
|
||||
|
||||
export function getBodyTestRecordById(store, id) {
|
||||
const numId = Number(id)
|
||||
const record = (store.bodyTest?.records || []).find((item) => item.id === numId)
|
||||
return record ? { ...record } : null
|
||||
}
|
||||
|
||||
export function getBodyTestHistory(store, year) {
|
||||
let list = (store.bodyTest?.records || []).map((item) => ({ ...item }))
|
||||
if (year && year !== 'all') {
|
||||
list = list.filter((r) => r.date.startsWith(String(year)))
|
||||
}
|
||||
return list
|
||||
}
|
||||
|
||||
export function getBodyTestChangeBadge(record, previous) {
|
||||
if (!previous?.metrics || !record?.metrics) return null
|
||||
const diff = Math.round((record.metrics.bodyFat - previous.metrics.bodyFat) * 10) / 10
|
||||
if (diff === 0) return null
|
||||
const sign = diff > 0 ? '+' : ''
|
||||
return { key: 'bodyFat', text: `体脂率${sign}${diff}%`, good: diff < 0 }
|
||||
}
|
||||
|
||||
export function getBodyTestYears(store) {
|
||||
const years = new Set((store.bodyTest?.records || []).map((r) => r.date.slice(0, 4)))
|
||||
return ['all', ...Array.from(years).sort().reverse()]
|
||||
}
|
||||
|
||||
export function computeGrade(score) {
|
||||
if (score >= 90) return { grade: 'A', gradeLabel: '优秀' }
|
||||
if (score >= 80) return { grade: 'B+', gradeLabel: '良好' }
|
||||
if (score >= 70) return { grade: 'B', gradeLabel: '中等' }
|
||||
if (score >= 60) return { grade: 'C', gradeLabel: '一般' }
|
||||
return { grade: 'D', gradeLabel: '需改善' }
|
||||
}
|
||||
|
||||
export function computeScore(metrics) {
|
||||
const bmi = metrics.bmi || 22
|
||||
const bodyFat = metrics.bodyFat || 25
|
||||
const muscle = metrics.muscleMass || 22
|
||||
const bmiScore = bmi >= 18.5 && bmi <= 24 ? 90 : bmi >= 17 && bmi <= 27 ? 75 : 60
|
||||
const fatScore = bodyFat <= 22 ? 92 : bodyFat <= 26 ? 80 : bodyFat <= 30 ? 68 : 55
|
||||
const muscleScore = muscle >= 22 ? 88 : muscle >= 20 ? 76 : 62
|
||||
return Math.round((bmiScore + fatScore + muscleScore) / 3)
|
||||
}
|
||||
|
||||
export function computeChanges(current, previous) {
|
||||
if (!previous?.metrics) return {}
|
||||
const keys = ['weight', 'bmi', 'bodyFat', 'muscleMass', 'visceralFat', 'bmr', 'bodyWater', 'boneMass']
|
||||
const changes = {}
|
||||
keys.forEach((key) => {
|
||||
const cur = Number(current.metrics[key])
|
||||
const prev = Number(previous.metrics[key])
|
||||
if (Number.isFinite(cur) && Number.isFinite(prev)) {
|
||||
const diff = Math.round((cur - prev) * 10) / 10
|
||||
changes[key] = diff
|
||||
}
|
||||
})
|
||||
return changes
|
||||
}
|
||||
|
||||
export function formatChangeValue(key, diff, unitSystem = 'metric') {
|
||||
if (diff === undefined || diff === null) return '--'
|
||||
const sign = diff > 0 ? '+' : ''
|
||||
const units = {
|
||||
weight: unitSystem === 'metric' ? 'kg' : 'lb',
|
||||
bodyFat: '%',
|
||||
muscleMass: 'kg',
|
||||
bmi: '',
|
||||
visceralFat: '级',
|
||||
bmr: 'kcal',
|
||||
bodyWater: '%',
|
||||
boneMass: 'kg'
|
||||
}
|
||||
const unit = units[key] || ''
|
||||
return `${sign}${diff}${unit}`
|
||||
}
|
||||
|
||||
export function buildBodyReportSummary(record, previous) {
|
||||
if (!record) {
|
||||
return {
|
||||
date: '--',
|
||||
weight: '--',
|
||||
bmi: '--',
|
||||
bodyFat: '--',
|
||||
bmr: '--',
|
||||
status: '暂无数据',
|
||||
change: '--'
|
||||
}
|
||||
}
|
||||
const changes = computeChanges(record, previous)
|
||||
const weightChange = changes.weight
|
||||
let changeText = '--'
|
||||
if (weightChange !== undefined) {
|
||||
const sign = weightChange > 0 ? '+' : ''
|
||||
changeText = `${sign}${weightChange}kg`
|
||||
}
|
||||
return {
|
||||
date: record.date,
|
||||
weight: String(record.metrics.weight),
|
||||
bmi: String(record.metrics.bmi),
|
||||
bodyFat: `${record.metrics.bodyFat}%`,
|
||||
bmr: String(record.metrics.bmr),
|
||||
status: record.status,
|
||||
change: changeText,
|
||||
recordId: record.id
|
||||
}
|
||||
}
|
||||
|
||||
export function getBodyTestTrendData(store, metricKey, limit = 6) {
|
||||
const records = [...(store.bodyTest?.records || [])].reverse().slice(-limit)
|
||||
return records.map((item) => ({
|
||||
id: item.id,
|
||||
date: item.date,
|
||||
label: item.date.slice(5),
|
||||
value: Number(item.metrics[metricKey]) || 0
|
||||
}))
|
||||
}
|
||||
|
||||
function getMetricDefs() {
|
||||
return [
|
||||
{ key: 'weight', label: '体重' },
|
||||
{ key: 'bmi', label: 'BMI' },
|
||||
{ key: 'bodyFat', label: '体脂率' },
|
||||
{ key: 'muscleMass', label: '肌肉量' },
|
||||
{ key: 'visceralFat', label: '内脏脂肪' },
|
||||
{ key: 'bmr', label: '基础代谢' }
|
||||
]
|
||||
}
|
||||
|
||||
export function getCompareData(store, idA, idB) {
|
||||
const a = getBodyTestRecordById(store, idA)
|
||||
const b = getBodyTestRecordById(store, idB)
|
||||
if (!a || !b) return null
|
||||
const metricDefs = getMetricDefs()
|
||||
const keys = ['weight', 'bmi', 'bodyFat', 'muscleMass', 'visceralFat', 'bmr']
|
||||
const metrics = keys.map((key) => ({
|
||||
key,
|
||||
label: metricDefs.find((m) => m.key === key)?.label || key,
|
||||
valueA: a.metrics[key],
|
||||
valueB: b.metrics[key],
|
||||
diff: Math.round((a.metrics[key] - b.metrics[key]) * 10) / 10
|
||||
}))
|
||||
return { recordA: a, recordB: b, metrics }
|
||||
}
|
||||
|
||||
export function getRecommendedCourses(record) {
|
||||
return []
|
||||
}
|
||||
|
||||
export function updateBodyTestSettings(store, patch) {
|
||||
store.bodyTest.settings = { ...store.bodyTest.settings, ...patch }
|
||||
return store
|
||||
}
|
||||
|
||||
export function connectBodyTestDevice(store) {
|
||||
store.bodyTest.device = {
|
||||
...store.bodyTest.device,
|
||||
connected: true,
|
||||
battery: Math.min(100, (store.bodyTest.device.battery || 80) + Math.floor(Math.random() * 5)),
|
||||
lastConnected: formatRecordTime(new Date())
|
||||
}
|
||||
return store
|
||||
}
|
||||
|
||||
export function disconnectBodyTestDevice(store) {
|
||||
store.bodyTest.device = { ...store.bodyTest.device, connected: false }
|
||||
return store
|
||||
}
|
||||
|
||||
function nextRecordId(records) {
|
||||
return (records || []).reduce((max, item) => Math.max(max, item.id || 0), 0) + 1
|
||||
}
|
||||
|
||||
/** 模拟一次完整体测并写入记录 */
|
||||
export function saveSimulatedBodyTestRecord(store, finalMetrics) {
|
||||
const now = new Date()
|
||||
const previous = getLatestBodyTestRecord(store)
|
||||
const metrics = { ...finalMetrics }
|
||||
const heightCm = Number(store.profile?.height) || 165
|
||||
const heightM = heightCm / 100
|
||||
metrics.bmi = Math.round((metrics.weight / (heightM * heightM)) * 10) / 10
|
||||
|
||||
const score = computeScore(metrics)
|
||||
const { grade, gradeLabel } = computeGrade(score)
|
||||
const status = score >= 80 ? '比较健康' : score >= 70 ? '需关注' : '建议改善'
|
||||
|
||||
const radar = {
|
||||
weight: Math.min(95, Math.round(score * 0.9 + Math.random() * 5)),
|
||||
bodyFat: Math.min(95, Math.round(100 - metrics.bodyFat * 2.5)),
|
||||
muscle: Math.min(95, Math.round(metrics.muscleMass * 3.2)),
|
||||
bone: Math.min(95, Math.round(metrics.boneMass * 32)),
|
||||
water: Math.min(95, Math.round(metrics.bodyWater * 1.4)),
|
||||
bmr: Math.min(95, Math.round(metrics.bmr / 16))
|
||||
}
|
||||
|
||||
const record = {
|
||||
id: nextRecordId(store.bodyTest.records),
|
||||
date: formatIsoDate(now),
|
||||
time: formatTime(now),
|
||||
score,
|
||||
grade,
|
||||
gradeLabel,
|
||||
status,
|
||||
metrics,
|
||||
radar,
|
||||
bodySegments: [],
|
||||
advice: [],
|
||||
recommendedCourseIds: []
|
||||
}
|
||||
|
||||
if (previous) {
|
||||
record.changes = computeChanges(record, previous)
|
||||
}
|
||||
|
||||
store.bodyTest.records.unshift(record)
|
||||
store.bodyReport = buildBodyReportSummary(record, previous)
|
||||
return record
|
||||
}
|
||||
|
||||
/** 测量过程实时数据插值 */
|
||||
export function interpolateMeasuringMetrics(progress, profile) {
|
||||
const baseWeight = Number(profile?.weight) || 64
|
||||
const target = {
|
||||
weight: baseWeight - 0.3 + Math.random() * 0.2,
|
||||
bodyFat: 24.5 + Math.random() * 0.8,
|
||||
muscleMass: 22.4 + Math.random() * 0.3,
|
||||
visceralFat: 6,
|
||||
bmr: 1380 + Math.floor(Math.random() * 20),
|
||||
bodyWater: 52.5 + Math.random(),
|
||||
boneMass: 2.4,
|
||||
protein: 16.2
|
||||
}
|
||||
const ratio = Math.min(1, progress / 100)
|
||||
return {
|
||||
weight: Math.round((baseWeight + (target.weight - baseWeight) * ratio) * 10) / 10,
|
||||
bodyFat: Math.round((26 + (target.bodyFat - 26) * ratio) * 10) / 10,
|
||||
muscleMass: Math.round((21.5 + (target.muscleMass - 21.5) * ratio) * 10) / 10,
|
||||
bmr: Math.round(1340 + (target.bmr - 1340) * ratio),
|
||||
bodyWater: Math.round((51 + (target.bodyWater - 51) * ratio) * 10) / 10
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user