feat: add slip upload endpoint

This commit is contained in:
Methapon2001 2025-01-13 11:00:13 +07:00
parent eca99dbcd1
commit f1312b586f
2 changed files with 43 additions and 1 deletions

View file

@ -621,4 +621,44 @@ export class CreditNoteAttachmentController extends Controller {
await this.#checkPermission(req.user, creditNoteId);
return await deleteFile(fileLocation.creditNote.attachment(creditNoteId, name));
}
@Get("file-slip")
@Security("keycloak")
async listSlip(@Request() req: RequestWithUser, @Path() creditNoteId: string) {
await this.#checkPermission(req.user, creditNoteId);
return await listFile(fileLocation.creditNote.slip(creditNoteId));
}
@Get("file-slip/{name}")
@Security("keycloak")
async getSlip(@Path() creditNoteId: string, @Path() name: string) {
return await getFile(fileLocation.creditNote.slip(creditNoteId, name));
}
@Head("file-slip/{name}")
async headSlip(@Path() creditNoteId: string, @Path() name: string) {
return await getPresigned("head", fileLocation.creditNote.slip(creditNoteId, name));
}
@Put("file-slip/{name}")
@Security("keycloak")
async putSlip(
@Request() req: RequestWithUser,
@Path() creditNoteId: string,
@Path() name: string,
) {
await this.#checkPermission(req.user, creditNoteId);
return await setFile(fileLocation.creditNote.slip(creditNoteId, name));
}
@Delete("filel-slip/{name}")
@Security("keycloak")
async delSlip(
@Request() req: RequestWithUser,
@Path() creditNoteId: string,
@Path() name: string,
) {
await this.#checkPermission(req.user, creditNoteId);
return await deleteFile(fileLocation.creditNote.slip(creditNoteId, name));
}
}

View file

@ -113,6 +113,8 @@ export const fileLocation = {
attachment: (taskId: string, name?: string) => `task/attachment-${taskId}/${name || ""}`,
},
creditNote: {
attachment: (taskId: string, name?: string) => `credit-note/attachment-${taskId}/${name || ""}`,
slip: (creditNoteId: string, name?: string) => `credit-note/slip-${creditNoteId}/${name || ""}`,
attachment: (creditNoteId: string, name?: string) =>
`credit-note/attachment-${creditNoteId}/${name || ""}`,
},
};