From 7ce9abe1de86127be3cc53e905d175404ea21566 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E6=B6=9B?= Date: Fri, 16 Sep 2022 17:26:41 +0800 Subject: [PATCH] =?UTF-8?q?enhance(model):=E5=A2=9E=E5=8A=A0=E4=B8=A4?= =?UTF-8?q?=E4=B8=AA=E7=94=A8=E4=BA=8E=E5=BF=AB=E9=80=9F=E8=BD=AC=E6=8D=A2?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E7=BB=93=E6=9E=84=E7=9A=84=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- model/park.go | 7 +++++++ model/user_detail.go | 7 +++++++ 2 files changed, 14 insertions(+) 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 +}