fix: error when update record not found
This commit is contained in:
parent
208aa77efd
commit
cb5d7ae208
1 changed files with 4 additions and 4 deletions
|
|
@ -134,6 +134,10 @@ export class CustomerController extends Controller {
|
||||||
@Request() req: RequestWithUser,
|
@Request() req: RequestWithUser,
|
||||||
@Body() body: CustomerUpdate,
|
@Body() body: CustomerUpdate,
|
||||||
) {
|
) {
|
||||||
|
if (!(await prisma.customer.findUnique({ where: { id: customerId } }))) {
|
||||||
|
throw new HttpError(HttpStatus.NOT_FOUND, "Customer cannot be found.", "data_not_found");
|
||||||
|
}
|
||||||
|
|
||||||
const record = await prisma.customer.update({
|
const record = await prisma.customer.update({
|
||||||
where: { id: customerId },
|
where: { id: customerId },
|
||||||
data: {
|
data: {
|
||||||
|
|
@ -143,10 +147,6 @@ export class CustomerController extends Controller {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!record) {
|
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "Customer cannot be found.");
|
|
||||||
}
|
|
||||||
|
|
||||||
return Object.assign(record, {
|
return Object.assign(record, {
|
||||||
imageUrl: await minio.presignedGetObject(
|
imageUrl: await minio.presignedGetObject(
|
||||||
MINIO_BUCKET,
|
MINIO_BUCKET,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue