refacto query for GET methods
This commit is contained in:
parent
7022e41fcb
commit
2cbdc1db02
@ -30,8 +30,9 @@ export default class DeedTypesController extends ApiController {
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
const officeId: string = req.body.user.office_Id;
|
||||
const officeWhereInput: Prisma.DeedTypesWhereInput = { office: { uid: officeId } };
|
||||
query.where = officeWhereInput;
|
||||
const officeWhereInput: Prisma.OfficesWhereInput = { uid: officeId } ;
|
||||
if(!query.where) query.where = { office: officeWhereInput};
|
||||
query.where.office = officeWhereInput;
|
||||
|
||||
//call service to get prisma entity
|
||||
const deedTypeEntities: DeedTypes[] = await this.deedTypesService.get(query);
|
||||
|
@ -30,8 +30,9 @@ export default class DeedsController extends ApiController {
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
const officeId: string = req.body.user.office_Id;
|
||||
const officeWhereInput: Prisma.DeedsWhereInput = { deed_type: { office: { uid: officeId } } };
|
||||
query.where = officeWhereInput;
|
||||
const officeWhereInput: Prisma.OfficesWhereInput = { uid: officeId } ;
|
||||
if(!query.where) query.where = { deed_type : {office: officeWhereInput}};
|
||||
query.where.deed_type!.office = officeWhereInput;
|
||||
|
||||
//call service to get prisma entity
|
||||
const deedEntities: Deeds[] = await this.deedsService.get(query);
|
||||
|
@ -30,8 +30,9 @@ export default class DocumentTypesController extends ApiController {
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
const officeId: string = req.body.user.office_Id;
|
||||
const officeWhereInput: Prisma.DocumentTypesWhereInput = { office: { uid: officeId } };
|
||||
query.where = officeWhereInput;
|
||||
const officeWhereInput: Prisma.OfficesWhereInput = { uid: officeId } ;
|
||||
if(!query.where) query.where = { office: officeWhereInput};
|
||||
query.where.office = officeWhereInput;
|
||||
|
||||
//call service to get prisma entity
|
||||
const documentTypeEntities: DocumentTypes[] = await this.documentTypesService.get(query);
|
||||
|
@ -30,8 +30,9 @@ 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.DocumentsWhereInput = { document_type: { office: { uid: officeId } } };
|
||||
query.where = officeWhereInput;
|
||||
const officeWhereInput: Prisma.OfficesWhereInput = { uid: officeId } ;
|
||||
if(!query.where) 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);
|
||||
|
@ -29,8 +29,9 @@ export default class FilesController extends ApiController {
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
const officeId: string = req.body.user.office_Id;
|
||||
const officeWhereInput: Prisma.FilesWhereInput = { document: { folder: { office: { uid: officeId } } } };
|
||||
query.where = officeWhereInput;
|
||||
const officeWhereInput: Prisma.OfficesWhereInput = { uid: officeId } ;
|
||||
if(!query.where) query.where = { document: { folder: {office: officeWhereInput}}};
|
||||
query.where.document!.folder!.office = officeWhereInput;
|
||||
//call service to get prisma entity
|
||||
const fileEntities = await this.filesService.get(query);
|
||||
|
||||
|
@ -29,8 +29,10 @@ export default class OfficeFoldersController extends ApiController {
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
const officeId: string = req.body.user.office_Id;
|
||||
const officeWhereInput: Prisma.OfficeFoldersWhereInput = { office: { uid: officeId } };
|
||||
query.where = officeWhereInput;
|
||||
const officeWhereInput: Prisma.OfficesWhereInput = { uid: officeId } ;
|
||||
if(!query.where) query.where = { office: officeWhereInput};
|
||||
query.where.office = officeWhereInput;
|
||||
|
||||
//call service to get prisma entity
|
||||
const officeFolderEntities: OfficeFolders[] = await this.officeFoldersService.get(query);
|
||||
|
||||
|
@ -29,8 +29,9 @@ export default class OfficeRolesController extends ApiController {
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
const officeId: string = req.body.user.office_Id;
|
||||
const officeWhereInput: Prisma.OfficeRolesWhereInput = { office: { uid: officeId } };
|
||||
query.where = officeWhereInput;
|
||||
const officeWhereInput: Prisma.OfficesWhereInput = { uid: officeId } ;
|
||||
if(!query.where) query.where = { office: officeWhereInput};
|
||||
query.where.office = officeWhereInput;
|
||||
|
||||
//call service to get prisma entity
|
||||
const officeRolesEntities = await this.officeRolesService.get(query);
|
||||
|
@ -28,8 +28,9 @@ export default class UsersController extends ApiController {
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
const officeId: string = req.body.user.office_Id;
|
||||
const officeWhereInput: Prisma.UsersWhereInput = { office_membership: { uid: officeId } };
|
||||
query.where = officeWhereInput;
|
||||
const officeWhereInput: Prisma.OfficesWhereInput = { uid: officeId } ;
|
||||
if(!query.where) query.where = { office_membership: officeWhereInput};
|
||||
query.where.office_membership = officeWhereInput;
|
||||
|
||||
//call service to get prisma entity
|
||||
const usersEntities = await this.usersService.get(query);
|
||||
|
@ -30,8 +30,9 @@ export default class DeedTypesController extends ApiController {
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
const officeId: string = req.body.user.office_Id;
|
||||
const officeWhereInput: Prisma.DeedTypesWhereInput = { office: { uid: officeId } };
|
||||
query.where = officeWhereInput;
|
||||
const officeWhereInput: Prisma.OfficesWhereInput = { uid: officeId } ;
|
||||
if(!query.where) query.where = { office: officeWhereInput};
|
||||
query.where.office = officeWhereInput;
|
||||
|
||||
//call service to get prisma entity
|
||||
const deedTypeEntities: DeedTypes[] = await this.deedTypesService.get(query);
|
||||
|
@ -30,8 +30,9 @@ export default class DeedsController extends ApiController {
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
const officeId: string = req.body.user.office_Id;
|
||||
const officeWhereInput: Prisma.DeedsWhereInput = { deed_type: { office: { uid: officeId } } };
|
||||
query.where = officeWhereInput;
|
||||
const officeWhereInput: Prisma.OfficesWhereInput = { uid: officeId } ;
|
||||
if(!query.where) query.where = { deed_type : {office: officeWhereInput}};
|
||||
query.where.deed_type!.office = officeWhereInput;
|
||||
|
||||
//call service to get prisma entity
|
||||
const deedEntities: Deeds[] = await this.deedsService.get(query);
|
||||
|
@ -30,8 +30,9 @@ export default class DocumentTypesController extends ApiController {
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
const officeId: string = req.body.user.office_Id;
|
||||
const officeWhereInput: Prisma.DocumentTypesWhereInput = { office: { uid: officeId } };
|
||||
query.where = officeWhereInput;
|
||||
const officeWhereInput: Prisma.OfficesWhereInput = { uid: officeId } ;
|
||||
if(!query.where) query.where = { office: officeWhereInput};
|
||||
query.where.office = officeWhereInput;
|
||||
|
||||
//call service to get prisma entity
|
||||
const documentTypeEntities: DocumentTypes[] = await this.documentTypesService.get(query);
|
||||
|
@ -30,8 +30,9 @@ 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.DocumentsWhereInput = { document_type: { office: { uid: officeId } } };
|
||||
query.where = officeWhereInput;
|
||||
const officeWhereInput: Prisma.OfficesWhereInput = { uid: officeId } ;
|
||||
if(!query.where) 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);
|
||||
|
@ -29,8 +29,9 @@ export default class FilesController extends ApiController {
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
const officeId: string = req.body.user.office_Id;
|
||||
const officeWhereInput: Prisma.FilesWhereInput = { document: { folder: { office: { uid: officeId } } } };
|
||||
query.where = officeWhereInput;
|
||||
const officeWhereInput: Prisma.OfficesWhereInput = { uid: officeId } ;
|
||||
if(!query.where) query.where = { document: { folder: {office: officeWhereInput}}};
|
||||
query.where.document!.folder!.office = officeWhereInput;
|
||||
//call service to get prisma entity
|
||||
const fileEntities = await this.filesService.get(query);
|
||||
|
||||
|
@ -29,8 +29,9 @@ export default class OfficeFoldersController extends ApiController {
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
const officeId: string = req.body.user.office_Id;
|
||||
const officeWhereInput: Prisma.OfficeFoldersWhereInput = { office: { uid: officeId } };
|
||||
query.where = officeWhereInput;
|
||||
const officeWhereInput: Prisma.OfficesWhereInput = { uid: officeId } ;
|
||||
if(!query.where) query.where = { office: officeWhereInput};
|
||||
query.where.office = officeWhereInput;
|
||||
//call service to get prisma entity
|
||||
const officeFolderEntities: OfficeFolders[] = await this.officeFoldersService.get(query);
|
||||
|
||||
|
@ -28,8 +28,9 @@ export default class OfficeRolesController extends ApiController {
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
const officeId: string = req.body.user.office_Id;
|
||||
const officeWhereInput: Prisma.OfficeRolesWhereInput = { office: { uid: officeId } };
|
||||
query.where = officeWhereInput;
|
||||
const officeWhereInput: Prisma.OfficesWhereInput = { uid: officeId } ;
|
||||
if(!query.where) query.where = { office: officeWhereInput};
|
||||
query.where.office = officeWhereInput;
|
||||
|
||||
//call service to get prisma entity
|
||||
const officeRolesEntities = await this.officeRolesService.get(query);
|
||||
|
@ -28,8 +28,9 @@ export default class UsersController extends ApiController {
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
const officeId: string = req.body.user.office_Id;
|
||||
const officeWhereInput: Prisma.UsersWhereInput = { office_membership: { uid: officeId } };
|
||||
query.where = officeWhereInput;
|
||||
const officeWhereInput: Prisma.OfficesWhereInput = { uid: officeId } ;
|
||||
if(!query.where) query.where = { office_membership: officeWhereInput};
|
||||
query.where.office_membership = officeWhereInput;
|
||||
|
||||
//call service to get prisma entity
|
||||
const usersEntities = await this.usersService.get(query);
|
||||
|
@ -22,7 +22,7 @@ export default class CustomersController extends ApiController {
|
||||
protected async get(req: Request, response: Response) {
|
||||
try {
|
||||
//get query
|
||||
let query = {};
|
||||
let query;
|
||||
if (req.query["q"]) {
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
@ -120,7 +120,7 @@ export default class CustomersController extends ApiController {
|
||||
return;
|
||||
}
|
||||
|
||||
let query = {};
|
||||
let query;
|
||||
if (req.query["q"]) {
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
|
@ -30,8 +30,9 @@ export default class DeedTypesController extends ApiController {
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
const officeId: string = req.body.user.office_Id;
|
||||
const officeWhereInput: Prisma.DeedTypesWhereInput = { office: { uid: officeId } };
|
||||
query.where = officeWhereInput;
|
||||
const officeWhereInput: Prisma.OfficesWhereInput = { uid: officeId } ;
|
||||
if(!query.where) query.where = { office: officeWhereInput};
|
||||
query.where.office = officeWhereInput;
|
||||
|
||||
//call service to get prisma entity
|
||||
const deedTypeEntities: DeedTypes[] = await this.deedTypesService.get(query);
|
||||
@ -131,7 +132,7 @@ export default class DeedTypesController extends ApiController {
|
||||
return;
|
||||
}
|
||||
|
||||
let query = {};
|
||||
let query;
|
||||
if (req.query["q"]) {
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
|
@ -30,8 +30,9 @@ export default class DeedsController extends ApiController {
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
const officeId: string = req.body.user.office_Id;
|
||||
const officeWhereInput: Prisma.DeedsWhereInput = { deed_type: { office: { uid: officeId } } };
|
||||
query.where = officeWhereInput;
|
||||
const officeWhereInput: Prisma.OfficesWhereInput = { uid: officeId } ;
|
||||
if(!query.where) query.where = { deed_type : {office: officeWhereInput}};
|
||||
query.where.deed_type!.office = officeWhereInput;
|
||||
|
||||
//call service to get prisma entity
|
||||
const deedEntities: Deeds[] = await this.deedsService.get(query);
|
||||
@ -60,7 +61,7 @@ export default class DeedsController extends ApiController {
|
||||
return;
|
||||
}
|
||||
|
||||
let query = {};
|
||||
let query;
|
||||
if (req.query["q"]) {
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
|
@ -30,8 +30,9 @@ export default class DocumentTypesController extends ApiController {
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
const officeId: string = req.body.user.office_Id;
|
||||
const officeWhereInput: Prisma.DocumentTypesWhereInput = { office: { uid: officeId } };
|
||||
query.where = officeWhereInput;
|
||||
const officeWhereInput: Prisma.OfficesWhereInput = { uid: officeId } ;
|
||||
if(!query.where) query.where = { office: officeWhereInput};
|
||||
query.where.office = officeWhereInput;
|
||||
|
||||
//call service to get prisma entity
|
||||
const documentTypeEntities: DocumentTypes[] = await this.documentTypesService.get(query);
|
||||
@ -125,7 +126,7 @@ export default class DocumentTypesController extends ApiController {
|
||||
return;
|
||||
}
|
||||
|
||||
let query = {};
|
||||
let query;
|
||||
if (req.query["q"]) {
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
|
@ -30,8 +30,9 @@ 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.DocumentsWhereInput = { document_type: { office: { uid: officeId } } };
|
||||
query.where = officeWhereInput;
|
||||
const officeWhereInput: Prisma.OfficesWhereInput = { uid: officeId } ;
|
||||
if(!query.where) 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);
|
||||
@ -160,7 +161,7 @@ export default class DocumentsController extends ApiController {
|
||||
return;
|
||||
}
|
||||
|
||||
let query = {};
|
||||
let query;
|
||||
if (req.query["q"]) {
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
|
@ -29,8 +29,10 @@ export default class FilesController extends ApiController {
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
const officeId: string = req.body.user.office_Id;
|
||||
const officeWhereInput: Prisma.FilesWhereInput = { document: { folder: { office: { uid: officeId } } } };
|
||||
query.where = officeWhereInput;
|
||||
const officeWhereInput: Prisma.OfficesWhereInput = { uid: officeId } ;
|
||||
if(!query.where) query.where = { document: { folder: {office: officeWhereInput}}};
|
||||
query.where.document!.folder!.office = officeWhereInput;
|
||||
|
||||
//call service to get prisma entity
|
||||
const fileEntities = await this.filesService.get(query);
|
||||
|
||||
@ -123,7 +125,7 @@ export default class FilesController extends ApiController {
|
||||
return;
|
||||
}
|
||||
|
||||
let query = {};
|
||||
let query;
|
||||
if (req.query["q"]) {
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
|
@ -29,8 +29,10 @@ export default class OfficeFoldersController extends ApiController {
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
const officeId: string = req.body.user.office_Id;
|
||||
const officeWhereInput: Prisma.OfficeFoldersWhereInput = { office: { uid: officeId } };
|
||||
query.where = officeWhereInput;
|
||||
const officeWhereInput: Prisma.OfficesWhereInput = { uid: officeId } ;
|
||||
if(!query.where) query.where = { office: officeWhereInput};
|
||||
query.where.office = officeWhereInput;
|
||||
|
||||
//call service to get prisma entity
|
||||
const officeFolderEntities: OfficeFolders[] = await this.officeFoldersService.get(query);
|
||||
|
||||
@ -82,12 +84,7 @@ export default class OfficeFoldersController extends ApiController {
|
||||
return;
|
||||
}
|
||||
|
||||
let query = {};
|
||||
if (req.query["q"]) {
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
|
||||
const officeFolderFound = await this.officeFoldersService.getByUid(uid, query);
|
||||
const officeFolderFound = await this.officeFoldersService.getByUid(uid);
|
||||
|
||||
if (!officeFolderFound) {
|
||||
this.httpNotFoundRequest(response, "office folder not found");
|
||||
@ -129,7 +126,7 @@ export default class OfficeFoldersController extends ApiController {
|
||||
return;
|
||||
}
|
||||
|
||||
let query = {};
|
||||
let query;
|
||||
if (req.query["q"]) {
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
|
@ -29,8 +29,9 @@ export default class OfficeRolesController extends ApiController {
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
const officeId: string = req.body.user.office_Id;
|
||||
const officeWhereInput: Prisma.OfficeRolesWhereInput = { office: { uid: officeId } };
|
||||
query.where = officeWhereInput;
|
||||
const officeWhereInput: Prisma.OfficesWhereInput = { uid: officeId } ;
|
||||
if(!query.where) query.where = { office: officeWhereInput};
|
||||
query.where.office = officeWhereInput;
|
||||
|
||||
//call service to get prisma entity
|
||||
const officeRolesEntities = await this.officeRolesService.get(query);
|
||||
@ -127,7 +128,7 @@ export default class OfficeRolesController extends ApiController {
|
||||
return;
|
||||
}
|
||||
|
||||
let query = {};
|
||||
let query;
|
||||
if (req.query["q"]) {
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ export default class OfficesController extends ApiController {
|
||||
protected async get(req: Request, response: Response) {
|
||||
try {
|
||||
//get query
|
||||
let query = {};
|
||||
let query;
|
||||
if (req.query["q"]) {
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
@ -107,7 +107,7 @@ export default class OfficesController extends ApiController {
|
||||
return;
|
||||
}
|
||||
|
||||
let query = {};
|
||||
let query;
|
||||
if (req.query["q"]) {
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ export default class RolesController extends ApiController {
|
||||
protected async get(req: Request, response: Response) {
|
||||
try {
|
||||
//get query
|
||||
let query = {};
|
||||
let query;
|
||||
if (req.query["q"]) {
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
@ -122,7 +122,7 @@ export default class RolesController extends ApiController {
|
||||
return;
|
||||
}
|
||||
|
||||
let query = {};
|
||||
let query;
|
||||
if (req.query["q"]) {
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ export default class RulesController extends ApiController {
|
||||
protected async get(req: Request, response: Response) {
|
||||
try {
|
||||
//get query
|
||||
let query = {};
|
||||
let query;
|
||||
if (req.query["q"]) {
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
@ -121,7 +121,7 @@ export default class RulesController extends ApiController {
|
||||
this.httpBadRequest(response, "No uid provided");
|
||||
return;
|
||||
}
|
||||
let query = {};
|
||||
let query;
|
||||
if (req.query["q"]) {
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ export default class UsersController extends ApiController {
|
||||
protected async get(req: Request, response: Response) {
|
||||
try {
|
||||
//get query
|
||||
let query = {};
|
||||
let query;
|
||||
if (req.query["q"]) {
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
@ -121,7 +121,7 @@ export default class UsersController extends ApiController {
|
||||
this.httpBadRequest(response, "No uid provided");
|
||||
return;
|
||||
}
|
||||
let query = {};
|
||||
let query;
|
||||
if (req.query["q"]) {
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ export default async function folderHandler(req: Request, response: Response, ne
|
||||
|
||||
const officeFolderService = Container.get(OfficeFoldersService);
|
||||
|
||||
if (officeFolderNumber) {
|
||||
if (officeFolderNumber && req.method == "POST") {
|
||||
const officeFoldersWithSameNumber = await officeFolderService.get({
|
||||
where: { folder_number: officeFolderNumber, office: { uid: officeId } },
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user