docs: word and order
This commit is contained in:
parent
9b2bff6ba5
commit
d8cf568206
10 changed files with 322 additions and 284 deletions
|
|
@ -33,8 +33,40 @@ if (!DEFAULT_INDEX) throw Error("Default ElasticSearch index must be specified."
|
|||
"/cabinet/{cabinetName}/drawer/{drawerName}/folder/{folderName}/subfolder/{subFolderName}/file",
|
||||
)
|
||||
export class SubFolderFileController extends Controller {
|
||||
@Get("/")
|
||||
@Tags("ไฟล์")
|
||||
@Security("bearerAuth")
|
||||
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
||||
public async getFile(
|
||||
@Path() cabinetName: string,
|
||||
@Path() drawerName: string,
|
||||
@Path() folderName: string,
|
||||
@Path() subFolderName: string,
|
||||
): Promise<EhrFile[]> {
|
||||
const search = await esClient.search<EhrFile & { attachment: Record<string, string> }>({
|
||||
index: DEFAULT_INDEX!,
|
||||
query: {
|
||||
prefix: {
|
||||
pathname: `${cabinetName}/${drawerName}/${folderName}/${subFolderName}`,
|
||||
},
|
||||
},
|
||||
size: 10000,
|
||||
});
|
||||
|
||||
const records = search.hits.hits
|
||||
.map((v) => {
|
||||
if (v._source) {
|
||||
const { attachment, ...rest } = v._source;
|
||||
return rest satisfies EhrFile;
|
||||
}
|
||||
})
|
||||
.filter((v: EhrFile | undefined): v is EhrFile => !!v);
|
||||
|
||||
return records;
|
||||
}
|
||||
|
||||
@Post("/")
|
||||
@Tags("SubFolder File")
|
||||
@Tags("ไฟล์")
|
||||
@Security("bearerAuth", ["admin"])
|
||||
@Response(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
|
|
@ -115,40 +147,8 @@ export class SubFolderFileController extends Controller {
|
|||
};
|
||||
}
|
||||
|
||||
@Get("/")
|
||||
@Tags("SubFolder File")
|
||||
@Security("bearerAuth")
|
||||
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
||||
public async getFile(
|
||||
@Path() cabinetName: string,
|
||||
@Path() drawerName: string,
|
||||
@Path() folderName: string,
|
||||
@Path() subFolderName: string,
|
||||
): Promise<EhrFile[]> {
|
||||
const search = await esClient.search<EhrFile & { attachment: Record<string, string> }>({
|
||||
index: DEFAULT_INDEX!,
|
||||
query: {
|
||||
prefix: {
|
||||
pathname: `${cabinetName}/${drawerName}/${folderName}/${subFolderName}`,
|
||||
},
|
||||
},
|
||||
size: 10000,
|
||||
});
|
||||
|
||||
const records = search.hits.hits
|
||||
.map((v) => {
|
||||
if (v._source) {
|
||||
const { attachment, ...rest } = v._source;
|
||||
return rest satisfies EhrFile;
|
||||
}
|
||||
})
|
||||
.filter((v: EhrFile | undefined): v is EhrFile => !!v);
|
||||
|
||||
return records;
|
||||
}
|
||||
|
||||
@Patch("/{fileName}")
|
||||
@Tags("SubFolder File")
|
||||
@Tags("ไฟล์")
|
||||
@Security("bearerAuth", ["admin"])
|
||||
@Response(HttpStatusCode.NOT_FOUND, "ไม่พบตำแหน่งที่ต้องการสร้างแฟ้ม")
|
||||
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
||||
|
|
@ -248,7 +248,7 @@ export class SubFolderFileController extends Controller {
|
|||
}
|
||||
|
||||
@Delete("/{fileName}")
|
||||
@Tags("SubFolder File")
|
||||
@Tags("ไฟล์")
|
||||
@Security("bearerAuth", ["admin"])
|
||||
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
||||
public async deleteFile(
|
||||
|
|
@ -266,7 +266,8 @@ export class SubFolderFileController extends Controller {
|
|||
}
|
||||
|
||||
@Get("/{fileName}")
|
||||
@Tags("Download")
|
||||
@Tags("ดาวน์โหลด")
|
||||
@Security("bearerAuth")
|
||||
@SuccessResponse(HttpStatusCode.OK)
|
||||
public async downloadFile(
|
||||
@Path() cabinetName: string,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue