diff --git a/model/park.go b/model/park.go index 437475c..3c093df 100644 --- a/model/park.go +++ b/model/park.go @@ -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 +} diff --git a/model/user_detail.go b/model/user_detail.go index d28984d..5a7257e 100644 --- a/model/user_detail.go +++ b/model/user_detail.go @@ -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 +}