feat: read file list

This commit is contained in:
Methapon2001 2023-11-20 11:08:25 +07:00
parent 478c89ea92
commit 510ad444df
No known key found for this signature in database
GPG key ID: 849924FEF46BD132

View file

@ -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<string, string>;
}
>({
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;
}
}