UNPKG

@tomei/sso

Version:
128 lines (105 loc) 2.57 kB
import { BelongsTo, Column, CreatedAt, DataType, ForeignKey, HasMany, Model, Table, UpdatedAt, } from 'sequelize-typescript'; import User from './user.entity'; import { GroupTypeEnum } from '../enum/group-type.enum'; import UserGroupModel from './user-group.entity'; import GroupPrivilegeModel from './group-privilege.entity'; import GroupObjectPrivilegeModel from './group-object-privilege.entity'; import GroupSystemAccessModel from './group-system-access.entity'; import GroupReportingUserModel from './group-reporting-user.entity'; @Table({ tableName: 'sso_Group', timestamps: true, createdAt: 'CreatedAt', updatedAt: 'UpdatedAt', }) export default class GroupModel extends Model { @Column({ primaryKey: true, allowNull: false, type: DataType.STRING(10), }) GroupCode: string; @Column({ allowNull: false, type: DataType.STRING(50), }) Name: string; @Column({ allowNull: true, type: DataType.STRING(100), }) Description: string; @Column({ allowNull: false, type: DataType.STRING(2000), }) Type: GroupTypeEnum; @ForeignKey(() => GroupModel) @Column({ allowNull: true, type: DataType.STRING(10), }) ParentGroupCode: string; @Column({ type: DataType.CHAR(1), }) InheritParentPrivilegeYN: string; @Column({ type: DataType.CHAR(1), }) InheritParentSystemAccessYN: string; @Column({ allowNull: false, type: DataType.CHAR(10), }) Status: string; @Column({ allowNull: false, type: DataType.STRING(10), }) Path: string; @ForeignKey(() => User) @Column({ allowNull: false, type: DataType.INTEGER, }) CreatedById: number; @ForeignKey(() => User) @Column({ allowNull: false, type: DataType.INTEGER, }) UpdatedById: number; @CreatedAt CreatedAt: Date; @UpdatedAt UpdatedAt: Date; @BelongsTo(() => User, 'CreatedById') CreatedByUser: User; @BelongsTo(() => User, 'UpdatedById') UpdatedByUser: User; @BelongsTo(() => GroupModel, 'ParentGroupCode') ParentGroup: GroupModel; @HasMany(() => GroupModel) ChildGroups: GroupModel[]; @HasMany(() => UserGroupModel) UserGroups: UserGroupModel[]; @HasMany(() => GroupPrivilegeModel) GroupPrivileges: GroupPrivilegeModel[]; @HasMany(() => GroupObjectPrivilegeModel) GroupObjectPrivileges: GroupObjectPrivilegeModel[]; @HasMany(() => GroupSystemAccessModel) GroupSystemAccesses: GroupSystemAccessModel[]; @HasMany(() => GroupReportingUserModel) GroupReportingUsers: GroupReportingUserModel[]; }