enhance(model):增加两个用于快速转换数据结构的方法。
This commit is contained in:
parent
dba74ecd49
commit
7ce9abe1de
|
@ -3,6 +3,7 @@ package model
|
|||
import (
|
||||
"time"
|
||||
|
||||
"github.com/jinzhu/copier"
|
||||
"github.com/shopspring/decimal"
|
||||
"github.com/uptrace/bun"
|
||||
)
|
||||
|
@ -64,3 +65,9 @@ type ParkPeriodStatistics struct {
|
|||
Name string `bun:",notnull" json:"name"`
|
||||
Period *time.Time `bun:"type:date" json:"period" time_format:"simple_date" time_location:"shanghai"`
|
||||
}
|
||||
|
||||
func FromPark(park Park) ParkSimplified {
|
||||
dest := ParkSimplified{}
|
||||
copier.Copy(&dest, park)
|
||||
return dest
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package model
|
|||
import (
|
||||
"time"
|
||||
|
||||
"github.com/jinzhu/copier"
|
||||
"github.com/shopspring/decimal"
|
||||
"github.com/uptrace/bun"
|
||||
)
|
||||
|
@ -45,3 +46,9 @@ type UserDetailSimplified struct {
|
|||
Contact *string `json:"contact"`
|
||||
Phone *string `json:"phone"`
|
||||
}
|
||||
|
||||
func FromUserDetail(user UserDetail) UserDetailSimplified {
|
||||
dest := UserDetailSimplified{}
|
||||
copier.Copy(&dest, user)
|
||||
return dest
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user