新增团课类型,类型标签,以及相关功能 #27
@@ -26,11 +26,32 @@
|
||||
- [查询会员预约记录](#查询会员预约记录)
|
||||
- [查询预约详情](#查询预约详情)
|
||||
- [查询课程预约记录](#查询课程预约记录)
|
||||
5. [数据模型](#数据模型)
|
||||
5. [团课类型管理接口](#团课类型管理接口)
|
||||
- [获取所有团课类型](#获取所有团课类型)
|
||||
- [根据ID获取团课类型](#根据ID获取团课类型)
|
||||
- [搜索团课类型](#搜索团课类型)
|
||||
- [根据分类获取团课类型](#根据分类获取团课类型)
|
||||
- [获取所有分类](#获取所有分类)
|
||||
- [创建团课类型](#创建团课类型)
|
||||
- [更新团课类型](#更新团课类型)
|
||||
- [删除团课类型](#删除团课类型)
|
||||
6. [团课标签管理接口](#团课标签管理接口)
|
||||
- [获取所有标签](#获取所有标签)
|
||||
- [根据ID获取标签](#根据ID获取标签)
|
||||
- [搜索标签](#搜索标签)
|
||||
- [获取类型的标签](#获取类型的标签)
|
||||
- [创建标签](#创建标签)
|
||||
- [更新标签](#更新标签)
|
||||
- [删除标签](#删除标签)
|
||||
- [为类型添加标签](#为类型添加标签)
|
||||
- [从类型移除标签](#从类型移除标签)
|
||||
- [清空类型标签](#清空类型标签)
|
||||
7. [数据模型](#数据模型)
|
||||
- [GroupCourse(团课)](#GroupCourse团课)
|
||||
- [GroupCourseBooking(团课预约)](#GroupCourseBooking团课预约)
|
||||
6. [状态码说明](#状态码说明)
|
||||
7. [业务规则](#业务规则)
|
||||
- [GroupCourseType(团课类型)](#GroupCourseType团课类型)
|
||||
7. [状态码说明](#状态码说明)
|
||||
8. [业务规则](#业务规则)
|
||||
|
||||
---
|
||||
|
||||
@@ -178,6 +199,78 @@
|
||||
|
||||
---
|
||||
|
||||
### 根据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
|
||||
{}
|
||||
```
|
||||
|
||||
**说明**: 此接口返回团课的完整信息,包括:
|
||||
- 团课基础信息
|
||||
- 团课对应的类型信息(包含基础难度、综合难度、难度等级等)
|
||||
- 该类型的所有标签信息
|
||||
|
||||
---
|
||||
|
||||
### 创建团课
|
||||
|
||||
| 属性 | 值 |
|
||||
@@ -628,6 +721,625 @@
|
||||
|
||||
---
|
||||
|
||||
## 团课类型管理接口
|
||||
|
||||
### 获取所有团课类型
|
||||
|
||||
| 属性 | 值 |
|
||||
|------|-----|
|
||||
| **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(团课)
|
||||
@@ -675,6 +1387,84 @@
|
||||
| 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. **课程强度系数**:高强度课程难度加成
|
||||
|
||||
---
|
||||
|
||||
## 状态码说明
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
一、基础有氧与热身(难度 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(需要数月甚至数年拉伸)
|
||||
@@ -35,6 +35,11 @@
|
||||
<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,8 +4,10 @@ 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;
|
||||
|
||||
@@ -124,4 +126,33 @@ 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
@@ -0,0 +1,27 @@
|
||||
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
@@ -0,0 +1,38 @@
|
||||
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,4 +36,6 @@ 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
@@ -0,0 +1,32 @@
|
||||
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
@@ -0,0 +1,43 @@
|
||||
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
@@ -0,0 +1,254 @@
|
||||
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
@@ -0,0 +1,113 @@
|
||||
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
@@ -0,0 +1,45 @@
|
||||
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
@@ -0,0 +1,33 @@
|
||||
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
@@ -0,0 +1,57 @@
|
||||
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
@@ -0,0 +1,217 @@
|
||||
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,6 +4,7 @@ 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;
|
||||
@@ -76,6 +77,14 @@ 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
@@ -0,0 +1,137 @@
|
||||
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
@@ -0,0 +1,32 @@
|
||||
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,4 +27,6 @@ public interface IGroupCourseRepository {
|
||||
Mono<Void> deleteById(Long id);
|
||||
|
||||
Mono<GroupCourse> updateCurrentMembers(Long id, Integer delta);
|
||||
|
||||
Flux<GroupCourse> findByCourseType(Long courseType);
|
||||
}
|
||||
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
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
@@ -0,0 +1,161 @@
|
||||
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,4 +178,10 @@ public class GroupCourseRepository implements IGroupCourseRepository {
|
||||
return Mono.empty();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<GroupCourse> findByCourseType(Long courseType) {
|
||||
return groupCourseDao.findByCourseTypeAndDeletedAtIsNull(courseType)
|
||||
.map(groupCourseConverter::toDomain);
|
||||
}
|
||||
}
|
||||
|
||||
+132
@@ -0,0 +1,132 @@
|
||||
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
@@ -0,0 +1,30 @@
|
||||
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,11 +4,13 @@ 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
@@ -0,0 +1,32 @@
|
||||
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
@@ -0,0 +1,112 @@
|
||||
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()));
|
||||
}
|
||||
}
|
||||
+101
-1
@@ -4,13 +4,18 @@ 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;
|
||||
@@ -33,6 +38,8 @@ 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;
|
||||
@@ -41,12 +48,15 @@ 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,
|
||||
@@ -54,6 +64,8 @@ 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;
|
||||
@@ -61,6 +73,93 @@ 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;
|
||||
@@ -391,6 +490,7 @@ public class GroupCourseService implements IGroupCourseService {
|
||||
|
||||
private Mono<Void> clearCache() {
|
||||
return redisUtil.deleteByPattern(CACHE_KEY_PREFIX + "*")
|
||||
.then(redisUtil.deleteByPattern(CACHE_KEY_ID_PREFIX + "*")).then();
|
||||
.then(redisUtil.deleteByPattern(CACHE_KEY_ID_PREFIX + "*"))
|
||||
.then(redisUtil.deleteByPattern(CACHE_KEY_DETAIL_PREFIX + "*")).then();
|
||||
}
|
||||
}
|
||||
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
+223
-152
File diff suppressed because one or more lines are too long
+35
-6
@@ -6,6 +6,8 @@ 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;
|
||||
@@ -69,6 +71,8 @@ public class SystemRouter {
|
||||
MemberCardTransactionHandler memberCardTransactionHandler,
|
||||
GroupCourseHandler groupCourseHandler,
|
||||
GroupCourseBookingHandler groupCourseBookingHandler,
|
||||
GroupCourseTypeHandler groupCourseTypeHandler,
|
||||
CourseLabelHandler courseLabelHandler,
|
||||
CheckInHandler checkInHandler,
|
||||
DataStatisticsHandler dataStatisticsHandler) {
|
||||
|
||||
@@ -265,12 +269,28 @@ public class SystemRouter {
|
||||
// ===== 团课课程管理 =====
|
||||
.GET("/api/groupCourse/list", groupCourseHandler::getAllGroupCourse)
|
||||
.POST("/api/groupCourse/page", groupCourseHandler::getGroupCoursesByPage)
|
||||
.GET("/api/groupCourse/{id}", groupCourseHandler::getGroupCourseById)
|
||||
.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)
|
||||
|
||||
// ===== 团课类型管理 =====
|
||||
.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)
|
||||
@@ -278,6 +298,15 @@ public class SystemRouter {
|
||||
.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)
|
||||
|
||||
// ========= 签到模块路由 ==========
|
||||
// ===== 签到核心功能 =====
|
||||
|
||||
+76
@@ -0,0 +1,76 @@
|
||||
-- ============================================
|
||||
-- 团课类型表
|
||||
-- ============================================
|
||||
|
||||
-- 团课类型表
|
||||
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
@@ -0,0 +1,73 @@
|
||||
-- ============================================
|
||||
-- 团课标签相关表
|
||||
-- ============================================
|
||||
|
||||
-- 团课标签表
|
||||
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;
|
||||
Reference in New Issue
Block a user