partial repository layer added

This commit is contained in:
Fran Jurmanović
2022-09-27 00:33:44 +02:00
parent 13ce0735d0
commit 82e97fc97f
73 changed files with 2686 additions and 1216 deletions

View File

@@ -0,0 +1,57 @@
package controller
import (
"wallet-api/pkg/model"
"wallet-api/pkg/service"
"wallet-api/pkg/utl/common"
"github.com/gin-gonic/gin"
)
type WalletHeaderController struct {
service *service.WalletService
}
/*
NewWalletHeaderController
Initializes WalletHeaderController.
Args:
*services.WalletService: Wallet service
*gin.RouterGroup: Gin Router Group
Returns:
*WalletHeaderController: Controller for "wallet/wallet-header" route interactions
*/
func NewWalletHeaderController(as *service.WalletService, routeGroups *common.RouteGroups) *WalletHeaderController {
wc := &WalletHeaderController{
service: as,
}
routeGroups.WalletHeader.GET("", wc.Get)
return wc
}
/*
Get
Args:
*gin.Context: Gin Application Context
*/
// ROUTE (GET /wallet/wallet-header)
func (wc *WalletHeaderController) Get(c *gin.Context) {
body := new(model.Auth)
walletId, _ := c.GetQuery("walletId")
auth := c.MustGet("auth")
body.Id = auth.(*model.Auth).Id
wm, exception := wc.service.GetHeader(c, body, walletId)
if exception != nil {
c.JSON(exception.StatusCode, exception)
return
}
c.JSON(200, wm)
}