Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | 1x 1x 1x 1x 4x 4x 3x 3x 3x 3x 3x 3x 1x 1x 4x 4x 1x 1x 1x 1x 1x 1x 1x 1x 1x 3x 3x 3x 2x 2x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 2x 1x | import { ClassError, ObjectBase } from '@tomei/general';
import { SystemRepository } from '../system/system.repository';
import { SystemPrivilegeRepository } from './system-privilege.repository';
import { ISystemPrivilegeAttr } from '../../interfaces/system-privilege.interface';
export class SystemPrivilege extends ObjectBase {
ObjectType = 'SystemPrivilege';
TableName = 'sso_SystemPrivilege';
ObjectId: string;
SystemCode: string;
ObjectName: string;
Description: string;
Status: string;
private _CreatedAt: Date;
private _UpdatedAt: Date;
private _CreatedById: number;
private _UpdatedById: number;
get PrivilegeCode() {
return this.ObjectId;
}
set PrivilegeCode(value: string) {
this.ObjectId = value;
}
set Name(value: string) {
this.ObjectName = value;
}
get Name() {
return this.ObjectName;
}
get CreatedAt() {
return this._CreatedAt;
}
get UpdatedAt() {
return this._UpdatedAt;
}
get CreatedById() {
return this._CreatedById;
}
get UpdatedById() {
return this._UpdatedById;
}
private static _Repository = new SystemPrivilegeRepository();
private static _SystemRepository = new SystemRepository();
private constructor(systemPrivilegeAttr?: ISystemPrivilegeAttr) {
super();
if (systemPrivilegeAttr) {
this.ObjectId = systemPrivilegeAttr.PrivilegeCode;
this.SystemCode = systemPrivilegeAttr.SystemCode;
this.ObjectName = systemPrivilegeAttr.Name;
this.Description = systemPrivilegeAttr.Description;
this.Status = systemPrivilegeAttr.Status;
this._CreatedById = systemPrivilegeAttr.CreatedById;
this._CreatedAt = systemPrivilegeAttr.CreatedAt;
this._UpdatedById = systemPrivilegeAttr.UpdatedById;
this._UpdatedAt = systemPrivilegeAttr.UpdatedAt;
}
}
static async init(dbTransaction: any, PrivilegeCode?: string) {
try {
const systemPrivilege = new SystemPrivilege();
if (PrivilegeCode) {
const systemPrivilegeAttr = await this._Repository.findByPk(
PrivilegeCode,
{
transaction: dbTransaction,
},
);
if (systemPrivilegeAttr) {
systemPrivilege.ObjectId = systemPrivilegeAttr.PrivilegeCode;
systemPrivilege.SystemCode = systemPrivilegeAttr.SystemCode;
systemPrivilege.ObjectName = systemPrivilegeAttr.Name;
systemPrivilege.Description = systemPrivilegeAttr.Description;
systemPrivilege.Status = systemPrivilegeAttr.Status;
systemPrivilege._CreatedById = systemPrivilegeAttr.CreatedById;
systemPrivilege._CreatedAt = systemPrivilegeAttr.CreatedAt;
systemPrivilege._UpdatedById = systemPrivilegeAttr.UpdatedById;
systemPrivilege._UpdatedAt = systemPrivilegeAttr.UpdatedAt;
} else {
throw new ClassError(
'SystemPrivilege',
'SystemPrivilegeErrMsg00',
'System Privilege Not Found',
);
}
}
return systemPrivilege;
} catch (error) {
throw error;
}
}
}
|