/**
 * 职位模型
 * @file Position.js
 * @description 职位数据模型
 */
const { DataTypes } = require('sequelize');
const { sequelize } = require('../config/database');

const Position = sequelize.define('Position', {
  id: {
    type: DataTypes.INTEGER,
    primaryKey: true,
    autoIncrement: true
  },
  name: {
    type: DataTypes.STRING(100),
    allowNull: false,
    comment: '职位名称'
  },
  level: {
    type: DataTypes.INTEGER,
    allowNull: false,
    comment: '职位级别'
  },
  description: {
    type: DataTypes.TEXT,
    allowNull: true,
    comment: '职位描述'
  },
  min_salary: {
    type: DataTypes.BIGINT,
    allowNull: false,
    defaultValue: 0,
    comment: '最低薪资（分）'
  },
  max_salary: {
    type: DataTypes.BIGINT,
    allowNull: false,
    defaultValue: 0,
    comment: '最高薪资（分）'
  },
  status: {
    type: DataTypes.ENUM('active', 'inactive'),
    allowNull: false,
    defaultValue: 'active',
    comment: '职位状态'
  },
  created_at: {
    type: DataTypes.DATE,
    allowNull: false,
    defaultValue: DataTypes.NOW
  },
  updated_at: {
    type: DataTypes.DATE,
    allowNull: false,
    defaultValue: DataTypes.NOW
  }
}, {
  sequelize,
  tableName: 'bank_positions',
  modelName: 'Position',
  timestamps: true,
  createdAt: 'created_at',
  updatedAt: 'updated_at'
});

module.exports = Position;
