- 在控制器中新增更新和激活训练计划的API - 在服务中实现相应的更新和激活逻辑,支持检查用户的激活计划 - 在模型中添加isActive字段以标识训练计划的激活状态 - 更新DTO以支持训练计划的更新操作
64 lines
1.9 KiB
TypeScript
64 lines
1.9 KiB
TypeScript
import { Column, DataType, Index, Model, PrimaryKey, Table } from 'sequelize-typescript';
|
|
|
|
export type PlanMode = 'daysOfWeek' | 'sessionsPerWeek';
|
|
export type PlanGoal = 'postpartum_recovery' | 'fat_loss' | 'posture_correction' | 'core_strength' | 'flexibility' | 'rehab' | 'stress_relief' | '';
|
|
|
|
@Table({
|
|
tableName: 't_training_plans',
|
|
underscored: true,
|
|
})
|
|
export class TrainingPlan extends Model {
|
|
@PrimaryKey
|
|
@Column({
|
|
type: DataType.UUID,
|
|
defaultValue: DataType.UUIDV4,
|
|
})
|
|
declare id: string;
|
|
|
|
|
|
@Column({ type: DataType.BOOLEAN, defaultValue: false, comment: '是否激活' })
|
|
declare isActive: boolean;
|
|
|
|
@Column({ type: DataType.STRING, allowNull: false })
|
|
declare userId: string;
|
|
|
|
// 计划名称
|
|
@Column({ type: DataType.STRING, allowNull: true })
|
|
declare name: string;
|
|
|
|
@Column({ type: DataType.DATE, allowNull: false })
|
|
declare createdAt: Date;
|
|
|
|
@Column({ type: DataType.DATE, allowNull: false })
|
|
declare startDate: Date;
|
|
|
|
@Column({ type: DataType.ENUM('daysOfWeek', 'sessionsPerWeek'), allowNull: false })
|
|
declare mode: PlanMode;
|
|
|
|
@Column({ type: DataType.JSON, allowNull: false, comment: '0-6' })
|
|
declare daysOfWeek: number[];
|
|
|
|
@Column({ type: DataType.INTEGER, allowNull: false })
|
|
declare sessionsPerWeek: number;
|
|
|
|
@Column({
|
|
type: DataType.ENUM('postpartum_recovery', 'fat_loss', 'posture_correction', 'core_strength', 'flexibility', 'rehab', 'stress_relief', ''),
|
|
allowNull: false,
|
|
})
|
|
declare goal: PlanGoal;
|
|
|
|
@Column({ type: DataType.FLOAT, allowNull: true })
|
|
declare startWeightKg: number | null;
|
|
|
|
@Column({ type: DataType.ENUM('morning', 'noon', 'evening', ''), allowNull: false, defaultValue: '' })
|
|
declare preferredTimeOfDay: 'morning' | 'noon' | 'evening' | '';
|
|
|
|
@Column({ type: DataType.DATE, defaultValue: DataType.NOW })
|
|
declare updatedAt: Date;
|
|
|
|
@Column({ type: DataType.BOOLEAN, defaultValue: false })
|
|
declare deleted: boolean;
|
|
}
|
|
|
|
|