niki/adapter/storage/models/actions.go

33 lines
789 B
Go
Raw Normal View History

2023-12-16 06:09:50 +00:00
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,
}
}