优化训练计划项目管理功能

- 更新训练项目文档,增加与动作库的智能关联和简化接口操作的说明
- 移除批量操作接口,专注于单项操作,提升用户体验
- 增强数据模型,确保训练项目与动作库的关联性,提升数据一致性和查询性能
- 更新服务逻辑,支持动作存在性验证,确保数据的准确性和完整性
This commit is contained in:
richarjiang
2025-08-15 11:37:11 +08:00
parent 8edc27b0ad
commit bea71af5d3
8 changed files with 565 additions and 448 deletions

View File

@@ -1,5 +1,6 @@
import { Column, DataType, ForeignKey, Model, PrimaryKey, Table, BelongsTo } from 'sequelize-typescript';
import { TrainingPlan } from './training-plan.model';
import { Exercise } from '../../exercises/models/exercise.model';
export type ScheduleItemType = 'exercise' | 'rest' | 'note';
@@ -25,15 +26,17 @@ export class ScheduleExercise extends Model {
@Column({ type: DataType.STRING, allowNull: false })
declare userId: string;
@Column({ type: DataType.STRING, allowNull: false, comment: '项目标识key' })
declare key: string;
// 关联到动作库仅exercise类型需要
@ForeignKey(() => Exercise)
@Column({ type: DataType.STRING, allowNull: true, comment: '关联的动作key仅exercise类型' })
declare exerciseKey: string;
@BelongsTo(() => Exercise, { foreignKey: 'exerciseKey', targetKey: 'key' })
declare exercise: Exercise;
@Column({ type: DataType.STRING, allowNull: false, comment: '项目名称' })
declare name: string;
@Column({ type: DataType.STRING, allowNull: true, comment: '项目分类' })
declare category: string;
@Column({ type: DataType.INTEGER, allowNull: true, comment: '组数' })
declare sets: number;