generated from PenaSide/GolangTemplate
update naming controllers
This commit is contained in:
parent
cf4cfc884e
commit
b43aad5209
@ -39,7 +39,7 @@ func NewAccountController(deps Deps) *AccountController {
|
||||
}
|
||||
}
|
||||
|
||||
func (receiver *AccountController) DeleteAccount(ctx *fiber.Ctx) error {
|
||||
func (receiver *AccountController) Delete(ctx *fiber.Ctx) error {
|
||||
userID, ok := receiver.middleWare.ExtractUserID(ctx)
|
||||
if !ok || userID == "" {
|
||||
return receiver.middleWare.NoAuth(ctx)
|
||||
@ -53,7 +53,7 @@ func (receiver *AccountController) DeleteAccount(ctx *fiber.Ctx) error {
|
||||
return ctx.Status(fiber.StatusOK).JSON(account)
|
||||
}
|
||||
|
||||
func (receiver *AccountController) ChangeAccount(ctx *fiber.Ctx) error {
|
||||
func (receiver *AccountController) Update(ctx *fiber.Ctx) error {
|
||||
userID, ok := receiver.middleWare.ExtractUserID(ctx)
|
||||
if !ok || userID == "" {
|
||||
return receiver.middleWare.NoAuth(ctx)
|
||||
@ -72,7 +72,7 @@ func (receiver *AccountController) ChangeAccount(ctx *fiber.Ctx) error {
|
||||
return ctx.Status(fiber.StatusOK).JSON(account)
|
||||
}
|
||||
|
||||
func (receiver *AccountController) SetAccountVerificationStatus(ctx *fiber.Ctx) error {
|
||||
func (receiver *AccountController) SetVerificationStatus(ctx *fiber.Ctx) error {
|
||||
userID := ctx.Params("userId")
|
||||
if userID == "" {
|
||||
return receiver.middleWare.Error(ctx, fiber.StatusBadRequest, "invalid format for parameter userId")
|
||||
@ -92,7 +92,7 @@ func (receiver *AccountController) SetAccountVerificationStatus(ctx *fiber.Ctx)
|
||||
return ctx.Status(fiber.StatusOK).JSON(account)
|
||||
}
|
||||
|
||||
func (receiver *AccountController) GetAccount(ctx *fiber.Ctx) error {
|
||||
func (receiver *AccountController) Get(ctx *fiber.Ctx) error {
|
||||
userID, ok := receiver.middleWare.ExtractUserID(ctx)
|
||||
if !ok || userID == "" {
|
||||
return receiver.middleWare.NoAuth(ctx)
|
||||
@ -106,7 +106,7 @@ func (receiver *AccountController) GetAccount(ctx *fiber.Ctx) error {
|
||||
return ctx.Status(fiber.StatusOK).JSON(account)
|
||||
}
|
||||
|
||||
func (receiver *AccountController) AddAccount(ctx *fiber.Ctx) error {
|
||||
func (receiver *AccountController) Create(ctx *fiber.Ctx) error {
|
||||
userID, ok := receiver.middleWare.ExtractUserID(ctx)
|
||||
if !ok || userID == "" {
|
||||
return receiver.middleWare.NoAuth(ctx)
|
||||
@ -146,7 +146,7 @@ func (receiver *AccountController) AddAccount(ctx *fiber.Ctx) error {
|
||||
return ctx.Status(fiber.StatusOK).JSON(account)
|
||||
}
|
||||
|
||||
func (receiver *AccountController) DeleteDirectAccount(ctx *fiber.Ctx) error {
|
||||
func (receiver *AccountController) DeleteCurrent(ctx *fiber.Ctx) error {
|
||||
userID := ctx.Params("userId")
|
||||
if userID == "" {
|
||||
return receiver.middleWare.Error(ctx, fiber.StatusBadRequest, "invalid format for parameter userId")
|
||||
@ -160,7 +160,7 @@ func (receiver *AccountController) DeleteDirectAccount(ctx *fiber.Ctx) error {
|
||||
return ctx.Status(fiber.StatusOK).JSON(account)
|
||||
}
|
||||
|
||||
func (receiver *AccountController) GetDirectAccount(ctx *fiber.Ctx) error {
|
||||
func (receiver *AccountController) GetCurrent(ctx *fiber.Ctx) error {
|
||||
userID := ctx.Params("userId")
|
||||
if userID == "" {
|
||||
return receiver.middleWare.Error(ctx, fiber.StatusBadRequest, "invalid format for parameter userId")
|
||||
@ -174,7 +174,7 @@ func (receiver *AccountController) GetDirectAccount(ctx *fiber.Ctx) error {
|
||||
return ctx.Status(fiber.StatusOK).JSON(account)
|
||||
}
|
||||
|
||||
func (receiver *AccountController) PaginationAccounts(ctx *fiber.Ctx) error {
|
||||
func (receiver *AccountController) Pagination(ctx *fiber.Ctx) error {
|
||||
pageStr := ctx.Query("page", "1")
|
||||
limitStr := ctx.Query("limit", "100")
|
||||
|
||||
|
@ -3,14 +3,14 @@ package account
|
||||
import "github.com/gofiber/fiber/v2"
|
||||
|
||||
func (receiver *AccountController) Register(router fiber.Router) {
|
||||
router.Delete("/account", receiver.DeleteAccount)
|
||||
router.Get("/account", receiver.GetAccount)
|
||||
router.Patch("/account", receiver.ChangeAccount)
|
||||
router.Post("/account", receiver.AddAccount)
|
||||
router.Delete("/account/:userId", receiver.DeleteDirectAccount)
|
||||
router.Get("/account/:userId", receiver.GetDirectAccount)
|
||||
router.Patch("/account/:userId", receiver.SetAccountVerificationStatus)
|
||||
router.Get("/accounts", receiver.PaginationAccounts)
|
||||
router.Delete("/account", receiver.Delete)
|
||||
router.Get("/account", receiver.Get)
|
||||
router.Patch("/account", receiver.Update)
|
||||
router.Post("/account", receiver.Create)
|
||||
router.Delete("/account/:userId", receiver.DeleteCurrent)
|
||||
router.Get("/account/:userId", receiver.GetCurrent)
|
||||
router.Patch("/account/:userId", receiver.SetVerificationStatus)
|
||||
router.Get("/accounts", receiver.Pagination)
|
||||
}
|
||||
|
||||
func (receiver *AccountController) Name() string {
|
||||
|
@ -53,12 +53,12 @@ func NewCartController(deps Deps) *CartController {
|
||||
}
|
||||
}
|
||||
|
||||
func (receiver *CartController) RemoveFromCart(ctx *fiber.Ctx) error {
|
||||
func (receiver *CartController) Remove(ctx *fiber.Ctx) error {
|
||||
userID, ok := receiver.middleWare.ExtractUserID(ctx)
|
||||
if !ok || userID == "" {
|
||||
return receiver.middleWare.NoAuth(ctx)
|
||||
}
|
||||
|
||||
// todo проверить менять или нет
|
||||
id := ctx.Query("id")
|
||||
if id == "" {
|
||||
return receiver.middleWare.Error(ctx, fiber.StatusBadRequest, "empty item id")
|
||||
@ -105,7 +105,7 @@ func (receiver *CartController) Add2cart(ctx *fiber.Ctx) error {
|
||||
return ctx.Status(fiber.StatusOK).JSON(cartItems)
|
||||
}
|
||||
|
||||
func (receiver *CartController) PayCart(ctx *fiber.Ctx) error {
|
||||
func (receiver *CartController) Pay(ctx *fiber.Ctx) error {
|
||||
userID, ok := receiver.middleWare.ExtractUserID(ctx)
|
||||
if !ok || userID == "" {
|
||||
return receiver.middleWare.NoAuth(ctx)
|
||||
|
@ -3,9 +3,9 @@ package cart
|
||||
import "github.com/gofiber/fiber/v2"
|
||||
|
||||
func (receiver *CartController) Register(router fiber.Router) {
|
||||
router.Delete("/cart", receiver.RemoveFromCart)
|
||||
router.Delete("/cart", receiver.Remove)
|
||||
router.Patch("/cart", receiver.Add2cart)
|
||||
router.Post("/cart/pay", receiver.PayCart)
|
||||
router.Post("/cart/pay", receiver.Pay)
|
||||
}
|
||||
|
||||
func (receiver *CartController) Name() string {
|
||||
|
@ -29,7 +29,7 @@ func NewCurrencyController(deps Deps) *CurrencyController {
|
||||
}
|
||||
}
|
||||
|
||||
func (receiver *CurrencyController) GetCurrencies(ctx *fiber.Ctx) error {
|
||||
func (receiver *CurrencyController) Get(ctx *fiber.Ctx) error {
|
||||
currencyList, err := receiver.currencyRepo.FindCurrenciesList(ctx.Context(), models.DefaultCurrencyListName)
|
||||
if err != nil && err.Type() != errors.ErrNotFound {
|
||||
return receiver.middleWare.ErrorOld(ctx, err)
|
||||
@ -42,7 +42,7 @@ func (receiver *CurrencyController) GetCurrencies(ctx *fiber.Ctx) error {
|
||||
return ctx.Status(fiber.StatusOK).JSON(currencyList)
|
||||
}
|
||||
|
||||
func (receiver *CurrencyController) UpdateCurrencies(ctx *fiber.Ctx) error {
|
||||
func (receiver *CurrencyController) Update(ctx *fiber.Ctx) error {
|
||||
var req struct {
|
||||
items []string
|
||||
}
|
||||
|
@ -3,8 +3,8 @@ package currency
|
||||
import "github.com/gofiber/fiber/v2"
|
||||
|
||||
func (receiver *CurrencyController) Register(router fiber.Router) {
|
||||
router.Get("/currencies", receiver.GetCurrencies)
|
||||
router.Put("/currencies", receiver.UpdateCurrencies)
|
||||
router.Get("/currencies", receiver.Get)
|
||||
router.Put("/currencies", receiver.Update)
|
||||
}
|
||||
|
||||
func (receiver *CurrencyController) Name() string {
|
||||
|
@ -51,7 +51,7 @@ func NewHistoryController(deps Deps) *HistoryController {
|
||||
}
|
||||
}
|
||||
|
||||
func (receiver *HistoryController) GetHistory(ctx *fiber.Ctx) error {
|
||||
func (receiver *HistoryController) Get(ctx *fiber.Ctx) error {
|
||||
var userID string
|
||||
|
||||
pageStr := ctx.Query("page")
|
||||
|
@ -3,7 +3,7 @@ package history
|
||||
import "github.com/gofiber/fiber/v2"
|
||||
|
||||
func (receiver *HistoryController) Register(router fiber.Router) {
|
||||
router.Get("/history", receiver.GetHistory)
|
||||
router.Get("/history", receiver.Get)
|
||||
router.Post("/history/ltv", receiver.CalculateLTV)
|
||||
router.Post("/promocode/ltv", receiver.PromocodeLTV)
|
||||
router.Post("/quizlogo/stat", receiver.QuizLogoStat)
|
||||
|
Loading…
Reference in New Issue
Block a user