@tomei/sso
Version:
Tomei SSO Package
91 lines (78 loc) • 2.53 kB
text/typescript
import { ClassError, ObjectBase } from '@tomei/general';
import { GroupSystemAccessRepository } from './group-system-access.repository';
import { IGroupSystemAccessAttr } from '../../interfaces/group-system-access.interface';
export class GroupSystemAccess extends ObjectBase {
ObjectType = 'GroupSystemAccess';
TableName = 'sso_GroupSystemAccess';
ObjectName: string;
ObjectId: string;
GroupSystemAccessId: number;
GroupCode: string;
SystemCode: string;
Status: string;
private _CreatedAt: Date;
private _UpdatedAt: Date;
private _CreatedById: number;
private _UpdatedById: number;
get CreatedAt() {
return this._CreatedAt;
}
set CreatedAt(CreatedAt: Date) {
this._CreatedAt = CreatedAt;
}
get UpdatedAt() {
return this._UpdatedAt;
}
set UpdatedAt(UpdatedAt: Date) {
this._UpdatedAt = UpdatedAt;
}
get CreatedById() {
return this._CreatedById;
}
set CreatedById(CreatedById: number) {
this._CreatedById = CreatedById;
}
get UpdatedById() {
return this._UpdatedById;
}
set UpdatedById(UpdatedById: number) {
this._UpdatedById = UpdatedById;
}
private static _Repository = new GroupSystemAccessRepository();
constructor(groupSystemAccessAttr?: IGroupSystemAccessAttr) {
super();
if (groupSystemAccessAttr) {
this.GroupSystemAccessId = groupSystemAccessAttr.GroupSystemAccessId;
this.GroupCode = groupSystemAccessAttr.GroupCode;
this.SystemCode = groupSystemAccessAttr.SystemCode;
this.Status = groupSystemAccessAttr.Status;
this._CreatedById = groupSystemAccessAttr.CreatedById;
this._CreatedAt = groupSystemAccessAttr.CreatedAt;
this._UpdatedById = groupSystemAccessAttr.UpdatedById;
this._UpdatedAt = groupSystemAccessAttr.UpdatedAt;
}
}
static async init(dbTransaction: any, GroupSystemAccessId?: number) {
try {
const groupSystemAccess = new GroupSystemAccess();
if (GroupSystemAccessId) {
const groupSystemAccess = await this._Repository.findOne({
where: { GroupSystemAccessId },
transaction: dbTransaction,
});
if (groupSystemAccess) {
return new GroupSystemAccess(groupSystemAccess.get({ plain: true }));
} else {
throw new ClassError(
'groupSystemAccess',
'groupSystemAccessErrMsg00',
'groupSystemAccess not found',
);
}
}
return groupSystemAccess;
} catch (error) {
throw error;
}
}
}