upgraded migrations and context usage

This commit is contained in:
Fran Jurmanović
2021-07-03 00:01:25 +02:00
parent 4189a0d333
commit 788ff3a146
33 changed files with 321 additions and 251 deletions

View File

@@ -22,12 +22,14 @@ func NewApiController(as *services.ApiService, s *gin.RouterGroup) *ApiControlle
}
func (ac *ApiController) getFirst(c *gin.Context) {
apiModel := ac.ApiService.GetFirst()
apiModel := ac.ApiService.GetFirst(c)
c.JSON(200, apiModel)
}
func (ac *ApiController) postMigrate(c *gin.Context) {
mr, er := ac.ApiService.PostMigrate()
migrateModel := c.MustGet("migrate")
version := migrateModel.(middleware.SecretCodeModel).Version
mr, er := ac.ApiService.PostMigrate(c, version)
if er.Message != "" {
c.JSON(er.StatusCode, er)

View File

@@ -31,7 +31,7 @@ func (rc *AuthController) PostLogin(c *gin.Context) {
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
return
}
returnedUser, exceptionReturn := rc.UsersService.Login(body)
returnedUser, exceptionReturn := rc.UsersService.Login(c, body)
if exceptionReturn.Message != "" {
c.JSON(exceptionReturn.StatusCode, exceptionReturn)
@@ -48,7 +48,7 @@ func (rc *AuthController) PostRegister(c *gin.Context) {
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
return
}
returnedUser, exceptionReturn := rc.UsersService.Create(body)
returnedUser, exceptionReturn := rc.UsersService.Create(c, body)
if exceptionReturn.Message != "" {
c.JSON(exceptionReturn.StatusCode, exceptionReturn)
@@ -61,7 +61,7 @@ func (rc *AuthController) Delete(c *gin.Context) {
authGet := c.MustGet("auth")
auth.Id = authGet.(*models.Auth).Id
mr, er := rc.UsersService.Deactivate(auth)
mr, er := rc.UsersService.Deactivate(c, auth)
if er.Message != "" {
c.JSON(er.StatusCode, er)

View File

@@ -29,14 +29,14 @@ func (wc *SubscriptionTypeController) New(c *gin.Context) {
return
}
wm := wc.SubscriptionTypeService.New(body)
wm := wc.SubscriptionTypeService.New(c, body)
c.JSON(200, wm)
}
func (wc *SubscriptionTypeController) GetAll(c *gin.Context) {
embed, _ := c.GetQuery("embed")
wm := wc.SubscriptionTypeService.GetAll(embed)
wm := wc.SubscriptionTypeService.GetAll(c, embed)
c.JSON(200, wm)
}

View File

@@ -29,7 +29,7 @@ func (wc *SubscriptionController) New(c *gin.Context) {
return
}
wm := wc.SubscriptionService.New(body)
wm := wc.SubscriptionService.New(c, body)
c.JSON(200, wm)
}
@@ -41,7 +41,7 @@ func (wc *SubscriptionController) GetAll(c *gin.Context) {
fr := FilteredResponse(c)
wallet, _ := c.GetQuery("walletId")
wc.SubscriptionService.GetAll(body, wallet, fr)
wc.SubscriptionService.GetAll(c, body, wallet, fr)
c.JSON(200, fr)
}

View File

@@ -29,14 +29,14 @@ func (wc *TransactionTypeController) New(c *gin.Context) {
return
}
wm := wc.TransactionTypeService.New(body)
wm := wc.TransactionTypeService.New(c, body)
c.JSON(200, wm)
}
func (wc *TransactionTypeController) GetAll(c *gin.Context) {
embed, _ := c.GetQuery("embed")
wm := wc.TransactionTypeService.GetAll(embed)
wm := wc.TransactionTypeService.GetAll(c, embed)
c.JSON(200, wm)
}

View File

@@ -29,7 +29,7 @@ func (wc *TransactionController) New(c *gin.Context) {
return
}
wm := wc.TransactionService.New(body)
wm := wc.TransactionService.New(c, body)
c.JSON(200, wm)
}
@@ -41,7 +41,7 @@ func (wc *TransactionController) GetAll(c *gin.Context) {
fr := FilteredResponse(c)
wallet, _ := c.GetQuery("walletId")
wc.TransactionService.GetAll(body, wallet, fr)
wc.TransactionService.GetAll(c, body, wallet, fr)
c.JSON(200, fr)
}

View File

@@ -28,7 +28,7 @@ func (wc *WalletsHeaderController) Get(c *gin.Context) {
auth := c.MustGet("auth")
body.Id = auth.(*models.Auth).Id
wm := wc.WalletService.GetHeader(body, walletId)
wm := wc.WalletService.GetHeader(c, body, walletId)
c.JSON(200, wm)
}

View File

@@ -33,7 +33,7 @@ func (wc *WalletsController) New(c *gin.Context) {
get := c.MustGet("auth")
body.UserID = get.(*models.Auth).Id
wm := wc.WalletService.New(body)
wm := wc.WalletService.New(c, body)
c.JSON(200, wm)
}
@@ -44,7 +44,7 @@ func (wc *WalletsController) Get(c *gin.Context) {
auth := c.MustGet("auth")
body.Id = auth.(*models.Auth).Id
wm := wc.WalletService.Get(body, embed)
wm := wc.WalletService.Get(c, body, embed)
c.JSON(200, wm)
}
@@ -56,7 +56,7 @@ func (wc *WalletsController) GetAll(c *gin.Context) {
fr := FilteredResponse(c)
wc.WalletService.GetAll(body, fr)
wc.WalletService.GetAll(c, body, fr)
c.JSON(200, fr)