Skip to content

Commit

Permalink
update tiket roles
Browse files Browse the repository at this point in the history
  • Loading branch information
rezapace committed Dec 1, 2023
1 parent cecc924 commit 10d5b07
Showing 1 changed file with 74 additions and 87 deletions.
161 changes: 74 additions & 87 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, TicketHandler *handler.TicketHandler, BlogHandler *handler.BlogHandler) []*Route {
func PublicRoutes(
authHandler *handler.AuthHandler,
TicketHandler *handler.TicketHandler,
BlogHandler *handler.BlogHandler) []*Route {
return []*Route{
{
Method: echo.POST,
Expand All @@ -49,6 +52,75 @@ func PublicRoutes(authHandler *handler.AuthHandler, TicketHandler *handler.Ticke
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 @@ -159,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 @@ -205,7 +256,7 @@ func PrivateRoutes(
Method: echo.GET,
Path: "/order",
Handler: OrderHandler.GetAllOrders,
Role: allRoles,
Role: onlyAdmin,
},

{
Expand All @@ -215,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

0 comments on commit 10d5b07

Please sign in to comment.