From 510ad444dfd40bd488a5458ed689108008f919e1 Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Mon, 20 Nov 2023 11:08:25 +0700 Subject: [PATCH] feat: read file list --- .../server/src/controllers/fileController.ts | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/Prototype/server/src/controllers/fileController.ts b/Prototype/server/src/controllers/fileController.ts index c050dca..7a7107c 100644 --- a/Prototype/server/src/controllers/fileController.ts +++ b/Prototype/server/src/controllers/fileController.ts @@ -1,6 +1,7 @@ import { Controller, FormField, + Get, Path, Post, Request, @@ -107,4 +108,43 @@ export class FileController extends Controller { return this.setStatus(HttpStatusCode.CREATED); } + + @Get("/{cabinetName}/drawer/{drawerName}/folder/{folderName}/file") + @Tags("File") + @SuccessResponse(HttpStatusCode.OK) + public async getFile( + @Path() cabinetName: string, + @Path() drawerName: string, + @Path() folderName: string, + ) { + const search = await esClient.search< + EhrFile & { + attachment: Record; + } + >({ + index: "ehr-api-client", + query: { + prefix: { + pathname: `${cabinetName}/${drawerName}/${folderName}/`, + }, + }, + }); + + const records = search.hits.hits + .map((v) => { + const { pathname, title, description, keyword, category, attachment } = v._source!; + + return { + pathname, + title, + description, + keyword, + category, + type: attachment["content_type"], + }; + }) + .filter((v) => !!v); + + return records; + } }