package model import ( "time" "github.com/jinzhu/copier" "github.com/shopspring/decimal" "github.com/uptrace/bun" ) type UserDetail struct { bun.BaseModel `bun:"table:user_detail,alias:d"` CreatedAndModifiedWithUser `bun:",extend"` DeletedWithUser `bun:",extend"` Id string `bun:",pk,notnull" json:"-"` Name *string `json:"name"` Abbr *string `json:"abbr"` Region *string `json:"region"` Address *string `json:"address"` Contact *string `json:"contact"` Phone *string `json:"phone"` UnitServiceFee decimal.Decimal `bun:",notnull" json:"unitServiceFee"` ServiceExpiration time.Time `bun:"type:date,notnull" json:"serviceExpiration" time_format:"simple_date" time_location:"shanghai"` } type JoinedUserDetail struct { UserDetail `bun:"extends"` Id string `json:"id"` Username string `json:"username"` Type int8 `json:"type"` Enabled bool `json:"enabled"` } type FullJoinedUserDetail struct { UserDetail `bun:"extends"` User `bun:"extends"` } type UserDetailSimplified struct { bun.BaseModel `bun:"table:user_detail,alias:d"` Id string `bun:",pk,notnull" json:"id"` Name *string `json:"name"` Abbr *string `json:"abbr"` Region *string `json:"region"` Address *string `json:"address"` Contact *string `json:"contact"` Phone *string `json:"phone"` } func FromUserDetail(user UserDetail) UserDetailSimplified { dest := UserDetailSimplified{} copier.Copy(&dest, user) return dest }