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 | 18x 18x 18x 18x 18x 34x 34x 16x 16x 2x 2x 2x 2x 1x 1x 1x 1x | /** * Book condition service. * @packageDocumentation */ import { Injectable, Inject, forwardRef } from '@nestjs/common'; import { DBService } from '../db/db.service'; import { NBBookCondition } from './book-condition.interface'; import { ServiceException } from '../service.exception'; /** * Book condition table name. */ export const bookConditionTableName = 'NB_BOOK_CONDITION'; /** * Book condition table service. */ @Injectable() export class BookConditionService { constructor( @Inject(forwardRef(() => DBService)) private readonly dbService: DBService, ) {} /** * Determine whether or not a book condition exists. * * @param conditionID The book condition's ID. * @params Whether or not the book condition exists. */ public async bookConditionExists(conditionID: number): Promise<boolean> { const bookCondition = await this.dbService.getByID<NBBookCondition>( bookConditionTableName, conditionID, ); return !!bookCondition; } /** * Determine whether or not a book condition exists. * * @param conditionName Thhe book condition's name. * @returns Whether or not the book condition exists. */ public async bookConditionExistsByName( conditionName: string, ): Promise<boolean> { const bookCondition = await this.dbService.getByFields<NBBookCondition>( bookConditionTableName, { name: conditionName }, ); return !!bookCondition; } /** * Get the name of a book condition. * * @param conditionID The book condition's ID. * @return The name of the book condition. */ public async getBookConditionName(conditionID: number): Promise<string> { const bookCondition = await this.dbService.getByID<NBBookCondition>( bookConditionTableName, conditionID, ); if (bookCondition) { return bookCondition.name; } else { throw new ServiceException('Book condition does not exist'); } } /** * Get all book conditions. * * @returns All book conditions. */ public async getBookConditions(): Promise<NBBookCondition[]> { const bookConditions = await this.dbService.list<NBBookCondition>( bookConditionTableName, { fieldName: 'id', sortOrder: 'ASC' }, ); return bookConditions; } } |