38 lines
831 B
Plaintext
38 lines
831 B
Plaintext
|
package entity
|
||
|
|
||
|
import (
|
||
|
"time"
|
||
|
)
|
||
|
|
||
|
// use to display a {name}
|
||
|
type {Name}Display struct {
|
||
|
ID int `json:"id"`
|
||
|
CreatedAt time.Time `json:"created_at"`
|
||
|
UpdatedAt time.Time `json:"updated_at"`
|
||
|
}
|
||
|
|
||
|
// use to create or update a {name}
|
||
|
type {Name}CreateUpdate struct {
|
||
|
{Name}Display
|
||
|
BusinessID int `json:"business_id"`
|
||
|
}
|
||
|
|
||
|
// Func that will check non empty field on {Name}Display and update {name}
|
||
|
func ValidateUpdate({name} *{Name}CreateUpdate, p *{Name}Display) *{Name}CreateUpdate {
|
||
|
|
||
|
{name}.ID = p.ID
|
||
|
{name}.CreatedAt = p.CreatedAt
|
||
|
{name}.UpdatedAt = p.UpdatedAt
|
||
|
|
||
|
return {name}
|
||
|
}
|
||
|
|
||
|
func {Name}DisplayFormatter({name} *{Name}CreateUpdate) (p *{Name}Display) {
|
||
|
p = &{Name}Display{
|
||
|
ID: {name}.ID,
|
||
|
CreatedAt: {name}.CreatedAt,
|
||
|
UpdatedAt: {name}.UpdatedAt,
|
||
|
}
|
||
|
|
||
|
return
|
||
|
}
|