online-order/command/generateCrud/entity.text

38 lines
831 B
Plaintext
Raw Permalink Normal View History

2023-11-17 20:16:02 +00:00
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
}