forked from ebhomengo/niki
33 lines
789 B
Go
33 lines
789 B
Go
|
package storage
|
||
|
|
||
|
import (
|
||
|
entitypiggybank "git.gocasts.ir/ebhomengo/niki/entity/piggy_bank"
|
||
|
"gorm.io/gorm"
|
||
|
"time"
|
||
|
)
|
||
|
|
||
|
type PiggyBank struct {
|
||
|
gorm.Model
|
||
|
TotalAmount uint
|
||
|
SerialNumber string
|
||
|
//to don't insert value in "updated_at" at "insert mode" :
|
||
|
//see more: https://gorm.io/docs/update.html
|
||
|
UpdatedAt *time.Time `json:"updated_at" gorm:"<-:update"`
|
||
|
}
|
||
|
|
||
|
func MapActionsStoreToEntity(piggyBank PiggyBank) entitypiggybank.PiggyBank {
|
||
|
returnModel := entitypiggybank.PiggyBank{
|
||
|
ID: piggyBank.ID,
|
||
|
SerialNumber: piggyBank.SerialNumber,
|
||
|
TotalAmount: piggyBank.TotalAmount,
|
||
|
}
|
||
|
return returnModel
|
||
|
}
|
||
|
|
||
|
func MapEntityToActionsStore(input entitypiggybank.PiggyBank) PiggyBank {
|
||
|
return PiggyBank{
|
||
|
SerialNumber: input.SerialNumber,
|
||
|
TotalAmount: input.TotalAmount,
|
||
|
}
|
||
|
}
|