mirror of
https://github.com/FJurmanovic/wallet-go-api.git
synced 2026-02-06 14:18:12 +00:00
WA-9 - implemented wallet
This commit is contained in:
@@ -22,7 +22,7 @@ func NewLoginController(rs *services.UsersService, s *gin.RouterGroup) *LoginCon
|
||||
}
|
||||
|
||||
func (rc *LoginController) Post(c *gin.Context) {
|
||||
body := new(models.LoginModel)
|
||||
body := new(models.Login)
|
||||
if err := c.ShouldBindJSON(&body); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
|
||||
@@ -22,9 +22,9 @@ func NewRegisterController(rs *services.UsersService, s *gin.RouterGroup) *Regis
|
||||
}
|
||||
|
||||
func (rc *RegisterController) Post(c *gin.Context) {
|
||||
body := new(models.UserModel)
|
||||
body := new(models.User)
|
||||
body.Init()
|
||||
if err := c.ShouldBindJSON(&body); err != nil {
|
||||
if err := c.ShouldBindJSON(body); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"wallet-api/pkg/models"
|
||||
"wallet-api/pkg/services"
|
||||
|
||||
@@ -22,21 +23,26 @@ func NewWalletsController(as *services.WalletService, s *gin.RouterGroup) *Walle
|
||||
}
|
||||
|
||||
func (wc *WalletsController) New(c *gin.Context) {
|
||||
body := new(models.AuthModel)
|
||||
body := new(models.NewWalletBody)
|
||||
|
||||
if err := c.ShouldBindJSON(body); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
get := c.MustGet("auth")
|
||||
body.Id = get.(*models.AuthModel).Id
|
||||
body.UserID = get.(*models.Auth).Id
|
||||
|
||||
wm := wc.WalletService.New(body)
|
||||
c.JSON(200, wm)
|
||||
}
|
||||
|
||||
func (wc *WalletsController) Get(c *gin.Context) {
|
||||
body := new(models.AuthModel)
|
||||
body := new(models.Auth)
|
||||
|
||||
embed, _ := c.GetQuery("embed")
|
||||
auth := c.MustGet("auth")
|
||||
body.Id = auth.(*models.AuthModel).Id
|
||||
body.Id = auth.(*models.Auth).Id
|
||||
|
||||
wm := wc.WalletService.Get(body, embed)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user