Documentation ¶
Index ¶
- Constants
- type BankAccount
- type DataHandler
- func (d *DataHandler) HandleBankAccounts(w http.ResponseWriter, r *http.Request)
- func (d *DataHandler) HandleBankers(w http.ResponseWriter, r *http.Request)
- func (d *DataHandler) HandleClients(w http.ResponseWriter, r *http.Request)
- func (d *DataHandler) HandleOperations(w http.ResponseWriter, r *http.Request)
- func (d *DataHandler) ProcessAPI(w http.ResponseWriter, r *http.Request)
- type Operation
- type UserBanker
- type UserClient
Constants ¶
const ErrorCannotAccessRessource = "You can not access this ressource"
ErrorCannotAccessRessource = "You can not access this ressource" with 403 http.StatusForbidden
const ErrorIDDoesNotExist = "id does not exist"
ErrorIDDoesNotExist = "id does not exist" with 404 http.StatusNotFound
const ErrorIDIsMissing = "id is missing"
ErrorIDIsMissing = "id is missing" with 404 http.StatusNotFound
const ErrorNotAuthorizeMethodOnRessource = "You're not authorize to execute this method on this ressource."
ErrorNotAuthorizeMethodOnRessource = "You're not authorize to execute this method on this ressource." with 405 http.StatusMethodNotAllowed
const ErrorRoleOfLoggedUser = "Could not get role of logged user"
ErrorRoleOfLoggedUser = "Could not get role of logged user" with 500 http.StatusInternalServerError
const ErrorUserIDIsMissing = "id of UserClient is missing"
ErrorUserIDIsMissing = "id of UserClient is missing"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BankAccount ¶
type BankAccount struct { ID uint `gorm:"primary_key"` CreatedAt time.Time `json:"-"` UpdatedAt time.Time `json:"-"` DeletedAt *time.Time `json:"-"` Number string UserClientID uint Type string Amount int BankOverdraft int Operations []Operation `gorm:"foreignkey:Debtor"` }
BankAccount belongs to an UserClient
type DataHandler ¶
type DataHandler struct {
// contains filtered or unexported fields
}
DataHandler init a gorm DB an presents API handlers
func NewDataHandler ¶
func NewDataHandler() *DataHandler
NewDataHandler init a DataHandler and returns a pointer to it
func (*DataHandler) HandleBankAccounts ¶
func (d *DataHandler) HandleBankAccounts(w http.ResponseWriter, r *http.Request)
HandleBankAccounts handle API call on BankAccounts
func (*DataHandler) HandleBankers ¶
func (d *DataHandler) HandleBankers(w http.ResponseWriter, r *http.Request)
HandleBankers handle API calls on Bankers
func (*DataHandler) HandleClients ¶
func (d *DataHandler) HandleClients(w http.ResponseWriter, r *http.Request)
HandleClients expose the UserClients API
func (*DataHandler) HandleOperations ¶
func (d *DataHandler) HandleOperations(w http.ResponseWriter, r *http.Request)
HandleOperations handle API calls on Operations
func (*DataHandler) ProcessAPI ¶
func (d *DataHandler) ProcessAPI(w http.ResponseWriter, r *http.Request)
ProcessAPI redirect API call to DataHandler to each correct API func
type Operation ¶
type Operation struct { ID uint `gorm:"primary_key"` Debtor uint CreatedAt time.Time `json:"-"` UpdatedAt time.Time `json:"-"` DeletedAt *time.Time `json:"-"` Amount int Date time.Time Creditor uint }
Operation reprensent a bank transaction registered in a BankAccount
type UserBanker ¶
type UserBanker struct { ID uint `gorm:"primary_key"` CreatedAt time.Time `json:"-"` UpdatedAt time.Time `json:"-"` DeletedAt *time.Time `json:"-"` UserID int `gorm:"not null;unique"` Name string UserClients []UserClient }
UserBanker has many UserClient
type UserClient ¶
type UserClient struct { ID uint `gorm:"primary_key"` CreatedAt time.Time `json:"-"` UpdatedAt time.Time `json:"-"` DeletedAt *time.Time `json:"-"` UserID int `gorm:"not null;unique"` Name string UserBankerID uint BankAccounts []BankAccount }
UserClient has many BankAccounts and one UserBanker