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