chore: update tag

This commit is contained in:
Methapon Metanipat 2024-09-17 08:54:47 +07:00
parent fdf3a42659
commit 7b296ec904
2 changed files with 29 additions and 103 deletions

View file

@ -502,110 +502,7 @@ export class CustomerBranchController extends Controller {
}
}
// @Route("api/v1/customer-branch/{branchId}/attachment")
// @Tags("Customer Branch")
// @Security("keycloak")
// export class CustomerAttachmentController extends Controller {
// @Get()
// async listAttachment(@Path() branchId: string) {
// const record = await prisma.customerBranch.findFirst({
// where: { id: branchId },
// });
//
// if (!record) {
// throw new HttpError(
// HttpStatus.NOT_FOUND,
// "Customer branch cannot be found.",
// "customerBranchNotFound",
// );
// }
//
// const list = await new Promise<string[]>((resolve, reject) => {
// const item: string[] = [];
//
// const stream = minio.listObjectsV2(
// MINIO_BUCKET,
// `${attachmentLocation(record.customerId, branchId)}/`,
// );
//
// stream.on("data", (v) => v && v.name && item.push(v.name));
// stream.on("end", () => resolve(item));
// stream.on("error", () => reject(new Error("MinIO error.")));
// });
//
// return list.map((v) => v.split("/").at(-1) as string);
// }
//
// @Get("{filename}")
// async getAttachment(
// @Request() req: RequestWithUser,
// @Path() branchId: string,
// @Path() filename: string,
// ) {
// const record = await prisma.customerBranch.findFirst({
// where: { id: branchId },
// });
//
// if (!record) {
// throw new HttpError(
// HttpStatus.NOT_FOUND,
// "Customer branch cannot be found.",
// "customerBranchNotFound",
// );
// }
//
// return await minio.presignedGetObject(
// MINIO_BUCKET,
// `${attachmentLocation(record.customerId, branchId)}/${filename}`,
// 12 * 60 * 60,
// );
// }
//
// @Put("{filename}")
// async addAttachment(
// @Request() req: RequestWithUser,
// @Path() branchId: string,
// @Path() filename: string,
// ) {
// const record = await prisma.customerBranch.findFirst({
// where: { id: branchId },
// });
//
// if (!record) {
// throw new HttpError(
// HttpStatus.NOT_FOUND,
// "Customer branch cannot be found.",
// "customerBranchNotFound",
// );
// }
//
// return req.res?.redirect(
// await minio.presignedPutObject(
// MINIO_BUCKET,
// `${attachmentLocation(record.customerId, branchId)}/${filename}`,
// 12 * 60 * 60,
// ),
// );
// }
//
// @Delete("{filename}")
// async deleteAttachment(@Path() branchId: string, @Path() filename: string) {
// const record = await prisma.customerBranch.findFirst({
// where: { id: branchId },
// });
//
// if (!record) throw notFoundError("Customer Branch");
//
// await minio.removeObject(
// MINIO_BUCKET,
// `${attachmentLocation(record.customerId, branchId)}/${filename}`,
// { forceDelete: true },
// );
// }
// }
@Route("api/v1/customer-branch/{branchId}")
@Tags("Customer Branch")
export class CustomerBranchFileController extends Controller {
private async checkPermission(user: RequestWithUser["user"], id: string) {
const data = await prisma.customerBranch.findFirst({
@ -626,6 +523,7 @@ export class CustomerBranchFileController extends Controller {
@Get("attachment")
@Security("keycloak")
@Tags("Customer Branch")
async listAttachment(@Request() req: RequestWithUser, @Path() branchId: string) {
await this.checkPermission(req.user, branchId);
return await listFile(fileLocation.customerBranch.attachment(branchId));
@ -633,12 +531,14 @@ export class CustomerBranchFileController extends Controller {
@Get("attachment/{name}")
@Security("keycloak")
@Tags("Customer Branch")
async getAttachment(@Path() branchId: string, @Path() name: string) {
return await getFile(fileLocation.customerBranch.attachment(branchId, name));
}
@Put("attachment/{name}")
@Security("keycloak")
@Tags("Customer Branch")
async putAttachment(
@Request() req: RequestWithUser,
@Path() branchId: string,
@ -650,6 +550,7 @@ export class CustomerBranchFileController extends Controller {
@Delete("attachment/{name}")
@Security("keycloak")
@Tags("Customer Branch")
async delAttachment(
@Request() req: RequestWithUser,
@Path() branchId: string,
@ -661,6 +562,7 @@ export class CustomerBranchFileController extends Controller {
@Get("file-citizen")
@Security("keycloak")
@Tags("Customer Branch Citizen")
async listCitizen(@Request() req: RequestWithUser, @Path() branchId: string) {
await this.checkPermission(req.user, branchId);
return await listFile(fileLocation.customerBranch.attachment(branchId));
@ -668,12 +570,14 @@ export class CustomerBranchFileController extends Controller {
@Get("file-citizen/{id}")
@Security("keycloak")
@Tags("Customer Branch Citizen")
async getCitizen(@Path() branchId: string, @Path() id: string) {
return await getFile(fileLocation.customerBranch.attachment(branchId, id));
}
@Put("file-citizen/{id}")
@Security("keycloak")
@Tags("Customer Branch Citizen")
async putCitizen(@Request() req: RequestWithUser, @Path() branchId: string, @Path() id: string) {
await this.checkPermission(req.user, branchId);
return req.res?.redirect(await setFile(fileLocation.customerBranch.attachment(branchId, id)));
@ -681,6 +585,7 @@ export class CustomerBranchFileController extends Controller {
@Delete("file-citizen/{id}")
@Security("keycloak")
@Tags("Customer Branch Citizen")
async delCitizen(@Request() req: RequestWithUser, @Path() branchId: string, @Path() id: string) {
await this.checkPermission(req.user, branchId);
return await deleteFile(fileLocation.customerBranch.citizen(branchId, id));
@ -688,6 +593,7 @@ export class CustomerBranchFileController extends Controller {
@Get("file-power-of-attorney")
@Security("keycloak")
@Tags("Customer Branch Power of Attorney")
async listPoa(@Request() req: RequestWithUser, @Path() branchId: string) {
await this.checkPermission(req.user, branchId);
return await listFile(fileLocation.customerBranch.powerOfAttorney(branchId));
@ -695,12 +601,14 @@ export class CustomerBranchFileController extends Controller {
@Get("file-power-of-attorney/{id}")
@Security("keycloak")
@Tags("Customer Branch Power of Attorney")
async getPoa(@Path() branchId: string, @Path() id: string) {
return await getFile(fileLocation.customerBranch.powerOfAttorney(branchId, id));
}
@Put("file-power-of-attorney/{id}")
@Security("keycloak")
@Tags("Customer Branch Power of Attorney")
async putPoa(@Request() req: RequestWithUser, @Path() branchId: string, @Path() id: string) {
await this.checkPermission(req.user, branchId);
return req.res?.redirect(
@ -710,12 +618,14 @@ export class CustomerBranchFileController extends Controller {
@Delete("file-power-of-attorney/{id}")
@Security("keycloak")
@Tags("Customer Branch Power of Attorney")
async delPoa(@Request() req: RequestWithUser, @Path() branchId: string, @Path() id: string) {
await this.checkPermission(req.user, branchId);
return await deleteFile(fileLocation.customerBranch.powerOfAttorney(branchId, id));
}
@Get("file-house-registration")
@Tags("Customer Branch House Registration")
@Security("keycloak")
async listHouseRegis(@Request() req: RequestWithUser, @Path() branchId: string) {
await this.checkPermission(req.user, branchId);
@ -724,12 +634,14 @@ export class CustomerBranchFileController extends Controller {
@Get("file-house-registration/{id}")
@Security("keycloak")
@Tags("Customer Branch House Registration")
async getHouseRegis(@Path() branchId: string, @Path() id: string) {
return await getFile(fileLocation.customerBranch.houseRegistration(branchId, id));
}
@Put("file-house-registration/{id}")
@Security("keycloak")
@Tags("Customer Branch House Registration")
async putHouseRegis(
@Request() req: RequestWithUser,
@Path() branchId: string,
@ -743,6 +655,7 @@ export class CustomerBranchFileController extends Controller {
@Delete("file-house-registration/{id}")
@Security("keycloak")
@Tags("Customer Branch House Registration")
async delHouseRegis(
@Request() req: RequestWithUser,
@Path() branchId: string,
@ -754,6 +667,7 @@ export class CustomerBranchFileController extends Controller {
@Get("file-commercial-registration")
@Security("keycloak")
@Tags("Customer Branch Commercial Registration")
async listCommercialRegis(@Request() req: RequestWithUser, @Path() branchId: string) {
await this.checkPermission(req.user, branchId);
return await listFile(fileLocation.customerBranch.commercialRegistration(branchId));
@ -761,12 +675,14 @@ export class CustomerBranchFileController extends Controller {
@Get("file-commercial-registration/{id}")
@Security("keycloak")
@Tags("Customer Branch Commercial Registration")
async getCommercialRegis(@Path() branchId: string, @Path() id: string) {
return await getFile(fileLocation.customerBranch.commercialRegistration(branchId, id));
}
@Put("file-commercial-registration/{id}")
@Security("keycloak")
@Tags("Customer Branch Commercial Registration")
async putCommercialRegis(
@Request() req: RequestWithUser,
@Path() branchId: string,
@ -780,6 +696,7 @@ export class CustomerBranchFileController extends Controller {
@Delete("file-commercial-registration/{id}")
@Security("keycloak")
@Tags("Customer Branch Commercial Registration")
async delCommercialRegis(
@Request() req: RequestWithUser,
@Path() branchId: string,
@ -791,6 +708,7 @@ export class CustomerBranchFileController extends Controller {
@Get("file-vat-registration")
@Security("keycloak")
@Tags("Customer Branch Vat Registration")
async listVatRegis(@Request() req: RequestWithUser, @Path() branchId: string) {
await this.checkPermission(req.user, branchId);
return await listFile(fileLocation.customerBranch.vatRegistration(branchId));
@ -798,12 +716,14 @@ export class CustomerBranchFileController extends Controller {
@Get("file-vat-registration/{id}")
@Security("keycloak")
@Tags("Customer Branch Vat Registration")
async getVatRegis(@Path() branchId: string, @Path() id: string) {
return await getFile(fileLocation.customerBranch.vatRegistration(branchId, id));
}
@Put("file-vat-registration/{id}")
@Security("keycloak")
@Tags("Customer Branch Vat Registration")
async putVatRegis(@Request() req: RequestWithUser, @Path() branchId: string, @Path() id: string) {
await this.checkPermission(req.user, branchId);
return req.res?.redirect(
@ -813,6 +733,7 @@ export class CustomerBranchFileController extends Controller {
@Delete("file-vat-registration/{id}")
@Security("keycloak")
@Tags("Customer Branch Vat Registration")
async delVatRegis(@Request() req: RequestWithUser, @Path() branchId: string, @Path() id: string) {
await this.checkPermission(req.user, branchId);
return await deleteFile(fileLocation.customerBranch.vatRegistration(branchId, id));

View file

@ -24,6 +24,11 @@
{ "name": "Branch User" },
{ "name": "Customer" },
{ "name": "Customer Branch" },
{ "name": "Customer Branch Citizen" },
{ "name": "Customer Branch House Registration" },
{ "name": "Customer Branch Vat Registration" },
{ "name": "Customer Branch Commercial Registration" },
{ "name": "Customer Branch Power of Attorney" },
{ "name": "Employee" },
{ "name": "Employee Checkup" },
{ "name": "Employee Passport" },