feat: branch attachment
This commit is contained in:
parent
155962b996
commit
b9a616b9a9
2 changed files with 36 additions and 0 deletions
|
|
@ -674,4 +674,39 @@ export class BranchFileController extends Controller {
|
|||
await this.checkPermission(req.user, branchId);
|
||||
return await deleteFile(fileLocation.branch.line(branchId));
|
||||
}
|
||||
|
||||
@Get("attachment")
|
||||
@Security("keycloak")
|
||||
async listAttachment(@Request() req: RequestWithUser, @Path() branchId: string) {
|
||||
await this.checkPermission(req.user, branchId);
|
||||
return await listFile(fileLocation.branch.attachment(branchId));
|
||||
}
|
||||
|
||||
@Get("attachment/{name}")
|
||||
@Security("keycloak")
|
||||
async getAttachment(@Path() branchId: string, @Path() name: string) {
|
||||
return await getFile(fileLocation.branch.attachment(branchId, name));
|
||||
}
|
||||
|
||||
@Put("attachment/{name}")
|
||||
@Security("keycloak")
|
||||
async putAttachment(
|
||||
@Request() req: RequestWithUser,
|
||||
@Path() branchId: string,
|
||||
@Path() name: string,
|
||||
) {
|
||||
await this.checkPermission(req.user, branchId);
|
||||
return req.res?.redirect(await setFile(fileLocation.branch.attachment(branchId, name)));
|
||||
}
|
||||
|
||||
@Delete("attachment/{name}")
|
||||
@Security("keycloak")
|
||||
async delAttachment(
|
||||
@Request() req: RequestWithUser,
|
||||
@Path() branchId: string,
|
||||
@Path() name: string,
|
||||
) {
|
||||
await this.checkPermission(req.user, branchId);
|
||||
return await deleteFile(fileLocation.branch.attachment(branchId, name));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ export const fileLocation = {
|
|||
line: (branchId: string) => `branch/line-qr-${branchId}`,
|
||||
bank: (branchId: string, bankId: string) => `branch/bank-qr-${branchId}-${bankId}`,
|
||||
img: (branchId: string, name?: string) => `branch/img-${branchId}/${name || ""}`,
|
||||
attachment: (branchId: string, name?: string) => `branch/attachment-${branchId}/${name || ""}`,
|
||||
},
|
||||
user: {
|
||||
profile: (userId: string, name?: string) => `user/profile-image-${userId}/${name || ""}`,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue