feat: read file list
This commit is contained in:
parent
478c89ea92
commit
510ad444df
1 changed files with 40 additions and 0 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue