refactor: optional metadata field (for file upload only)

This commit is contained in:
Methapon2001 2023-11-27 17:30:20 +07:00
parent 17b70e8d5e
commit bc13f0e5ce
No known key found for this signature in database
GPG key ID: 849924FEF46BD132
4 changed files with 22 additions and 34 deletions

View file

@ -75,10 +75,10 @@ export class FileController extends Controller {
@Body()
body: {
file: string;
title: string;
description: string;
category: string;
keyword: string;
title?: string;
description?: string;
category?: string;
keyword?: string;
},
@Path() cabinetName: string,
@Path() drawerName: string,
@ -118,10 +118,10 @@ export class FileController extends Controller {
fileName: body.file,
fileSize: 0,
fileType: "",
title: body.title,
description: body.description,
category: body.category.split(","),
keyword: body.keyword.split(","),
title: body.title ?? "",
description: body.description ?? "",
category: body.category?.split(",") ?? [],
keyword: body.keyword?.split(",") ?? [],
upload: false,
createdAt: new Date().toISOString(),
createdBy: rec ? rec.createdBy : "n/a",
@ -148,6 +148,7 @@ export class FileController extends Controller {
@Tags("ไฟล์")
@Security("bearerAuth", ["admin"])
@Response(HttpStatusCode.NOT_FOUND, "ไม่พบตำแหน่งที่ต้องการสร้างแฟ้ม")
@Response(HttpStatusCode.NO_CONTENT, "สำเร็จ")
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
public async updateFile(
@Request() request: { user: { preferred_username: string } },

View file

@ -78,10 +78,10 @@ export class SubFolderFileController extends Controller {
@Body()
body: {
file: string;
title: string;
description: string;
category: string;
keyword: string;
title?: string;
description?: string;
category?: string;
keyword?: string;
},
@Path() cabinetName: string,
@Path() drawerName: string,
@ -122,10 +122,10 @@ export class SubFolderFileController extends Controller {
fileName: body.file,
fileSize: 0,
fileType: "",
title: body.title,
description: body.description,
category: body.category.split(","),
keyword: body.keyword.split(","),
title: body.title ?? "",
description: body.description ?? "",
category: body.category?.split(",") ?? [],
keyword: body.keyword?.split(",") ?? [],
upload: false,
createdAt: new Date().toISOString(),
createdBy: rec ? rec.createdBy : "n/a",

View file

@ -326,7 +326,7 @@ export function RegisterRoutes(app: Router) {
function FileController_uploadFile(request: any, response: any, next: any) {
const args = {
request: {"in":"request","name":"request","required":true,"dataType":"object"},
body: {"in":"body","name":"body","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"keyword":{"dataType":"string","required":true},"category":{"dataType":"string","required":true},"description":{"dataType":"string","required":true},"title":{"dataType":"string","required":true},"file":{"dataType":"string","required":true}}},
body: {"in":"body","name":"body","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"keyword":{"dataType":"string"},"category":{"dataType":"string"},"description":{"dataType":"string"},"title":{"dataType":"string"},"file":{"dataType":"string","required":true}}},
cabinetName: {"in":"path","name":"cabinetName","required":true,"dataType":"string"},
drawerName: {"in":"path","name":"drawerName","required":true,"dataType":"string"},
folderName: {"in":"path","name":"folderName","required":true,"dataType":"string"},
@ -730,7 +730,7 @@ export function RegisterRoutes(app: Router) {
function SubFolderFileController_uploadFile(request: any, response: any, next: any) {
const args = {
request: {"in":"request","name":"request","required":true,"dataType":"object"},
body: {"in":"body","name":"body","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"keyword":{"dataType":"string","required":true},"category":{"dataType":"string","required":true},"description":{"dataType":"string","required":true},"title":{"dataType":"string","required":true},"file":{"dataType":"string","required":true}}},
body: {"in":"body","name":"body","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"keyword":{"dataType":"string"},"category":{"dataType":"string"},"description":{"dataType":"string"},"title":{"dataType":"string"},"file":{"dataType":"string","required":true}}},
cabinetName: {"in":"path","name":"cabinetName","required":true,"dataType":"string"},
drawerName: {"in":"path","name":"drawerName","required":true,"dataType":"string"},
folderName: {"in":"path","name":"folderName","required":true,"dataType":"string"},

View file

@ -692,10 +692,6 @@
}
},
"required": [
"keyword",
"category",
"description",
"title",
"file",
"upload",
"updatedBy",
@ -771,10 +767,6 @@
}
},
"required": [
"keyword",
"category",
"description",
"title",
"file"
],
"type": "object"
@ -811,6 +803,9 @@
}
}
},
"204": {
"description": "สำเร็จ"
},
"404": {
"description": "ไม่พบตำแหน่งที่ต้องการสร้างแฟ้ม"
}
@ -1772,10 +1767,6 @@
}
},
"required": [
"keyword",
"category",
"description",
"title",
"file",
"upload",
"updatedBy",
@ -1859,10 +1850,6 @@
}
},
"required": [
"keyword",
"category",
"description",
"title",
"file"
],
"type": "object"