All files / src/dtos role-rights.dto.ts

60% Statements 12/20
0% Branches 0/64
0% Functions 0/1
55.56% Lines 10/18

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 871x 1x       1x         1x                       1x                   1x                   1x                   1x                   1x                   1x                            
import {model, property} from '@loopback/repository';
import {Constants} from '../configs';
import {Access} from '../types';
 
@model({name: 'RoleRightsDto'})
export class RoleRightsDto {
  @property({
    type: 'number',
    required: true,
  })
  feature_id: number;
 
  feature_name: string;
 
  @property({
    type: 'number',
    required: true,
    default: Constants.Access.Denied,
    jsonSchema: {
      enum: Object.values(Constants.Access),
    },
  })
  create: number;
 
  @property({
    type: 'number',
    required: true,
    default: Constants.Access.Denied,
    jsonSchema: {
      enum: Object.values(Constants.Access),
    },
  })
  retrieve: number;
 
  @property({
    type: 'number',
    required: true,
    default: Constants.Access.Denied,
    jsonSchema: {
      enum: Object.values(Constants.Access),
    },
  })
  update: number;
 
  @property({
    type: 'number',
    required: true,
    default: Constants.Access.Denied,
    jsonSchema: {
      enum: Object.values(Constants.Access),
    },
  })
  delete: number;
 
  @property({
    type: 'number',
    required: true,
    default: Constants.Access.Denied,
    jsonSchema: {
      enum: Object.values(Constants.Access),
    },
  })
  validate: number;
 
  @property({
    type: 'number',
    required: true,
    default: Constants.Access.Denied,
    jsonSchema: {
      enum: Object.values(Constants.Access),
    },
  })
  override: number;
 
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
  constructor(data?: Partial<RoleRightsDto & Access & any>) {
    this.feature_id = data?.feature?.id;
    this.feature_name = data?.feature?.name;
    this.create = data?.allow_create ?? Constants.Access.Denied;
    this.retrieve = data?.allow_retrieve ?? Constants.Access.Denied;
    this.update = data?.allow_update ?? Constants.Access.Denied;
    this.delete = data?.allow_delete ?? Constants.Access.Denied;
    this.validate = data?.allow_validate ?? Constants.Access.Denied;
    this.override = data?.allow_override ?? Constants.Access.Denied;
  }
}