package router import ( "app/handlers" "app/middlewares" login "app/services" "github.com/labstack/echo/v4" ) func UserRoutes(e *echo.Echo) { users := e.Group("/users") users.POST("/", handlers.RegisterUser) users.GET("/usernames/:name", handlers.GetSameUserNames) users.GET("/:id", handlers.GetUserByID) users.PUT("/username/:id", handlers.UpdateUserName) users.PUT("/email/:id", handlers.UpdateEmail) users.PUT("/password/:id", handlers.UpdatePassword) users.PUT("/role/:id", handlers.UpdateRole) users.PUT("/nationalcode/:id", handlers.UpdateNationalCode) users.PUT("/birthday/:id", handlers.UpdateBirthDay) users.PUT("/firstname/:id", handlers.UpdateFirstName) users.PUT("/lastname/:id", handlers.UpdateLastName) users.PUT("/postcode/:id", handlers.UpdatePostCode) users.DELETE("/:id", handlers.DeleteUser) } // create new user ===> post : users/ // get user by id ===> get : users/23 // get users by name ===> get : users/nima // update username ===> put : users/username send json // update email ===> put : users/email send json // update password ===> put : users/password send json // update role ===> put : users/role send json // update nationalCode ===> put : users/nationalcode send json // update birthday ===> put : users/birthday send json // update firstname ===> put : users/firstname send json // update lastname ===> put : users/lastname send json // update postcode ===> put : users/postcode send json // delete user ===> delete : users/23 func ProductRoutes(e *echo.Echo) { products := e.Group("/products") products.POST("/", handlers.CreateProduct) products.GET("/:name", handlers.GetProductByName) products.GET("/:id", handlers.GetProductByID) products.GET("/category/:name", handlers.GetProductByCategory) products.PUT("/productname/:id", handlers.UpdateProductName) products.PUT("/description/:id", handlers.UpdateDescription) products.PUT("/warranty/:id", handlers.UpdateWarranty) products.PUT("/quantity/:id", handlers.UpdateQuantity) products.PUT("/category/:id", handlers.UpdateCategory) products.PUT("/price/:id", handlers.UpdatePrice) products.DELETE("/:id", handlers.DeleteProduct) } func OrderRoutes(e *echo.Echo) { orders := e.Group("/orders") //orders.POST("/", handlers.CreateOrder) orders.GET("/:id", handlers.GetUserOrders) orders.DELETE("/:id", handlers.DeleteOrder) } func AddressRoutes(e *echo.Echo) { address := e.Group("/address") address.POST("/", handlers.CreateAddress) address.GET("/:id", handlers.GetUserAddresses) address.PUT("/:id", handlers.UpdateAddress) address.DELETE("/:id", handlers.DeleteAddress) } func CommentRoutes(e *echo.Echo) { comments := e.Group("/comments") comments.POST("/", handlers.CreateComment) comments.GET("/user/:id", handlers.GetUserComments) comments.GET("/product/:id", handlers.GetProductComments) comments.PUT("/:id", handlers.UpdateComment) comments.DELETE("/:id", handlers.DeleteComment) } func SpecsRoutes(e *echo.Echo) { specs := e.Group("/specs") specs.POST("/", handlers.CreateSpecs) specs.GET("/:id", handlers.GetSpecs) specs.PUT("/type/:id", handlers.UpdateType) specs.PUT("/value/:id", handlers.UpdateValue) specs.DELETE("/:id", handlers.DeleteSpecs) } func PhoneRoutes(e *echo.Echo) { phones := e.Group("/phones") //phones.POST("/", handlers.CreatePhone) phones.GET("/:id", handlers.GetUserPhoneNumbers) phones.PUT("/phonenumber/:id", handlers.UpdatePhoneNumber) phones.PUT("/cellphonenumber/:id", handlers.UpdateCellPhoneNumber) phones.DELETE("/:id", handlers.DeletePhone) } func WishlistRoutes(e *echo.Echo) { wishlist := e.Group("/wishlist") wishlist.POST("/", handlers.CreateWishlist) wishlist.GET("/:id", handlers.GetWishlist) wishlist.DELETE("/:id", handlers.DeleteWishlist) } func CartRoutes(e *echo.Echo) { cart := e.Group("/cart") cart.POST("/", handlers.Create_cart_item) cart.GET("/:id", handlers.GetCartItems) cart.PUT("/:id", handlers.UpdateItemStatus) cart.DELETE("/:id", handlers.Remove_cart_item) } func LoginLogout(e *echo.Echo) { e.POST("/login", login.LoginByEmail) e.GET("/logout", login.Logout) e.GET("/test", login.Test) admin := e.Group("/admin") admin.Use(middlewares.AdminOnly()) }