From 10d5b07eff975816f8a76bb6d3ec7fc7227214f6 Mon Sep 17 00:00:00 2001 From: Reza Hidayat Date: Sat, 2 Dec 2023 05:47:23 +0700 Subject: [PATCH] update tiket roles --- internal/http/router/routes.go | 161 +++++++++++++++------------------ 1 file changed, 74 insertions(+), 87 deletions(-) diff --git a/internal/http/router/routes.go b/internal/http/router/routes.go index f35787b..d66946c 100644 --- a/internal/http/router/routes.go +++ b/internal/http/router/routes.go @@ -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, @@ -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, + }, } } @@ -159,13 +231,6 @@ func PrivateRoutes( Role: onlyAdmin, }, - { - Method: echo.GET, - Path: "/blog", - Handler: BlogHandler.GetAllBlogs, - Role: allRoles, - }, - { Method: echo.PUT, Path: "/blog/:id", @@ -173,13 +238,6 @@ func PrivateRoutes( Role: onlyAdmin, }, - { - Method: echo.GET, - Path: "/blog/:id", - Handler: BlogHandler.GetBlog, - Role: allRoles, - }, - { Method: echo.DELETE, Path: "/blog/:id", @@ -187,13 +245,6 @@ func PrivateRoutes( Role: onlyAdmin, }, - { - Method: echo.GET, - Path: "/blog/search/:search", - Handler: BlogHandler.SearchBlog, - Role: allRoles, - }, - { Method: echo.POST, Path: "/order", @@ -205,7 +256,7 @@ func PrivateRoutes( Method: echo.GET, Path: "/order", Handler: OrderHandler.GetAllOrders, - Role: allRoles, + Role: onlyAdmin, }, { @@ -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,