68 lines
1.9 KiB
Go
68 lines
1.9 KiB
Go
package vo
|
|
|
|
import (
|
|
"electricity_bill_calc/model"
|
|
"electricity_bill_calc/tools"
|
|
)
|
|
|
|
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"`
|
|
}
|