Spaces:
Runtime error
Runtime error
Download controller/account_controller.go from lifedebugger/banking-crud-api: direct link, hf CLI and curl.
- Browser
- Download file 1.48 kB
-
https://huggingface.co/spaces/lifedebugger/banking-crud-api/resolve/main/controller/account_controller.go
- Command line
-
hf download hf://spaces/lifedebugger/banking-crud-api/controller/account_controller.go
-
curl -L -o account_controller.go https://huggingface.co/spaces/lifedebugger/banking-crud-api/resolve/main/controller/account_controller.go
1.48 kB
| package controller | |
| import ( | |
| "fmt" | |
| "abdanhafidz.com/go-boilerplate/models/dto" | |
| "abdanhafidz.com/go-boilerplate/services" | |
| "github.com/gin-gonic/gin" | |
| ) | |
| type AccountController interface { | |
| CreateAccount(ctx *gin.Context) | |
| VerifyAccount(ctx *gin.Context) | |
| ResetPIN(ctx *gin.Context) | |
| BlockAccount(ctx *gin.Context) | |
| } | |
| type accountController struct { | |
| accountService services.AccountService | |
| } | |
| func NewAccountController(accountService services.AccountService) AccountController { | |
| return &accountController{ | |
| accountService: accountService, | |
| } | |
| } | |
| func (c *accountController) CreateAccount(ctx *gin.Context) { | |
| req := RequestJSON[dto.AccountRequest](ctx) | |
| fmt.Println(req) | |
| res, err := c.accountService.CreateAccount(ctx.Request.Context(), req.Name, req.Dateofbirth) | |
| ResponseJSON(ctx, req, res, err) | |
| } | |
| func (c *accountController) VerifyAccount(ctx *gin.Context) { | |
| req := RequestJSON[dto.VerifyAccountRequest](ctx) | |
| fmt.Println(req) | |
| res, err := c.accountService.VerifyAccount(ctx.Request.Context(), req) | |
| ResponseJSON(ctx, req, res, err) | |
| } | |
| func (c *accountController) ResetPIN(ctx *gin.Context) { | |
| req := RequestJSON[dto.VerifyAccountRequest](ctx) | |
| res, err := c.accountService.ResetPIN(ctx.Request.Context(), req) | |
| ResponseJSON(ctx, req, res, err) | |
| } | |
| func (c *accountController) BlockAccount(ctx *gin.Context) { | |
| req := RequestJSON[dto.VerifyAccountRequest](ctx) | |
| res, err := c.accountService.BlockAccount(ctx.Request.Context(), req) | |
| ResponseJSON(ctx, req, res, err) | |
| } | |