-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduced Order and OrderItems structs to manage order-related data.
- Loading branch information
1 parent
630c612
commit f4af654
Showing
2 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package order | ||
|
||
import ( | ||
"Go_Food_Delivery/pkg/database/models/restaurant" | ||
userModel "Go_Food_Delivery/pkg/database/models/user" | ||
"Go_Food_Delivery/pkg/database/models/utils" | ||
"github.com/uptrace/bun" | ||
) | ||
|
||
type Order struct { | ||
bun.BaseModel `bun:"table:orders"` | ||
OrderID int64 `bun:",pk,autoincrement" json:"order_id"` | ||
UserID int64 `bun:"user_id,notnull" json:"user_id"` | ||
RestaurantID int64 `bun:"restaurant_id,notnull" json:"restaurant_id"` | ||
OrderStatus string `bun:"order_status,notnull" json:"order_status"` | ||
TotalAmount float64 `bun:"total_amount,notnull" json:"total_amount"` | ||
DeliveryAddress string `bun:"delivery_address,notnull" json:"delivery_address"` | ||
utils.Timestamp | ||
Restaurant *restaurant.Restaurant `bun:"rel:belongs-to,join:restaurant_id=restaurant_id"` | ||
User *userModel.User `bun:"rel:belongs-to,join:user_id=id"` | ||
} | ||
|
||
type OrderItems struct { | ||
bun.BaseModel `bun:"table:order_items"` | ||
OrderItemID int64 `bun:",pk,autoincrement" json:"order_item_id"` | ||
OrderID int64 `bun:"order_id,notnull" json:"order_id"` | ||
ItemID int64 `bun:"item_id,notnull" json:"item_id"` | ||
Quantity int64 `bun:"quantity,notnull" json:"quantity"` | ||
Price float64 `bun:"price,notnull" json:"price"` | ||
utils.Timestamp | ||
MenuItem *restaurant.MenuItem `bun:"rel:belongs-to,join:item_id=menu_id"` | ||
Order *Order `bun:"rel:belongs-to,join:order_id=order_id"` | ||
} |