All files / src/controllers/public/scan box.controller.ts

71.43% Statements 10/14
100% Branches 0/0
0% Functions 0/4
66.67% Lines 8/12

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 421x 1x 1x 1x     1x             1x               1x                   1x                    
import {authenticate} from '@loopback/authentication';
import {get, param, post, requestBody} from '@loopback/rest';
import {service} from '@loopback/core';
import {BoxService} from '@logchain/services/scan/box.service';
 
@authenticate('aws-cognito')
export class BoxController {
  constructor(
    @service(BoxService)
    public boxService: BoxService,
  ) {}
 
  @get('/box/pmo/{pmoId}')
  async findByPMOId(
    @param.path.number('pmoId')
    pmoId: number,
  ) {
    return this.boxService.findByPMOId(pmoId);
  }
 
  @post('/box/create')
  async createBox(
    @requestBody()
    body: {
      pmoIds: number[];
    },
  ) {
    return this.boxService.createBox(body);
  }
 
  @post('/box/delete')
  async deleteBox(
    @requestBody()
    body: {
      id: number;
      pmoIds: number[]; 
      temporaryNo?: string;
    },
  ) {
    return this.boxService.deleteBox(body.id, body.pmoIds, body.temporaryNo);
  }
}