UNPKG

@tomei/sso

Version:
201 lines (167 loc) 3.41 kB
import { BelongsTo, BelongsToMany, Column, CreatedAt, DataType, ForeignKey, HasMany, HasOne, Model, Table, UpdatedAt, } from 'sequelize-typescript'; import Staff from './staff.entity'; import { YN } from '../enum/yn.enum'; import { UserStatus } from '../enum/user-status.enum'; import UserSystemAccessModel from './user-system-access.entity'; import UserPrivilegeModel from './user-privilege.entity'; import UserGroupModel from './user-group.entity'; import UserObjectPrivilegeModel from './user-object-privilege.entity'; @Table({ tableName: 'sso_User', timestamps: true, createdAt: 'CreatedAt', updatedAt: 'UpdatedAt', }) export default class User extends Model { @Column({ primaryKey: true, allowNull: false, autoIncrement: true, type: DataType.INTEGER, }) UserId: number; @Column({ allowNull: true, type: DataType.STRING, }) UserName: string; @Column({ allowNull: false, type: DataType.STRING, }) Email: string; @Column({ allowNull: false, type: DataType.STRING, }) Password: string; @Column({ allowNull: true, type: DataType.STRING, }) FullName: string; @Column({ allowNull: true, type: DataType.STRING, }) IdNo: string; @Column({ allowNull: true, type: DataType.STRING, }) IdType: string; @Column({ allowNull: true, type: DataType.STRING, }) ContactNo: string; @Column({ allowNull: false, type: DataType.STRING, }) Status: UserStatus; @Column({ allowNull: false, type: DataType.CHAR(1), }) DefaultPasswordChangedYN: YN; @Column({ allowNull: true, type: DataType.CHAR(1), defaultValue: 'N', }) MFABypassYN: YN; @Column({ type: DataType.DATE, }) FirstLoginAt: Date; @Column({ type: DataType.DATE, }) LastLoginAt: Date; @Column({ type: DataType.TINYINT, }) MFAEnabled: number; @Column({ type: DataType.TEXT, }) MFAConfig: string; @Column({ type: DataType.STRING, }) RecoveryEmail: string; @Column({ allowNull: false, type: DataType.INTEGER, }) FailedLoginAttemptCount: number; @Column({ type: DataType.DATE, }) LastFailedLoginAt: Date; @Column({ type: DataType.DATE, }) LastPasswordChangedAt: Date; @Column({ allowNull: false, type: DataType.CHAR(1), }) NeedToChangePasswordYN: YN; @Column({ allowNull: true, type: DataType.STRING, }) PasscodeHash: string; @Column({ type: DataType.DATE, }) PasscodeUpdatedAt: Date; @ForeignKey(() => User) @Column({ type: DataType.INTEGER, }) CreatedById: number; @CreatedAt CreatedAt: Date; @ForeignKey(() => User) @Column({ type: DataType.INTEGER, }) UpdatedById: number; @UpdatedAt UpdatedAt: Date; @HasOne(() => Staff, 'UserId') Staff: Staff; @HasMany(() => UserGroupModel, 'UserId') UserGroups: UserGroupModel[]; @HasMany(() => UserSystemAccessModel) UserSystemAccesses: UserSystemAccessModel[]; @HasMany(() => UserPrivilegeModel) UserPrivileges: UserPrivilegeModel[]; @HasMany(() => UserObjectPrivilegeModel) UserObjectPrivileges: UserObjectPrivilegeModel[]; @BelongsTo(() => User, { as: 'CreatedBy', foreignKey: 'CreatedById', }) CreatedBy: User; @BelongsTo(() => User, { as: 'UpdatedBy', foreignKey: 'UpdatedById', }) UpdatedBy: User; }