package vo import ( "electricity_bill_calc/model" "electricity_bill_calc/tools" "github.com/shopspring/decimal" ) type ParkInformationForm struct { Name string `json:"name"` Region *string `json:"region"` Address *string `json:"address"` Contact *string `json:"contact"` Phone *string `json:"phone"` Area *string `json:"area"` Capacity *string `json:"capacity"` TenementQuantity *string `json:"tenement"` TaxRate *string `json:"taxRate"` Category int16 `json:"category"` MeterType int16 `json:"submeter"` PricePolicy int16 `json:"pricePolicy"` BasicPooled int16 `json:"basicDiluted"` AdjustPooled int16 `json:"adjustDiluted"` LossPooled int16 `json:"lossDiluted"` PublicPooled int16 `json:"publicDiluted"` } func (pcf ParkInformationForm) TryIntoPark() (*model.Park, error) { area, err := tools.NewNullDecimalFromString(pcf.Area) if err != nil { return nil, err } tenementQuantity, err := tools.NewNullDecimalFromString(pcf.TenementQuantity) if err != nil { return nil, err } capacity, err := tools.NewNullDecimalFromString(pcf.Capacity) if err != nil { return nil, err } taxRate, err := tools.NewNullDecimalFromString(pcf.TaxRate) if err != nil { return nil, err } return &model.Park{ Name: pcf.Name, Region: pcf.Region, Address: pcf.Address, Contact: pcf.Contact, Phone: pcf.Phone, Area: area, TenementQuantity: tenementQuantity, Capacity: capacity, Category: pcf.Category, MeterType: pcf.MeterType, PricePolicy: pcf.PricePolicy, BasicPooled: pcf.BasicPooled, AdjustPooled: pcf.AdjustPooled, LossPooled: pcf.LossPooled, PublicPooled: pcf.PublicPooled, TaxRate: taxRate, }, nil } type ParkBuildingInformationForm struct { Name string `json:"name"` Floors string `json:"floors"` } type SimplifiedParkDetail struct { Id string `json:"id"` UserId string `json:"userId"` Name string `json:"name"` TenementStr *string `json:"tenement"` AreaStr *string `json:"area"` CapacityStr *string `json:"capacity"` Category int16 `json:"category"` MeterType int16 `json:"meter04kvType"` Region *string `json:"region"` Address *string `json:"address"` Contact *string `json:"contact"` Phone *string `json:"phone"` } func (spd *SimplifiedParkDetail) TenementQuantity(tq decimal.NullDecimal) { spd.TenementStr = tools.NullDecimalToString(tq) } func (spd *SimplifiedParkDetail) Area(area decimal.NullDecimal) { spd.AreaStr = tools.NullDecimalToString(area) } func (spd *SimplifiedParkDetail) Capacity(capacity decimal.NullDecimal) { spd.CapacityStr = tools.NullDecimalToString(capacity) }