UNPKG

@tomei/sso

Version:
102 lines (86 loc) 1.7 kB
import { BelongsTo, Column, CreatedAt, DataType, ForeignKey, Index, Model, Table, } from 'sequelize-typescript'; import User from './user.entity'; import { APIKeyStatusEnum } from '../enum/api-key.enum'; import SystemModel from './system.entity'; @Table({ tableName: 'sso_ApiKey', timestamps: true, createdAt: 'CreatedAt', updatedAt: false, }) export default class APIKeyModel extends Model { @Column({ primaryKey: true, type: DataType.INTEGER, allowNull: false, autoIncrement: true, }) APIKeyId: number; @Column({ type: DataType.STRING(128), }) ApiKey: string; @Column({ type: DataType.STRING(255), allowNull: false, }) Name: string; @ForeignKey(() => SystemModel) @Column({ allowNull: false, type: DataType.STRING(10), }) SystemCode: string; @Column({ type: DataType.TEXT, allowNull: true, }) Description: string; @Column({ type: DataType.STRING(50), allowNull: false, }) Status: APIKeyStatusEnum; @Column({ type: DataType.DATE, allowNull: true, }) ExpirationDate: Date; @ForeignKey(() => User) @Column({ type: DataType.INTEGER, }) CreatedById: number; @ForeignKey(() => User) @Column({ type: DataType.INTEGER, }) RevokedById: number; @CreatedAt CreatedAt: Date; @Column({ type: DataType.DATE, allowNull: true, }) RevokedAt: Date; @Column({ type: DataType.TEXT, allowNull: true, }) RevokedReason: string; @BelongsTo(() => User, 'CreatedById') CreatedByUser: User; @BelongsTo(() => User, 'RevokedById') UpdatedByUser: User; @BelongsTo(() => SystemModel, 'SystemCode') System: SystemModel; }