From bbeda11fc694220d60348316df05fd4bf56ea8e1 Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Thu, 14 Dec 2023 11:03:35 +0700 Subject: [PATCH] chore: small adjust --- .../src/controllers/storageController.ts | 2 +- Services/server/src/routes.ts | 35 ++++ Services/server/src/swagger.json | 154 +++++++++++++++++- 3 files changed, 189 insertions(+), 2 deletions(-) diff --git a/Services/server/src/controllers/storageController.ts b/Services/server/src/controllers/storageController.ts index 15fb998..c592a2c 100644 --- a/Services/server/src/controllers/storageController.ts +++ b/Services/server/src/controllers/storageController.ts @@ -634,7 +634,7 @@ export class StorageController extends Controller { const pathname = body.path.join("/") + `/${body.file}`; const search = await esClient.search }>({ - index: DEFAULT_INDEX!, + index: DEFAULT_INDEX, query: { match: { pathname }, }, diff --git a/Services/server/src/routes.ts b/Services/server/src/routes.ts index 639dcb0..cdbba04 100644 --- a/Services/server/src/routes.ts +++ b/Services/server/src/routes.ts @@ -138,6 +138,15 @@ const models: TsoaRoute.Models = { "additionalProperties": false, }, // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + "DownloadFileBody": { + "dataType": "refObject", + "properties": { + "path": {"dataType":"array","array":{"dataType":"string"},"required":true}, + "file": {"dataType":"string","required":true}, + }, + "additionalProperties": false, + }, + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa }; const validationService = new ValidationService(models); @@ -914,6 +923,32 @@ export function RegisterRoutes(app: Router) { } }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + app.post('/storage/file/download', + authenticateMiddleware([{"bearerAuth":["management-role","admin"]}]), + ...(fetchMiddlewares(StorageController)), + ...(fetchMiddlewares(StorageController.prototype.downloadFile)), + + function StorageController_downloadFile(request: any, response: any, next: any) { + const args = { + body: {"in":"body","name":"body","required":true,"ref":"DownloadFileBody"}, + }; + + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + + let validatedArgs: any[] = []; + try { + validatedArgs = getValidatedArgs(args, request, response); + + const controller = new StorageController(); + + + const promise = controller.downloadFile.apply(controller, validatedArgs as any); + promiseHandler(controller, promise, response, 200, next); + } catch (err) { + return next(err); + } + }); + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa app.get('/cabinet/:cabinetName/drawer/:drawerName/folder/:folderName/subfolder', authenticateMiddleware([{"bearerAuth":[]}]), ...(fetchMiddlewares(SubFolderController)), diff --git a/Services/server/src/swagger.json b/Services/server/src/swagger.json index 48a105f..a2d430c 100644 --- a/Services/server/src/swagger.json +++ b/Services/server/src/swagger.json @@ -467,6 +467,31 @@ ], "type": "object", "additionalProperties": false + }, + "DownloadFileBody": { + "properties": { + "path": { + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "แฟ้ม 1", + "แฟ้ม 2", + "แฟ้ม 3" + ] + }, + "file": { + "type": "string", + "example": "ไฟล์ 1 แก้ไข.xlsx" + } + }, + "required": [ + "path", + "file" + ], + "type": "object", + "additionalProperties": false } }, "securitySchemes": { @@ -2119,7 +2144,7 @@ "description": "สำเร็จ" } }, - "description": "ลบ Folder หรือ File ออกจากระบบ", + "description": "ลบ Folder ออกจากระบบ", "tags": [ "Storage Folder" ], @@ -2327,6 +2352,7 @@ "description": "สำเร็จ" } }, + "description": "ลบ File ออกจากระบบ", "tags": [ "Storage File" ], @@ -2351,6 +2377,132 @@ } } }, + "/storage/file/download": { + "post": { + "operationId": "DownloadFile", + "responses": { + "200": { + "description": "สำเร็จ", + "content": { + "application/json": { + "schema": { + "properties": { + "createdBy": { + "type": "string" + }, + "createdAt": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "string", + "format": "date-time" + } + ] + }, + "updatedBy": { + "type": "string" + }, + "updatedAt": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "string", + "format": "date-time" + } + ] + }, + "upload": { + "type": "boolean" + }, + "path": { + "type": "string" + }, + "keyword": { + "items": { + "type": "string" + }, + "type": "array" + }, + "category": { + "items": { + "type": "string" + }, + "type": "array" + }, + "description": { + "type": "string" + }, + "title": { + "type": "string" + }, + "fileType": { + "type": "string" + }, + "fileSize": { + "type": "number", + "format": "double" + }, + "fileName": { + "type": "string" + }, + "pathname": { + "type": "string" + }, + "downloadUrl": { + "type": "string" + } + }, + "required": [ + "createdBy", + "createdAt", + "updatedBy", + "updatedAt", + "upload", + "path", + "keyword", + "category", + "description", + "title", + "fileType", + "fileSize", + "fileName", + "pathname", + "downloadUrl" + ], + "type": "object" + } + } + } + } + }, + "tags": [ + "Download" + ], + "security": [ + { + "bearerAuth": [ + "management-role", + "admin" + ] + } + ], + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/DownloadFileBody" + } + } + } + } + } + }, "/cabinet/{cabinetName}/drawer/{drawerName}/folder/{folderName}/subfolder": { "get": { "operationId": "ListFolder",