WA-9 - implemented wallet

This commit is contained in:
Fran Jurmanović
2021-05-16 17:43:45 +02:00
parent 32fd64716e
commit 55010c83d6
15 changed files with 64 additions and 68 deletions

View File

@@ -1,14 +1,14 @@
package models
type TokenModel struct {
type Token struct {
Token string `json:"token"`
}
type LoginModel struct {
type Login struct {
Email string
Password string
}
type AuthModel struct {
type Auth struct {
Id string
}

View File

@@ -6,13 +6,13 @@ import (
"github.com/google/uuid"
)
type CommonModel struct {
type BaseModel struct {
Id string `json:"id" pg:"id,pk"`
DateCreated time.Time `json:"dateCreated" pg:"datecreated"`
DateUpdated time.Time `json:"dateUpdated" pg:"dateupdated"`
DateCreated time.Time `json:"dateCreated" pg:"date_created"`
DateUpdated time.Time `json:"dateUpdated" pg:"date_updated"`
}
func (cm *CommonModel) Init() {
func (cm *BaseModel) Init() {
date := time.Now()
cm.Id = uuid.NewString()
cm.DateCreated = date

View File

@@ -1,6 +1,6 @@
package models
type ExceptionModel struct {
type Exception struct {
ErrorCode string `json:"errorCode"`
Message string `json:"message"`
StatusCode int `json:"statusCode"`

View File

@@ -1,23 +1,23 @@
package models
type UserModel struct {
type User struct {
tableName struct{} `pg:"users,alias:users"`
CommonModel
BaseModel
Username string `json:"username" pg:"username"`
Password string `json:"password" pg:"password"`
Email string `json:"email" pg:"email"`
}
type UserReturnInfoModel struct {
type UserReturnInfo struct {
tableName struct{} `pg:"users,alias:users"`
CommonModel
BaseModel
Username string `json:"username"`
Email string `json:"email"`
}
func (um *UserModel) Payload() *UserReturnInfoModel {
payload := new(UserReturnInfoModel)
payload.CommonModel = um.CommonModel
func (um *User) Payload() *UserReturnInfo {
payload := new(UserReturnInfo)
payload.BaseModel = um.BaseModel
payload.Username = um.Username
payload.Email = um.Email

View File

@@ -1,16 +1,14 @@
package models
type WalletModel struct {
type Wallet struct {
tableName struct{} `pg:"wallets,alias:wallets"`
CommonModel
WalletTypeID string `json:"walletTypeId" pg:"wallet_type_id"`
WalletType *WalletTypeModel `json:"walletType" pg:"rel:has-one,fk:wallet_type_id"`
UserID string `json:"userId" pg:"user_id"`
User *UserReturnInfoModel `json:"user" pg:"rel:has-one,fk:user_id"`
BaseModel
Name string `json:"name" pg:"name"`
UserID string `json:"userId" pg:"user_id"`
User *UserReturnInfo `json:"user" pg:"rel:has-one,fk:user_id"`
}
type WalletTypeModel struct {
tableName struct{} `pg:"walletTypes,alias:walletTypes"`
CommonModel
Name string `json:"name"`
type NewWalletBody struct {
Name string `json:"name"`
UserID string `json:"userId"`
}