refactor: move field lineId contact field
This commit is contained in:
parent
ddb2155c44
commit
155bb19b9b
1 changed files with 34 additions and 2 deletions
|
|
@ -36,6 +36,7 @@ type BranchCreate = {
|
|||
zipCode: string;
|
||||
email: string;
|
||||
telephoneNo: string;
|
||||
lineId: string;
|
||||
longitude: string;
|
||||
latitude: string;
|
||||
|
||||
|
|
@ -55,6 +56,7 @@ type BranchUpdate = {
|
|||
zipCode?: string;
|
||||
email?: string;
|
||||
telephoneNo?: string;
|
||||
lineId?: string;
|
||||
longitude?: string;
|
||||
latitude?: string;
|
||||
|
||||
|
|
@ -64,6 +66,10 @@ type BranchUpdate = {
|
|||
headOfficeId?: string | null;
|
||||
};
|
||||
|
||||
function lineImageLoc(id: string) {
|
||||
return `branch/line-qr-${id}`;
|
||||
}
|
||||
|
||||
@Route("api/branch")
|
||||
@Tags("Branch")
|
||||
@Security("keycloak")
|
||||
|
|
@ -273,7 +279,18 @@ export class BranchController extends Controller {
|
|||
|
||||
this.setStatus(HttpStatus.CREATED);
|
||||
|
||||
return record;
|
||||
return Object.assign(record, {
|
||||
qrCodeImageUrl: await minio.presignedGetObject(
|
||||
MINIO_BUCKET,
|
||||
lineImageLoc(record.id),
|
||||
12 * 60 * 60,
|
||||
),
|
||||
qrCodeImageUploadUrl: await minio.presignedPutObject(
|
||||
MINIO_BUCKET,
|
||||
lineImageLoc(record.id),
|
||||
12 * 60 * 60,
|
||||
),
|
||||
});
|
||||
}
|
||||
|
||||
@Put("{branchId}")
|
||||
|
|
@ -354,7 +371,18 @@ export class BranchController extends Controller {
|
|||
where: { id: branchId },
|
||||
});
|
||||
|
||||
return record;
|
||||
return Object.assign(record, {
|
||||
qrCodeImageUrl: await minio.presignedGetObject(
|
||||
MINIO_BUCKET,
|
||||
lineImageLoc(record.id),
|
||||
12 * 60 * 60,
|
||||
),
|
||||
qrCodeImageUploadUrl: await minio.presignedPutObject(
|
||||
MINIO_BUCKET,
|
||||
lineImageLoc(record.id),
|
||||
12 * 60 * 60,
|
||||
),
|
||||
});
|
||||
}
|
||||
|
||||
@Delete("{branchId}")
|
||||
|
|
@ -376,6 +404,10 @@ export class BranchController extends Controller {
|
|||
throw new HttpError(HttpStatus.FORBIDDEN, "Branch is in used.", "data_in_used");
|
||||
}
|
||||
|
||||
await minio.removeObject(MINIO_BUCKET, lineImageLoc(branchId), {
|
||||
forceDelete: true,
|
||||
});
|
||||
|
||||
return await prisma.branch.delete({
|
||||
include: {
|
||||
province: true,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue