mirror of
https://github.com/FJurmanovic/wallet-go-api.git
synced 2026-02-06 06:08:16 +00:00
fixes on structuring
This commit is contained in:
@@ -8,3 +8,7 @@ type LoginModel struct {
|
||||
Email string
|
||||
Password string
|
||||
}
|
||||
|
||||
type AuthModel struct {
|
||||
Id string
|
||||
}
|
||||
|
||||
@@ -1,9 +1,20 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
type CommonModel struct {
|
||||
Id string `json:"id" pg:"id"`
|
||||
Id string `json:"id" pg:"id,pk"`
|
||||
DateCreated time.Time `json:"dateCreated" pg:"datecreated"`
|
||||
DateUpdated time.Time `json:"dateUpdated" pg:"dateupdated"`
|
||||
}
|
||||
|
||||
func (cm *CommonModel) Init() {
|
||||
date := time.Now()
|
||||
cm.Id = uuid.NewString()
|
||||
cm.DateCreated = date
|
||||
cm.DateUpdated = date
|
||||
}
|
||||
|
||||
@@ -3,9 +3,9 @@ package models
|
||||
type UserModel struct {
|
||||
tableName struct{} `pg:"users,alias:users"`
|
||||
CommonModel
|
||||
Username string `json:"username"`
|
||||
Password string `json:"password"`
|
||||
Email string `json:"email"`
|
||||
Username string `json:"username" pg:"username"`
|
||||
Password string `json:"password" pg:"password"`
|
||||
Email string `json:"email" pg:"email"`
|
||||
}
|
||||
|
||||
type UserReturnInfoModel struct {
|
||||
@@ -15,11 +15,11 @@ type UserReturnInfoModel struct {
|
||||
Email string `json:"email"`
|
||||
}
|
||||
|
||||
func (um *UserModel) Payload() UserReturnInfoModel {
|
||||
payload := UserReturnInfoModel{
|
||||
CommonModel: um.CommonModel,
|
||||
Username: um.Username,
|
||||
Email: um.Email,
|
||||
}
|
||||
func (um *UserModel) Payload() *UserReturnInfoModel {
|
||||
payload := new(UserReturnInfoModel)
|
||||
payload.CommonModel = um.CommonModel
|
||||
payload.Username = um.Username
|
||||
payload.Email = um.Email
|
||||
|
||||
return payload
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user