fix erros & access

This commit is contained in:
OxSaitama 2023-10-24 21:50:49 +02:00
parent 6ceb96ea4c
commit 99985590bc
44 changed files with 287 additions and 198 deletions

View File

@ -25,14 +25,17 @@ 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
let query; let query: Prisma.CustomersFindManyArgs = {};
if (req.query["q"]) { if (req.query["q"]) {
query = JSON.parse(req.query["q"] as string); query = JSON.parse(req.query["q"] as string);
if (query.where?.uid) {
this.httpBadRequest(response, "You can't filter by uid");
return;
}
} }
const officeId: string = req.body.user.office_Id; const officeId: string = req.body.user.office_Id;
if (query.where?.office_folders?.some?.office_uid) delete query.where.office_folders.some.office_uid; if (query.where?.office_folders) delete query.where.office_folders;
if (query.where?.office_folders?.some?.office?.uid) delete query.where?.office_folders?.some?.office?.uid;
const customerWhereInput: Prisma.CustomersWhereInput = { ...query.where, office_folders: { some: { office_uid: officeId } } }; const customerWhereInput: Prisma.CustomersWhereInput = { ...query.where, office_folders: { some: { office_uid: officeId } } };
query.where = customerWhereInput; query.where = customerWhereInput;
@ -50,7 +53,6 @@ export default class CustomersController extends ApiController {
} }
} }
/** /**
* @description Create a new customer * @description Create a new customer
*/ */
@ -128,27 +130,29 @@ export default class CustomersController extends ApiController {
return; return;
} }
const customers = await this.customersService.get({ if (customerEntity.contact?.email) {
where: { const customers = await this.customersService.get({
contact: { email: customerEntity.contact?.email }, where: {
office_folders: { contact: { email: customerEntity.contact?.email },
some: { office_folders: {
office_uid: req.body.user.office_Id, some: {
office_uid: req.body.user.office_Id,
},
}, },
}, },
}, });
});
if (customers.length != 0) { if (customers.length != 0) {
try { try {
customers.forEach((customer) => { customers.forEach((customer) => {
if (customer.uid != uid) { if (customer.uid != uid) {
throw new Error("email déjà utilisé"); throw new Error("email déjà utilisé");
} }
}); });
} catch (error) { } catch (error) {
this.httpValidationError(response, [{ property: "email", constraints: { unique: "email déjà utilisé" } }]); this.httpValidationError(response, [{ property: "email", constraints: { unique: "email déjà utilisé" } }]);
return; return;
}
} }
} }

View File

@ -29,6 +29,10 @@ export default class DeedTypesController extends ApiController {
let query: Prisma.DeedTypesFindManyArgs = {}; let query: Prisma.DeedTypesFindManyArgs = {};
if (req.query["q"]) { if (req.query["q"]) {
query = JSON.parse(req.query["q"] as string); query = JSON.parse(req.query["q"] as string);
if(query.where?.uid) {
this.httpBadRequest(response, "You can't filter by uid");
return;
}
} }
if (req.query["search"] && typeof req.query["search"] === "string") { if (req.query["search"] && typeof req.query["search"] === "string") {

View File

@ -29,6 +29,10 @@ export default class DeedsController extends ApiController {
let query: Prisma.DeedsFindManyArgs = {}; let query: Prisma.DeedsFindManyArgs = {};
if (req.query["q"]) { if (req.query["q"]) {
query = JSON.parse(req.query["q"] as string); query = JSON.parse(req.query["q"] as string);
if(query.where?.uid) {
this.httpBadRequest(response, "You can't filter by uid");
return;
}
} }
const officeId: string = req.body.user.office_Id; const officeId: string = req.body.user.office_Id;
const officeWhereInput: Prisma.OfficesWhereInput = { uid: officeId } ; const officeWhereInput: Prisma.OfficesWhereInput = { uid: officeId } ;

View File

@ -29,6 +29,10 @@ export default class DocumentTypesController extends ApiController {
let query: Prisma.DocumentTypesFindManyArgs = {}; let query: Prisma.DocumentTypesFindManyArgs = {};
if (req.query["q"]) { if (req.query["q"]) {
query = JSON.parse(req.query["q"] as string); query = JSON.parse(req.query["q"] as string);
if(query.where?.uid) {
this.httpBadRequest(response, "You can't filter by uid");
return;
}
} }
const officeId: string = req.body.user.office_Id; const officeId: string = req.body.user.office_Id;
const officeWhereInput: Prisma.OfficesWhereInput = { uid: officeId } ; const officeWhereInput: Prisma.OfficesWhereInput = { uid: officeId } ;

View File

@ -30,6 +30,10 @@ export default class DocumentsController extends ApiController {
let query: Prisma.DocumentsFindManyArgs = {}; let query: Prisma.DocumentsFindManyArgs = {};
if (req.query["q"]) { if (req.query["q"]) {
query = JSON.parse(req.query["q"] as string); query = JSON.parse(req.query["q"] as string);
if(query.where?.uid) {
this.httpBadRequest(response, "You can't filter by uid");
return;
}
} }
const officeId: string = req.body.user.office_Id; const officeId: string = req.body.user.office_Id;
const officeWhereInput: Prisma.OfficesWhereInput = { uid: officeId }; const officeWhereInput: Prisma.OfficesWhereInput = { uid: officeId };

View File

@ -1,5 +1,5 @@
import { Response, Request } from "express"; import { Response, Request } from "express";
import { Controller, Delete, Get } from "@ControllerPattern/index"; import { Controller, Get } from "@ControllerPattern/index";
import ApiController from "@Common/system/controller-pattern/ApiController"; import ApiController from "@Common/system/controller-pattern/ApiController";
import { Service } from "typedi"; import { Service } from "typedi";
import FilesService from "@Services/common/FilesService/FilesService"; import FilesService from "@Services/common/FilesService/FilesService";
@ -28,6 +28,10 @@ export default class FilesController extends ApiController {
let query: Prisma.FilesFindManyArgs = {}; let query: Prisma.FilesFindManyArgs = {};
if (req.query["q"]) { if (req.query["q"]) {
query = JSON.parse(req.query["q"] as string); query = JSON.parse(req.query["q"] as string);
if(query.where?.uid) {
this.httpBadRequest(response, "You can't filter by uid");
return;
}
} }
const officeId: string = req.body.user.office_Id; const officeId: string = req.body.user.office_Id;
const officeWhereInput: Prisma.OfficesWhereInput = { uid: officeId } ; const officeWhereInput: Prisma.OfficesWhereInput = { uid: officeId } ;
@ -75,44 +79,6 @@ export default class FilesController extends ApiController {
} }
} }
/**
* @description Delete a specific File
*/
@Delete("/api/v1/admin/files/:uid", [authHandler, roleHandler, ruleHandler, fileHandler])
protected async delete(req: Request, response: Response) {
try {
const uid = req.params["uid"];
if (!uid) {
this.httpBadRequest(response, "No uid provided");
return;
}
const fileFound = await this.filesService.getByUid(uid);
if (!fileFound) {
this.httpNotFoundRequest(response, "file not found");
return;
}
//call service to get prisma entity
const fileEntity = await this.filesService.deleteKeyAndArchive(uid);
if (!fileEntity) {
this.httpNotFoundRequest(response, "file not found");
return;
}
//Hydrate ressource with prisma entity
const file = File.hydrate<File>(fileEntity, { strategy: "excludeAll" });
//success
this.httpSuccess(response, file);
} catch (error) {
this.httpInternalError(response, error);
return;
}
}
/** /**
* @description Get a specific File by uid * @description Get a specific File by uid
*/ */

View File

@ -28,6 +28,10 @@ export default class OfficeFoldersController extends ApiController {
let query: Prisma.OfficeFoldersFindManyArgs = {}; let query: Prisma.OfficeFoldersFindManyArgs = {};
if (req.query["q"]) { if (req.query["q"]) {
query = JSON.parse(req.query["q"] as string); query = JSON.parse(req.query["q"] as string);
if(query.where?.uid) {
this.httpBadRequest(response, "You can't filter by uid");
return;
}
} }
if (req.query["search"] && typeof req.query["search"] === "string") { if (req.query["search"] && typeof req.query["search"] === "string") {

View File

@ -29,6 +29,10 @@ export default class OfficeRolesController extends ApiController {
let query: Prisma.OfficeRolesFindManyArgs = {}; let query: Prisma.OfficeRolesFindManyArgs = {};
if (req.query["q"]) { if (req.query["q"]) {
query = JSON.parse(req.query["q"] as string); query = JSON.parse(req.query["q"] as string);
if(query.where?.uid) {
this.httpBadRequest(response, "You can't filter by uid");
return;
}
} }
if (req.query["search"] && typeof req.query["search"] === "string") { if (req.query["search"] && typeof req.query["search"] === "string") {

View File

@ -3,7 +3,7 @@ import { Controller, Get } from "@ControllerPattern/index";
import ApiController from "@Common/system/controller-pattern/ApiController"; import ApiController from "@Common/system/controller-pattern/ApiController";
import OfficesService from "@Services/admin/OfficesService/OfficesService"; import OfficesService from "@Services/admin/OfficesService/OfficesService";
import { Service } from "typedi"; import { Service } from "typedi";
import { Offices } from "@prisma/client"; import { Offices, Prisma } from "@prisma/client";
import { Office as OfficeResource } from "le-coffre-resources/dist/Admin"; import { Office as OfficeResource } from "le-coffre-resources/dist/Admin";
import ruleHandler from "@App/middlewares/RulesHandler"; import ruleHandler from "@App/middlewares/RulesHandler";
import authHandler from "@App/middlewares/AuthHandler"; import authHandler from "@App/middlewares/AuthHandler";
@ -22,9 +22,13 @@ 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
let query; let query: Prisma.OfficesFindManyArgs = {};
if (req.query["q"]) { if (req.query["q"]) {
query = JSON.parse(req.query["q"] as string); query = JSON.parse(req.query["q"] as string);
if (query.where?.uid) {
this.httpBadRequest(response, "You can't filter by uid");
return;
}
} }
//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);

View File

@ -7,6 +7,7 @@ import { Role } from "le-coffre-resources/dist/Admin";
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 roleHandler from "@App/middlewares/RolesHandler"; import roleHandler from "@App/middlewares/RolesHandler";
import { Prisma } from "@prisma/client";
@Controller() @Controller()
@Service() @Service()
@ -22,9 +23,13 @@ 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
let query; let query: Prisma.RolesFindManyArgs = {};
if (req.query["q"]) { if (req.query["q"]) {
query = JSON.parse(req.query["q"] as string); query = JSON.parse(req.query["q"] as string);
if (query.where?.uid) {
this.httpBadRequest(response, "You can't filter by uid");
return;
}
} }
//call service to get prisma entity //call service to get prisma entity

View File

@ -7,6 +7,7 @@ import { Rule } from "le-coffre-resources/dist/Admin";
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 roleHandler from "@App/middlewares/RolesHandler"; import roleHandler from "@App/middlewares/RolesHandler";
import { Prisma } from "@prisma/client";
@Controller() @Controller()
@Service() @Service()
@ -22,9 +23,13 @@ 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
let query; let query: Prisma.RulesFindManyArgs = {};
if (req.query["q"]) { if (req.query["q"]) {
query = JSON.parse(req.query["q"] as string); query = JSON.parse(req.query["q"] as string);
if (query.where?.uid) {
this.httpBadRequest(response, "You can't filter by uid");
return;
}
} }
//call service to get prisma entity //call service to get prisma entity

View File

@ -29,6 +29,10 @@ export default class UsersController extends ApiController {
let query: Prisma.UsersFindManyArgs = {}; let query: Prisma.UsersFindManyArgs = {};
if (req.query["q"]) { if (req.query["q"]) {
query = JSON.parse(req.query["q"] as string); query = JSON.parse(req.query["q"] as string);
if(query.where?.uid) {
this.httpBadRequest(response, "You can't filter by uid");
return;
}
} }
if (req.query["search"] && typeof req.query["search"] === "string") { if (req.query["search"] && typeof req.query["search"] === "string") {

View File

@ -28,6 +28,10 @@ export default class DocumentsController extends ApiController {
let query: Prisma.DocumentsFindManyArgs = {}; let query: Prisma.DocumentsFindManyArgs = {};
if (req.query["q"]) { if (req.query["q"]) {
query = JSON.parse(req.query["q"] as string); query = JSON.parse(req.query["q"] as string);
if(query.where?.uid) {
this.httpBadRequest(response, "You can't filter by uid");
return;
}
} }
const email: string = req.body.user.email; const email: string = req.body.user.email;
if (!email) { if (!email) {
@ -66,7 +70,7 @@ export default class DocumentsController extends ApiController {
return; return;
} }
//get query //get query
let query: Prisma.DocumentsInclude = {}; let query;
if (req.query["q"]) { if (req.query["q"]) {
query = JSON.parse(req.query["q"] as string); query = JSON.parse(req.query["q"] as string);
if (query.folder) delete query.folder; if (query.folder) delete query.folder;

View File

@ -34,6 +34,10 @@ export default class FilesController extends ApiController {
let query: Prisma.FilesFindManyArgs = {}; let query: Prisma.FilesFindManyArgs = {};
if (req.query["q"]) { if (req.query["q"]) {
query = JSON.parse(req.query["q"] as string); query = JSON.parse(req.query["q"] as string);
if (query.where?.uid) {
this.httpBadRequest(response, "You can't filter by uid");
return;
}
} }
const email: string = req.body.user.email; const email: string = req.body.user.email;
if (!email) { if (!email) {
@ -144,19 +148,22 @@ export default class FilesController extends ApiController {
return; return;
} }
const fileFound = await this.filesService.getByUid(uid); const fileFound = await this.filesService.getByUid(uid, { document: { include: { files: true, document_type: true } } });
if (!fileFound) { if (!fileFound) {
this.httpNotFoundRequest(response, "file not found"); this.httpNotFoundRequest(response, "file not found");
return; return;
} }
const fileFoundEntity = File.hydrate<File>(fileFound, { strategy: "excludeAll" });
//call service to get prisma entity //call service to get prisma entity
const fileEntity = await this.filesService.deleteKeyAndArchive(uid); const fileEntity = await this.filesService.deleteKeyAndArchive(uid);
if (
if (!fileEntity) { !(fileFoundEntity.document!.files?.find((file) => file.archived_at === null && file.uid !== uid)) &&
this.httpNotFoundRequest(response, "file not found"); fileFoundEntity.document!.document_type!.name === "Autres documents"
return; ) {
await this.documentService.delete(fileFoundEntity.document!.uid!);
} }
//Hydrate ressource with prisma entity //Hydrate ressource with prisma entity

View File

@ -7,9 +7,6 @@ import { OfficeFolders, Prisma } from "@prisma/client";
import { OfficeFolder } from "le-coffre-resources/dist/Customer"; import { OfficeFolder } from "le-coffre-resources/dist/Customer";
import officeFolderHandler from "@App/middlewares/CustomerHandler/FolderHandler"; import officeFolderHandler from "@App/middlewares/CustomerHandler/FolderHandler";
import authHandler from "@App/middlewares/AuthHandler"; import authHandler from "@App/middlewares/AuthHandler";
// import authHandler from "@App/middlewares/AuthHandler";
// import ruleHandler from "@App/middlewares/RulesHandler";
// import folderHandler from "@App/middlewares/OfficeMembershipHandlers/FolderHandler";
@Controller() @Controller()
@Service() @Service()
@ -28,6 +25,10 @@ export default class OfficeFoldersController extends ApiController {
let query: Prisma.OfficeFoldersFindManyArgs = {}; let query: Prisma.OfficeFoldersFindManyArgs = {};
if (req.query["q"]) { if (req.query["q"]) {
query = JSON.parse(req.query["q"] as string); query = JSON.parse(req.query["q"] as string);
if(query.where?.uid) {
this.httpBadRequest(response, "You can't filter by uid");
return;
}
} }
const email: string = req.body.user.email; const email: string = req.body.user.email;
@ -79,7 +80,7 @@ export default class OfficeFoldersController extends ApiController {
const email: string = req.body.user.email; const email: string = req.body.user.email;
let query: Prisma.OfficeFoldersInclude = {}; let query;
if (req.query["q"]) { if (req.query["q"]) {
query = JSON.parse(req.query["q"] as string); query = JSON.parse(req.query["q"] as string);
if (query?.customers) delete query.customers; if (query?.customers) delete query.customers;
@ -95,7 +96,9 @@ export default class OfficeFoldersController extends ApiController {
//Hydrate ressource with prisma entity //Hydrate ressource with prisma entity
const officeFolder = OfficeFolder.hydrate<OfficeFolder>(officeFolderEntity, { strategy: "excludeAll" }); const officeFolder = OfficeFolder.hydrate<OfficeFolder>(officeFolderEntity, { strategy: "excludeAll" });
officeFolder.customers = officeFolder.customers!.filter((customer) => customer.contact?.email === email); if(officeFolder.customers) {
officeFolder.customers = officeFolder.customers!.filter((customer) => customer.contact?.email === email);
}
//success //success
this.httpSuccess(response, officeFolder); this.httpSuccess(response, officeFolder);

View File

@ -27,6 +27,10 @@ export default class CustomersController extends ApiController {
let query: Prisma.CustomersFindManyArgs = {}; let query: Prisma.CustomersFindManyArgs = {};
if (req.query["q"]) { if (req.query["q"]) {
query = JSON.parse(req.query["q"] as string); query = JSON.parse(req.query["q"] as string);
if(query.where?.uid) {
this.httpBadRequest(response, "You can't filter by uid");
return;
}
} }
const officeId: string = req.body.user.office_Id; const officeId: string = req.body.user.office_Id;

View File

@ -28,6 +28,10 @@ export default class DeedTypesController extends ApiController {
let query: Prisma.DeedTypesFindManyArgs = {}; let query: Prisma.DeedTypesFindManyArgs = {};
if (req.query["q"]) { if (req.query["q"]) {
query = JSON.parse(req.query["q"] as string); query = JSON.parse(req.query["q"] as string);
if(query.where?.uid) {
this.httpBadRequest(response, "You can't filter by uid");
return;
}
} }
const officeId: string = req.body.user.office_Id; const officeId: string = req.body.user.office_Id;
const officeWhereInput: Prisma.OfficesWhereInput = { uid: officeId } ; const officeWhereInput: Prisma.OfficesWhereInput = { uid: officeId } ;

View File

@ -28,11 +28,15 @@ export default class DeedsController extends ApiController {
let query: Prisma.DeedsFindManyArgs = {}; let query: Prisma.DeedsFindManyArgs = {};
if (req.query["q"]) { if (req.query["q"]) {
query = JSON.parse(req.query["q"] as string); query = JSON.parse(req.query["q"] as string);
if(query.where?.uid) {
this.httpBadRequest(response, "You can't filter by uid");
return;
}
} }
const officeId: string = req.body.user.office_Id; const officeId: string = req.body.user.office_Id;
const officeWhereInput: Prisma.OfficesWhereInput = { uid: officeId } ; const officeWhereInput: Prisma.OfficesWhereInput = { uid: officeId } ;
if(!query.where) query.where = { deed_type : {office: officeWhereInput}}; if(query.where?.deed_type) delete query.where.deed_type;
query.where.deed_type!.office = officeWhereInput; query.where = {...query.where, deed_type : {office: officeWhereInput}};
//call service to get prisma entity //call service to get prisma entity
const deedEntities: Deeds[] = await this.deedsService.get(query); const deedEntities: Deeds[] = await this.deedsService.get(query);

View File

@ -27,6 +27,10 @@ export default class DocumentTypesController extends ApiController {
let query: Prisma.DocumentTypesFindManyArgs = {}; let query: Prisma.DocumentTypesFindManyArgs = {};
if (req.query["q"]) { if (req.query["q"]) {
query = JSON.parse(req.query["q"] as string); query = JSON.parse(req.query["q"] as string);
if(query.where?.uid) {
this.httpBadRequest(response, "You can't filter by uid");
return;
}
} }
const officeId: string = req.body.user.office_Id; const officeId: string = req.body.user.office_Id;
const officeWhereInput: Prisma.OfficesWhereInput = { uid: officeId } ; const officeWhereInput: Prisma.OfficesWhereInput = { uid: officeId } ;

View File

@ -35,6 +35,10 @@ export default class DocumentsController extends ApiController {
let query: Prisma.DocumentsFindManyArgs = {}; let query: Prisma.DocumentsFindManyArgs = {};
if (req.query["q"]) { if (req.query["q"]) {
query = JSON.parse(req.query["q"] as string); query = JSON.parse(req.query["q"] as string);
if(query.where?.uid) {
this.httpBadRequest(response, "You can't filter by uid");
return;
}
} }
const officeId: string = req.body.user.office_Id; const officeId: string = req.body.user.office_Id;
const officeWhereInput: Prisma.OfficesWhereInput = { uid: officeId }; const officeWhereInput: Prisma.OfficesWhereInput = { uid: officeId };
@ -120,6 +124,11 @@ export default class DocumentsController extends ApiController {
return; return;
} }
if(documentFound.document_status === EDocumentStatus.REFUSED || documentFound.document_status === EDocumentStatus.VALIDATED) {
this.httpForbidden(response, "You are not allowed to update a VALIDATED or REFUSED document");
return;
}
//init Document resource with request body values //init Document resource with request body values
const documentEntity = Document.hydrate<Document>(req.body); const documentEntity = Document.hydrate<Document>(req.body);

View File

@ -1,5 +1,5 @@
import { Response, Request } from "express"; import { Response, Request } from "express";
import { Controller, Delete, Get } from "@ControllerPattern/index"; import { Controller, Get } from "@ControllerPattern/index";
import ApiController from "@Common/system/controller-pattern/ApiController"; import ApiController from "@Common/system/controller-pattern/ApiController";
import { Service } from "typedi"; import { Service } from "typedi";
import FilesService from "@Services/common/FilesService/FilesService"; import FilesService from "@Services/common/FilesService/FilesService";
@ -27,6 +27,10 @@ export default class FilesController extends ApiController {
let query: Prisma.FilesFindManyArgs = {}; let query: Prisma.FilesFindManyArgs = {};
if (req.query["q"]) { if (req.query["q"]) {
query = JSON.parse(req.query["q"] as string); query = JSON.parse(req.query["q"] as string);
if(query.where?.uid) {
this.httpBadRequest(response, "You can't filter by uid");
return;
}
} }
const officeId: string = req.body.user.office_Id; const officeId: string = req.body.user.office_Id;
const officeWhereInput: Prisma.OfficesWhereInput = { uid: officeId } ; const officeWhereInput: Prisma.OfficesWhereInput = { uid: officeId } ;
@ -74,44 +78,6 @@ export default class FilesController extends ApiController {
} }
} }
/**
* @description Delete a specific File
*/
@Delete("/api/v1/notary/files/:uid", [authHandler, ruleHandler, fileHandler])
protected async delete(req: Request, response: Response) {
try {
const uid = req.params["uid"];
if (!uid) {
this.httpBadRequest(response, "No uid provided");
return;
}
const fileFound = await this.filesService.getByUid(uid);
if (!fileFound) {
this.httpNotFoundRequest(response, "file not found");
return;
}
//call service to get prisma entity
const fileEntity = await this.filesService.deleteKeyAndArchive(uid);
if (!fileEntity) {
this.httpNotFoundRequest(response, "file not found");
return;
}
//Hydrate ressource with prisma entity
const file = File.hydrate<File>(fileEntity, { strategy: "excludeAll" });
//success
this.httpSuccess(response, file);
} catch (error) {
this.httpInternalError(response, error);
return;
}
}
/** /**
* @description Get a specific File by uid * @description Get a specific File by uid
*/ */

View File

@ -275,6 +275,10 @@ export default class OfficeFoldersController extends ApiController {
let query: Prisma.OfficeFolderAnchorsFindManyArgs = {}; let query: Prisma.OfficeFolderAnchorsFindManyArgs = {};
if (req.query["q"]) { if (req.query["q"]) {
query = JSON.parse(req.query["q"] as string); query = JSON.parse(req.query["q"] as string);
if(query.where?.uid) {
this.httpBadRequest(response, "You can't filter by uid");
return;
}
} }
query.where = { query.where = {

View File

@ -27,6 +27,10 @@ export default class OfficeFoldersController extends ApiController {
let query: Prisma.OfficeFoldersFindManyArgs = {}; let query: Prisma.OfficeFoldersFindManyArgs = {};
if (req.query["q"]) { if (req.query["q"]) {
query = JSON.parse(req.query["q"] as string); query = JSON.parse(req.query["q"] as string);
if(query.where?.uid) {
this.httpBadRequest(response, "You can't filter by uid");
return;
}
} }
if (req.query["search"] && typeof req.query["search"] === "string") { if (req.query["search"] && typeof req.query["search"] === "string") {
@ -186,7 +190,7 @@ export default class OfficeFoldersController extends ApiController {
} }
//call service to get prisma entity //call service to get prisma entity
const officeFolderEntityUpdated = await this.officeFoldersService.update(uid, officefolderToUpdate); const officeFolderEntityUpdated = await this.officeFoldersService.updateStatus(uid, officefolderToUpdate);
//Hydrate ressource with prisma entity //Hydrate ressource with prisma entity
const officeFolders = OfficeFolder.hydrate<OfficeFolder>(officeFolderEntityUpdated, { const officeFolders = OfficeFolder.hydrate<OfficeFolder>(officeFolderEntityUpdated, {
@ -232,7 +236,7 @@ export default class OfficeFoldersController extends ApiController {
await validateOrReject(officefolderToUpdate, { groups: ["updateFolder"], forbidUnknownValues: false }); await validateOrReject(officefolderToUpdate, { groups: ["updateFolder"], forbidUnknownValues: false });
//call service to get prisma entity //call service to get prisma entity
const officeFolderEntityUpdated = await this.officeFoldersService.update(uid, officefolderToUpdate); const officeFolderEntityUpdated = await this.officeFoldersService.updateStatus(uid, officefolderToUpdate);
//Hydrate ressource with prisma entity //Hydrate ressource with prisma entity
const officeFolders = OfficeFolder.hydrate<OfficeFolder>(officeFolderEntityUpdated, { const officeFolders = OfficeFolder.hydrate<OfficeFolder>(officeFolderEntityUpdated, {

View File

@ -26,6 +26,10 @@ export default class OfficeRolesController extends ApiController {
let query: Prisma.OfficeRolesFindManyArgs = {}; let query: Prisma.OfficeRolesFindManyArgs = {};
if (req.query["q"]) { if (req.query["q"]) {
query = JSON.parse(req.query["q"] as string); query = JSON.parse(req.query["q"] as string);
if(query.where?.uid) {
this.httpBadRequest(response, "You can't filter by uid");
return;
}
} }
const officeId: string = req.body.user.office_Id; const officeId: string = req.body.user.office_Id;
const officeWhereInput: Prisma.OfficesWhereInput = { uid: officeId } ; const officeWhereInput: Prisma.OfficesWhereInput = { uid: officeId } ;

View File

@ -3,7 +3,7 @@ import { Controller, Get } from "@ControllerPattern/index";
import ApiController from "@Common/system/controller-pattern/ApiController"; import ApiController from "@Common/system/controller-pattern/ApiController";
import OfficesService from "@Services/notary/OfficesService/OfficesService"; import OfficesService from "@Services/notary/OfficesService/OfficesService";
import { Service } from "typedi"; import { Service } from "typedi";
import { Offices } from "@prisma/client"; import { Offices, Prisma } from "@prisma/client";
import { Office as OfficeResource } from "le-coffre-resources/dist/Notary"; import { Office as OfficeResource } from "le-coffre-resources/dist/Notary";
import ruleHandler from "@App/middlewares/RulesHandler"; import ruleHandler from "@App/middlewares/RulesHandler";
import authHandler from "@App/middlewares/AuthHandler"; import authHandler from "@App/middlewares/AuthHandler";
@ -21,9 +21,13 @@ 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
let query; let query: Prisma.OfficesFindManyArgs = {};
if (req.query["q"]) { if (req.query["q"]) {
query = JSON.parse(req.query["q"] as string); query = JSON.parse(req.query["q"] as string);
if (query.where?.uid) {
this.httpBadRequest(response, "You can't filter by uid");
return;
}
} }
//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);

View File

@ -6,6 +6,7 @@ import { Service } from "typedi";
import { Role } from "le-coffre-resources/dist/Notary"; import { Role } from "le-coffre-resources/dist/Notary";
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 { Prisma } from "@prisma/client";
@Controller() @Controller()
@Service() @Service()
@ -21,9 +22,13 @@ 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
let query; let query: Prisma.RolesFindManyArgs = {};
if (req.query["q"]) { if (req.query["q"]) {
query = JSON.parse(req.query["q"] as string); query = JSON.parse(req.query["q"] as string);
if (query.where?.uid) {
this.httpBadRequest(response, "You can't filter by uid");
return;
}
} }
//call service to get prisma entity //call service to get prisma entity

View File

@ -6,6 +6,7 @@ import { Service } from "typedi";
import { Rule } from "le-coffre-resources/dist/Notary"; import { Rule } from "le-coffre-resources/dist/Notary";
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 { Prisma } from "@prisma/client";
@Controller() @Controller()
@Service() @Service()
@ -21,9 +22,13 @@ 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
let query; let query: Prisma.RulesFindManyArgs = {};
if (req.query["q"]) { if (req.query["q"]) {
query = JSON.parse(req.query["q"] as string); query = JSON.parse(req.query["q"] as string);
if (query.where?.uid) {
this.httpBadRequest(response, "You can't filter by uid");
return;
}
} }
query.where = { query.where = {

View File

@ -22,12 +22,14 @@ export default class UserNotificationController extends ApiController {
protected async get(req: Request, response: Response) { protected async get(req: Request, response: Response) {
try { try {
//get query //get query
let query: any = {}; let query: Prisma.UserNotificationsFindManyArgs = {};
if (req.query["q"]) { if (req.query["q"]) {
query = JSON.parse(req.query["q"] as string); query = JSON.parse(req.query["q"] as string);
if (query.where?.uid) {
this.httpBadRequest(response, "You can't filter by uid");
return;
}
} }
const userId: string = req.body.user.userId; const userId: string = req.body.user.userId;
if(query.where?.user_uid) delete query.where.user_uid; if(query.where?.user_uid) delete query.where.user_uid;
if(query.where?.user?.uid) delete query.where.user.uid; if(query.where?.user?.uid) delete query.where.user.uid;

View File

@ -26,6 +26,10 @@ export default class UsersController extends ApiController {
let query: Prisma.UsersFindManyArgs = {}; let query: Prisma.UsersFindManyArgs = {};
if (req.query["q"]) { if (req.query["q"]) {
query = JSON.parse(req.query["q"] as string); query = JSON.parse(req.query["q"] as string);
if(query.where?.uid) {
this.httpBadRequest(response, "You can't filter by uid");
return;
}
} }
const officeId: string = req.body.user.office_Id; const officeId: string = req.body.user.office_Id;
const officeWhereInput: Prisma.OfficesWhereInput = { uid: officeId } ; const officeWhereInput: Prisma.OfficesWhereInput = { uid: officeId } ;

View File

@ -25,17 +25,21 @@ 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
let query; let query: Prisma.CustomersFindManyArgs = {};
if (req.query["q"]) { if (req.query["q"]) {
query = JSON.parse(req.query["q"] as string); query = JSON.parse(req.query["q"] as string);
if (query.where?.uid) {
this.httpBadRequest(response, "You can't filter by uid");
return;
}
} }
const officeId: string = req.body.user.office_Id; const officeId: string = req.body.user.office_Id;
if(query.where?.office_folders?.some?.office_uid) delete query.where.office_folders.some.office_uid; if (query.where?.office_folders?.some?.office_uid) delete query.where.office_folders.some.office_uid;
if(query.where?.office_folders?.some?.office?.uid) delete query.where?.office_folders?.some?.office?.uid; if (query.where?.office_folders?.some?.office?.uid) delete query.where?.office_folders?.some?.office?.uid;
const customerWhereInput: Prisma.CustomersWhereInput = { ...query.where, office_folders: { some: { office_uid: officeId } }}; const customerWhereInput: Prisma.CustomersWhereInput = { ...query.where, office_folders: { some: { office_uid: officeId } } };
query.where = customerWhereInput; query.where = customerWhereInput;
//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);
@ -50,7 +54,6 @@ export default class CustomersController extends ApiController {
} }
} }
/** /**
* @description Create a new customer * @description Create a new customer
*/ */
@ -128,27 +131,29 @@ export default class CustomersController extends ApiController {
return; return;
} }
const customers = await this.customersService.get({ if (customerEntity.contact?.email) {
where: { const customers = await this.customersService.get({
contact: { email: customerEntity.contact?.email }, where: {
office_folders: { contact: { email: customerEntity.contact?.email },
some: { office_folders: {
office_uid: req.body.user.office_Id, some: {
office_uid: req.body.user.office_Id,
},
}, },
}, },
}, });
});
if (customers.length != 0) { if (customers.length != 0) {
try { try {
customers.forEach((customer) => { customers.forEach((customer) => {
if (customer.uid != uid) { if (customer.uid != uid) {
throw new Error("email déjà utilisé"); throw new Error("email déjà utilisé");
} }
}); });
} catch (error) { } catch (error) {
this.httpValidationError(response, [{ property: "email", constraints: { unique: "email déjà utilisé" } }]); this.httpValidationError(response, [{ property: "email", constraints: { unique: "email déjà utilisé" } }]);
return; return;
}
} }
} }
@ -189,7 +194,7 @@ export default class CustomersController extends ApiController {
if (req.query["q"]) { if (req.query["q"]) {
query = JSON.parse(req.query["q"] as string); query = JSON.parse(req.query["q"] as string);
} }
const customerEntity = await this.customersService.getByUid(uid, query); const customerEntity = await this.customersService.getByUid(uid, query);
if (!customerEntity) { if (!customerEntity) {

View File

@ -29,6 +29,10 @@ export default class DeedTypesController extends ApiController {
let query: Prisma.DeedTypesFindManyArgs = {}; let query: Prisma.DeedTypesFindManyArgs = {};
if (req.query["q"]) { if (req.query["q"]) {
query = JSON.parse(req.query["q"] as string); query = JSON.parse(req.query["q"] as string);
if(query.where?.uid) {
this.httpBadRequest(response, "You can't filter by uid");
return;
}
} }
if (req.query["search"] && typeof req.query["search"] === "string") { if (req.query["search"] && typeof req.query["search"] === "string") {

View File

@ -29,6 +29,10 @@ export default class DeedsController extends ApiController {
let query: Prisma.DeedsFindManyArgs = {}; let query: Prisma.DeedsFindManyArgs = {};
if (req.query["q"]) { if (req.query["q"]) {
query = JSON.parse(req.query["q"] as string); query = JSON.parse(req.query["q"] as string);
if(query.where?.uid) {
this.httpBadRequest(response, "You can't filter by uid");
return;
}
} }
const officeId: string = req.body.user.office_Id; const officeId: string = req.body.user.office_Id;
const officeWhereInput: Prisma.OfficesWhereInput = { uid: officeId } ; const officeWhereInput: Prisma.OfficesWhereInput = { uid: officeId } ;

View File

@ -29,6 +29,10 @@ export default class DocumentTypesController extends ApiController {
let query: Prisma.DocumentTypesFindManyArgs = {}; let query: Prisma.DocumentTypesFindManyArgs = {};
if (req.query["q"]) { if (req.query["q"]) {
query = JSON.parse(req.query["q"] as string); query = JSON.parse(req.query["q"] as string);
if(query.where?.uid) {
this.httpBadRequest(response, "You can't filter by uid");
return;
}
} }
const officeId: string = req.body.user.office_Id; const officeId: string = req.body.user.office_Id;
const officeWhereInput: Prisma.OfficesWhereInput = { uid: officeId } ; const officeWhereInput: Prisma.OfficesWhereInput = { uid: officeId } ;

View File

@ -30,6 +30,10 @@ export default class DocumentsController extends ApiController {
let query: Prisma.DocumentsFindManyArgs = {}; let query: Prisma.DocumentsFindManyArgs = {};
if (req.query["q"]) { if (req.query["q"]) {
query = JSON.parse(req.query["q"] as string); query = JSON.parse(req.query["q"] as string);
if(query.where?.uid) {
this.httpBadRequest(response, "You can't filter by uid");
return;
}
} }
const officeId: string = req.body.user.office_Id; const officeId: string = req.body.user.office_Id;

View File

@ -1,5 +1,5 @@
import { Response, Request } from "express"; import { Response, Request } from "express";
import { Controller, Delete, Get } from "@ControllerPattern/index"; import { Controller, Get } from "@ControllerPattern/index";
import ApiController from "@Common/system/controller-pattern/ApiController"; import ApiController from "@Common/system/controller-pattern/ApiController";
import { Service } from "typedi"; import { Service } from "typedi";
import FilesService from "@Services/common/FilesService/FilesService"; import FilesService from "@Services/common/FilesService/FilesService";
@ -28,6 +28,10 @@ export default class FilesController extends ApiController {
let query: Prisma.FilesFindManyArgs = {}; let query: Prisma.FilesFindManyArgs = {};
if (req.query["q"]) { if (req.query["q"]) {
query = JSON.parse(req.query["q"] as string); query = JSON.parse(req.query["q"] as string);
if(query.where?.uid) {
this.httpBadRequest(response, "You can't filter by uid");
return;
}
} }
const officeId: string = req.body.user.office_Id; const officeId: string = req.body.user.office_Id;
const officeWhereInput: Prisma.OfficesWhereInput = { uid: officeId } ; const officeWhereInput: Prisma.OfficesWhereInput = { uid: officeId } ;
@ -76,44 +80,6 @@ export default class FilesController extends ApiController {
} }
} }
/**
* @description Delete a specific File
*/
@Delete("/api/v1/super-admin/files/:uid", [authHandler, roleHandler, ruleHandler, fileHandler])
protected async delete(req: Request, response: Response) {
try {
const uid = req.params["uid"];
if (!uid) {
this.httpBadRequest(response, "No uid provided");
return;
}
const fileFound = await this.filesService.getByUid(uid);
if (!fileFound) {
this.httpNotFoundRequest(response, "file not found");
return;
}
//call service to get prisma entity
const fileEntity = await this.filesService.deleteKeyAndArchive(uid);
if (!fileEntity) {
this.httpNotFoundRequest(response, "file not found");
return;
}
//Hydrate ressource with prisma entity
const file = File.hydrate<File>(fileEntity, { strategy: "excludeAll" });
//success
this.httpSuccess(response, file);
} catch (error) {
this.httpInternalError(response, error);
return;
}
}
/** /**
* @description Get a specific File by uid * @description Get a specific File by uid
*/ */

View File

@ -28,6 +28,10 @@ export default class OfficeFoldersController extends ApiController {
let query: Prisma.OfficeFoldersFindManyArgs = {}; let query: Prisma.OfficeFoldersFindManyArgs = {};
if (req.query["q"]) { if (req.query["q"]) {
query = JSON.parse(req.query["q"] as string); query = JSON.parse(req.query["q"] as string);
if(query.where?.uid) {
this.httpBadRequest(response, "You can't filter by uid");
return;
}
} }
if (req.query["search"] && typeof req.query["search"] === "string") { if (req.query["search"] && typeof req.query["search"] === "string") {

View File

@ -28,6 +28,10 @@ export default class OfficeRolesController extends ApiController {
let query: Prisma.OfficeRolesFindManyArgs = {}; let query: Prisma.OfficeRolesFindManyArgs = {};
if (req.query["q"]) { if (req.query["q"]) {
query = JSON.parse(req.query["q"] as string); query = JSON.parse(req.query["q"] as string);
if(query.where?.uid) {
this.httpBadRequest(response, "You can't filter by uid");
return;
}
} }
if(req.query["search"] && typeof req.query["search"] === "string") { if(req.query["search"] && typeof req.query["search"] === "string") {

View File

@ -3,7 +3,7 @@ import { Controller, Get, Post, Put } from "@ControllerPattern/index";
import ApiController from "@Common/system/controller-pattern/ApiController"; import ApiController from "@Common/system/controller-pattern/ApiController";
import OfficesService from "@Services/super-admin/OfficesService/OfficesService"; import OfficesService from "@Services/super-admin/OfficesService/OfficesService";
import { Service } from "typedi"; import { Service } from "typedi";
import { Offices } from "@prisma/client"; import { Offices, Prisma } from "@prisma/client";
import { Office as OfficeResource } from "le-coffre-resources/dist/SuperAdmin"; import { Office as OfficeResource } from "le-coffre-resources/dist/SuperAdmin";
import { validateOrReject } from "class-validator"; import { validateOrReject } from "class-validator";
import ruleHandler from "@App/middlewares/RulesHandler"; import ruleHandler from "@App/middlewares/RulesHandler";
@ -23,9 +23,13 @@ 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
let query; let query: Prisma.OfficesFindManyArgs = {};
if (req.query["q"]) { if (req.query["q"]) {
query = JSON.parse(req.query["q"] as string); query = JSON.parse(req.query["q"] as string);
if (query.where?.uid) {
this.httpBadRequest(response, "You can't filter by uid");
return;
}
} }
if(req.query["search"] && typeof req.query["search"] === "string") { if(req.query["search"] && typeof req.query["search"] === "string") {

View File

@ -8,6 +8,7 @@ import { Role } from "le-coffre-resources/dist/SuperAdmin";
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 roleHandler from "@App/middlewares/RolesHandler"; import roleHandler from "@App/middlewares/RolesHandler";
import { Prisma } from "@prisma/client";
@Controller() @Controller()
@Service() @Service()
@ -23,9 +24,13 @@ 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
let query; let query: Prisma.RolesFindManyArgs = {};
if (req.query["q"]) { if (req.query["q"]) {
query = JSON.parse(req.query["q"] as string); query = JSON.parse(req.query["q"] as string);
if (query.where?.uid) {
this.httpBadRequest(response, "You can't filter by uid");
return;
}
} }
//call service to get prisma entity //call service to get prisma entity

View File

@ -8,6 +8,7 @@ import { Rule } from "le-coffre-resources/dist/SuperAdmin";
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 roleHandler from "@App/middlewares/RolesHandler"; import roleHandler from "@App/middlewares/RolesHandler";
import { Prisma } from "@prisma/client";
@Controller() @Controller()
@Service() @Service()
@ -23,9 +24,13 @@ 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
let query; let query: Prisma.RulesFindManyArgs = {};
if (req.query["q"]) { if (req.query["q"]) {
query = JSON.parse(req.query["q"] as string); query = JSON.parse(req.query["q"] as string);
if (query.where?.uid) {
this.httpBadRequest(response, "You can't filter by uid");
return;
}
} }
//call service to get prisma entity //call service to get prisma entity

View File

@ -10,6 +10,7 @@ import ruleHandler from "@App/middlewares/RulesHandler";
import roleHandler from "@App/middlewares/RolesHandler"; import roleHandler from "@App/middlewares/RolesHandler";
import RolesService from "@Services/super-admin/RolesService/RolesService"; import RolesService from "@Services/super-admin/RolesService/RolesService";
import OfficeRolesService from "@Services/super-admin/OfficeRolesService/OfficeRolesService"; import OfficeRolesService from "@Services/super-admin/OfficeRolesService/OfficeRolesService";
import { Prisma } from "@prisma/client";
@Controller() @Controller()
@Service() @Service()
@ -25,9 +26,13 @@ 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
let query; let query: Prisma.UsersFindManyArgs = {};
if (req.query["q"]) { if (req.query["q"]) {
query = JSON.parse(req.query["q"] as string); query = JSON.parse(req.query["q"] as string);
if (query.where?.uid) {
this.httpBadRequest(response, "You can't filter by uid");
return;
}
} }
if (req.query["search"] && typeof req.query["search"] === "string") { if (req.query["search"] && typeof req.query["search"] === "string") {

View File

@ -55,6 +55,18 @@ export default class OfficeFoldersRepository extends BaseRepository {
return this.model.create({ ...createArgs, include: { stakeholders: true } }); return this.model.create({ ...createArgs, include: { stakeholders: true } });
} }
public async updateStatus(uid: string, status: EFolderStatus, archived_description: string | null) {
return this.model.update({
where: {
uid: uid,
},
data: {
status: status,
archived_description: archived_description,
},
});
}
/** /**
* @description : Update data of an office folder * @description : Update data of an office folder
*/ */
@ -67,8 +79,6 @@ export default class OfficeFoldersRepository extends BaseRepository {
folder_number: officeFolder.folder_number, folder_number: officeFolder.folder_number,
name: officeFolder.name, name: officeFolder.name,
description: officeFolder.description, description: officeFolder.description,
status: EFolderStatus[officeFolder.status as keyof typeof EFolderStatus],
archived_description: officeFolder.archived_description,
stakeholders: { stakeholders: {
set: officeFolder.stakeholders?.map((stakeholder) => ({ set: officeFolder.stakeholders?.map((stakeholder) => ({
uid: stakeholder.uid!, uid: stakeholder.uid!,

View File

@ -34,6 +34,14 @@ export default class DocumentsService extends BaseService {
return this.documentsRepository.create(document); return this.documentsRepository.create(document);
} }
/**
* @description : Delete a document
* @throws {Error} If document cannot be created
*/
public async delete(uid: string): Promise<Documents> {
return this.documentsRepository.delete(uid);
}
/** /**
* @description : Modify a document * @description : Modify a document
* @throws {Error} If document cannot be modified * @throws {Error} If document cannot be modified

View File

@ -3,7 +3,7 @@ import OfficeFoldersRepository from "@Repositories/OfficeFoldersRepository";
import BaseService from "@Services/BaseService"; import BaseService from "@Services/BaseService";
import { OfficeFolder } from "le-coffre-resources/dist/Notary"; import { OfficeFolder } from "le-coffre-resources/dist/Notary";
import { Service } from "typedi"; import { Service } from "typedi";
import { Prisma } from "@prisma/client"; import { EFolderStatus, Prisma } from "@prisma/client";
import DeedsService from "../DeedsService/DeedsService"; import DeedsService from "../DeedsService/DeedsService";
@Service() @Service()
@ -41,6 +41,14 @@ export default class OfficeFoldersService extends BaseService {
return this.officeFoldersRepository.update(officeFolderuid, officeFolderEntity); return this.officeFoldersRepository.update(officeFolderuid, officeFolderEntity);
} }
/**
* @description : Modify a folder status
* @throws {Error} If folder cannot be modified
*/
public async updateStatus(uid: string, officeFolderEntity: OfficeFolder) {
return this.officeFoldersRepository.updateStatus(uid,officeFolderEntity.status as EFolderStatus, officeFolderEntity.archived_description);
}
/** /**
* @description : Get a folder by uid * @description : Get a folder by uid
* @throws {Error} If folder cannot be get by uid * @throws {Error} If folder cannot be get by uid