-
Notifications
You must be signed in to change notification settings - Fork 0
/
pet.transport.go
34 lines (27 loc) · 1.15 KB
/
pet.transport.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package apiV1
import (
"github.com/2110366-2566-2/tortoise-app-backend/internal/database"
"github.com/2110366-2566-2/tortoise-app-backend/internal/services"
"github.com/2110366-2566-2/tortoise-app-backend/internal/storage"
"github.com/gin-gonic/gin"
)
func PetController(r *gin.RouterGroup, db *database.Handler, stg *storage.Handler) {
// Create a new pet handler
petHandler := services.NewPetHandler(db, stg)
allUser := r.Group("/")
allUser.Use(roleMiddleware("seller", "admin", "buyer"))
sellerAdmin := r.Group("/")
sellerAdmin.Use(roleMiddleware("seller", "admin"))
// Set up routes
// allUser.GET("/old", petHandler.GetAllPets)
allUser.GET("/", petHandler.GetFilteredPets)
allUser.GET("/pet/:petID", petHandler.GetPetByPetID)
allUser.GET("/seller/:userID", petHandler.GetPetBySeller)
sellerAdmin.POST("/seller/:userID", petHandler.CreatePet)
sellerAdmin.PUT("/pet/:petID", petHandler.UpdatePet)
sellerAdmin.DELETE("/pet/:petID", petHandler.DeletePet)
// master data
allUser.GET("/master", petHandler.GetMasterData)
allUser.GET("/master/:category", petHandler.GetMasterDataByCategory)
allUser.GET("/master/categories", petHandler.GetCategories)
}