fix examination type create and update
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
import { ExaminationType, Paging } from "entity";
|
||||
import { ExaminationType, Paging, Service } from "entity";
|
||||
import { NextFunction, Response } from "express";
|
||||
import { Request } from "express-jwt";
|
||||
import Joi from "joi";
|
||||
@ -10,6 +10,7 @@ import { ExaminationTypeModel } from "../model/examination_type";
|
||||
import { ServiceModel } from "../model/service";
|
||||
import { OrmHelper } from "../helpers/orm";
|
||||
import moment from "moment";
|
||||
import { In } from "typeorm";
|
||||
|
||||
const log: Logger<ILogObj> = new Logger({
|
||||
name: "[ExaminationTypeController]",
|
||||
@ -93,12 +94,10 @@ export class ExaminationTypeController {
|
||||
let exist = await ExaminationTypeModel.list(filter).then((q) => q.getOne());
|
||||
if (exist) throw { message: "Examination Type " + Language.lang.failed_duplicate };
|
||||
|
||||
let services: any[] = [];
|
||||
let services: Service[] = [];
|
||||
if (param.service_ids && param.service_ids.length > 0) {
|
||||
for (const serviceId of param.service_ids) {
|
||||
const svc = await ServiceModel.list({ id: serviceId }).then((q) => q.getOne());
|
||||
if (svc) services.push(svc);
|
||||
}
|
||||
services = await queryRunner.manager.getRepository(Service).find({ where: { id: In(param.service_ids) } });
|
||||
if (services.length != param.service_ids.length) throw { message: "Service not found" };
|
||||
}
|
||||
|
||||
let examinationType = new ExaminationType();
|
||||
@ -179,12 +178,10 @@ export class ExaminationTypeController {
|
||||
|
||||
if (!examinationType) throw { message: "Examination Type " + Language.lang.failed_not_found };
|
||||
|
||||
let services: any[] = [];
|
||||
let services: Service[] = [];
|
||||
if (param.service_ids && param.service_ids.length > 0) {
|
||||
for (const serviceId of param.service_ids) {
|
||||
const svc = await ServiceModel.list({ id: serviceId }).then((q) => q.getOne());
|
||||
if (svc) services.push(svc);
|
||||
}
|
||||
services = await queryRunner.manager.getRepository(Service).find({ where: { id: In(param.service_ids) } });
|
||||
if (services.length != param.service_ids.length) throw { message: "Service not found" };
|
||||
}
|
||||
|
||||
examinationType.name = param.name;
|
||||
|
||||
Reference in New Issue
Block a user