import { BelongsTo, Column, DataType, ForeignKey, Model, Table } from 'sequelize-typescript'; import { ExerciseCategory } from './exercise-category.model'; @Table({ tableName: 't_exercises', underscored: true, }) export class Exercise extends Model { @Column({ type: DataType.STRING, primaryKey: true, comment: '动作唯一键(英文/下划线)', }) declare key: string; @Column({ type: DataType.STRING, allowNull: false, comment: '动作名称' }) declare name: string; @Column({ type: DataType.STRING, allowNull: false, comment: '中文分类名(冗余,便于展示)' }) declare categoryName: string; @Column({ type: DataType.TEXT, allowNull: true, comment: '动作描述' }) declare description: string; @Column({ type: DataType.TEXT, allowNull: false, comment: '主要锻炼肌肉群' }) declare targetMuscleGroups: string; @Column({ type: DataType.STRING, allowNull: true, comment: '器械名称(器械普拉提专用)' }) declare equipmentName: string; @Column({ type: DataType.INTEGER, allowNull: true, comment: '入门级别建议练习次数' }) declare beginnerReps: number; @Column({ type: DataType.INTEGER, allowNull: true, comment: '入门级别建议组数' }) declare beginnerSets: number; @Column({ type: DataType.INTEGER, allowNull: true, comment: '呼吸循环次数(替代普通次数)' }) declare breathingCycles: number; @Column({ type: DataType.INTEGER, allowNull: true, comment: '保持时间(秒)' }) declare holdDuration: number; @Column({ type: DataType.STRING, allowNull: true, comment: '特殊说明(如每侧、前后各等)' }) declare specialInstructions: string; @ForeignKey(() => ExerciseCategory) @Column({ type: DataType.STRING, allowNull: false, comment: '分类键' }) declare categoryKey: string; @BelongsTo(() => ExerciseCategory, { foreignKey: 'categoryKey', targetKey: 'key' }) declare category: ExerciseCategory; @Column({ type: DataType.INTEGER, allowNull: false, defaultValue: 0, comment: '排序(分类内)' }) declare sortOrder: number; @Column({ type: DataType.DATE, defaultValue: DataType.NOW }) declare createdAt: Date; @Column({ type: DataType.DATE, defaultValue: DataType.NOW }) declare updatedAt: Date; }