refactor: move field
This commit is contained in:
parent
155bb19b9b
commit
6b6f9e9de0
1 changed files with 4 additions and 46 deletions
|
|
@ -26,19 +26,13 @@ if (!process.env.MINIO_BUCKET) {
|
|||
const MINIO_BUCKET = process.env.MINIO_BUCKET;
|
||||
|
||||
type BranchContactCreate = {
|
||||
lineId: string;
|
||||
telephoneNo: string;
|
||||
};
|
||||
|
||||
type BranchContactUpdate = {
|
||||
lineId?: string;
|
||||
telephoneNo?: string;
|
||||
};
|
||||
|
||||
function imageLocation(id: string) {
|
||||
return `branch/contact-${id}`;
|
||||
}
|
||||
|
||||
@Route("api/branch/{branchId}/contact")
|
||||
@Tags("Branch Contact")
|
||||
@Security("keycloak")
|
||||
|
|
@ -60,16 +54,7 @@ export class BranchContactController extends Controller {
|
|||
]);
|
||||
|
||||
return {
|
||||
result: await Promise.all(
|
||||
result.map(async (v) => ({
|
||||
...v,
|
||||
qrCodeImageUrl: await minio.presignedGetObject(
|
||||
MINIO_BUCKET,
|
||||
imageLocation(v.id),
|
||||
12 * 60 * 60,
|
||||
),
|
||||
})),
|
||||
),
|
||||
result,
|
||||
page,
|
||||
pageSize,
|
||||
total,
|
||||
|
|
@ -88,9 +73,7 @@ export class BranchContactController extends Controller {
|
|||
);
|
||||
}
|
||||
|
||||
return Object.assign(record, {
|
||||
qrCodeImageUrl: await minio.presignedGetObject(MINIO_BUCKET, imageLocation(record.id)),
|
||||
});
|
||||
return record;
|
||||
}
|
||||
|
||||
@Post()
|
||||
|
|
@ -112,18 +95,7 @@ export class BranchContactController extends Controller {
|
|||
|
||||
this.setStatus(HttpStatus.CREATED);
|
||||
|
||||
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,
|
||||
),
|
||||
});
|
||||
return record;
|
||||
}
|
||||
|
||||
@Put("{contactId}")
|
||||
|
|
@ -150,18 +122,7 @@ export class BranchContactController extends Controller {
|
|||
where: { id: contactId, branchId },
|
||||
});
|
||||
|
||||
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,
|
||||
),
|
||||
});
|
||||
return record;
|
||||
}
|
||||
|
||||
@Delete("{contactId}")
|
||||
|
|
@ -174,8 +135,5 @@ export class BranchContactController extends Controller {
|
|||
"data_not_found",
|
||||
);
|
||||
}
|
||||
await minio.removeObject(MINIO_BUCKET, imageLocation(contactId), {
|
||||
forceDelete: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue