feat: additional field

This commit is contained in:
Methapon2001 2023-12-26 14:52:02 +07:00
parent 2da9f91e4e
commit ae2e0edfd2
No known key found for this signature in database
GPG key ID: 849924FEF46BD132
5 changed files with 110 additions and 1 deletions

View file

@ -75,10 +75,14 @@ interface FileBody {
title?: string;
/** @example "การเงิน" */
description?: string;
/** @example "นายก" */
author?: string;
/** @example ["การเงิน", "รายงาน"] */
category?: string[];
/** @example ["การเงิน", "รายรับ", "รายจ่าย"] */
keyword?: string[];
/** @example {} */
metadata?: { [key: string]: unknown };
/** @example false */
hidden?: boolean;
}
@ -250,6 +254,7 @@ export class StorageController extends Controller {
path: "ตู้เอกสาร 1/ลิ้นชัก 1/แฟ้ม 1/",
title: "เอกสาร",
description: "เอกสารการเงิน",
author: "นายก",
category: ["บัญชี"],
keyword: ["เงิน", "บัญชี", "รายจ่าย", "รายรับ"],
upload: false,
@ -498,6 +503,7 @@ export class StorageController extends Controller {
path: "ตู้เอกสาร 1/ลิ้นชัก 1/แฟ้ม 1/",
title: "เอกสาร",
description: "เอกสารการเงิน",
author: "นายก",
category: ["บัญชี"],
keyword: ["เงิน", "บัญชี", "รายจ่าย", "รายรับ"],
upload: false,
@ -540,9 +546,11 @@ export class StorageController extends Controller {
fileSize: 0, // Will be get by minio object storage after file is uploaded
fileType: "", // Will be determined by minio object storage after file is uploaded
title: body.title ?? validFileName, // default to same as filename
author: body.author ?? "",
description: body.description ?? "",
category: body.category ?? [],
keyword: body.keyword ?? [],
metadata: body.metadata ?? {},
upload: false, // flag
hidden: body.hidden ?? false,
createdAt: new Date().toISOString(),
@ -675,6 +683,12 @@ export class StorageController extends Controller {
id: id,
doc: {
...metadata,
metadata: metadata["metadata"]
? {
...source["metadata"], // keep old field
...metadata["metadata"], // replace some field that user update
}
: undefined,
path: stripLeadingSlash(`${to.path.join("/")}/`),
pathname: dst,
fileName: to.file,
@ -786,6 +800,7 @@ export class StorageController extends Controller {
description: "เอกสารการเงิน",
category: ["บัญชี"],
keyword: ["เงิน", "บัญชี", "รายจ่าย", "รายรับ"],
author: "นายก",
upload: false,
hidden: false,
fileName: "เอกสาร 1.pdf",