mirror of
https://github.com/FJurmanovic/wallet-go-api.git
synced 2026-02-06 06:08:16 +00:00
WA-9 - implemented wallet
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package models
|
||||
|
||||
type ExceptionModel struct {
|
||||
type Exception struct {
|
||||
ErrorCode string `json:"errorCode"`
|
||||
Message string `json:"message"`
|
||||
StatusCode int `json:"statusCode"`
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user