feat: edit branch endpoint
This commit is contained in:
parent
e58141b864
commit
63de7b3e52
1 changed files with 29 additions and 0 deletions
|
|
@ -70,6 +70,35 @@ export class BranchContactController extends Controller {
|
|||
});
|
||||
}
|
||||
|
||||
@Patch("{contactId}")
|
||||
async editBranchContact(
|
||||
@Request() req: RequestWithUser,
|
||||
@Body() body: BranchContactUpdate,
|
||||
@Path() branchId: string,
|
||||
@Path() contactId: string,
|
||||
) {
|
||||
const record = await prisma.branchContact.update({
|
||||
include: { branch: true },
|
||||
data: { ...body, updateBy: req.user.name },
|
||||
where: { id: contactId, branchId },
|
||||
});
|
||||
if (!record) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "Branch cannot be found.");
|
||||
}
|
||||
return Object.assign(record, {
|
||||
qrCodeImageUrl: await minio.presignedGetObject(
|
||||
MINIO_BUCKET,
|
||||
imageLocation(record.id),
|
||||
12 * 60 * 60,
|
||||
),
|
||||
qrCodeImageUploadUrl: await minio.presignedPutObject(
|
||||
MINIO_BUCKET,
|
||||
imageLocation(record.id),
|
||||
12 * 60 * 60,
|
||||
),
|
||||
});
|
||||
}
|
||||
|
||||
@Delete("{contactId}")
|
||||
async deleteBranchContact(@Path() branchId: string, @Path() contactId: string) {
|
||||
const result = await prisma.branchContact.deleteMany({ where: { id: contactId, branchId } });
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue