const { DataTypes } = require('sequelize');
const BaseModel = require('./BaseModel');

/**
 * 牛只品种模型
 */
class CattleType extends BaseModel {
  static init(sequelize) {
    return super.init({
      id: {
        type: DataTypes.INTEGER,
        primaryKey: true,
        comment: '品种ID'
      },
      name: {
        type: DataTypes.STRING(100),
        allowNull: false,
        comment: '品种名称'
      },
      description: {
        type: DataTypes.TEXT,
        allowNull: true,
        comment: '品种描述'
      }
    }, {
      sequelize,
      modelName: 'CattleType',
      tableName: 'cattle_type',
      comment: '牛只品种表',
      timestamps: true,
      createdAt: 'created_at',
      updatedAt: 'updated_at'
    });
  }

  // 关联关系已在 models/index.js 中定义
  // static associate(models) {
  //   // 一个品种可以有多个牛只
  //   this.hasMany(models.IotCattle, {
  //     foreignKey: 'varieties',
  //     as: 'cattle'
  //   });
  // }
}

module.exports = CattleType;
