/** * 员工模型 * @file Employee.js * @description 员工数据模型 */ const { DataTypes } = require('sequelize'); const { sequelize } = require('../config/database'); const Employee = sequelize.define('Employee', { id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true }, name: { type: DataTypes.STRING(50), allowNull: false, comment: '员工姓名' }, employee_id: { type: DataTypes.STRING(20), allowNull: false, unique: true, comment: '员工编号' }, department_id: { type: DataTypes.INTEGER, allowNull: false, comment: '部门ID' }, position_id: { type: DataTypes.INTEGER, allowNull: false, comment: '职位ID' }, phone: { type: DataTypes.STRING(20), allowNull: true, comment: '联系电话' }, email: { type: DataTypes.STRING(100), allowNull: true, comment: '邮箱地址' }, hire_date: { type: DataTypes.DATEONLY, allowNull: false, comment: '入职日期' }, salary: { type: DataTypes.BIGINT, allowNull: false, defaultValue: 0, comment: '薪资(分)' }, status: { type: DataTypes.ENUM('active', 'inactive', 'resigned'), 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_employees', modelName: 'Employee', timestamps: true, createdAt: 'created_at', updatedAt: 'updated_at' }); module.exports = Employee;