feat: create branch contact endpoint
This commit is contained in:
parent
aa182a314e
commit
5aded1d215
1 changed files with 26 additions and 0 deletions
|
|
@ -29,4 +29,30 @@ const MINIO_BUCKET = process.env.MINIO_BUCKET;
|
||||||
@Tags("Branch Contact")
|
@Tags("Branch Contact")
|
||||||
@Security("keycloak")
|
@Security("keycloak")
|
||||||
export class BranchContactController extends Controller {
|
export class BranchContactController extends Controller {
|
||||||
|
@Post()
|
||||||
|
async createBranchContact(
|
||||||
|
@Request() req: RequestWithUser,
|
||||||
|
@Path() branchId: string,
|
||||||
|
@Body() body: BranchContactCreate,
|
||||||
|
) {
|
||||||
|
if (!(await prisma.branch.findFirst({ where: { id: branchId } }))) {
|
||||||
|
throw new HttpError(HttpStatus.BAD_REQUEST, "Branch not found.");
|
||||||
|
}
|
||||||
|
const record = await prisma.branchContact.create({
|
||||||
|
include: { branch: true },
|
||||||
|
data: { ...body, branchId, createdBy: req.user.name, updateBy: req.user.name },
|
||||||
|
});
|
||||||
|
return Object.assign(record, {
|
||||||
|
qrCodeImageUrl: await minio.presignedGetObject(
|
||||||
|
MINIO_BUCKET,
|
||||||
|
`branch/contact-${record.id}`,
|
||||||
|
12 * 60 * 60,
|
||||||
|
),
|
||||||
|
qrCodeImageUploadUrl: await minio.presignedPutObject(
|
||||||
|
MINIO_BUCKET,
|
||||||
|
`branch/contact-${record.id}`,
|
||||||
|
12 * 60 * 60,
|
||||||
|
),
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue