Skip to content
Snippets Groups Projects
Commit 2677a48b authored by Fikri Naufal Hamdi's avatar Fikri Naufal Hamdi
Browse files

feat: add image column in tenant table

parent e59dfeca
Branches
Tags
4 merge requests!50feat: merge with master,!43feat(UC04): merge with develop,!34feat: merge to add api for getting order_product by id_order,!21feat: add image column in tenant table
...@@ -13,6 +13,7 @@ class TenantController { ...@@ -13,6 +13,7 @@ class TenantController {
new_tenant.open_hour = req.body.open_hour; new_tenant.open_hour = req.body.open_hour;
new_tenant.description = req.body.description; new_tenant.description = req.body.description;
new_tenant.rating = req.body.rating; new_tenant.rating = req.body.rating;
new_tenant.image = req.body.image;
await new TenantsRepo().createTenant(new_tenant); await new TenantsRepo().createTenant(new_tenant);
...@@ -21,6 +22,7 @@ class TenantController { ...@@ -21,6 +22,7 @@ class TenantController {
message: "Successfully created tenant!", message: "Successfully created tenant!",
}); });
} catch (err) { } catch (err) {
console.log(err);
res.status(500).json({ res.status(500).json({
status: "Internal Server Error!", status: "Internal Server Error!",
message: "Internal Server Error!", message: "Internal Server Error!",
...@@ -73,6 +75,7 @@ class TenantController { ...@@ -73,6 +75,7 @@ class TenantController {
data: tenants, data: tenants,
}); });
} catch (err) { } catch (err) {
console.log(err);
res.status(500).json({ res.status(500).json({
status: "Internal Server Error!", status: "Internal Server Error!",
message: "Internal Server Error!", message: "Internal Server Error!",
...@@ -91,6 +94,7 @@ class TenantController { ...@@ -91,6 +94,7 @@ class TenantController {
tenant.open_hour = req.body.open_hour; tenant.open_hour = req.body.open_hour;
tenant.description = req.body.description; tenant.description = req.body.description;
tenant.rating = req.body.rating; tenant.rating = req.body.rating;
tenant.image = req.body.image;
await new TenantsRepo().updateTenant(tenant); await new TenantsRepo().updateTenant(tenant);
......
...@@ -52,6 +52,12 @@ export class Tenants extends Model { ...@@ -52,6 +52,12 @@ export class Tenants extends Model {
}) })
rating!: number | null; rating!: number | null;
@Column({
type: DataType.STRING(255),
field: "image",
})
image!: number | null;
@ForeignKey(() => Users) @ForeignKey(() => Users)
@BelongsTo(() => Users, "id") @BelongsTo(() => Users, "id")
user!: Users; user!: Users;
......
...@@ -40,6 +40,7 @@ export default class TenantRepo implements ITenantRepo { ...@@ -40,6 +40,7 @@ export default class TenantRepo implements ITenantRepo {
open_hour: tenant.open_hour, open_hour: tenant.open_hour,
description: tenant.description, description: tenant.description,
rating: tenant.rating, rating: tenant.rating,
image: tenant.image,
}); });
} catch (error: any) { } catch (error: any) {
throw new Error(`Error while creating tenant: ${error.message}`); throw new Error(`Error while creating tenant: ${error.message}`);
...@@ -60,6 +61,7 @@ export default class TenantRepo implements ITenantRepo { ...@@ -60,6 +61,7 @@ export default class TenantRepo implements ITenantRepo {
existingTenant.open_hour = tenant.open_hour; existingTenant.open_hour = tenant.open_hour;
existingTenant.description = tenant.description; existingTenant.description = tenant.description;
existingTenant.rating = tenant.rating; existingTenant.rating = tenant.rating;
existingTenant.image = tenant.image;
await existingTenant.save(); await existingTenant.save();
} catch (error: any) { } catch (error: any) {
......
...@@ -11,6 +11,7 @@ export const createTenantSchema = z.object({ ...@@ -11,6 +11,7 @@ export const createTenantSchema = z.object({
open_hour: z.string().nullable(), open_hour: z.string().nullable(),
description: z.string().nullable(), description: z.string().nullable(),
rating: z.number().nullable(), rating: z.number().nullable(),
image: z.string().nullable(),
}), }),
}); });
...@@ -25,6 +26,7 @@ export const updateTenantSchema = z.object({ ...@@ -25,6 +26,7 @@ export const updateTenantSchema = z.object({
open_hour: z.string().nullable(), open_hour: z.string().nullable(),
description: z.string().nullable(), description: z.string().nullable(),
rating: z.number().nullable(), rating: z.number().nullable(),
image: z.string().nullable(),
}) })
.partial(), .partial(),
}); });
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment