order services and controllers per namespace
This commit is contained in:
parent
70d0fb6e71
commit
7d80f3e136
@ -4,7 +4,6 @@ import ApiController from "@Common/system/controller-pattern/ApiController";
|
||||
import CustomersService from "@Services/admin/CustomersService/CustomersService";
|
||||
import { Service } from "typedi";
|
||||
import { Customer } from "le-coffre-resources/dist/Admin";
|
||||
import { Customers } from "@prisma/client";
|
||||
import { validateOrReject } from "class-validator";
|
||||
import authHandler from "@App/middlewares/AuthHandler";
|
||||
import ruleHandler from "@App/middlewares/RulesHandler";
|
||||
@ -23,7 +22,10 @@ export default class CustomersController extends ApiController {
|
||||
protected async get(req: Request, response: Response) {
|
||||
try {
|
||||
//get query
|
||||
const query = JSON.parse(req.query["q"] as string);
|
||||
let query = {};
|
||||
if (req.query["q"]) {
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
|
||||
//call service to get prisma entity
|
||||
const customersEntities = await this.customersService.get(query);
|
||||
@ -117,17 +119,14 @@ export default class CustomersController extends ApiController {
|
||||
this.httpBadRequest(response, "No uid provided");
|
||||
return;
|
||||
}
|
||||
|
||||
let customerEntity: Customers | null;
|
||||
//get query
|
||||
let query = {};
|
||||
if (req.query["q"]) {
|
||||
const query = JSON.parse(req.query["q"] as string);
|
||||
customerEntity = await this.customersService.getByUid(uid, query);
|
||||
} else {
|
||||
//call service to get prisma entity
|
||||
customerEntity = await this.customersService.getByUid(uid);
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
|
||||
const customerEntity = await this.customersService.getByUid(uid, query);
|
||||
|
||||
if (!customerEntity) {
|
||||
this.httpNotFoundRequest(response, "customer not found");
|
||||
return;
|
||||
|
@ -25,7 +25,10 @@ export default class DeedTypesController extends ApiController {
|
||||
protected async get(req: Request, response: Response) {
|
||||
try {
|
||||
//get query
|
||||
const query = JSON.parse(req.query["q"] as string);
|
||||
let query: Prisma.DeedTypesFindManyArgs = {};
|
||||
if (req.query["q"]) {
|
||||
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;
|
||||
@ -127,17 +130,14 @@ export default class DeedTypesController extends ApiController {
|
||||
this.httpBadRequest(response, "No uid provided");
|
||||
return;
|
||||
}
|
||||
|
||||
let deedTypeEntity: DeedTypes | null;
|
||||
//get query
|
||||
let query = {};
|
||||
if (req.query["q"]) {
|
||||
const query = JSON.parse(req.query["q"] as string);
|
||||
deedTypeEntity = await this.deedTypesService.getByUid(uid, query);
|
||||
} else {
|
||||
//call service to get prisma entity
|
||||
deedTypeEntity = await this.deedTypesService.getByUid(uid);
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
|
||||
const deedTypeEntity = await this.deedTypesService.getByUid(uid, query);
|
||||
|
||||
if (!deedTypeEntity) {
|
||||
this.httpNotFoundRequest(response, "deed type not found");
|
||||
return;
|
||||
|
@ -25,7 +25,10 @@ export default class DeedsController extends ApiController {
|
||||
protected async get(req: Request, response: Response) {
|
||||
try {
|
||||
//get query
|
||||
const query = JSON.parse(req.query["q"] as string);
|
||||
let query: Prisma.DeedsFindManyArgs = {};
|
||||
if (req.query["q"]) {
|
||||
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;
|
||||
@ -56,17 +59,14 @@ export default class DeedsController extends ApiController {
|
||||
this.httpBadRequest(response, "No uid provided");
|
||||
return;
|
||||
}
|
||||
|
||||
let deedEntity: Deeds | null;
|
||||
//get query
|
||||
let query = {};
|
||||
if (req.query["q"]) {
|
||||
const query = JSON.parse(req.query["q"] as string);
|
||||
deedEntity = await this.deedsService.getByUid(uid, query);
|
||||
} else {
|
||||
//call service to get prisma entity
|
||||
deedEntity = await this.deedsService.getByUid(uid);
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
|
||||
const deedEntity = await this.deedsService.getByUid(uid, query);
|
||||
|
||||
if (!deedEntity) {
|
||||
this.httpNotFoundRequest(response, "deed not found");
|
||||
return;
|
||||
|
@ -25,7 +25,10 @@ export default class DocumentTypesController extends ApiController {
|
||||
protected async get(req: Request, response: Response) {
|
||||
try {
|
||||
//get query
|
||||
const query = JSON.parse(req.query["q"] as string);
|
||||
let query: Prisma.DocumentTypesFindManyArgs = {};
|
||||
if (req.query["q"]) {
|
||||
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;
|
||||
@ -121,17 +124,14 @@ export default class DocumentTypesController extends ApiController {
|
||||
this.httpBadRequest(response, "No uid provided");
|
||||
return;
|
||||
}
|
||||
|
||||
let documentTypeEntity: DocumentTypes | null;
|
||||
//get query
|
||||
let query = {};
|
||||
if (req.query["q"]) {
|
||||
const query = JSON.parse(req.query["q"] as string);
|
||||
documentTypeEntity = await this.documentTypesService.getByUid(uid, query);
|
||||
} else {
|
||||
//call service to get prisma entity
|
||||
documentTypeEntity = await this.documentTypesService.getByUid(uid);
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
|
||||
const documentTypeEntity = await this.documentTypesService.getByUid(uid, query);
|
||||
|
||||
//Hydrate ressource with prisma entity
|
||||
const user = ObjectHydrate.hydrate<DocumentType>(new DocumentType(), documentTypeEntity!, { strategy: "excludeAll" });
|
||||
|
||||
|
@ -25,7 +25,10 @@ export default class DocumentsController extends ApiController {
|
||||
protected async get(req: Request, response: Response) {
|
||||
try {
|
||||
//get query
|
||||
const query = JSON.parse(req.query["q"] as string);
|
||||
let query: Prisma.DocumentsFindManyArgs = {};
|
||||
if (req.query["q"]) {
|
||||
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;
|
||||
@ -156,17 +159,14 @@ export default class DocumentsController extends ApiController {
|
||||
this.httpBadRequest(response, "No uid provided");
|
||||
return;
|
||||
}
|
||||
|
||||
let documentEntity: Documents | null;
|
||||
//get query
|
||||
let query = {};
|
||||
if (req.query["q"]) {
|
||||
const query = JSON.parse(req.query["q"] as string);
|
||||
documentEntity = await this.documentsService.getByUid(uid, query);
|
||||
} else {
|
||||
//call service to get prisma entity
|
||||
documentEntity = await this.documentsService.getByUid(uid);
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
|
||||
const documentEntity = await this.documentsService.getByUid(uid, query);
|
||||
|
||||
if (!documentEntity) {
|
||||
this.httpNotFoundRequest(response, "document not found");
|
||||
return;
|
||||
|
@ -24,7 +24,10 @@ export default class FilesController extends ApiController {
|
||||
protected async get(req: Request, response: Response) {
|
||||
try {
|
||||
//get query
|
||||
const query = JSON.parse(req.query["q"] as string);
|
||||
let query: Prisma.FilesFindManyArgs = {};
|
||||
if (req.query["q"]) {
|
||||
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;
|
||||
@ -119,8 +122,13 @@ export default class FilesController extends ApiController {
|
||||
this.httpBadRequest(response, "No uid provided");
|
||||
return;
|
||||
}
|
||||
//get query
|
||||
let query = {};
|
||||
if (req.query["q"]) {
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
|
||||
const fileEntity = await this.filesService.getByUid(uid);
|
||||
const fileEntity = await this.filesService.getByUid(uid, query);
|
||||
|
||||
if (!fileEntity) {
|
||||
this.httpNotFoundRequest(response, "file not found");
|
||||
|
@ -24,7 +24,10 @@ export default class OfficeFoldersController extends ApiController {
|
||||
protected async get(req: Request, response: Response) {
|
||||
try {
|
||||
//get query
|
||||
const query = JSON.parse(req.query["q"] as string);
|
||||
let query: Prisma.OfficeFoldersFindManyArgs = {};
|
||||
if (req.query["q"]) {
|
||||
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;
|
||||
@ -120,16 +123,13 @@ export default class OfficeFoldersController extends ApiController {
|
||||
this.httpBadRequest(response, "No uid provided");
|
||||
return;
|
||||
}
|
||||
|
||||
let officeFolderEntity: OfficeFolders | null;
|
||||
//get query
|
||||
let query = {};
|
||||
if (req.query["q"]) {
|
||||
const 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);
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
|
||||
const officeFolderEntity = await this.officeFoldersService.getByUid(uid, query);
|
||||
|
||||
if (!officeFolderEntity) {
|
||||
this.httpNotFoundRequest(response, "folder not found");
|
||||
|
@ -5,7 +5,7 @@ import OfficeRolesService from "@Services/admin/OfficeRolesService/OfficeRolesSe
|
||||
import { Service } from "typedi";
|
||||
import { validateOrReject } from "class-validator";
|
||||
import { OfficeRole } from "le-coffre-resources/dist/Admin";
|
||||
import { OfficeRoles, Prisma } from "@prisma/client";
|
||||
import { Prisma } from "@prisma/client";
|
||||
import authHandler from "@App/middlewares/AuthHandler";
|
||||
import ruleHandler from "@App/middlewares/RulesHandler";
|
||||
import officeRoleHandler from "@App/middlewares/OfficeMembershipHandlers/OfficeRoleHandler";
|
||||
@ -24,7 +24,10 @@ export default class OfficeRolesController extends ApiController {
|
||||
protected async get(req: Request, response: Response) {
|
||||
try {
|
||||
//get query
|
||||
const query = JSON.parse(req.query["q"] as string);
|
||||
let query: Prisma.OfficeRolesFindManyArgs = {};
|
||||
if (req.query["q"]) {
|
||||
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;
|
||||
@ -123,15 +126,13 @@ export default class OfficeRolesController extends ApiController {
|
||||
this.httpBadRequest(response, "No uid provided");
|
||||
return;
|
||||
}
|
||||
let officeRoleEntity: OfficeRoles | null;
|
||||
//get query
|
||||
let query = {};
|
||||
if (req.query["q"]) {
|
||||
const query = JSON.parse(req.query["q"] as string);
|
||||
officeRoleEntity = await this.officeRolesService.getByUid(uid, query);
|
||||
} else {
|
||||
//call service to get prisma entity
|
||||
officeRoleEntity = await this.officeRolesService.getByUid(uid);
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
|
||||
const officeRoleEntity = await this.officeRolesService.getByUid(uid, query);
|
||||
|
||||
if (!officeRoleEntity) {
|
||||
this.httpNotFoundRequest(response, "officeRole not found");
|
||||
|
@ -21,7 +21,10 @@ export default class OfficesController extends ApiController {
|
||||
protected async get(req: Request, response: Response) {
|
||||
try {
|
||||
//get query
|
||||
const query = JSON.parse(req.query["q"] as string);
|
||||
let query = {};
|
||||
if (req.query["q"]) {
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
//call service to get prisma entity
|
||||
const officesEntities: Offices[] = await this.officesService.get(query);
|
||||
//Hydrate ressource with prisma entity
|
||||
@ -45,15 +48,13 @@ export default class OfficesController extends ApiController {
|
||||
this.httpBadRequest(response, "No uid provided");
|
||||
return;
|
||||
}
|
||||
let officeEntity: Offices | null;
|
||||
//get query
|
||||
let query = {};
|
||||
if (req.query["q"]) {
|
||||
const query = JSON.parse(req.query["q"] as string);
|
||||
officeEntity = await this.officesService.getByUid(uid, query);
|
||||
} else {
|
||||
//call service to get prisma entity
|
||||
officeEntity = await this.officesService.getByUid(uid);
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
|
||||
const officeEntity = await this.officesService.getByUid(uid, query);
|
||||
|
||||
if (!officeEntity) {
|
||||
this.httpNotFoundRequest(response, "office not found");
|
||||
|
@ -4,7 +4,6 @@ import ApiController from "@Common/system/controller-pattern/ApiController";
|
||||
import RolesService from "@Services/admin/RolesService/RolesService";
|
||||
import { Service } from "typedi";
|
||||
import { Role } from "le-coffre-resources/dist/Admin";
|
||||
import { Roles } from "@prisma/client";
|
||||
import authHandler from "@App/middlewares/AuthHandler";
|
||||
import ruleHandler from "@App/middlewares/RulesHandler";
|
||||
|
||||
@ -22,7 +21,10 @@ export default class RolesController extends ApiController {
|
||||
protected async get(req: Request, response: Response) {
|
||||
try {
|
||||
//get query
|
||||
const query = JSON.parse(req.query["q"] as string);
|
||||
let query = {};
|
||||
if (req.query["q"]) {
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
|
||||
//call service to get prisma entity
|
||||
const rolesEntities = await this.rolesService.get(query);
|
||||
@ -49,16 +51,14 @@ export default class RolesController extends ApiController {
|
||||
this.httpBadRequest(response, "No uid provided");
|
||||
return;
|
||||
}
|
||||
let roleEntity: Roles | null;
|
||||
//get query
|
||||
let query = {};
|
||||
if (req.query["q"]) {
|
||||
const query = JSON.parse(req.query["q"] as string);
|
||||
roleEntity = await this.rolesService.getByUid(uid, query);
|
||||
} else {
|
||||
//call service to get prisma entity
|
||||
roleEntity = await this.rolesService.getByUid(uid);
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
|
||||
const roleEntity = await this.rolesService.getByUid(uid, query);
|
||||
|
||||
if (!roleEntity) {
|
||||
this.httpNotFoundRequest(response, "role not found");
|
||||
return;
|
||||
|
@ -4,7 +4,6 @@ import ApiController from "@Common/system/controller-pattern/ApiController";
|
||||
import RulesService from "@Services/admin/RulesService/RulesService";
|
||||
import { Service } from "typedi";
|
||||
import { Rule } from "le-coffre-resources/dist/Admin";
|
||||
import { Rules } from "@prisma/client";
|
||||
import authHandler from "@App/middlewares/AuthHandler";
|
||||
import ruleHandler from "@App/middlewares/RulesHandler";
|
||||
|
||||
@ -22,7 +21,10 @@ export default class RulesController extends ApiController {
|
||||
protected async get(req: Request, response: Response) {
|
||||
try {
|
||||
//get query
|
||||
const query = JSON.parse(req.query["q"] as string);
|
||||
let query = {};
|
||||
if (req.query["q"]) {
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
|
||||
//call service to get prisma entity
|
||||
const rulesEntities = await this.rulesService.get(query);
|
||||
@ -49,16 +51,14 @@ export default class RulesController extends ApiController {
|
||||
this.httpBadRequest(response, "No uid provided");
|
||||
return;
|
||||
}
|
||||
let ruleEntity: Rules | null;
|
||||
//get query
|
||||
let query = {};
|
||||
if (req.query["q"]) {
|
||||
const query = JSON.parse(req.query["q"] as string);
|
||||
ruleEntity = await this.rulesService.getByUid(uid, query);
|
||||
} else {
|
||||
//call service to get prisma entity
|
||||
ruleEntity = await this.rulesService.getByUid(uid);
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
|
||||
const ruleEntity = await this.rulesService.getByUid(uid, query);
|
||||
|
||||
if (!ruleEntity) {
|
||||
this.httpNotFoundRequest(response, "rule not found");
|
||||
return;
|
||||
|
@ -4,7 +4,7 @@ import ApiController from "@Common/system/controller-pattern/ApiController";
|
||||
import UsersService from "@Services/admin/UsersService/UsersService";
|
||||
import { Service } from "typedi";
|
||||
import User from "le-coffre-resources/dist/Admin";
|
||||
import { Prisma, Users } from "@prisma/client";
|
||||
import { Prisma } from "@prisma/client";
|
||||
import authHandler from "@App/middlewares/AuthHandler";
|
||||
import ruleHandler from "@App/middlewares/RulesHandler";
|
||||
import userHandler from "@App/middlewares/OfficeMembershipHandlers/UserHandler";
|
||||
@ -23,7 +23,10 @@ export default class UsersController extends ApiController {
|
||||
protected async get(req: Request, response: Response) {
|
||||
try {
|
||||
//get query
|
||||
const query = JSON.parse(req.query["q"] as string);
|
||||
let query: Prisma.UsersFindManyArgs = {};
|
||||
if (req.query["q"]) {
|
||||
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;
|
||||
@ -53,16 +56,14 @@ export default class UsersController extends ApiController {
|
||||
this.httpBadRequest(response, "No uid provided");
|
||||
return;
|
||||
}
|
||||
let userEntity: Users | null;
|
||||
//get query
|
||||
let query = {};
|
||||
if (req.query["q"]) {
|
||||
const query = JSON.parse(req.query["q"] as string);
|
||||
userEntity = await this.usersService.getByUid(uid, query);
|
||||
} else {
|
||||
//call service to get prisma entity
|
||||
userEntity = await this.usersService.getByUid(uid);
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
|
||||
const userEntity = await this.usersService.getByUid(uid, query);
|
||||
|
||||
if (!userEntity) {
|
||||
this.httpNotFoundRequest(response, "user not found");
|
||||
return;
|
||||
|
@ -23,7 +23,10 @@ export default class DocumentsController extends ApiController {
|
||||
protected async get(req: Request, response: Response) {
|
||||
try {
|
||||
//get query
|
||||
const query = JSON.parse(req.query["q"] as string);
|
||||
let query: Prisma.CustomersFindManyArgs = {};
|
||||
if (req.query["q"]) {
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
const customerId: string = req.body.user.customerId;
|
||||
const customerWhereInput: Prisma.DocumentsWhereInput ={ depositor: { uid: customerId } };
|
||||
query.where = customerWhereInput;
|
||||
@ -53,17 +56,14 @@ export default class DocumentsController extends ApiController {
|
||||
this.httpBadRequest(response, "No uid provided");
|
||||
return;
|
||||
}
|
||||
|
||||
let documentEntity: Documents | null;
|
||||
//get query
|
||||
let query = {};
|
||||
if (req.query["q"]) {
|
||||
const query = JSON.parse(req.query["q"] as string);
|
||||
documentEntity = await this.documentsService.getByUid(uid, query);
|
||||
} else {
|
||||
//call service to get prisma entity
|
||||
documentEntity = await this.documentsService.getByUid(uid);
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
|
||||
const documentEntity = await this.documentsService.getByUid(uid, query);
|
||||
|
||||
if (!documentEntity) {
|
||||
this.httpNotFoundRequest(response, "document not found");
|
||||
return;
|
||||
|
@ -26,7 +26,10 @@ export default class FilesController extends ApiController {
|
||||
protected async get(req: Request, response: Response) {
|
||||
try {
|
||||
//get query
|
||||
const query = JSON.parse(req.query["q"] as string);
|
||||
let query: Prisma.FilesFindManyArgs = {};
|
||||
if (req.query["q"]) {
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
const customerId: string = req.body.user.customerId;
|
||||
const customerWhereInput: Prisma.FilesWhereInput = { document: { depositor: { uid: customerId } } };
|
||||
query.where = customerWhereInput;
|
||||
@ -198,8 +201,13 @@ export default class FilesController extends ApiController {
|
||||
this.httpBadRequest(response, "No uid provided");
|
||||
return;
|
||||
}
|
||||
//get query
|
||||
let query = {};
|
||||
if (req.query["q"]) {
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
|
||||
const fileEntity = await this.filesService.getByUid(uid);
|
||||
const fileEntity = await this.filesService.getByUid(uid, query);
|
||||
|
||||
if (!fileEntity) {
|
||||
this.httpNotFoundRequest(response, "file not found");
|
||||
|
@ -4,7 +4,6 @@ import ApiController from "@Common/system/controller-pattern/ApiController";
|
||||
import CustomersService from "@Services/notary/CustomersService/CustomersService";
|
||||
import { Service } from "typedi";
|
||||
import { Customer } from "le-coffre-resources/dist/Notary";
|
||||
import { Customers } from "@prisma/client";
|
||||
import { validateOrReject } from "class-validator";
|
||||
import authHandler from "@App/middlewares/AuthHandler";
|
||||
import ruleHandler from "@App/middlewares/RulesHandler";
|
||||
@ -23,7 +22,10 @@ export default class CustomersController extends ApiController {
|
||||
protected async get(req: Request, response: Response) {
|
||||
try {
|
||||
//get query
|
||||
const query = JSON.parse(req.query["q"] as string);
|
||||
let query = {};
|
||||
if (req.query["q"]) {
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
|
||||
//call service to get prisma entity
|
||||
const customersEntities = await this.customersService.get(query);
|
||||
@ -118,16 +120,14 @@ export default class CustomersController extends ApiController {
|
||||
return;
|
||||
}
|
||||
|
||||
let customerEntity: Customers | null;
|
||||
//get query
|
||||
let query = {};
|
||||
if (req.query["q"]) {
|
||||
const query = JSON.parse(req.query["q"] as string);
|
||||
customerEntity = await this.customersService.getByUid(uid, query);
|
||||
} else {
|
||||
//call service to get prisma entity
|
||||
customerEntity = await this.customersService.getByUid(uid);
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
|
||||
const customerEntity = await this.customersService.getByUid(uid, query);
|
||||
|
||||
if (!customerEntity) {
|
||||
this.httpNotFoundRequest(response, "customer not found");
|
||||
return;
|
||||
|
@ -25,7 +25,10 @@ export default class DeedTypesController extends ApiController {
|
||||
protected async get(req: Request, response: Response) {
|
||||
try {
|
||||
//get query
|
||||
const query = JSON.parse(req.query["q"] as string);
|
||||
let query: Prisma.DeedTypesFindManyArgs = {};
|
||||
if (req.query["q"]) {
|
||||
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;
|
||||
@ -127,17 +130,14 @@ export default class DeedTypesController extends ApiController {
|
||||
this.httpBadRequest(response, "No uid provided");
|
||||
return;
|
||||
}
|
||||
|
||||
let deedTypeEntity: DeedTypes | null;
|
||||
//get query
|
||||
let query = {};
|
||||
if (req.query["q"]) {
|
||||
const query = JSON.parse(req.query["q"] as string);
|
||||
deedTypeEntity = await this.deedTypesService.getByUid(uid, query);
|
||||
} else {
|
||||
//call service to get prisma entity
|
||||
deedTypeEntity = await this.deedTypesService.getByUid(uid);
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
|
||||
const deedTypeEntity = await this.deedTypesService.getByUid(uid, query);
|
||||
|
||||
if (!deedTypeEntity) {
|
||||
this.httpNotFoundRequest(response, "deed type not found");
|
||||
return;
|
||||
|
@ -25,7 +25,10 @@ export default class DeedsController extends ApiController {
|
||||
protected async get(req: Request, response: Response) {
|
||||
try {
|
||||
//get query
|
||||
const query = JSON.parse(req.query["q"] as string);
|
||||
let query: Prisma.DeedsFindManyArgs = {};
|
||||
if (req.query["q"]) {
|
||||
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;
|
||||
@ -56,16 +59,11 @@ export default class DeedsController extends ApiController {
|
||||
this.httpBadRequest(response, "No uid provided");
|
||||
return;
|
||||
}
|
||||
|
||||
let deedEntity: Deeds | null;
|
||||
//get query
|
||||
let query = {};
|
||||
if (req.query["q"]) {
|
||||
const query = JSON.parse(req.query["q"] as string);
|
||||
deedEntity = await this.deedsService.getByUid(uid, query);
|
||||
} else {
|
||||
//call service to get prisma entity
|
||||
deedEntity = await this.deedsService.getByUid(uid);
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
const deedEntity = await this.deedsService.getByUid(uid, query);
|
||||
|
||||
if (!deedEntity) {
|
||||
this.httpNotFoundRequest(response, "deed not found");
|
||||
|
@ -25,7 +25,10 @@ export default class DocumentTypesController extends ApiController {
|
||||
protected async get(req: Request, response: Response) {
|
||||
try {
|
||||
//get query
|
||||
const query = JSON.parse(req.query["q"] as string);
|
||||
let query: Prisma.DocumentTypesFindManyArgs = {};
|
||||
if (req.query["q"]) {
|
||||
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;
|
||||
@ -121,17 +124,14 @@ export default class DocumentTypesController extends ApiController {
|
||||
this.httpBadRequest(response, "No uid provided");
|
||||
return;
|
||||
}
|
||||
|
||||
let documentTypeEntity: DocumentTypes | null;
|
||||
//get query
|
||||
let query = {};
|
||||
if (req.query["q"]) {
|
||||
const query = JSON.parse(req.query["q"] as string);
|
||||
documentTypeEntity = await this.documentTypesService.getByUid(uid, query);
|
||||
} else {
|
||||
//call service to get prisma entity
|
||||
documentTypeEntity = await this.documentTypesService.getByUid(uid);
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
|
||||
const documentTypeEntity = await this.documentTypesService.getByUid(uid, query);
|
||||
|
||||
//Hydrate ressource with prisma entity
|
||||
const user = ObjectHydrate.hydrate<DocumentType>(new DocumentType(), documentTypeEntity!, { strategy: "excludeAll" });
|
||||
|
||||
|
@ -25,7 +25,10 @@ export default class DocumentsController extends ApiController {
|
||||
protected async get(req: Request, response: Response) {
|
||||
try {
|
||||
//get query
|
||||
const query = JSON.parse(req.query["q"] as string);
|
||||
let query: Prisma.DocumentsFindManyArgs = {};
|
||||
if (req.query["q"]) {
|
||||
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;
|
||||
@ -156,17 +159,14 @@ export default class DocumentsController extends ApiController {
|
||||
this.httpBadRequest(response, "No uid provided");
|
||||
return;
|
||||
}
|
||||
|
||||
let documentEntity: Documents | null;
|
||||
//get query
|
||||
let query = {};
|
||||
if (req.query["q"]) {
|
||||
const query = JSON.parse(req.query["q"] as string);
|
||||
documentEntity = await this.documentsService.getByUid(uid, query);
|
||||
} else {
|
||||
//call service to get prisma entity
|
||||
documentEntity = await this.documentsService.getByUid(uid);
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
|
||||
const documentEntity = await this.documentsService.getByUid(uid, query);
|
||||
|
||||
if (!documentEntity) {
|
||||
this.httpNotFoundRequest(response, "document not found");
|
||||
return;
|
||||
|
@ -24,7 +24,10 @@ export default class FilesController extends ApiController {
|
||||
protected async get(req: Request, response: Response) {
|
||||
try {
|
||||
//get query
|
||||
const query = JSON.parse(req.query["q"] as string);
|
||||
let query: Prisma.FilesFindManyArgs = {};
|
||||
if (req.query["q"]) {
|
||||
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;
|
||||
@ -119,8 +122,13 @@ export default class FilesController extends ApiController {
|
||||
this.httpBadRequest(response, "No uid provided");
|
||||
return;
|
||||
}
|
||||
//get query
|
||||
let query = {};
|
||||
if (req.query["q"]) {
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
|
||||
const fileEntity = await this.filesService.getByUid(uid);
|
||||
const fileEntity = await this.filesService.getByUid(uid, query);
|
||||
|
||||
if (!fileEntity) {
|
||||
this.httpNotFoundRequest(response, "file not found");
|
||||
|
@ -24,7 +24,10 @@ export default class OfficeFoldersController extends ApiController {
|
||||
protected async get(req: Request, response: Response) {
|
||||
try {
|
||||
//get query
|
||||
const query = JSON.parse(req.query["q"] as string);
|
||||
let query: Prisma.OfficeFoldersFindManyArgs = {};
|
||||
if (req.query["q"]) {
|
||||
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;
|
||||
@ -120,17 +123,14 @@ export default class OfficeFoldersController extends ApiController {
|
||||
this.httpBadRequest(response, "No uid provided");
|
||||
return;
|
||||
}
|
||||
|
||||
let officeFolderEntity: OfficeFolders | null;
|
||||
//get query
|
||||
let query = {};
|
||||
if (req.query["q"]) {
|
||||
const 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);
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
|
||||
const officeFolderEntity = await this.officeFoldersService.getByUid(uid, query);
|
||||
|
||||
if (!officeFolderEntity) {
|
||||
this.httpNotFoundRequest(response, "folder not found");
|
||||
return;
|
||||
|
@ -4,7 +4,7 @@ import ApiController from "@Common/system/controller-pattern/ApiController";
|
||||
import OfficeRolesService from "@Services/notary/OfficeRolesService/OfficeRolesService";
|
||||
import { Service } from "typedi";
|
||||
import { OfficeRole } from "le-coffre-resources/dist/Notary";
|
||||
import { OfficeRoles, Prisma } from "@prisma/client";
|
||||
import { Prisma } from "@prisma/client";
|
||||
import authHandler from "@App/middlewares/AuthHandler";
|
||||
import ruleHandler from "@App/middlewares/RulesHandler";
|
||||
import officeRoleHandler from "@App/middlewares/OfficeMembershipHandlers/OfficeRoleHandler";
|
||||
@ -23,7 +23,10 @@ export default class OfficeRolesController extends ApiController {
|
||||
protected async get(req: Request, response: Response) {
|
||||
try {
|
||||
//get query
|
||||
const query = JSON.parse(req.query["q"] as string);
|
||||
let query: Prisma.OfficeRolesFindManyArgs = {};
|
||||
if (req.query["q"]) {
|
||||
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;
|
||||
@ -53,16 +56,14 @@ export default class OfficeRolesController extends ApiController {
|
||||
this.httpBadRequest(response, "No uid provided");
|
||||
return;
|
||||
}
|
||||
let officeRoleEntity: OfficeRoles | null;
|
||||
//get query
|
||||
let query = {};
|
||||
if (req.query["q"]) {
|
||||
const query = JSON.parse(req.query["q"] as string);
|
||||
officeRoleEntity = await this.officeRolesService.getByUid(uid, query);
|
||||
} else {
|
||||
//call service to get prisma entity
|
||||
officeRoleEntity = await this.officeRolesService.getByUid(uid);
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
|
||||
const officeRoleEntity = await this.officeRolesService.getByUid(uid, query);
|
||||
|
||||
if (!officeRoleEntity) {
|
||||
this.httpNotFoundRequest(response, "officeRole not found");
|
||||
return;
|
||||
|
@ -21,7 +21,10 @@ export default class OfficesController extends ApiController {
|
||||
protected async get(req: Request, response: Response) {
|
||||
try {
|
||||
//get query
|
||||
const query = JSON.parse(req.query["q"] as string);
|
||||
let query = {};
|
||||
if (req.query["q"]) {
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
//call service to get prisma entity
|
||||
const officesEntities: Offices[] = await this.officesService.get(query);
|
||||
//Hydrate ressource with prisma entity
|
||||
@ -33,7 +36,7 @@ export default class OfficesController extends ApiController {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @description Get a specific office by uid
|
||||
*/
|
||||
@ -45,16 +48,14 @@ export default class OfficesController extends ApiController {
|
||||
this.httpBadRequest(response, "No uid provided");
|
||||
return;
|
||||
}
|
||||
let officeEntity: Offices | null;
|
||||
//get query
|
||||
let query = {};
|
||||
if (req.query["q"]) {
|
||||
const query = JSON.parse(req.query["q"] as string);
|
||||
officeEntity = await this.officesService.getByUid(uid, query);
|
||||
} else {
|
||||
//call service to get prisma entity
|
||||
officeEntity = await this.officesService.getByUid(uid);
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
|
||||
const officeEntity = await this.officesService.getByUid(uid, query);
|
||||
|
||||
if (!officeEntity) {
|
||||
this.httpNotFoundRequest(response, "office not found");
|
||||
return;
|
||||
|
@ -4,7 +4,6 @@ import ApiController from "@Common/system/controller-pattern/ApiController";
|
||||
import RolesService from "@Services/notary/RolesService/RolesService";
|
||||
import { Service } from "typedi";
|
||||
import { Role } from "le-coffre-resources/dist/Notary";
|
||||
import { Roles } from "@prisma/client";
|
||||
import authHandler from "@App/middlewares/AuthHandler";
|
||||
import ruleHandler from "@App/middlewares/RulesHandler";
|
||||
|
||||
@ -22,7 +21,10 @@ export default class RolesController extends ApiController {
|
||||
protected async get(req: Request, response: Response) {
|
||||
try {
|
||||
//get query
|
||||
const query = JSON.parse(req.query["q"] as string);
|
||||
let query = {};
|
||||
if (req.query["q"]) {
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
|
||||
//call service to get prisma entity
|
||||
const rolesEntities = await this.rolesService.get(query);
|
||||
@ -49,16 +51,14 @@ export default class RolesController extends ApiController {
|
||||
this.httpBadRequest(response, "No uid provided");
|
||||
return;
|
||||
}
|
||||
let roleEntity: Roles | null;
|
||||
//get query
|
||||
let query = {};
|
||||
if (req.query["q"]) {
|
||||
const query = JSON.parse(req.query["q"] as string);
|
||||
roleEntity = await this.rolesService.getByUid(uid, query);
|
||||
} else {
|
||||
//call service to get prisma entity
|
||||
roleEntity = await this.rolesService.getByUid(uid);
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
|
||||
const roleEntity = await this.rolesService.getByUid(uid, query);
|
||||
|
||||
if (!roleEntity) {
|
||||
this.httpNotFoundRequest(response, "role not found");
|
||||
return;
|
||||
|
@ -4,7 +4,6 @@ import ApiController from "@Common/system/controller-pattern/ApiController";
|
||||
import RulesService from "@Services/notary/RulesService/RulesService";
|
||||
import { Service } from "typedi";
|
||||
import { Rule } from "le-coffre-resources/dist/Notary";
|
||||
import { Rules } from "@prisma/client";
|
||||
import authHandler from "@App/middlewares/AuthHandler";
|
||||
import ruleHandler from "@App/middlewares/RulesHandler";
|
||||
|
||||
@ -22,7 +21,10 @@ export default class RulesController extends ApiController {
|
||||
protected async get(req: Request, response: Response) {
|
||||
try {
|
||||
//get query
|
||||
const query = JSON.parse(req.query["q"] as string);
|
||||
let query = {};
|
||||
if (req.query["q"]) {
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
|
||||
//call service to get prisma entity
|
||||
const rulesEntities = await this.rulesService.get(query);
|
||||
@ -49,16 +51,14 @@ export default class RulesController extends ApiController {
|
||||
this.httpBadRequest(response, "No uid provided");
|
||||
return;
|
||||
}
|
||||
let ruleEntity: Rules | null;
|
||||
//get query
|
||||
let query = {};
|
||||
if (req.query["q"]) {
|
||||
const query = JSON.parse(req.query["q"] as string);
|
||||
ruleEntity = await this.rulesService.getByUid(uid, query);
|
||||
} else {
|
||||
//call service to get prisma entity
|
||||
ruleEntity = await this.rulesService.getByUid(uid);
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
|
||||
const ruleEntity = await this.rulesService.getByUid(uid, query);
|
||||
|
||||
if (!ruleEntity) {
|
||||
this.httpNotFoundRequest(response, "rule not found");
|
||||
return;
|
||||
|
@ -4,7 +4,7 @@ import ApiController from "@Common/system/controller-pattern/ApiController";
|
||||
import UsersService from "@Services/notary/UsersService/UsersService";
|
||||
import { Service } from "typedi";
|
||||
import User from "le-coffre-resources/dist/Notary";
|
||||
import { Prisma, Users } from "@prisma/client";
|
||||
import { Prisma } from "@prisma/client";
|
||||
import authHandler from "@App/middlewares/AuthHandler";
|
||||
import ruleHandler from "@App/middlewares/RulesHandler";
|
||||
import userHandler from "@App/middlewares/OfficeMembershipHandlers/UserHandler";
|
||||
@ -23,7 +23,10 @@ export default class UsersController extends ApiController {
|
||||
protected async get(req: Request, response: Response) {
|
||||
try {
|
||||
//get query
|
||||
const query = JSON.parse(req.query["q"] as string);
|
||||
let query: Prisma.UsersFindManyArgs = {};
|
||||
if (req.query["q"]) {
|
||||
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;
|
||||
@ -53,16 +56,14 @@ export default class UsersController extends ApiController {
|
||||
this.httpBadRequest(response, "No uid provided");
|
||||
return;
|
||||
}
|
||||
let userEntity: Users | null;
|
||||
//get query
|
||||
let query = {};
|
||||
if (req.query["q"]) {
|
||||
const query = JSON.parse(req.query["q"] as string);
|
||||
userEntity = await this.usersService.getByUid(uid, query);
|
||||
} else {
|
||||
//call service to get prisma entity
|
||||
userEntity = await this.usersService.getByUid(uid);
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
|
||||
const userEntity = await this.usersService.getByUid(uid, query);
|
||||
|
||||
if (!userEntity) {
|
||||
this.httpNotFoundRequest(response, "user not found");
|
||||
return;
|
||||
|
@ -4,7 +4,6 @@ import ApiController from "@Common/system/controller-pattern/ApiController";
|
||||
import CustomersService from "@Services/super-admin/CustomersService/CustomersService";
|
||||
import { Service } from "typedi";
|
||||
import { Customer } from "le-coffre-resources/dist/SuperAdmin";
|
||||
import { Customers } from "@prisma/client";
|
||||
import { validateOrReject } from "class-validator";
|
||||
import authHandler from "@App/middlewares/AuthHandler";
|
||||
import ruleHandler from "@App/middlewares/RulesHandler";
|
||||
@ -23,7 +22,10 @@ export default class CustomersController extends ApiController {
|
||||
protected async get(req: Request, response: Response) {
|
||||
try {
|
||||
//get query
|
||||
const query = JSON.parse(req.query["q"] as string);
|
||||
let query = {};
|
||||
if (req.query["q"]) {
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
|
||||
//call service to get prisma entity
|
||||
const customersEntities = await this.customersService.get(query);
|
||||
@ -118,15 +120,12 @@ export default class CustomersController extends ApiController {
|
||||
return;
|
||||
}
|
||||
|
||||
let customerEntity: Customers | null;
|
||||
//get query
|
||||
let query = {};
|
||||
if (req.query["q"]) {
|
||||
const query = JSON.parse(req.query["q"] as string);
|
||||
customerEntity = await this.customersService.getByUid(uid, query);
|
||||
} else {
|
||||
//call service to get prisma entity
|
||||
customerEntity = await this.customersService.getByUid(uid);
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
|
||||
const customerEntity = await this.customersService.getByUid(uid, query);
|
||||
|
||||
if (!customerEntity) {
|
||||
this.httpNotFoundRequest(response, "customer not found");
|
||||
|
@ -25,7 +25,10 @@ export default class DeedTypesController extends ApiController {
|
||||
protected async get(req: Request, response: Response) {
|
||||
try {
|
||||
//get query
|
||||
const query = JSON.parse(req.query["q"] as string);
|
||||
let query: Prisma.DeedTypesFindManyArgs = {};
|
||||
if (req.query["q"]) {
|
||||
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;
|
||||
@ -128,16 +131,14 @@ export default class DeedTypesController extends ApiController {
|
||||
return;
|
||||
}
|
||||
|
||||
let deedTypeEntity: DeedTypes | null;
|
||||
//get query
|
||||
let query = {};
|
||||
if (req.query["q"]) {
|
||||
const query = JSON.parse(req.query["q"] as string);
|
||||
deedTypeEntity = await this.deedTypesService.getByUid(uid, query);
|
||||
} else {
|
||||
//call service to get prisma entity
|
||||
deedTypeEntity = await this.deedTypesService.getByUid(uid);
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
|
||||
const deedTypeEntity = await this.deedTypesService.getByUid(uid, query);
|
||||
|
||||
|
||||
if (!deedTypeEntity) {
|
||||
this.httpNotFoundRequest(response, "deed type not found");
|
||||
return;
|
||||
|
@ -25,7 +25,10 @@ export default class DeedsController extends ApiController {
|
||||
protected async get(req: Request, response: Response) {
|
||||
try {
|
||||
//get query
|
||||
const query = JSON.parse(req.query["q"] as string);
|
||||
let query: Prisma.DeedsFindManyArgs = {};
|
||||
if (req.query["q"]) {
|
||||
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;
|
||||
@ -57,16 +60,13 @@ export default class DeedsController extends ApiController {
|
||||
return;
|
||||
}
|
||||
|
||||
let deedEntity: Deeds | null;
|
||||
//get query
|
||||
let query = {};
|
||||
if (req.query["q"]) {
|
||||
const query = JSON.parse(req.query["q"] as string);
|
||||
deedEntity = await this.deedsService.getByUid(uid, query);
|
||||
} else {
|
||||
//call service to get prisma entity
|
||||
deedEntity = await this.deedsService.getByUid(uid);
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
|
||||
const deedEntity = await this.deedsService.getByUid(uid, query);
|
||||
|
||||
if (!deedEntity) {
|
||||
this.httpNotFoundRequest(response, "deed not found");
|
||||
return;
|
||||
|
@ -25,7 +25,10 @@ export default class DocumentTypesController extends ApiController {
|
||||
protected async get(req: Request, response: Response) {
|
||||
try {
|
||||
//get query
|
||||
const query = JSON.parse(req.query["q"] as string);
|
||||
let query: Prisma.DocumentTypesFindManyArgs = {};
|
||||
if (req.query["q"]) {
|
||||
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;
|
||||
@ -122,15 +125,12 @@ export default class DocumentTypesController extends ApiController {
|
||||
return;
|
||||
}
|
||||
|
||||
let documentTypeEntity: DocumentTypes | null;
|
||||
//get query
|
||||
let query = {};
|
||||
if (req.query["q"]) {
|
||||
const query = JSON.parse(req.query["q"] as string);
|
||||
documentTypeEntity = await this.documentTypesService.getByUid(uid, query);
|
||||
} else {
|
||||
//call service to get prisma entity
|
||||
documentTypeEntity = await this.documentTypesService.getByUid(uid);
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
|
||||
const documentTypeEntity = await this.documentTypesService.getByUid(uid, query);
|
||||
|
||||
//Hydrate ressource with prisma entity
|
||||
const user = ObjectHydrate.hydrate<DocumentType>(new DocumentType(), documentTypeEntity!, { strategy: "excludeAll" });
|
||||
|
@ -25,7 +25,10 @@ export default class DocumentsController extends ApiController {
|
||||
protected async get(req: Request, response: Response) {
|
||||
try {
|
||||
//get query
|
||||
const query = JSON.parse(req.query["q"] as string);
|
||||
let query: Prisma.DocumentsFindManyArgs = {};
|
||||
if (req.query["q"]) {
|
||||
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;
|
||||
@ -157,15 +160,12 @@ export default class DocumentsController extends ApiController {
|
||||
return;
|
||||
}
|
||||
|
||||
let documentEntity: Documents | null;
|
||||
//get query
|
||||
let query = {};
|
||||
if (req.query["q"]) {
|
||||
const query = JSON.parse(req.query["q"] as string);
|
||||
documentEntity = await this.documentsService.getByUid(uid, query);
|
||||
} else {
|
||||
//call service to get prisma entity
|
||||
documentEntity = await this.documentsService.getByUid(uid);
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
|
||||
const documentEntity = await this.documentsService.getByUid(uid, query);
|
||||
|
||||
if (!documentEntity) {
|
||||
this.httpNotFoundRequest(response, "document not found");
|
||||
|
@ -24,7 +24,10 @@ export default class FilesController extends ApiController {
|
||||
protected async get(req: Request, response: Response) {
|
||||
try {
|
||||
//get query
|
||||
const query = JSON.parse(req.query["q"] as string);
|
||||
let query: Prisma.FilesFindManyArgs = {};
|
||||
if (req.query["q"]) {
|
||||
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;
|
||||
@ -120,7 +123,12 @@ export default class FilesController extends ApiController {
|
||||
return;
|
||||
}
|
||||
|
||||
const fileEntity = await this.filesService.getByUid(uid);
|
||||
let query = {};
|
||||
if (req.query["q"]) {
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
|
||||
const fileEntity = await this.filesService.getByUid(uid, query);
|
||||
|
||||
if (!fileEntity) {
|
||||
this.httpNotFoundRequest(response, "file not found");
|
||||
|
@ -24,7 +24,10 @@ export default class OfficeFoldersController extends ApiController {
|
||||
protected async get(req: Request, response: Response) {
|
||||
try {
|
||||
//get query
|
||||
const query = JSON.parse(req.query["q"] as string);
|
||||
let query: Prisma.OfficeFoldersFindManyArgs = {};
|
||||
if (req.query["q"]) {
|
||||
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;
|
||||
@ -79,7 +82,12 @@ export default class OfficeFoldersController extends ApiController {
|
||||
return;
|
||||
}
|
||||
|
||||
const officeFolderFound = await this.officeFoldersService.getByUid(uid);
|
||||
let query = {};
|
||||
if (req.query["q"]) {
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
|
||||
const officeFolderFound = await this.officeFoldersService.getByUid(uid, query);
|
||||
|
||||
if (!officeFolderFound) {
|
||||
this.httpNotFoundRequest(response, "office folder not found");
|
||||
@ -124,7 +132,10 @@ export default class OfficeFoldersController extends ApiController {
|
||||
let officeFolderEntity: OfficeFolders | null;
|
||||
//get query
|
||||
if (req.query["q"]) {
|
||||
const query = JSON.parse(req.query["q"] as string);
|
||||
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
|
||||
|
@ -5,7 +5,7 @@ import OfficeRolesService from "@Services/super-admin/OfficeRolesService/OfficeR
|
||||
import { Service } from "typedi";
|
||||
import { validateOrReject } from "class-validator";
|
||||
import { OfficeRole } from "le-coffre-resources/dist/SuperAdmin";
|
||||
import { OfficeRoles, Prisma } from "@prisma/client";
|
||||
import { Prisma } from "@prisma/client";
|
||||
import authHandler from "@App/middlewares/AuthHandler";
|
||||
import ruleHandler from "@App/middlewares/RulesHandler";
|
||||
import officeRoleHandler from "@App/middlewares/OfficeMembershipHandlers/OfficeRoleHandler";
|
||||
@ -24,7 +24,10 @@ export default class OfficeRolesController extends ApiController {
|
||||
protected async get(req: Request, response: Response) {
|
||||
try {
|
||||
//get query
|
||||
const query = JSON.parse(req.query["q"] as string);
|
||||
let query: Prisma.OfficeRolesFindManyArgs = {};
|
||||
if (req.query["q"]) {
|
||||
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;
|
||||
@ -123,16 +126,14 @@ export default class OfficeRolesController extends ApiController {
|
||||
this.httpBadRequest(response, "No uid provided");
|
||||
return;
|
||||
}
|
||||
let officeRoleEntity: OfficeRoles | null;
|
||||
//get query
|
||||
|
||||
let query = {};
|
||||
if (req.query["q"]) {
|
||||
const query = JSON.parse(req.query["q"] as string);
|
||||
officeRoleEntity = await this.officeRolesService.getByUid(uid, query);
|
||||
} else {
|
||||
//call service to get prisma entity
|
||||
officeRoleEntity = await this.officeRolesService.getByUid(uid);
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
|
||||
const officeRoleEntity = await this.officeRolesService.getByUid(uid, query);
|
||||
|
||||
if (!officeRoleEntity) {
|
||||
this.httpNotFoundRequest(response, "officeRole not found");
|
||||
return;
|
||||
|
@ -22,7 +22,10 @@ export default class OfficesController extends ApiController {
|
||||
protected async get(req: Request, response: Response) {
|
||||
try {
|
||||
//get query
|
||||
const query = JSON.parse(req.query["q"] as string);
|
||||
let query = {};
|
||||
if (req.query["q"]) {
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
//call service to get prisma entity
|
||||
const officesEntities: Offices[] = await this.officesService.get(query);
|
||||
//Hydrate ressource with prisma entity
|
||||
@ -103,16 +106,14 @@ export default class OfficesController extends ApiController {
|
||||
this.httpBadRequest(response, "No uid provided");
|
||||
return;
|
||||
}
|
||||
let officeEntity: Offices | null;
|
||||
//get query
|
||||
|
||||
let query = {};
|
||||
if (req.query["q"]) {
|
||||
const query = JSON.parse(req.query["q"] as string);
|
||||
officeEntity = await this.officesService.getByUid(uid, query);
|
||||
} else {
|
||||
//call service to get prisma entity
|
||||
officeEntity = await this.officesService.getByUid(uid);
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
|
||||
const officeEntity = await this.officesService.getByUid(uid, query);
|
||||
|
||||
if (!officeEntity) {
|
||||
this.httpNotFoundRequest(response, "office not found");
|
||||
return;
|
||||
|
@ -5,7 +5,6 @@ import RolesService from "@Services/super-admin/RolesService/RolesService";
|
||||
import { Service } from "typedi";
|
||||
import { validateOrReject } from "class-validator";
|
||||
import { Role } from "le-coffre-resources/dist/SuperAdmin";
|
||||
import { Roles } from "@prisma/client";
|
||||
import authHandler from "@App/middlewares/AuthHandler";
|
||||
import ruleHandler from "@App/middlewares/RulesHandler";
|
||||
|
||||
@ -23,7 +22,10 @@ export default class RolesController extends ApiController {
|
||||
protected async get(req: Request, response: Response) {
|
||||
try {
|
||||
//get query
|
||||
const query = JSON.parse(req.query["q"] as string);
|
||||
let query = {};
|
||||
if (req.query["q"]) {
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
|
||||
//call service to get prisma entity
|
||||
const rolesEntities = await this.rolesService.get(query);
|
||||
@ -119,16 +121,14 @@ export default class RolesController extends ApiController {
|
||||
this.httpBadRequest(response, "No uid provided");
|
||||
return;
|
||||
}
|
||||
let roleEntity: Roles | null;
|
||||
//get query
|
||||
|
||||
let query = {};
|
||||
if (req.query["q"]) {
|
||||
const query = JSON.parse(req.query["q"] as string);
|
||||
roleEntity = await this.rolesService.getByUid(uid, query);
|
||||
} else {
|
||||
//call service to get prisma entity
|
||||
roleEntity = await this.rolesService.getByUid(uid);
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
|
||||
const roleEntity = await this.rolesService.getByUid(uid, query);
|
||||
|
||||
if (!roleEntity) {
|
||||
this.httpNotFoundRequest(response, "role not found");
|
||||
return;
|
||||
|
@ -5,7 +5,6 @@ import RulesService from "@Services/super-admin/RulesService/RulesService";
|
||||
import { Service } from "typedi";
|
||||
import { validateOrReject } from "class-validator";
|
||||
import { Rule } from "le-coffre-resources/dist/SuperAdmin";
|
||||
import { Rules } from "@prisma/client";
|
||||
import authHandler from "@App/middlewares/AuthHandler";
|
||||
import ruleHandler from "@App/middlewares/RulesHandler";
|
||||
|
||||
@ -23,7 +22,10 @@ export default class RulesController extends ApiController {
|
||||
protected async get(req: Request, response: Response) {
|
||||
try {
|
||||
//get query
|
||||
const query = JSON.parse(req.query["q"] as string);
|
||||
let query = {};
|
||||
if (req.query["q"]) {
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
|
||||
//call service to get prisma entity
|
||||
const rulesEntities = await this.rulesService.get(query);
|
||||
@ -119,16 +121,13 @@ export default class RulesController extends ApiController {
|
||||
this.httpBadRequest(response, "No uid provided");
|
||||
return;
|
||||
}
|
||||
let ruleEntity: Rules | null;
|
||||
//get query
|
||||
let query = {};
|
||||
if (req.query["q"]) {
|
||||
const query = JSON.parse(req.query["q"] as string);
|
||||
ruleEntity = await this.rulesService.getByUid(uid, query);
|
||||
} else {
|
||||
//call service to get prisma entity
|
||||
ruleEntity = await this.rulesService.getByUid(uid);
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
|
||||
const ruleEntity = await this.rulesService.getByUid(uid, query);
|
||||
|
||||
if (!ruleEntity) {
|
||||
this.httpNotFoundRequest(response, "rule not found");
|
||||
return;
|
||||
|
@ -5,7 +5,6 @@ import UsersService from "@Services/super-admin/UsersService/UsersService";
|
||||
import { Service } from "typedi";
|
||||
import { validateOrReject } from "class-validator";
|
||||
import User from "le-coffre-resources/dist/SuperAdmin";
|
||||
import { Users } from "@prisma/client";
|
||||
import authHandler from "@App/middlewares/AuthHandler";
|
||||
import ruleHandler from "@App/middlewares/RulesHandler";
|
||||
|
||||
@ -23,7 +22,10 @@ export default class UsersController extends ApiController {
|
||||
protected async get(req: Request, response: Response) {
|
||||
try {
|
||||
//get query
|
||||
const query = JSON.parse(req.query["q"] as string);
|
||||
let query = {};
|
||||
if (req.query["q"]) {
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
|
||||
//call service to get prisma entity
|
||||
const usersEntities = await this.usersService.get(query);
|
||||
@ -119,15 +121,11 @@ export default class UsersController extends ApiController {
|
||||
this.httpBadRequest(response, "No uid provided");
|
||||
return;
|
||||
}
|
||||
let userEntity: Users | null;
|
||||
//get query
|
||||
let query = {};
|
||||
if (req.query["q"]) {
|
||||
const query = JSON.parse(req.query["q"] as string);
|
||||
userEntity = await this.usersService.getByUid(uid, query);
|
||||
} else {
|
||||
//call service to get prisma entity
|
||||
userEntity = await this.usersService.getByUid(uid);
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
const userEntity = await this.usersService.getByUid(uid, query);
|
||||
|
||||
if (!userEntity) {
|
||||
this.httpNotFoundRequest(response, "user not found");
|
||||
|
@ -82,7 +82,7 @@ export default class DeedsRepository extends BaseRepository {
|
||||
/**
|
||||
* @description : Find unique deed
|
||||
*/
|
||||
public async findOneByUid(uid: string, query?: Prisma.DeedsInclude) {
|
||||
public async findOneByUid(uid: string, query?: Prisma.DeedsInclude): Promise<Deeds | null> {
|
||||
return this.model.findUnique({
|
||||
where: {
|
||||
uid: uid,
|
||||
|
@ -145,7 +145,7 @@ export default class UsersRepository extends BaseRepository {
|
||||
/**
|
||||
* @description : Find one user
|
||||
*/
|
||||
public async findOneByUid(uid: string, query?: Prisma.UsersInclude) {
|
||||
public async findOneByUid(uid: string, query?: Prisma.UsersInclude): Promise<Users | null> {
|
||||
return this.model.findUnique({
|
||||
where: {
|
||||
uid: uid,
|
||||
|
Loading…
x
Reference in New Issue
Block a user