All files / components/group-reporting-user group-reporting-user.ts

86.2% Statements 25/29
81.25% Branches 13/16
33.33% Functions 2/6
86.2% Lines 25/29

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 821x 1x     1x     2x 2x                     1x                                     2x 2x 1x 1x 1x 1x 1x 1x 1x 1x 1x         4x 4x 3x           2x 1x   1x             1x   2x                
import { ClassError, HashTable, ObjectBase } from '@tomei/general';
import { GroupReportingUserRepository } from './group-reporting-user.repository';
import { IGroupReportingUserAttr } from '../../interfaces/group-reporting-user.interface';
 
export class GroupReportingUser extends ObjectBase {
  ObjectId: string;
  ObjectName: string;
  TableName = 'sso_GroupReportingUser';
  ObjectType = 'GroupReportingUser';
 
  GroupReportingUserId: number;
  GroupCode: string;
  UserId: number;
  Rank: number;
  Status: string;
  private _CreatedById: number;
  private _CreatedAt: Date;
  private _UpdatedById: number;
  private _UpdatedAt: Date;
  private static _Repo = new GroupReportingUserRepository();
 
  get CreatedById(): number {
    return this._CreatedById;
  }
 
  get CreatedAt(): Date {
    return this._CreatedAt;
  }
 
  get UpdatedById(): number {
    return this._UpdatedById;
  }
 
  get UpdatedAt(): Date {
    return this._UpdatedAt;
  }
 
  private constructor(groupReportingUserAttr?: IGroupReportingUserAttr) {
    super();
    if (groupReportingUserAttr) {
      this.GroupReportingUserId = groupReportingUserAttr.GroupReportingUserId;
      this.GroupCode = groupReportingUserAttr.GroupCode;
      this.UserId = groupReportingUserAttr?.UserId;
      this.Rank = groupReportingUserAttr?.Rank;
      this.Status = groupReportingUserAttr?.Status;
      this._CreatedById = groupReportingUserAttr.CreatedById;
      this._CreatedAt = groupReportingUserAttr.CreatedAt;
      this._UpdatedById = groupReportingUserAttr.UpdatedById;
      this._UpdatedAt = groupReportingUserAttr.UpdatedAt;
    }
  }
 
  public static async init(dbTransaction: any, GroupReportingUserId?: string) {
    try {
      if (GroupReportingUserId) {
        const groupReportingUser = await GroupReportingUser._Repo.findByPk(
          GroupReportingUserId,
          {
            transaction: dbTransaction,
          },
        );
        if (groupReportingUser) {
          return new GroupReportingUser(groupReportingUser);
        } else {
          throw new ClassError(
            'GroupReportingUser',
            'GroupReportingUserErrMsg00',
            'GroupReportingUser Not Found',
          );
        }
      }
      return new GroupReportingUser();
    } catch (error) {
      throw new ClassError(
        'GroupReportingUser',
        'GroupReportingUserErrMsg01',
        'Failed To Initialize GroupReportingUser',
      );
    }
  }
}