Skip to content

Commit

Permalink
Refactoring repo layout
Browse files Browse the repository at this point in the history
  • Loading branch information
KrylixZA committed Dec 21, 2024
1 parent 2cbf220 commit 46bb6df
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
7 changes: 0 additions & 7 deletions cmd/accounts/app/account.go

This file was deleted.

7 changes: 4 additions & 3 deletions cmd/accounts/app/accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package app

import (
"encoding/json"
"github.com/KrylixZA/bank-with-dapr/pkg/models"
"net/http"

dapr "github.com/dapr/go-sdk/client"
Expand Down Expand Up @@ -32,7 +33,7 @@ func GetAccountsForUser(c *gin.Context) {

func CreateAccountForUser(c *gin.Context) {
userId := c.Param("userId")
var account account
var account models.Account

accounts, err := getAccountsForUser(userId, c)
if err != nil {
Expand All @@ -54,7 +55,7 @@ func CreateAccountForUser(c *gin.Context) {
c.IndentedJSON(http.StatusCreated, nil)
}

func getAccountsForUser(userId string, c *gin.Context) (accounts []account, err error) {
func getAccountsForUser(userId string, c *gin.Context) (accounts []models.Account, err error) {
client, err := dapr.NewClient()
if err != nil {
return nil, err
Expand All @@ -74,7 +75,7 @@ func getAccountsForUser(userId string, c *gin.Context) (accounts []account, err
return accounts, nil
}

func saveAccountsForUser(userId string, accounts []account, c *gin.Context) (err error) {
func saveAccountsForUser(userId string, accounts []models.Account, c *gin.Context) (err error) {
client, err := dapr.NewClient()
if err != nil {
return err
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package app
package enums

type AccountType int

Expand Down
9 changes: 9 additions & 0 deletions pkg/models/account.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package models

import "github.com/KrylixZA/bank-with-dapr/pkg/enums"

type Account struct {
AccountID string `json:"accountId"`
AccountType enums.AccountType `json:"accountType"`
Balance float64 `json:"balance"`
}

0 comments on commit 46bb6df

Please sign in to comment.