diff --git a/src/app/api/super-admin/DocumentsController.ts b/src/app/api/super-admin/DocumentsController.ts index 7ccdb18c..03621ba8 100644 --- a/src/app/api/super-admin/DocumentsController.ts +++ b/src/app/api/super-admin/DocumentsController.ts @@ -1,14 +1,14 @@ -import { Response, Request } from "express"; -import { Controller, Delete, Get, Post, Put } from "@ControllerPattern/index"; -import ApiController from "@Common/system/controller-pattern/ApiController"; -import { Service } from "typedi"; -import DocumentsService from "@Services/super-admin/DocumentsService/DocumentsService"; -import { Documents, Prisma } from "@prisma/client"; -import { Document } from "le-coffre-resources/dist/SuperAdmin"; -import { validateOrReject } from "class-validator"; import authHandler from "@App/middlewares/AuthHandler"; -import ruleHandler from "@App/middlewares/RulesHandler"; import documentHandler from "@App/middlewares/OfficeMembershipHandlers/DocumentHandler"; +import ruleHandler from "@App/middlewares/RulesHandler"; +import ApiController from "@Common/system/controller-pattern/ApiController"; +import { Controller, Delete, Get, Post, Put } from "@ControllerPattern/index"; +import { Documents, Prisma } from "@prisma/client"; +import DocumentsService from "@Services/super-admin/DocumentsService/DocumentsService"; +import { validateOrReject } from "class-validator"; +import { Request, Response } from "express"; +import { Document } from "le-coffre-resources/dist/SuperAdmin"; +import { Service } from "typedi"; @Controller() @Service() @@ -30,12 +30,18 @@ export default class DocumentsController extends ApiController { query = JSON.parse(req.query["q"] as string); } const officeId: string = req.body.user.office_Id; + const officeWhereInput: Prisma.OfficesWhereInput = { uid: officeId } ; + if(!query.where) query.where = { document_type : {office: officeWhereInput}}; - query.where.document_type!.office = officeWhereInput; + + // query.where.document_type!.office = officeWhereInput; //call service to get prisma entity + const documentEntities = await this.documentsService.get(query); + console.log(documentEntities); + //Hydrate ressource with prisma entity const documents = Document.hydrateArray(documentEntities, { strategy: "excludeAll" });