fix folder query controller
This commit is contained in:
parent
feb3818fae
commit
d47b375957
@ -7,7 +7,7 @@ import { Files, Prisma } from "@prisma/client";
|
||||
import { File } from "le-coffre-resources/dist/Customer";
|
||||
import { Document } from "le-coffre-resources/dist/Customer";
|
||||
import { validateOrReject } from "class-validator";
|
||||
import DocumentsService from "@Services/super-admin/DocumentsService/DocumentsService";
|
||||
import DocumentsService from "@Services/customer/DocumentsService/DocumentsService";
|
||||
import authHandler from "@App/middlewares/AuthHandler";
|
||||
import fileHandler from "@App/middlewares/CustomerHandler/FileHandler";
|
||||
|
||||
|
@ -129,18 +129,12 @@ export default class OfficeFoldersController extends ApiController {
|
||||
return;
|
||||
}
|
||||
|
||||
let officeFolderEntity: OfficeFolders | null;
|
||||
//get query
|
||||
if (req.query["q"]) {
|
||||
let query = {};
|
||||
let query = {};
|
||||
if (req.query["q"]) {
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
officeFolderEntity = await this.officeFoldersService.getByUid(uid, query);
|
||||
} else {
|
||||
//call service to get prisma entity
|
||||
officeFolderEntity = await this.officeFoldersService.getByUid(uid);
|
||||
}
|
||||
|
||||
const officeFolderEntity = await this.officeFoldersService.getByUid(uid, query);
|
||||
|
||||
if (!officeFolderEntity) {
|
||||
this.httpNotFoundRequest(response, "folder not found");
|
||||
|
@ -3,6 +3,7 @@ import BaseRepository from "@Repositories/BaseRepository";
|
||||
import { Service } from "typedi";
|
||||
import { Documents, EDocumentStatus, Prisma } from "@prisma/client";
|
||||
import { Document } from "le-coffre-resources/dist/SuperAdmin";
|
||||
import { Document as DocumentCustomer } from "le-coffre-resources/dist/Customer";
|
||||
|
||||
@Service()
|
||||
export default class DocumentsRepository extends BaseRepository {
|
||||
@ -94,7 +95,7 @@ export default class DocumentsRepository extends BaseRepository {
|
||||
/**
|
||||
* @description : Update data of a document
|
||||
*/
|
||||
public async update(uid: string, document: Partial<Document>, refusedReason?: string): Promise<Documents> {
|
||||
public async update(uid: string, document: Partial<DocumentCustomer>, refusedReason?: string): Promise<Documents> {
|
||||
return this.model.update({
|
||||
where: {
|
||||
uid: uid,
|
||||
|
@ -18,22 +18,6 @@ export default class DocumentsService extends BaseService {
|
||||
return this.documentsRepository.findMany(query);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description : Create a new document
|
||||
* @throws {Error} If document cannot be created
|
||||
*/
|
||||
public async create(document: Document): Promise<Documents> {
|
||||
return this.documentsRepository.create(document);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description : Create new documents
|
||||
* @throws {Error} If documents or one of them cannot be created
|
||||
*/
|
||||
public async createMany(documents: Document[]): Promise<Documents[]> {
|
||||
return this.documentsRepository.createMany(documents);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description : Modify a document
|
||||
* @throws {Error} If document cannot be modified
|
||||
@ -42,14 +26,6 @@ export default class DocumentsService extends BaseService {
|
||||
return this.documentsRepository.update(uid, document);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description : Delete a document
|
||||
* @throws {Error} If document cannot be deleted
|
||||
*/
|
||||
public async delete(uid: string): Promise<Documents> {
|
||||
return this.documentsRepository.delete(uid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description : Get a document by uid
|
||||
* @throws {Error} If document cannot be get by uid
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { EOfficeStatus } from "le-coffre-resources/dist/Customer/Office";
|
||||
import { EOfficeStatus } from "le-coffre-resources/dist/Notary/Office";
|
||||
import User, { Address, Contact, Office, DeedType, DocumentType, Customer, OfficeFolder, Deed } from "le-coffre-resources/dist/SuperAdmin";
|
||||
|
||||
export const userAddress: Address = {
|
||||
|
Loading…
x
Reference in New Issue
Block a user