models

package
v0.0.0-...-6a5da2a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 23, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const ErrorCannotAccessRessource = "You can not access this ressource"

ErrorCannotAccessRessource = "You can not access this ressource" with 403 http.StatusForbidden

View Source
const ErrorIDDoesNotExist = "id does not exist"

ErrorIDDoesNotExist = "id does not exist" with 404 http.StatusNotFound

View Source
const ErrorIDIsMissing = "id is missing"

ErrorIDIsMissing = "id is missing" with 404 http.StatusNotFound

View Source
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

View Source
const ErrorRoleOfLoggedUser = "Could not get role of logged user"

ErrorRoleOfLoggedUser = "Could not get role of logged user" with 500 http.StatusInternalServerError

View Source
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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL