docs: word and order

This commit is contained in:
Methapon2001 2023-11-27 14:06:51 +07:00
parent 9b2bff6ba5
commit d8cf568206
No known key found for this signature in database
GPG key ID: 849924FEF46BD132
10 changed files with 322 additions and 284 deletions

View file

@ -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,