refactor: input keyword / category

This commit is contained in:
Methapon2001 2023-12-01 10:55:36 +07:00
parent 7b894383da
commit cbc867c8e3
No known key found for this signature in database
GPG key ID: 849924FEF46BD132
6 changed files with 514 additions and 401 deletions

View file

@ -35,4 +35,4 @@ app.listen(PORT, "0.0.0.0", () =>
console.log(`[APP] Application is running on http://localhost:${PORT}`),
);
rabbitmq.init(amqHandler).catch((e) => console.error(e));
// rabbitmq.init(amqHandler).catch((e) => console.error(e));

View file

@ -2,6 +2,7 @@ import {
Body,
Controller,
Delete,
Example,
Get,
Patch,
Path,
@ -31,10 +32,33 @@ if (!DEFAULT_INDEX) throw Error("Default ElasticSearch index must be specified."
@Route("/cabinet/{cabinetName}/drawer/{drawerName}/folder/{folderName}/file")
export class FileController extends Controller {
/**
* @example cabinetName "ตู้เอกสาร 1"
* @example drawerName "ลิ้นชัก 1"
* @example folderName "แฟ้ม 1"
*/
@Get("/")
@Tags("ไฟล์")
@Security("bearerAuth")
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
@Example([
{
pathname: "ตู้เอกสาร 1/ลิ้นชัก 1/แฟ้ม 1/เอกสาร 1",
path: "ตู้เอกสาร 1/ลิ้นชัก 1/แฟ้ม 1/",
title: "เอกสาร",
description: "เอกสารการเงิน",
category: ["บัญชี"],
keyword: ["เงิน", "บัญชี", "รายจ่าย", "รายรับ"],
upload: false,
fileName: "เอกสาร 1",
fileSize: 10240,
fileType: "application/pdf",
createdAt: "2021-07-20T12:33:13.018Z",
createdBy: "admin",
updatedAt: "2021-07-20T12:33:13.018Z",
updatedBy: "admin",
},
])
public async getFile(
@Path() cabinetName: string,
@Path() drawerName: string,
@ -62,6 +86,11 @@ export class FileController extends Controller {
return records;
}
/**
* @example cabinetName "ตู้เอกสาร 1"
* @example drawerName "ลิ้นชัก 1"
* @example folderName "แฟ้ม 1"
*/
@Post("/")
@Tags("ไฟล์")
@Security("bearerAuth", ["admin"])
@ -70,15 +99,46 @@ export class FileController extends Controller {
"ตำแหน่งที่ระบุไม่พบ กรุณาเตรียมตำแหน่งที่ต้องการก่อนดำเนินการ",
)
@SuccessResponse(HttpStatusCode.CREATED, "สำเร็จ")
@Example({
pathname: "ตู้เอกสาร 1/ลิ้นชัก 1/แฟ้ม 1/เอกสาร 1",
path: "ตู้เอกสาร 1/ลิ้นชัก 1/แฟ้ม 1/",
title: "เอกสาร",
description: "เอกสารการเงิน",
category: ["บัญชี"],
keyword: ["เงิน", "บัญชี", "รายจ่าย", "รายรับ"],
upload: false,
fileName: "เอกสาร 1",
fileSize: 10240,
fileType: "application/pdf",
createdAt: "2021-07-20T12:33:13.018Z",
createdBy: "admin",
updatedAt: "2021-07-20T12:33:13.018Z",
updatedBy: "admin",
})
public async uploadFile(
@Request() request: { user: { preferred_username: string } },
@Body()
body: {
/**
* @example "เอกสาร 1"
*/
file: string;
/**
* @example "เอกสาร"
*/
title?: string;
/**
* @example "เอกสารการเงิน"
*/
description?: string;
category?: string;
keyword?: string;
/**
* @example ["บัญชี"]
*/
category?: string[];
/**
* @example ["เงิน", "บัญชี", "รายจ่าย", "รายรับ"]
*/
keyword?: string[];
},
@Path() cabinetName: string,
@Path() drawerName: string,
@ -125,8 +185,8 @@ export class FileController extends Controller {
fileType: "",
title: body.title ?? "",
description: body.description ?? "",
category: body.category?.split(",") ?? [],
keyword: body.keyword?.split(",") ?? [],
category: body.category ?? [],
keyword: body.keyword ?? [],
upload: false,
createdAt: new Date().toISOString(),
createdBy: rec ? rec.createdBy : "n/a",
@ -150,6 +210,12 @@ export class FileController extends Controller {
};
}
/**
* @example cabinetName "ตู้เอกสาร 1"
* @example drawerName "ลิ้นชัก 1"
* @example folderName "แฟ้ม 1"
* @example fileName "เอกสาร 1"
*/
@Patch("/{fileName}")
@Tags("ไฟล์")
@Security("bearerAuth", ["admin"])
@ -164,11 +230,26 @@ export class FileController extends Controller {
@Path() fileName: string,
@Body()
body: {
/**
* @example "เอกสารใหม่"
*/
file?: string;
/**
* @example "เอกสารการเงิน"
*/
title?: string;
/**
* @example "เอกสารการเงินฉบับใหม่"
*/
description?: string;
category?: string;
keyword?: string;
/**
* @example ["บัญชี"]
*/
category?: string[];
/**
* @example ["เงิน", "บัญชี", "รายจ่าย", "รายรับ"]
*/
keyword?: string[];
},
): Promise<void | { upload: string }> {
if (body.file && body.file.length > 85) {
@ -238,8 +319,6 @@ export class FileController extends Controller {
id,
doc: {
...body,
keyword: body.keyword?.split(","),
category: body.category?.split(","),
updatedAt: new Date().toISOString(),
updatedBy: request.user.preferred_username ?? "n/a",
},
@ -258,6 +337,12 @@ export class FileController extends Controller {
: this.setStatus(HttpStatusCode.NO_CONTENT);
}
/**
* @example cabinetName "ตู้เอกสาร 1"
* @example drawerName "ลิ้นชัก 1"
* @example folderName "แฟ้ม 1"
* @example fileName "เอกสารใหม่"
*/
@Delete("/{fileName}")
@Tags("ไฟล์")
@Security("bearerAuth", ["admin"])
@ -275,6 +360,12 @@ export class FileController extends Controller {
return this.setStatus(HttpStatusCode.NO_CONTENT);
}
/**
* @example cabinetName "ตู้เอกสาร 1"
* @example drawerName "ลิ้นชัก 1"
* @example folderName "แฟ้ม 1"
* @example fileName "เอกสารใหม่"
*/
@Get("/{fileName}")
@Tags("ดาวน์โหลด")
@Security("bearerAuth")

View file

@ -1,104 +0,0 @@
import { Body, Controller, Get, Path, Post, Put, Query, Route, SuccessResponse } from "tsoa";
import { replaceIllegalChars } from "../utils/minio";
import minioClient from "../minio";
import HttpStatusCode from "../interfaces/http-status";
import HttpError from "../interfaces/http-error";
const DEFAULT_BUCKET = process.env.MINIO_BUCKET;
const DEFAULT_INDEX = process.env.ELASTICSEARCH_INDEX;
if (!DEFAULT_BUCKET) throw Error("Default MinIO bucket must be specified.");
if (!DEFAULT_INDEX) throw Error("Default ElasticSearch index must be specified.");
@Route("/storage/d")
export class StorageController extends Controller {
@Get()
@SuccessResponse(HttpStatusCode.OK, "Success")
public async getFolder(@Query() path: string, @Query() bucket?: string) {
const list = await new Promise<{ pathname: string; name: string }[]>((resolve, reject) => {
const item: { pathname: string; name: string }[] = [];
const stream = minioClient.listObjectsV2(bucket ?? DEFAULT_BUCKET!, path);
stream.on("data", (v) => {
if (v && v.prefix) {
item.push({
pathname: v.prefix,
name: v.prefix.slice(path?.length).split("/")[0],
});
}
});
stream.on("end", () => resolve(item));
stream.on("error", () => reject(new Error("เกิดข้อผิดพลาดกับระบบจัดการไฟล์")));
});
return list;
}
@Post()
@SuccessResponse(HttpStatusCode.CREATED, "Success")
public async createFolder(@Query() path: string, @Query() bucket?: string) {
const fragments = path.split("/").filter(Boolean);
await Promise.all(
fragments.map(async (_, i, a) => {
const path = [...a.slice(0, i + 1)].map((x) => replaceIllegalChars(x)).join("/");
const created = await minioClient
.putObject(bucket ?? DEFAULT_BUCKET!, `${path}/.keep`, "", 0)
.catch((e) => console.error(e));
if (!created) throw new Error("เกิดข้อผิดพลาดกับระบบจัดการไฟล์");
}),
);
return this.setStatus(HttpStatusCode.CREATED);
}
@Put()
@SuccessResponse(HttpStatusCode.NO_CONTENT, "Success")
public async updateFolder(
@Body()
body: {
from: {
bucket: string;
path: string;
};
to: {
bucket: string;
path: string;
};
},
) {
const src = body.from.path.split("/").filter(Boolean).join("/");
const dst = body.to.path.split("/").filter(Boolean).join("/");
if (
!Boolean(
await minioClient
.statObject(DEFAULT_BUCKET!, `${dst.replace(/^\/|\/$/g, "")}/.keep`)
.catch((e) => {
if (e.code === "NotFound") return false;
throw new Error(`Minio Error: ${e}`);
}),
)
)
throw new HttpError(HttpStatusCode.NOT_FOUND, "Destination Not Found");
const list = await new Promise<{ pathname: string; name: string }[]>((resolve, reject) => {
const item: { pathname: string; name: string }[] = [];
const stream = minioClient.listObjectsV2(body.from.bucket, src);
stream.on("data", (v) => {
if (v && v.prefix) {
item.push({
pathname: v.prefix,
name: v.prefix.slice(src.length).split("/")[0],
});
}
});
stream.on("error", (e) => reject(new Error(`Minio Error: ${e}`)));
stream.on("end", () => resolve(item));
});
return this.setStatus(HttpStatusCode.NO_CONTENT);
}
}

View file

@ -2,6 +2,7 @@ import {
Body,
Controller,
Delete,
Example,
Get,
Patch,
Path,
@ -33,10 +34,34 @@ 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 {
/**
* @example cabinetName "ตู้เอกสาร 1"
* @example drawerName "ลิ้นชัก 1"
* @example folderName "แฟ้ม 1"
* @example subFolderName "แฟ้มย่อย 1"
*/
@Get("/")
@Tags("ไฟล์")
@Security("bearerAuth")
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
@Example([
{
pathname: "ตู้เอกสาร 1/ลิ้นชัก 1/แฟ้ม 1/แฟ้มย่อย 1/เอกสาร 1",
path: "ตู้เอกสาร 1/ลิ้นชัก 1/แฟ้ม 1/แฟ้มย่อย 1/",
title: "เอกสาร",
description: "เอกสารการเงิน",
category: ["บัญชี"],
keyword: ["เงิน", "บัญชี", "รายจ่าย", "รายรับ"],
upload: false,
fileName: "เอกสาร 1",
fileSize: 10240,
fileType: "application/pdf",
createdAt: "2021-07-20T12:33:13.018Z",
createdBy: "admin",
updatedAt: "2021-07-20T12:33:13.018Z",
updatedBy: "admin",
},
])
public async getFile(
@Path() cabinetName: string,
@Path() drawerName: string,
@ -65,6 +90,12 @@ export class SubFolderFileController extends Controller {
return records;
}
/**
* @example cabinetName "ตู้เอกสาร 1"
* @example drawerName "ลิ้นชัก 1"
* @example folderName "แฟ้ม 1"
* @example subFolderName "แฟ้มย่อย 1"
*/
@Post("/")
@Tags("ไฟล์")
@Security("bearerAuth", ["admin"])
@ -73,15 +104,46 @@ export class SubFolderFileController extends Controller {
"ตำแหน่งที่ระบุไม่พบ กรุณาเตรียมตำแหน่งที่ต้องการก่อนดำเนินการ",
)
@SuccessResponse(HttpStatusCode.CREATED, "สำเร็จ")
@Example({
pathname: "ตู้เอกสาร 1/ลิ้นชัก 1/แฟ้ม 1/แฟ้มย่อย 1/เอกสาร 1",
path: "ตู้เอกสาร 1/ลิ้นชัก 1/แฟ้ม 1/แฟ้มย่อย 1/",
title: "เอกสาร",
description: "เอกสารการเงิน",
category: ["บัญชี"],
keyword: ["เงิน", "บัญชี", "รายจ่าย", "รายรับ"],
upload: false,
fileName: "เอกสาร 1",
fileSize: 10240,
fileType: "application/pdf",
createdAt: "2021-07-20T12:33:13.018Z",
createdBy: "admin",
updatedAt: "2021-07-20T12:33:13.018Z",
updatedBy: "admin",
})
public async uploadFile(
@Request() request: { user: { preferred_username: string } },
@Body()
body: {
/**
* @example "เอกสาร 1"
*/
file: string;
/**
* @example "เอกสาร"
*/
title?: string;
/**
* @example "เอกสารการเงิน"
*/
description?: string;
category?: string;
keyword?: string;
/**
* @example ["บัญชี"]
*/
category?: string[];
/**
* @example ["เงิน", "บัญชี", "รายจ่าย", "รายรับ"]
*/
keyword?: string[];
},
@Path() cabinetName: string,
@Path() drawerName: string,
@ -129,8 +191,8 @@ export class SubFolderFileController extends Controller {
fileType: "",
title: body.title ?? "",
description: body.description ?? "",
category: body.category?.split(",") ?? [],
keyword: body.keyword?.split(",") ?? [],
category: body.category ?? [],
keyword: body.keyword ?? [],
upload: false,
createdAt: new Date().toISOString(),
createdBy: rec ? rec.createdBy : "n/a",
@ -154,6 +216,13 @@ export class SubFolderFileController extends Controller {
};
}
/**
* @example cabinetName "ตู้เอกสาร 1"
* @example drawerName "ลิ้นชัก 1"
* @example folderName "แฟ้ม 1"
* @example subFolderName "แฟ้มย่อย 1"
* @example fileName "เอกสาร 1"
*/
@Patch("/{fileName}")
@Tags("ไฟล์")
@Security("bearerAuth", ["admin"])
@ -168,11 +237,26 @@ export class SubFolderFileController extends Controller {
@Path() fileName: string,
@Body()
body: {
/**
* @example "เอกสารใหม่"
*/
file?: string;
/**
* @example "เอกสารการเงิน"
*/
title?: string;
/**
* @example "เอกสารการเงินฉบับใหม่"
*/
description?: string;
category?: string;
keyword?: string;
/**
* @example ["บัญชี"]
*/
category?: string[];
/**
* @example ["เงิน", "บัญชี", "รายจ่าย", "รายรับ"]
*/
keyword?: string[];
},
) {
if (body.file && body.file.length > 85) {
@ -241,8 +325,6 @@ export class SubFolderFileController extends Controller {
id,
doc: {
...body,
keyword: body.keyword?.split(","),
category: body.category?.split(","),
updatedAt: new Date().toISOString(),
updatedBy: request.user.preferred_username ?? "n/a",
},
@ -261,6 +343,13 @@ export class SubFolderFileController extends Controller {
: this.setStatus(HttpStatusCode.NO_CONTENT);
}
/**
* @example cabinetName "ตู้เอกสาร 1"
* @example drawerName "ลิ้นชัก 1"
* @example folderName "แฟ้ม 1"
* @example subFolderName "แฟ้มย่อย 1"
* @example fileName "เอกสาร 1"
*/
@Delete("/{fileName}")
@Tags("ไฟล์")
@Security("bearerAuth", ["admin"])
@ -279,6 +368,13 @@ export class SubFolderFileController extends Controller {
return this.setStatus(HttpStatusCode.NO_CONTENT);
}
/**
* @example cabinetName "ตู้เอกสาร 1"
* @example drawerName "ลิ้นชัก 1"
* @example folderName "แฟ้ม 1"
* @example folderName "แฟ้มย่อย 1"
* @example fileName "เอกสาร 1"
*/
@Get("/{fileName}")
@Tags("ดาวน์โหลด")
@Security("bearerAuth")

View file

@ -13,8 +13,6 @@ import { FolderController } from './controllers/folderController';
// 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
import { SearchController } from './controllers/searchController';
// 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
import { StorageController } from './controllers/storageController';
// 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
import { SubFolderController } from './controllers/subFolderController';
// 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
import { SubFolderFileController } from './controllers/subFolderFileController';
@ -327,7 +325,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"},"category":{"dataType":"string"},"description":{"dataType":"string"},"title":{"dataType":"string"},"file":{"dataType":"string","required":true}}},
body: {"in":"body","name":"body","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"keyword":{"dataType":"array","array":{"dataType":"string"}},"category":{"dataType":"array","array":{"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"},
@ -361,7 +359,7 @@ export function RegisterRoutes(app: Router) {
drawerName: {"in":"path","name":"drawerName","required":true,"dataType":"string"},
folderName: {"in":"path","name":"folderName","required":true,"dataType":"string"},
fileName: {"in":"path","name":"fileName","required":true,"dataType":"string"},
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"}}},
body: {"in":"body","name":"body","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"keyword":{"dataType":"array","array":{"dataType":"string"}},"category":{"dataType":"array","array":{"dataType":"string"}},"description":{"dataType":"string"},"title":{"dataType":"string"},"file":{"dataType":"string"}}},
};
// 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
@ -577,83 +575,6 @@ 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.get('/storage/d',
...(fetchMiddlewares<RequestHandler>(StorageController)),
...(fetchMiddlewares<RequestHandler>(StorageController.prototype.getFolder)),
function StorageController_getFolder(request: any, response: any, next: any) {
const args = {
path: {"in":"query","name":"path","required":true,"dataType":"string"},
bucket: {"in":"query","name":"bucket","dataType":"string"},
};
// 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.getFolder.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.post('/storage/d',
...(fetchMiddlewares<RequestHandler>(StorageController)),
...(fetchMiddlewares<RequestHandler>(StorageController.prototype.createFolder)),
function StorageController_createFolder(request: any, response: any, next: any) {
const args = {
path: {"in":"query","name":"path","required":true,"dataType":"string"},
bucket: {"in":"query","name":"bucket","dataType":"string"},
};
// 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.createFolder.apply(controller, validatedArgs as any);
promiseHandler(controller, promise, response, 201, 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.put('/storage/d',
...(fetchMiddlewares<RequestHandler>(StorageController)),
...(fetchMiddlewares<RequestHandler>(StorageController.prototype.updateFolder)),
function StorageController_updateFolder(request: any, response: any, next: any) {
const args = {
body: {"in":"body","name":"body","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"to":{"dataType":"nestedObjectLiteral","nestedProperties":{"path":{"dataType":"string","required":true},"bucket":{"dataType":"string","required":true}},"required":true},"from":{"dataType":"nestedObjectLiteral","nestedProperties":{"path":{"dataType":"string","required":true},"bucket":{"dataType":"string","required":true}},"required":true}}},
};
// 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.updateFolder.apply(controller, validatedArgs as any);
promiseHandler(controller, promise, response, 204, 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<RequestHandler>(SubFolderController)),
@ -808,7 +729,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"},"category":{"dataType":"string"},"description":{"dataType":"string"},"title":{"dataType":"string"},"file":{"dataType":"string","required":true}}},
body: {"in":"body","name":"body","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"keyword":{"dataType":"array","array":{"dataType":"string"}},"category":{"dataType":"array","array":{"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"},
@ -844,7 +765,7 @@ export function RegisterRoutes(app: Router) {
folderName: {"in":"path","name":"folderName","required":true,"dataType":"string"},
subFolderName: {"in":"path","name":"subFolderName","required":true,"dataType":"string"},
fileName: {"in":"path","name":"fileName","required":true,"dataType":"string"},
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"}}},
body: {"in":"body","name":"body","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"keyword":{"dataType":"array","array":{"dataType":"string"}},"category":{"dataType":"array","array":{"dataType":"string"}},"description":{"dataType":"string"},"title":{"dataType":"string"},"file":{"dataType":"string"}}},
};
// 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

View file

@ -599,6 +599,35 @@
"$ref": "#/components/schemas/StorageFile"
},
"type": "array"
},
"examples": {
"Example 1": {
"value": [
{
"pathname": "ตู้เอกสาร 1/ลิ้นชัก 1/แฟ้ม 1/เอกสาร 1",
"path": "ตู้เอกสาร 1/ลิ้นชัก 1/แฟ้ม 1/",
"title": "เอกสาร",
"description": "เอกสารการเงิน",
"category": [
"บัญชี"
],
"keyword": [
"เงิน",
"บัญชี",
"รายจ่าย",
"รายรับ"
],
"upload": false,
"fileName": "เอกสาร 1",
"fileSize": 10240,
"fileType": "application/pdf",
"createdAt": "2021-07-20T12:33:13.018Z",
"createdBy": "admin",
"updatedAt": "2021-07-20T12:33:13.018Z",
"updatedBy": "admin"
}
]
}
}
}
}
@ -619,7 +648,8 @@
"required": true,
"schema": {
"type": "string"
}
},
"example": "ตู้เอกสาร 1"
},
{
"in": "path",
@ -627,7 +657,8 @@
"required": true,
"schema": {
"type": "string"
}
},
"example": "ลิ้นชัก 1"
},
{
"in": "path",
@ -635,7 +666,8 @@
"required": true,
"schema": {
"type": "string"
}
},
"example": "แฟ้ม 1"
}
]
},
@ -649,10 +681,16 @@
"schema": {
"properties": {
"keyword": {
"type": "string"
"items": {
"type": "string"
},
"type": "array"
},
"category": {
"type": "string"
"items": {
"type": "string"
},
"type": "array"
},
"description": {
"type": "string"
@ -704,6 +742,33 @@
"createdAt"
],
"type": "object"
},
"examples": {
"Example 1": {
"value": {
"pathname": "ตู้เอกสาร 1/ลิ้นชัก 1/แฟ้ม 1/เอกสาร 1",
"path": "ตู้เอกสาร 1/ลิ้นชัก 1/แฟ้ม 1/",
"title": "เอกสาร",
"description": "เอกสารการเงิน",
"category": [
"บัญชี"
],
"keyword": [
"เงิน",
"บัญชี",
"รายจ่าย",
"รายรับ"
],
"upload": false,
"fileName": "เอกสาร 1",
"fileSize": 10240,
"fileType": "application/pdf",
"createdAt": "2021-07-20T12:33:13.018Z",
"createdBy": "admin",
"updatedAt": "2021-07-20T12:33:13.018Z",
"updatedBy": "admin"
}
}
}
}
}
@ -729,7 +794,8 @@
"required": true,
"schema": {
"type": "string"
}
},
"example": "ตู้เอกสาร 1"
},
{
"in": "path",
@ -737,7 +803,8 @@
"required": true,
"schema": {
"type": "string"
}
},
"example": "ลิ้นชัก 1"
},
{
"in": "path",
@ -745,7 +812,8 @@
"required": true,
"schema": {
"type": "string"
}
},
"example": "แฟ้ม 1"
}
],
"requestBody": {
@ -755,19 +823,37 @@
"schema": {
"properties": {
"keyword": {
"type": "string"
"items": {
"type": "string"
},
"type": "array",
"example": [
"เงิน",
"บัญชี",
"รายจ่าย",
"รายรับ"
]
},
"category": {
"type": "string"
"items": {
"type": "string"
},
"type": "array",
"example": [
"บัญชี"
]
},
"description": {
"type": "string"
"type": "string",
"example": "เอกสารการเงิน"
},
"title": {
"type": "string"
"type": "string",
"example": "เอกสาร"
},
"file": {
"type": "string"
"type": "string",
"example": "เอกสาร 1"
}
},
"required": [
@ -831,7 +917,8 @@
"required": true,
"schema": {
"type": "string"
}
},
"example": "ตู้เอกสาร 1"
},
{
"in": "path",
@ -839,7 +926,8 @@
"required": true,
"schema": {
"type": "string"
}
},
"example": "ลิ้นชัก 1"
},
{
"in": "path",
@ -847,7 +935,8 @@
"required": true,
"schema": {
"type": "string"
}
},
"example": "แฟ้ม 1"
},
{
"in": "path",
@ -855,7 +944,8 @@
"required": true,
"schema": {
"type": "string"
}
},
"example": "เอกสาร 1"
}
],
"requestBody": {
@ -865,19 +955,37 @@
"schema": {
"properties": {
"keyword": {
"type": "string"
"items": {
"type": "string"
},
"type": "array",
"example": [
"เงิน",
"บัญชี",
"รายจ่าย",
"รายรับ"
]
},
"category": {
"type": "string"
"items": {
"type": "string"
},
"type": "array",
"example": [
"บัญชี"
]
},
"description": {
"type": "string"
"type": "string",
"example": "เอกสารการเงินฉบับใหม่"
},
"title": {
"type": "string"
"type": "string",
"example": "เอกสารการเงิน"
},
"file": {
"type": "string"
"type": "string",
"example": "เอกสารใหม่"
}
},
"type": "object"
@ -910,7 +1018,8 @@
"required": true,
"schema": {
"type": "string"
}
},
"example": "ตู้เอกสาร 1"
},
{
"in": "path",
@ -918,7 +1027,8 @@
"required": true,
"schema": {
"type": "string"
}
},
"example": "ลิ้นชัก 1"
},
{
"in": "path",
@ -926,7 +1036,8 @@
"required": true,
"schema": {
"type": "string"
}
},
"example": "แฟ้ม 1"
},
{
"in": "path",
@ -934,7 +1045,8 @@
"required": true,
"schema": {
"type": "string"
}
},
"example": "เอกสารใหม่"
}
]
},
@ -1054,7 +1166,8 @@
"required": true,
"schema": {
"type": "string"
}
},
"example": "ตู้เอกสาร 1"
},
{
"in": "path",
@ -1062,7 +1175,8 @@
"required": true,
"schema": {
"type": "string"
}
},
"example": "ลิ้นชัก 1"
},
{
"in": "path",
@ -1070,7 +1184,8 @@
"required": true,
"schema": {
"type": "string"
}
},
"example": "แฟ้ม 1"
},
{
"in": "path",
@ -1078,7 +1193,8 @@
"required": true,
"schema": {
"type": "string"
}
},
"example": "เอกสารใหม่"
}
]
}
@ -1372,140 +1488,6 @@
}
}
},
"/storage/d": {
"get": {
"operationId": "GetFolder",
"responses": {
"200": {
"description": "Success",
"content": {
"application/json": {
"schema": {
"items": {
"properties": {
"name": {
"type": "string"
},
"pathname": {
"type": "string"
}
},
"required": [
"name",
"pathname"
],
"type": "object"
},
"type": "array"
}
}
}
}
},
"security": [],
"parameters": [
{
"in": "query",
"name": "path",
"required": true,
"schema": {
"type": "string"
}
},
{
"in": "query",
"name": "bucket",
"required": false,
"schema": {
"type": "string"
}
}
]
},
"post": {
"operationId": "CreateFolder",
"responses": {
"201": {
"description": "Success"
}
},
"security": [],
"parameters": [
{
"in": "query",
"name": "path",
"required": true,
"schema": {
"type": "string"
}
},
{
"in": "query",
"name": "bucket",
"required": false,
"schema": {
"type": "string"
}
}
]
},
"put": {
"operationId": "UpdateFolder",
"responses": {
"204": {
"description": "Success"
}
},
"security": [],
"parameters": [],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"properties": {
"to": {
"properties": {
"path": {
"type": "string"
},
"bucket": {
"type": "string"
}
},
"required": [
"path",
"bucket"
],
"type": "object"
},
"from": {
"properties": {
"path": {
"type": "string"
},
"bucket": {
"type": "string"
}
},
"required": [
"path",
"bucket"
],
"type": "object"
}
},
"required": [
"to",
"from"
],
"type": "object"
}
}
}
}
}
},
"/cabinet/{cabinetName}/drawer/{drawerName}/folder/{folderName}/subfolder": {
"get": {
"operationId": "ListFolder",
@ -1804,6 +1786,35 @@
"$ref": "#/components/schemas/StorageFile"
},
"type": "array"
},
"examples": {
"Example 1": {
"value": [
{
"pathname": "ตู้เอกสาร 1/ลิ้นชัก 1/แฟ้ม 1/แฟ้มย่อย 1/เอกสาร 1",
"path": "ตู้เอกสาร 1/ลิ้นชัก 1/แฟ้ม 1/แฟ้มย่อย 1/",
"title": "เอกสาร",
"description": "เอกสารการเงิน",
"category": [
"บัญชี"
],
"keyword": [
"เงิน",
"บัญชี",
"รายจ่าย",
"รายรับ"
],
"upload": false,
"fileName": "เอกสาร 1",
"fileSize": 10240,
"fileType": "application/pdf",
"createdAt": "2021-07-20T12:33:13.018Z",
"createdBy": "admin",
"updatedAt": "2021-07-20T12:33:13.018Z",
"updatedBy": "admin"
}
]
}
}
}
}
@ -1824,7 +1835,8 @@
"required": true,
"schema": {
"type": "string"
}
},
"example": "ตู้เอกสาร 1"
},
{
"in": "path",
@ -1832,7 +1844,8 @@
"required": true,
"schema": {
"type": "string"
}
},
"example": "ลิ้นชัก 1"
},
{
"in": "path",
@ -1840,7 +1853,8 @@
"required": true,
"schema": {
"type": "string"
}
},
"example": "แฟ้ม 1"
},
{
"in": "path",
@ -1848,7 +1862,8 @@
"required": true,
"schema": {
"type": "string"
}
},
"example": "แฟ้มย่อย 1"
}
]
},
@ -1862,10 +1877,16 @@
"schema": {
"properties": {
"keyword": {
"type": "string"
"items": {
"type": "string"
},
"type": "array"
},
"category": {
"type": "string"
"items": {
"type": "string"
},
"type": "array"
},
"description": {
"type": "string"
@ -1917,6 +1938,33 @@
"createdAt"
],
"type": "object"
},
"examples": {
"Example 1": {
"value": {
"pathname": "ตู้เอกสาร 1/ลิ้นชัก 1/แฟ้ม 1/แฟ้มย่อย 1/เอกสาร 1",
"path": "ตู้เอกสาร 1/ลิ้นชัก 1/แฟ้ม 1/แฟ้มย่อย 1/",
"title": "เอกสาร",
"description": "เอกสารการเงิน",
"category": [
"บัญชี"
],
"keyword": [
"เงิน",
"บัญชี",
"รายจ่าย",
"รายรับ"
],
"upload": false,
"fileName": "เอกสาร 1",
"fileSize": 10240,
"fileType": "application/pdf",
"createdAt": "2021-07-20T12:33:13.018Z",
"createdBy": "admin",
"updatedAt": "2021-07-20T12:33:13.018Z",
"updatedBy": "admin"
}
}
}
}
}
@ -1942,7 +1990,8 @@
"required": true,
"schema": {
"type": "string"
}
},
"example": "ตู้เอกสาร 1"
},
{
"in": "path",
@ -1950,7 +1999,8 @@
"required": true,
"schema": {
"type": "string"
}
},
"example": "ลิ้นชัก 1"
},
{
"in": "path",
@ -1958,7 +2008,8 @@
"required": true,
"schema": {
"type": "string"
}
},
"example": "แฟ้ม 1"
},
{
"in": "path",
@ -1966,7 +2017,8 @@
"required": true,
"schema": {
"type": "string"
}
},
"example": "แฟ้มย่อย 1"
}
],
"requestBody": {
@ -1976,19 +2028,37 @@
"schema": {
"properties": {
"keyword": {
"type": "string"
"items": {
"type": "string"
},
"type": "array",
"example": [
"เงิน",
"บัญชี",
"รายจ่าย",
"รายรับ"
]
},
"category": {
"type": "string"
"items": {
"type": "string"
},
"type": "array",
"example": [
"บัญชี"
]
},
"description": {
"type": "string"
"type": "string",
"example": "เอกสารการเงิน"
},
"title": {
"type": "string"
"type": "string",
"example": "เอกสาร"
},
"file": {
"type": "string"
"type": "string",
"example": "เอกสาร 1"
}
},
"required": [
@ -2049,7 +2119,8 @@
"required": true,
"schema": {
"type": "string"
}
},
"example": "ตู้เอกสาร 1"
},
{
"in": "path",
@ -2057,7 +2128,8 @@
"required": true,
"schema": {
"type": "string"
}
},
"example": "ลิ้นชัก 1"
},
{
"in": "path",
@ -2065,7 +2137,8 @@
"required": true,
"schema": {
"type": "string"
}
},
"example": "แฟ้ม 1"
},
{
"in": "path",
@ -2073,7 +2146,8 @@
"required": true,
"schema": {
"type": "string"
}
},
"example": "แฟ้มย่อย 1"
},
{
"in": "path",
@ -2081,7 +2155,8 @@
"required": true,
"schema": {
"type": "string"
}
},
"example": "เอกสาร 1"
}
],
"requestBody": {
@ -2091,19 +2166,37 @@
"schema": {
"properties": {
"keyword": {
"type": "string"
"items": {
"type": "string"
},
"type": "array",
"example": [
"เงิน",
"บัญชี",
"รายจ่าย",
"รายรับ"
]
},
"category": {
"type": "string"
"items": {
"type": "string"
},
"type": "array",
"example": [
"บัญชี"
]
},
"description": {
"type": "string"
"type": "string",
"example": "เอกสารการเงินฉบับใหม่"
},
"title": {
"type": "string"
"type": "string",
"example": "เอกสารการเงิน"
},
"file": {
"type": "string"
"type": "string",
"example": "เอกสารใหม่"
}
},
"type": "object"
@ -2136,7 +2229,8 @@
"required": true,
"schema": {
"type": "string"
}
},
"example": "ตู้เอกสาร 1"
},
{
"in": "path",
@ -2144,7 +2238,8 @@
"required": true,
"schema": {
"type": "string"
}
},
"example": "ลิ้นชัก 1"
},
{
"in": "path",
@ -2152,7 +2247,8 @@
"required": true,
"schema": {
"type": "string"
}
},
"example": "แฟ้ม 1"
},
{
"in": "path",
@ -2160,7 +2256,8 @@
"required": true,
"schema": {
"type": "string"
}
},
"example": "แฟ้มย่อย 1"
},
{
"in": "path",
@ -2168,7 +2265,8 @@
"required": true,
"schema": {
"type": "string"
}
},
"example": "เอกสาร 1"
}
]
},
@ -2288,7 +2386,8 @@
"required": true,
"schema": {
"type": "string"
}
},
"example": "ตู้เอกสาร 1"
},
{
"in": "path",
@ -2296,7 +2395,8 @@
"required": true,
"schema": {
"type": "string"
}
},
"example": "ลิ้นชัก 1"
},
{
"in": "path",
@ -2304,6 +2404,14 @@
"required": true,
"schema": {
"type": "string"
},
"examples": {
"Example 1": {
"value": "แฟ้ม 1"
},
"Example 2": {
"value": "แฟ้มย่อย 1"
}
}
},
{
@ -2320,7 +2428,8 @@
"required": true,
"schema": {
"type": "string"
}
},
"example": "เอกสาร 1"
}
]
}