🐛 Fixing documents get
This commit is contained in:
parent
77f24af33c
commit
7777bc6e91
@ -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 authHandler from "@App/middlewares/AuthHandler";
|
||||||
import ruleHandler from "@App/middlewares/RulesHandler";
|
|
||||||
import documentHandler from "@App/middlewares/OfficeMembershipHandlers/DocumentHandler";
|
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()
|
@Controller()
|
||||||
@Service()
|
@Service()
|
||||||
@ -30,12 +30,18 @@ export default class DocumentsController extends ApiController {
|
|||||||
query = JSON.parse(req.query["q"] as string);
|
query = JSON.parse(req.query["q"] as string);
|
||||||
}
|
}
|
||||||
const officeId: string = req.body.user.office_Id;
|
const officeId: string = req.body.user.office_Id;
|
||||||
|
|
||||||
const officeWhereInput: Prisma.OfficesWhereInput = { uid: officeId } ;
|
const officeWhereInput: Prisma.OfficesWhereInput = { uid: officeId } ;
|
||||||
|
|
||||||
if(!query.where) query.where = { document_type : {office: officeWhereInput}};
|
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
|
//call service to get prisma entity
|
||||||
|
|
||||||
const documentEntities = await this.documentsService.get(query);
|
const documentEntities = await this.documentsService.get(query);
|
||||||
|
console.log(documentEntities);
|
||||||
|
|
||||||
|
|
||||||
//Hydrate ressource with prisma entity
|
//Hydrate ressource with prisma entity
|
||||||
const documents = Document.hydrateArray<Document>(documentEntities, { strategy: "excludeAll" });
|
const documents = Document.hydrateArray<Document>(documentEntities, { strategy: "excludeAll" });
|
||||||
|
Loading…
x
Reference in New Issue
Block a user