fix(model):调整Decimal类型,防止bun框架将其认定为JSONB类型。

This commit is contained in:
徐涛 2022-09-20 12:31:55 +08:00
parent b5c2455af7
commit efc0a605b7
9 changed files with 96 additions and 96 deletions

View File

@ -16,47 +16,47 @@ type EndUserDetail struct {
ParkId string `bun:",pk,notnull" json:"parkId"` ParkId string `bun:",pk,notnull" json:"parkId"`
MeterId string `bun:"meter_04kv_id,pk,notnull" json:"meterId"` MeterId string `bun:"meter_04kv_id,pk,notnull" json:"meterId"`
Seq int64 `bun:"type:bigint,notnull" json:"seq"` Seq int64 `bun:"type:bigint,notnull" json:"seq"`
Ratio decimal.Decimal `bun:",notnull" json:"ratio"` Ratio decimal.Decimal `bun:"type:numeric,notnull" json:"ratio"`
Address *string `json:"address"` Address *string `json:"address"`
CustomerName *string `json:"customerName"` CustomerName *string `json:"customerName"`
ContactName *string `json:"contactName"` ContactName *string `json:"contactName"`
ContactPhone *string `json:"contactPhone"` ContactPhone *string `json:"contactPhone"`
IsPublicMeter bool `bun:"public_meter,notnull" json:"isPublicMeter"` IsPublicMeter bool `bun:"public_meter,notnull" json:"isPublicMeter"`
WillDilute bool `bun:"dilute,notnull" json:"willDilute"` WillDilute bool `bun:"dilute,notnull" json:"willDilute"`
LastPeriodOverall decimal.Decimal `bun:",notnull" json:"lastPeriodOverall"` LastPeriodOverall decimal.Decimal `bun:"type:numeric,notnull" json:"lastPeriodOverall"`
LastPeriodCritical decimal.Decimal `bun:",notnull" json:"lastPeriodCritical"` LastPeriodCritical decimal.Decimal `bun:"type:numeric,notnull" json:"lastPeriodCritical"`
LastPeriodPeak decimal.Decimal `bun:",notnull" json:"lastPeriodPeak"` LastPeriodPeak decimal.Decimal `bun:"type:numeric,notnull" json:"lastPeriodPeak"`
LastPeriodFlat decimal.Decimal `bun:",notnull" json:"lastPeriodFlat"` LastPeriodFlat decimal.Decimal `bun:"type:numeric,notnull" json:"lastPeriodFlat"`
LastPeriodValley decimal.Decimal `bun:",notnull" json:"lastPeriodValley"` LastPeriodValley decimal.Decimal `bun:"type:numeric,notnull" json:"lastPeriodValley"`
CurrentPeriodOverall decimal.Decimal `bun:",notnull" json:"currentPeriodOverall"` CurrentPeriodOverall decimal.Decimal `bun:"type:numeric,notnull" json:"currentPeriodOverall"`
CurrentPeriodCritical decimal.Decimal `bun:",notnull" json:"currentPeriodCritical"` CurrentPeriodCritical decimal.Decimal `bun:"type:numeric,notnull" json:"currentPeriodCritical"`
CurrentPeriodPeak decimal.Decimal `bun:",notnull" json:"currentPeriodPeak"` CurrentPeriodPeak decimal.Decimal `bun:"type:numeric,notnull" json:"currentPeriodPeak"`
CurrentPeriodFlat decimal.Decimal `bun:",notnull" json:"currentPeriodFlat"` CurrentPeriodFlat decimal.Decimal `bun:"type:numeric,notnull" json:"currentPeriodFlat"`
CurrentPeriodValley decimal.Decimal `bun:",notnull" json:"currentPeriodValley"` CurrentPeriodValley decimal.Decimal `bun:"type:numeric,notnull" json:"currentPeriodValley"`
AdjustOverall decimal.Decimal `bun:",notnull" json:"adjustOverall"` AdjustOverall decimal.Decimal `bun:"type:numeric,notnull" json:"adjustOverall"`
AdjustCritical decimal.Decimal `bun:",notnull" json:"adjustCritical"` AdjustCritical decimal.Decimal `bun:"type:numeric,notnull" json:"adjustCritical"`
AdjustPeak decimal.Decimal `bun:",notnull" json:"adjustPeak"` AdjustPeak decimal.Decimal `bun:"type:numeric,notnull" json:"adjustPeak"`
AdjustFlat decimal.Decimal `bun:",notnull" json:"adjustFlat"` AdjustFlat decimal.Decimal `bun:"type:numeric,notnull" json:"adjustFlat"`
AdjustValley decimal.Decimal `bun:",notnull" json:"adjustValley"` AdjustValley decimal.Decimal `bun:"type:numeric,notnull" json:"adjustValley"`
Overall decimal.NullDecimal `json:"overall"` Overall decimal.NullDecimal `bun:"type:numeric" json:"overall"`
OverallFee decimal.NullDecimal `json:"overallFee"` OverallFee decimal.NullDecimal `bun:"type:numeric" json:"overallFee"`
OverallProportion decimal.Decimal `bun:",notnull" json:"-"` OverallProportion decimal.Decimal `bun:"type:numeric,notnull" json:"-"`
Critical decimal.NullDecimal `json:"critical"` Critical decimal.NullDecimal `bun:"type:numeric" json:"critical"`
CriticalFee decimal.NullDecimal `json:"criticalFee"` CriticalFee decimal.NullDecimal `bun:"type:numeric" json:"criticalFee"`
Peak decimal.NullDecimal `json:"peak"` Peak decimal.NullDecimal `bun:"type:numeric" json:"peak"`
PeakFee decimal.NullDecimal `json:"peakFee"` PeakFee decimal.NullDecimal `bun:"type:numeric" json:"peakFee"`
Flat decimal.NullDecimal `json:"flat"` Flat decimal.NullDecimal `bun:"type:numeric" json:"flat"`
FlatFee decimal.NullDecimal `json:"flatFee"` FlatFee decimal.NullDecimal `bun:"type:numeric" json:"flatFee"`
Valley decimal.NullDecimal `json:"valley"` Valley decimal.NullDecimal `bun:"type:numeric" json:"valley"`
ValleyFee decimal.NullDecimal `json:"valleyFee"` ValleyFee decimal.NullDecimal `bun:"type:numeric" json:"valleyFee"`
BasicFeeDiluted decimal.NullDecimal `json:"basicFeeDiluted"` BasicFeeDiluted decimal.NullDecimal `bun:"type:numeric" json:"basicFeeDiluted"`
AdjustFeeDiluted decimal.NullDecimal `json:"adjustFeeDiluted"` AdjustFeeDiluted decimal.NullDecimal `bun:"type:numeric" json:"adjustFeeDiluted"`
LossDiluted decimal.NullDecimal `json:"lossDiluted"` LossDiluted decimal.NullDecimal `bun:"type:numeric" json:"lossDiluted"`
LossFeeDiluted decimal.NullDecimal `json:"lossFeeDiluted"` LossFeeDiluted decimal.NullDecimal `bun:"type:numeric" json:"lossFeeDiluted"`
MaintenanceFeeDiluted decimal.NullDecimal `json:"maintenanceFeeDiluted"` MaintenanceFeeDiluted decimal.NullDecimal `bun:"type:numeric" json:"maintenanceFeeDiluted"`
PublicConsumptionDiluted decimal.NullDecimal `json:"publicConsumptionDiluted"` PublicConsumptionDiluted decimal.NullDecimal `bun:"type:numeric" json:"publicConsumptionDiluted"`
FinalDiluted decimal.NullDecimal `json:"finalDiluted"` FinalDiluted decimal.NullDecimal `bun:"type:numeric" json:"finalDiluted"`
FinalCharge decimal.NullDecimal `json:"finalCharge"` FinalCharge decimal.NullDecimal `bun:"type:numeric" json:"finalCharge"`
Initialize bool `bun:"-" json:"-"` Initialize bool `bun:"-" json:"-"`
Origin *Meter04KV `bun:"rel:belongs-to,join:park_id=park_id,join:meter_04kv_id=code" json:"-"` Origin *Meter04KV `bun:"rel:belongs-to,join:park_id=park_id,join:meter_04kv_id=code" json:"-"`
} }

View File

@ -15,7 +15,7 @@ type MaintenanceFee struct {
Id string `bun:",pk,notnull" json:"id"` Id string `bun:",pk,notnull" json:"id"`
ParkId string `bun:",notnull" json:"parkId"` ParkId string `bun:",notnull" json:"parkId"`
Name string `bun:",notnull" json:"name"` Name string `bun:",notnull" json:"name"`
Fee decimal.Decimal `bun:",notnull" json:"fee"` Fee decimal.Decimal `bun:"type:numeric,notnull" json:"fee"`
Memo *string `bun:"type:text" json:"memo"` Memo *string `bun:"type:text" json:"memo"`
Enabled bool `bun:",notnull" json:"enabled"` Enabled bool `bun:",notnull" json:"enabled"`
} }

View File

@ -17,7 +17,7 @@ type Meter04KV struct {
CustomerName *string `json:"customerName" excel:"name"` CustomerName *string `json:"customerName" excel:"name"`
ContactName *string `json:"contactName" excel:"contact"` ContactName *string `json:"contactName" excel:"contact"`
ContactPhone *string `json:"contactPhone" excel:"phone"` ContactPhone *string `json:"contactPhone" excel:"phone"`
Ratio decimal.Decimal `bun:",notnull" json:"ratio" excel:"ratio"` Ratio decimal.Decimal `bun:"type:numeric,notnull" json:"ratio" excel:"ratio"`
Seq int64 `bun:"type:bigint,notnull" json:"seq" excel:"seq"` Seq int64 `bun:"type:bigint,notnull" json:"seq" excel:"seq"`
IsPublicMeter bool `bun:"public_meter,notnull" json:"isPublicMeter" excel:"public"` IsPublicMeter bool `bun:"public_meter,notnull" json:"isPublicMeter" excel:"public"`
WillDilute bool `bun:"dilute,notnull" json:"willDilute" excel:"dilute"` WillDilute bool `bun:"dilute,notnull" json:"willDilute" excel:"dilute"`

View File

@ -28,9 +28,9 @@ type Park struct {
UserId string `bun:",notnull" json:"userId"` UserId string `bun:",notnull" json:"userId"`
Name string `bun:",notnull" json:"name"` Name string `bun:",notnull" json:"name"`
Abbr *string `json:"abbr"` Abbr *string `json:"abbr"`
Area decimal.NullDecimal `json:"area"` Area decimal.NullDecimal `bun:"type:numeric" json:"area"`
TenementQuantity decimal.NullDecimal `json:"tenement"` TenementQuantity decimal.NullDecimal `bun:"type:numeric" json:"tenement"`
Capacity decimal.NullDecimal `json:"capacity"` Capacity decimal.NullDecimal `bun:"type:numeric" json:"capacity"`
Category int8 `bun:"type:smallint,notnull" json:"category"` Category int8 `bun:"type:smallint,notnull" json:"category"`
SubmeterType int8 `bun:"meter_04kv_type,type:smallint,notnull" json:"meter04kvType"` SubmeterType int8 `bun:"meter_04kv_type,type:smallint,notnull" json:"meter04kvType"`
Region *string `json:"region"` Region *string `json:"region"`

View File

@ -10,55 +10,55 @@ import (
type ReportSummary struct { type ReportSummary struct {
bun.BaseModel `bun:"table:report_summary,alias:rs"` bun.BaseModel `bun:"table:report_summary,alias:rs"`
ReportId string `bun:",pk,notnull" json:"-"` ReportId string `bun:",pk,notnull" json:"-"`
Overall decimal.Decimal `bun:",notnull" json:"overall"` Overall decimal.Decimal `bun:"type:numeric,notnull" json:"overall"`
OverallFee decimal.Decimal `bun:",notnull" json:"overallFee"` OverallFee decimal.Decimal `bun:"type:numeric,notnull" json:"overallFee"`
ConsumptionFee decimal.NullDecimal `json:"consumptionFee"` ConsumptionFee decimal.NullDecimal `bun:"type:numeric" json:"consumptionFee"`
OverallPrice decimal.NullDecimal `json:"overallPrice"` OverallPrice decimal.NullDecimal `bun:"type:numeric" json:"overallPrice"`
Critical decimal.Decimal `bun:",notnull" json:"critical"` Critical decimal.Decimal `bun:"type:numeric,notnull" json:"critical"`
CriticalFee decimal.Decimal `bun:",notnull" json:"criticalFee"` CriticalFee decimal.Decimal `bun:"type:numeric,notnull" json:"criticalFee"`
CriticalPrice decimal.NullDecimal `json:"criticalPrice"` CriticalPrice decimal.NullDecimal `bun:"type:numeric" json:"criticalPrice"`
Peak decimal.Decimal `bun:",notnull" json:"peak"` Peak decimal.Decimal `bun:"type:numeric,notnull" json:"peak"`
PeakFee decimal.Decimal `bun:",notnull" json:"peakFee"` PeakFee decimal.Decimal `bun:"type:numeric,notnull" json:"peakFee"`
PeakPrice decimal.NullDecimal `json:"peakPrice"` PeakPrice decimal.NullDecimal `bun:"type:numeric" json:"peakPrice"`
Flat decimal.Decimal `bun:",notnull" json:"flat"` Flat decimal.Decimal `bun:"type:numeric,notnull" json:"flat"`
FlatFee decimal.Decimal `bun:",notnull" json:"flatFee"` FlatFee decimal.Decimal `bun:"type:numeric,notnull" json:"flatFee"`
FlatPrice decimal.NullDecimal `json:"flatPrice"` FlatPrice decimal.NullDecimal `bun:"type:numeric" json:"flatPrice"`
Valley decimal.Decimal `bun:",notnull" json:"valley"` Valley decimal.Decimal `bun:"type:numeric,notnull" json:"valley"`
ValleyFee decimal.Decimal `bun:",notnull" json:"valleyFee"` ValleyFee decimal.Decimal `bun:"type:numeric,notnull" json:"valleyFee"`
ValleyPrice decimal.NullDecimal `json:"valleyPrice"` ValleyPrice decimal.NullDecimal `bun:"type:numeric" json:"valleyPrice"`
Loss decimal.NullDecimal `json:"loss"` Loss decimal.NullDecimal `bun:"type:numeric" json:"loss"`
LossFee decimal.NullDecimal `json:"lossFee"` LossFee decimal.NullDecimal `bun:"type:numeric" json:"lossFee"`
LossProportion decimal.NullDecimal `json:"lossProportion"` LossProportion decimal.NullDecimal `bun:"type:numeric" json:"lossProportion"`
CustomerConsumption decimal.NullDecimal `json:"customerConsumption"` CustomerConsumption decimal.NullDecimal `bun:"type:numeric" json:"customerConsumption"`
CustomerConsumptionFee decimal.NullDecimal `json:"customerConsumptionFee"` CustomerConsumptionFee decimal.NullDecimal `bun:"type:numeric" json:"customerConsumptionFee"`
CustomerConsumptionCritical decimal.NullDecimal `json:"customerConsumptionCritical"` CustomerConsumptionCritical decimal.NullDecimal `bun:"type:numeric" json:"customerConsumptionCritical"`
CustomerConsumptionCriticalFee decimal.NullDecimal `json:"customerConsumptionCriticalFee"` CustomerConsumptionCriticalFee decimal.NullDecimal `bun:"type:numeric" json:"customerConsumptionCriticalFee"`
CustomerConsumptionPeak decimal.NullDecimal `json:"customerConsumptionPeak"` CustomerConsumptionPeak decimal.NullDecimal `bun:"type:numeric" json:"customerConsumptionPeak"`
CustomerConsumptionPeakFee decimal.NullDecimal `json:"customerConsumptionPeakFee"` CustomerConsumptionPeakFee decimal.NullDecimal `bun:"type:numeric" json:"customerConsumptionPeakFee"`
CustomerConsumptionFlat decimal.NullDecimal `json:"customerConsumptionFlat"` CustomerConsumptionFlat decimal.NullDecimal `bun:"type:numeric" json:"customerConsumptionFlat"`
CustomerConsumptionFlatFee decimal.NullDecimal `json:"customerConsumptionFlatFee"` CustomerConsumptionFlatFee decimal.NullDecimal `bun:"type:numeric" json:"customerConsumptionFlatFee"`
CustomerConsumptionValley decimal.NullDecimal `json:"customerConsumptionValley"` CustomerConsumptionValley decimal.NullDecimal `bun:"type:numeric" json:"customerConsumptionValley"`
CustomerConsumptionValleyFee decimal.NullDecimal `json:"customerConsumptionValleyFee"` CustomerConsumptionValleyFee decimal.NullDecimal `bun:"type:numeric" json:"customerConsumptionValleyFee"`
PublicConsumption decimal.NullDecimal `json:"publicConsumption"` PublicConsumption decimal.NullDecimal `bun:"type:numeric" json:"publicConsumption"`
PublicConsumptionFee decimal.NullDecimal `json:"publicConsumptionFee"` PublicConsumptionFee decimal.NullDecimal `bun:"type:numeric" json:"publicConsumptionFee"`
PublicConsumptionProportion decimal.NullDecimal `json:"publicConsumptionProportion"` PublicConsumptionProportion decimal.NullDecimal `bun:"type:numeric" json:"publicConsumptionProportion"`
PublicConsumptionCritical decimal.NullDecimal `json:"publicConsumptionCritical"` PublicConsumptionCritical decimal.NullDecimal `bun:"type:numeric" json:"publicConsumptionCritical"`
PublicConsumptionCriticalFee decimal.NullDecimal `json:"publicConsumptionCriticalFee"` PublicConsumptionCriticalFee decimal.NullDecimal `bun:"type:numeric" json:"publicConsumptionCriticalFee"`
PublicConsumptionPeak decimal.NullDecimal `json:"publicConsumptionPeak"` PublicConsumptionPeak decimal.NullDecimal `bun:"type:numeric" json:"publicConsumptionPeak"`
PublicConsumptionPeakFee decimal.NullDecimal `json:"publicConsumptionPeakFee"` PublicConsumptionPeakFee decimal.NullDecimal `bun:"type:numeric" json:"publicConsumptionPeakFee"`
PublicConsumptionFlat decimal.NullDecimal `json:"publicConsumptionFlat"` PublicConsumptionFlat decimal.NullDecimal `bun:"type:numeric" json:"publicConsumptionFlat"`
PublicConsumptionFlatFee decimal.NullDecimal `json:"publicConsumptionFlatFee"` PublicConsumptionFlatFee decimal.NullDecimal `bun:"type:numeric" json:"publicConsumptionFlatFee"`
PublicConsumptionValley decimal.NullDecimal `json:"publicConsumptionValley"` PublicConsumptionValley decimal.NullDecimal `bun:"type:numeric" json:"publicConsumptionValley"`
PublicConsumptionValleyFee decimal.NullDecimal `json:"publicConsumptionValleyFee"` PublicConsumptionValleyFee decimal.NullDecimal `bun:"type:numeric" json:"publicConsumptionValleyFee"`
BasicFee decimal.Decimal `bun:",notnull" json:"basicFee"` BasicFee decimal.Decimal `bun:"type:numeric,notnull" json:"basicFee"`
BasicDilutedPrice decimal.NullDecimal `json:"basicDilutedPrice"` BasicDilutedPrice decimal.NullDecimal `bun:"type:numeric" json:"basicDilutedPrice"`
AdjustFee decimal.Decimal `bun:",notnull" json:"adjustFee"` AdjustFee decimal.Decimal `bun:"type:numeric,notnull" json:"adjustFee"`
AdjustDilutedPrice decimal.NullDecimal `json:"adjustDilutedPrice"` AdjustDilutedPrice decimal.NullDecimal `bun:"type:numeric" json:"adjustDilutedPrice"`
MaintenanceDilutedPrice decimal.NullDecimal `json:"maintencanceDilutedPrice"` MaintenanceDilutedPrice decimal.NullDecimal `bun:"type:numeric" json:"maintencanceDilutedPrice"`
LossDilutedPrice decimal.NullDecimal `json:"lossDilutedPrice"` LossDilutedPrice decimal.NullDecimal `bun:"type:numeric" json:"lossDilutedPrice"`
PublicConsumptionDilutedPrice decimal.NullDecimal `json:"publicConsumptionDilutedPrice"` PublicConsumptionDilutedPrice decimal.NullDecimal `bun:"type:numeric" json:"publicConsumptionDilutedPrice"`
MaintenanceOverall decimal.NullDecimal `json:"maintenanceOverall"` MaintenanceOverall decimal.NullDecimal `bun:"type:numeric" json:"maintenanceOverall"`
FinalDilutedOverall decimal.NullDecimal `json:"finalDilutedOverall"` FinalDilutedOverall decimal.NullDecimal `bun:"type:numeric" json:"finalDilutedOverall"`
} }
func (s ReportSummary) Validate() (bool, error) { func (s ReportSummary) Validate() (bool, error) {

View File

@ -13,9 +13,9 @@ type UserCharge struct {
Created `bun:"extend"` Created `bun:"extend"`
Seq int64 `bun:"type:bigint,pk,notnull,autoincrement" json:"seq"` Seq int64 `bun:"type:bigint,pk,notnull,autoincrement" json:"seq"`
UserId string `bun:",notnull" json:"userId"` UserId string `bun:",notnull" json:"userId"`
Fee decimal.NullDecimal `json:"fee"` Fee decimal.NullDecimal `bun:"type:numeric" json:"fee"`
Discount decimal.NullDecimal `json:"discount"` Discount decimal.NullDecimal `bun:"type:numeric" json:"discount"`
Amount decimal.NullDecimal `json:"amount"` Amount decimal.NullDecimal `bun:"type:numeric" json:"amount"`
ChargeTo Date `bun:"type:date,notnull" json:"chargeTo"` ChargeTo Date `bun:"type:date,notnull" json:"chargeTo"`
Settled bool `bun:",notnull" json:"settled"` Settled bool `bun:",notnull" json:"settled"`
SettledAt *time.Time `bun:"type:timestamptz" json:"settledAt" time_format:"simple_datetime" time_location:"shanghai"` SettledAt *time.Time `bun:"type:timestamptz" json:"settledAt" time_format:"simple_datetime" time_location:"shanghai"`

View File

@ -20,7 +20,7 @@ type UserDetail struct {
Address *string `json:"address"` Address *string `json:"address"`
Contact *string `json:"contact"` Contact *string `json:"contact"`
Phone *string `json:"phone"` Phone *string `json:"phone"`
UnitServiceFee decimal.Decimal `bun:",notnull" json:"unitServiceFee"` UnitServiceFee decimal.Decimal `bun:"type:numeric,notnull" json:"unitServiceFee"`
ServiceExpiration Date `bun:"type:date,notnull" json:"serviceExpiration"` ServiceExpiration Date `bun:"type:date,notnull" json:"serviceExpiration"`
} }

View File

@ -15,7 +15,7 @@ type WillDilutedFee struct {
ReportId string `bun:",notnull" json:"reportId"` ReportId string `bun:",notnull" json:"reportId"`
SourceId *string `json:"sourceId"` SourceId *string `json:"sourceId"`
Name string `bun:",notnull" json:"name"` Name string `bun:",notnull" json:"name"`
Fee decimal.Decimal `bun:",notnull" json:"fee"` Fee decimal.Decimal `bun:"type:numeric,notnull" json:"fee"`
Memo *string `bun:"type:text" json:"memo"` Memo *string `bun:"type:text" json:"memo"`
Origin *MaintenanceFee `bun:"rel:belongs-to,join:source_id=id"` Origin *MaintenanceFee `bun:"rel:belongs-to,join:source_id=id"`
} }

View File

@ -154,7 +154,7 @@ func (_EndUserService) newVirtualExcelAnalysisError(err error) *excel.ExcelAnaly
} }
func (es _EndUserService) BatchImportNonPVRegister(reportId string, file io.Reader) *exceptions.BatchError { func (es _EndUserService) BatchImportNonPVRegister(reportId string, file io.Reader) *exceptions.BatchError {
ctx, cancel := global.TimeoutContext() ctx, cancel := global.TimeoutContext(120)
defer cancel() defer cancel()
errs := exceptions.NewBatchError() errs := exceptions.NewBatchError()
@ -255,7 +255,7 @@ func (es _EndUserService) BatchImportNonPVRegister(reportId string, file io.Read
} }
func (es _EndUserService) BatchImportPVRegister(reportId string, file io.Reader) *exceptions.BatchError { func (es _EndUserService) BatchImportPVRegister(reportId string, file io.Reader) *exceptions.BatchError {
ctx, cancel := global.TimeoutContext() ctx, cancel := global.TimeoutContext(120)
defer cancel() defer cancel()
errs := exceptions.NewBatchError() errs := exceptions.NewBatchError()