const { DataTypes } = require('sequelize');
const bcrypt = require('bcryptjs');
const db = require('../config/db.config');
const Employees = db.define('Employees', {
    id: {
        type: DataTypes.INTEGER,
        allowNull: false,
        autoIncrement: true,
        primaryKey: true
    },
    sn: {
        type: DataTypes.STRING(50),
        allowNull: false,
        unique: true
    },
    name: {
        type: DataTypes.STRING(100),
        allowNull: false
    },
    email: {
        type: DataTypes.STRING(100),
        allowNull: true,
        unique: true
    },
    mobile: {
        type: DataTypes.STRING(20),
        allowNull: true
    },
    cardNo: {
        type: DataTypes.STRING(50),
        allowNull: true
    },
    idCard: {
        type: DataTypes.STRING(50),
        allowNull: true
    },
    type: {
        type: DataTypes.TINYINT,
        allowNull: false,
        defaultValue: 1
    },  // 1=Employee 2=Visitor 3=Blacklist
    verifyStyle: {
        type: DataTypes.TINYINT,
        allowNull: false,
        defaultValue: 0
    },
    faceUrl: {
        type: DataTypes.STRING(500),
        allowNull: true
    },
    acGroupNumber: {
        type: DataTypes.INTEGER,
        allowNull: false,
        defaultValue: 0
    },
    expiredType: {
        type: DataTypes.TINYINT,
        allowNull: false,
        defaultValue: 0
    },
    validTimeBegin: {
        type: DataTypes.BIGINT,
        allowNull: true
    },
    validTimeEnd: {
        type: DataTypes.BIGINT,
        allowNull: true
    },
    isActive: {
        type: DataTypes.BOOLEAN,
        allowNull: false,
        defaultValue: true
    },
    documentUrl: {
        type: DataTypes.STRING(500),
        allowNull: true
    },
    documentBack: {
        type: DataTypes.STRING(500),
        allowNull: true
    },
    docNumber: {
        type: DataTypes.STRING,
        allowNull: true
    },
    ageVerified: {
        type: DataTypes.BOOLEAN,
        allowNull: true,
        defaultValue: null
    },
    extractedDob: {
        type: DataTypes.STRING,
        allowNull: true
    },
    faceMatched: {
        type: DataTypes.BOOLEAN,
        allowNull: true,
        defaultValue: null
    },
    createdBy: {
        type: DataTypes.INTEGER,
        allowNull: true
    },
}, {
    tableName: 'employees',
    timestamps: true,
    createdAt: 'createdAt',
    updatedAt: 'updatedAt'
});

module.exports = Employees;