-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add endpoint to list restaurant by ID
Added a new method `listRestaurantById` in the handler, which retrieves a restaurant by its ID. Included the corresponding route in `routes.go` and implemented the `ListRestaurantById` method in the service layer. Updated the restaurant interface to include this new method.
- Loading branch information
1 parent
185f78d
commit a712021
Showing
4 changed files
with
32 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
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,16 @@ | ||
package restaurant | ||
|
||
import ( | ||
"Go_Food_Delivery/pkg/database/models/restaurant" | ||
"context" | ||
) | ||
|
||
func (restSrv *RestaurantService) ListRestaurantById(ctx context.Context, restaurantId int64) (restaurant.Restaurant, error) { | ||
var restro restaurant.Restaurant | ||
|
||
err := restSrv.db.Select(ctx, &restro, "restaurant_id", restaurantId) | ||
if err != nil { | ||
return restaurant.Restaurant{}, err | ||
} | ||
return restro, nil | ||
} |