package model import ( "context" "time" "github.com/shopspring/decimal" "github.com/uptrace/bun" ) type MaintenanceFee struct { bun.BaseModel `bun:"table:maintenance_fee,alias:m"` CreatedAndModified `bun:"extend"` Deleted `bun:"extend"` Id string `bun:",pk,notnull" json:"id"` ParkId string `bun:",notnull" json:"parkId"` Name string `bun:",notnull" json:"name"` Period string `bun:",notnull" json:"period"` Fee decimal.Decimal `bun:"type:numeric,notnull" json:"fee"` Memo *string `bun:"type:text" json:"memo"` Enabled bool `bun:",notnull" json:"enabled"` Park Park `bun:"rel:belongs-to,join:park_id=id"` } var _ bun.BeforeAppendModelHook = (*MaintenanceFee)(nil) func (f *MaintenanceFee) BeforeAppendModel(ctx context.Context, query bun.Query) error { oprTime := time.Now() switch query.(type) { case *bun.InsertQuery: f.CreatedAt = oprTime f.LastModifiedAt = &oprTime case *bun.UpdateQuery: f.LastModifiedAt = &oprTime } return nil } type AdditionalCharge struct { ParkId string `json:"parkId"` Period string `json:"period"` Fee decimal.Decimal `json:"fee"` Price decimal.Decimal `json:"price"` QuarterPrice decimal.Decimal `json:"quarterPrice"` SemiAnnualPrice decimal.Decimal `json:"semiAnnualPrice"` Enterprise UserDetailSimplified `json:"user"` Park Park `json:"park"` }