Skip to content

Commit

Permalink
Merge pull request Capstone-Mikti#40 from Capstone-Mikti/reza
Browse files Browse the repository at this point in the history
Update postman
  • Loading branch information
rezapace authored Dec 1, 2023
2 parents ea1a475 + 3ecc2f4 commit 8b08ff5
Show file tree
Hide file tree
Showing 5 changed files with 3,334 additions and 1,178 deletions.
5 changes: 5 additions & 0 deletions %USERPROFILE%/go/bin/pkg/sumdb/sum.golang.org/latest
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
go.sum database tree
20857462
Kn0F1e8O8fQOl6YvfyegETTq1tmu1qpkfDZj5AtvhWI=

— sum.golang.org Az3gru8zyaj7EuaczqV+hDOTF+63AeV8mvhZHqRv6bbiV3gaYIvN9DnNHoSzVwNBCGSXS7qp50Ui6l9wNpxiJmNpwAc=
16 changes: 14 additions & 2 deletions internal/builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,26 @@ import (
func BuildPublicRoutes(cfg *config.Config, db *gorm.DB) []*router.Route {
registrationRepository := repository.NewRegistrationRepository(db)
registrationService := service.NewRegistrationService(registrationRepository)
userRepository := repository.NewUserRepository(db) // kenapa make ini? karena nge find email nya dari user_repository

userRepository := repository.NewUserRepository(db)
loginService := service.NewLoginService(userRepository)
tokenService := service.NewTokenService(cfg)

BlogRepository := repository.NewBlogRepository(db)
BlogService := service.NewBlogService(BlogRepository)
BlogHandler := handler.NewBlogHandler(BlogService)

ticketRepository := repository.NewTicketRepository(db)
ticketService := service.NewTicketService(ticketRepository)
ticketHandler := handler.NewTicketHandler(ticketService)

authHandler := handler.NewAuthHandler(registrationService, loginService, tokenService)

return router.PublicRoutes(authHandler)
// Update the line below with the additional TicketHandler argument
return router.PublicRoutes(authHandler, ticketHandler, BlogHandler) // Update this line
}


func BuildPrivateRoutes(cfg *config.Config, db *gorm.DB) []*router.Route {
// Create a user handler
userRepository := repository.NewUserRepository(db)
Expand Down
175 changes: 86 additions & 89 deletions internal/http/router/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ type Route struct {

// membuat fungsi untuk mengembalikan route
// pada func ini perlu login krna private
func PublicRoutes(authHandler *handler.AuthHandler) []*Route {
func PublicRoutes(
authHandler *handler.AuthHandler,
TicketHandler *handler.TicketHandler,
BlogHandler *handler.BlogHandler) []*Route {
return []*Route{
{
Method: echo.POST,
Expand All @@ -39,6 +42,85 @@ func PublicRoutes(authHandler *handler.AuthHandler) []*Route {
Path: "/register",
Handler: authHandler.Registration,
},
{
Method: echo.GET,
Path: "/public/blog",
Handler: BlogHandler.GetAllBlogs,
},
{
Method: echo.GET,
Path: "/public/ticket",
Handler: TicketHandler.GetAllTickets,
},
{
Method: echo.GET,
Path: "/blog",
Handler: BlogHandler.GetAllBlogs,
},
{
Method: echo.GET,
Path: "/blog/:id",
Handler: BlogHandler.GetBlog,
},
{
Method: echo.GET,
Path: "/blog/search/:search",
Handler: BlogHandler.SearchBlog,
},
//filter ticket by location
{
Method: echo.GET,
Path: "/ticket/location/:location",
Handler: TicketHandler.FilterTicket,
},
// filter ticket by category
{
Method: echo.GET,
Path: "/ticket/category/:category",
Handler: TicketHandler.FilterTicketByCategory,
},
// filter ticket by range time (start - end)
{
Method: echo.GET,
Path: "/ticket/range/:start/:end",
Handler: TicketHandler.FilterTicketByRangeTime,
},
// filter ticket by price (min - max)
{
Method: echo.GET,
Path: "/ticket/price/:min/:max",
Handler: TicketHandler.FilterTicketByPrice,
},
//sortir tiket dari yang terbaru
{
Method: echo.GET,
Path: "/ticket/terbaru",
Handler: TicketHandler.SortTicketByNewest,
},
//sortir tiket dari yang termahal
{
Method: echo.GET,
Path: "/ticket/most-expensive",
Handler: TicketHandler.SortTicketByMostExpensive,
},
//sortir tiket dari yang termurah
{
Method: echo.GET,
Path: "/ticket/cheapest",
Handler: TicketHandler.SortTicketByCheapest,
},
// filter ticket by most bought
{
Method: echo.GET,
Path: "/ticket/most-bought",
Handler: TicketHandler.SortTicketByMostBought,
},
// ticket yang masih tersedia
{
Method: echo.GET,
Path: "/ticket/available",
Handler: TicketHandler.SortTicketByAvailable,
},
}
}

Expand Down Expand Up @@ -102,9 +184,9 @@ func PrivateRoutes(

{
Method: echo.GET,
Path: "/ticket",
Path: "/ticketa",
Handler: TicketHandler.GetAllTickets,
Role: allRoles,
Role: onlyAdmin,
},

{
Expand Down Expand Up @@ -149,41 +231,20 @@ func PrivateRoutes(
Role: onlyAdmin,
},

{
Method: echo.GET,
Path: "/blog",
Handler: BlogHandler.GetAllBlogs,
Role: allRoles,
},

{
Method: echo.PUT,
Path: "/blog/:id",
Handler: BlogHandler.UpdateBlog,
Role: onlyAdmin,
},

{
Method: echo.GET,
Path: "/blog/:id",
Handler: BlogHandler.GetBlog,
Role: allRoles,
},

{
Method: echo.DELETE,
Path: "/blog/:id",
Handler: BlogHandler.DeleteBlog,
Role: onlyAdmin,
},

{
Method: echo.GET,
Path: "/blog/search/:search",
Handler: BlogHandler.SearchBlog,
Role: allRoles,
},

{
Method: echo.POST,
Path: "/order",
Expand All @@ -195,7 +256,7 @@ func PrivateRoutes(
Method: echo.GET,
Path: "/order",
Handler: OrderHandler.GetAllOrders,
Role: allRoles,
Role: onlyAdmin,
},

{
Expand All @@ -205,70 +266,6 @@ func PrivateRoutes(
Role: allRoles,
},

//filter ticket by location
{
Method: echo.GET,
Path: "/ticket/location/:location",
Handler: TicketHandler.FilterTicket,
Role: allRoles,
},
// filter ticket by category
{
Method: echo.GET,
Path: "/ticket/category/:category",
Handler: TicketHandler.FilterTicketByCategory,
Role: allRoles,
},
// filter ticket by range time (start - end)
{
Method: echo.GET,
Path: "/ticket/range/:start/:end",
Handler: TicketHandler.FilterTicketByRangeTime,
Role: allRoles,
},
// filter ticket by price (min - max)
{
Method: echo.GET,
Path: "/ticket/price/:min/:max",
Handler: TicketHandler.FilterTicketByPrice,
Role: allRoles,
},
//sortir tiket dari yang terbaru
{
Method: echo.GET,
Path: "/ticket/terbaru",
Handler: TicketHandler.SortTicketByNewest,
Role: allRoles,
},
//sortir tiket dari yang termahal
{
Method: echo.GET,
Path: "/ticket/most-expensive",
Handler: TicketHandler.SortTicketByMostExpensive,
Role: allRoles,
},
//sortir tiket dari yang termurah
{
Method: echo.GET,
Path: "/ticket/cheapest",
Handler: TicketHandler.SortTicketByCheapest,
Role: allRoles,
},
// filter ticket by most bought
{
Method: echo.GET,
Path: "/ticket/most-bought",
Handler: TicketHandler.SortTicketByMostBought,
Role: allRoles,
},
// ticket yang masih tersedia
{
Method: echo.GET,
Path: "/ticket/available",
Handler: TicketHandler.SortTicketByAvailable,
Role: allRoles,
},

// create notification
{
Method: echo.POST,
Expand Down
Loading

0 comments on commit 8b08ff5

Please sign in to comment.