refactor(model):基本完成对于数据实体模型的迁移。
This commit is contained in:
parent
9380879ab5
commit
ae6e6490b2
|
@ -4,60 +4,59 @@ import (
|
|||
"errors"
|
||||
|
||||
"github.com/shopspring/decimal"
|
||||
"github.com/uptrace/bun"
|
||||
)
|
||||
|
||||
type EndUserDetail struct {
|
||||
CreatedAndModified `xorm:"extends"`
|
||||
ReportId string `xorm:"varchar(120) pk not null" json:"reportId"`
|
||||
ParkId string `xorm:"varchar(120) pk not null" json:"parkId"`
|
||||
MeterId string `xorm:"meter_04kv_id varchar(120) pk not null" json:"meterId"`
|
||||
Seq int64 `xorm:"bigint not null default 0" json:"seq"`
|
||||
Ratio decimal.Decimal `xorm:"numeric(8,4) not null default 1" json:"ratio"`
|
||||
Address *string `xorm:"varchar(100)" json:"address"`
|
||||
CustomerName *string `xorm:"varchar(100)" json:"customerName"`
|
||||
ContactName *string `xorm:"varchar(70)" json:"contactName"`
|
||||
ContactPhone *string `xorm:"varchar(50)" json:"contactPhone"`
|
||||
IsPublicMeter bool `xorm:"'public_meter' bool not null default false" json:"isPublicMeter"`
|
||||
WillDilute bool `xorm:"'dilute' bool not null default false" json:"willDilute"`
|
||||
LastPeriodOverall decimal.Decimal `xorm:"numeric(14,2) not null default 0" json:"lastPeriodOverall"`
|
||||
LastPeriodCritical decimal.Decimal `xorm:"numeric(14,2) not null default 0" json:"lastPeriodCritical"`
|
||||
LastPeriodPeak decimal.Decimal `xorm:"numeric(14,2) not null default 0" json:"lastPeriodPeak"`
|
||||
LastPeriodFlat decimal.Decimal `xorm:"numeric(14,2) not null default 0" json:"lastPeriodFlat"`
|
||||
LastPeriodValley decimal.Decimal `xorm:"numeric(14,2) not null default 0" json:"lastPeriodValley"`
|
||||
CurrentPeriodOverall decimal.Decimal `xorm:"numeric(14,2) not null default 0" json:"currentPeriodOverall"`
|
||||
CurrentPeriodCritical decimal.Decimal `xorm:"numeric(14,2) not null default 0" json:"currentPeriodCritical"`
|
||||
CurrentPeriodPeak decimal.Decimal `xorm:"numeric(14,2) not null default 0" json:"currentPeriodPeak"`
|
||||
CurrentPeriodFlat decimal.Decimal `xorm:"numeric(14,2) not null default 0" json:"currentPeriodFlat"`
|
||||
CurrentPeriodValley decimal.Decimal `xorm:"numeric(14,2) not null default 0" json:"currentPeriodValley"`
|
||||
AdjustOverall decimal.Decimal `xorm:"numeric(14,2) not null default 0" json:"adjustOverall"`
|
||||
AdjustCritical decimal.Decimal `xorm:"numeric(14,2) not null default 0" json:"adjustCritical"`
|
||||
AdjustPeak decimal.Decimal `xorm:"numeric(14,2) not null default 0" json:"adjustPeak"`
|
||||
AdjustFlat decimal.Decimal `xorm:"numeric(14,2) not null default 0" json:"adjustFlat"`
|
||||
AdjustValley decimal.Decimal `xorm:"numeric(14,2) not null default 0" json:"adjustValley"`
|
||||
Overall decimal.NullDecimal `xorm:"numeric(14,2)" json:"overall"`
|
||||
OverallFee decimal.NullDecimal `xorm:"numeric(14,2)" json:"overallFee"`
|
||||
OverallProportion decimal.Decimal `xorm:"numeric(16,15) not null default 0" json:"-"`
|
||||
Critical decimal.NullDecimal `xorm:"numeric(14,2)" json:"critical"`
|
||||
CriticalFee decimal.NullDecimal `xorm:"numeric(18,8)" json:"criticalFee"`
|
||||
Peak decimal.NullDecimal `xorm:"numeric(14,2)" json:"peak"`
|
||||
PeakFee decimal.NullDecimal `xorm:"numeric(18,8)" json:"peakFee"`
|
||||
Flat decimal.NullDecimal `xorm:"numeric(14,2)" json:"flat"`
|
||||
FlatFee decimal.NullDecimal `xorm:"numeric(18,8)" json:"flatFee"`
|
||||
Valley decimal.NullDecimal `xorm:"numeric(14,2)" json:"valley"`
|
||||
ValleyFee decimal.NullDecimal `xorm:"numeric(18,8)" json:"valleyFee"`
|
||||
BasicFeeDiluted decimal.NullDecimal `xorm:"numeric(18,8)" json:"basicFeeDiluted"`
|
||||
AdjustFeeDiluted decimal.NullDecimal `xorm:"numeric(18,8)" json:"adjustFeeDiluted"`
|
||||
LossDiluted decimal.NullDecimal `xorm:"numeric(18,8)" json:"lossDiluted"`
|
||||
LossFeeDiluted decimal.NullDecimal `xorm:"numeric(18,8)" json:"lossFeeDiluted"`
|
||||
MaintenanceFeeDiluted decimal.NullDecimal `xorm:"numeric(18,8)" json:"maintenanceFeeDiluted"`
|
||||
PublicConsumptionDiluted decimal.NullDecimal `xorm:"numeric(18,8)" json:"publicConsumptionDiluted"`
|
||||
FinalDiluted decimal.NullDecimal `xorm:"numeric(14,2)" json:"finalDiluted"`
|
||||
FinalCharge decimal.NullDecimal `xorm:"numeric(14,2)" json:"finalCharge"`
|
||||
Initialize bool `xorm:"-" json:"-"`
|
||||
}
|
||||
|
||||
func (EndUserDetail) TableName() string {
|
||||
return "end_user_detail"
|
||||
bun.BaseModel `bun:"table:end_user_detail,alias:eud"`
|
||||
CreatedAndModified `bun:",extend"`
|
||||
ReportId string `bun:",pk,notnull" json:"reportId"`
|
||||
ParkId string `bun:",pk,notnull" json:"parkId"`
|
||||
MeterId string `bun:"meter_04kv_id,pk,notnull" json:"meterId"`
|
||||
Seq int64 `bun:"type:bigint,notnull,default:0" json:"seq"`
|
||||
Ratio decimal.Decimal `bun:",notnull,default:1" json:"ratio"`
|
||||
Address *string `json:"address"`
|
||||
CustomerName *string `json:"customerName"`
|
||||
ContactName *string `json:"contactName"`
|
||||
ContactPhone *string `json:"contactPhone"`
|
||||
IsPublicMeter bool `bun:"public_meter,notnull,default:false" json:"isPublicMeter"`
|
||||
WillDilute bool `bun:"dilute,notnull,default:false" json:"willDilute"`
|
||||
LastPeriodOverall decimal.Decimal `bun:",notnull,default:0" json:"lastPeriodOverall"`
|
||||
LastPeriodCritical decimal.Decimal `bun:",notnull,default:0" json:"lastPeriodCritical"`
|
||||
LastPeriodPeak decimal.Decimal `bun:",notnull,default:0" json:"lastPeriodPeak"`
|
||||
LastPeriodFlat decimal.Decimal `bun:",notnull,default:0" json:"lastPeriodFlat"`
|
||||
LastPeriodValley decimal.Decimal `bun:",notnull,default:0" json:"lastPeriodValley"`
|
||||
CurrentPeriodOverall decimal.Decimal `bun:",notnull,default:0" json:"currentPeriodOverall"`
|
||||
CurrentPeriodCritical decimal.Decimal `bun:",notnull,default:0" json:"currentPeriodCritical"`
|
||||
CurrentPeriodPeak decimal.Decimal `bun:",notnull,default:0" json:"currentPeriodPeak"`
|
||||
CurrentPeriodFlat decimal.Decimal `bun:",notnull,default:0" json:"currentPeriodFlat"`
|
||||
CurrentPeriodValley decimal.Decimal `bun:",notnull,default:0" json:"currentPeriodValley"`
|
||||
AdjustOverall decimal.Decimal `bun:",notnull,default:0" json:"adjustOverall"`
|
||||
AdjustCritical decimal.Decimal `bun:",notnull,default:0" json:"adjustCritical"`
|
||||
AdjustPeak decimal.Decimal `bun:",notnull,default:0" json:"adjustPeak"`
|
||||
AdjustFlat decimal.Decimal `bun:",notnull,default:0" json:"adjustFlat"`
|
||||
AdjustValley decimal.Decimal `bun:",notnull,default:0" json:"adjustValley"`
|
||||
Overall decimal.NullDecimal `json:"overall"`
|
||||
OverallFee decimal.NullDecimal `json:"overallFee"`
|
||||
OverallProportion decimal.Decimal `bun:",notnull,default:0" json:"-"`
|
||||
Critical decimal.NullDecimal `json:"critical"`
|
||||
CriticalFee decimal.NullDecimal `json:"criticalFee"`
|
||||
Peak decimal.NullDecimal `json:"peak"`
|
||||
PeakFee decimal.NullDecimal `json:"peakFee"`
|
||||
Flat decimal.NullDecimal `json:"flat"`
|
||||
FlatFee decimal.NullDecimal `json:"flatFee"`
|
||||
Valley decimal.NullDecimal `json:"valley"`
|
||||
ValleyFee decimal.NullDecimal `json:"valleyFee"`
|
||||
BasicFeeDiluted decimal.NullDecimal `json:"basicFeeDiluted"`
|
||||
AdjustFeeDiluted decimal.NullDecimal `json:"adjustFeeDiluted"`
|
||||
LossDiluted decimal.NullDecimal `json:"lossDiluted"`
|
||||
LossFeeDiluted decimal.NullDecimal `json:"lossFeeDiluted"`
|
||||
MaintenanceFeeDiluted decimal.NullDecimal `json:"maintenanceFeeDiluted"`
|
||||
PublicConsumptionDiluted decimal.NullDecimal `json:"publicConsumptionDiluted"`
|
||||
FinalDiluted decimal.NullDecimal `json:"finalDiluted"`
|
||||
FinalCharge decimal.NullDecimal `json:"finalCharge"`
|
||||
Initialize bool `bun:"-" json:"-"`
|
||||
Origin *Meter04KV `bun:"rel:belongs-to,join:park_id=park_id,join:meter_04kv_id=code"`
|
||||
}
|
||||
|
||||
func (d EndUserDetail) Validate() (bool, error) {
|
||||
|
|
|
@ -2,19 +2,17 @@ package model
|
|||
|
||||
import (
|
||||
"github.com/shopspring/decimal"
|
||||
"github.com/uptrace/bun"
|
||||
)
|
||||
|
||||
type MaintenanceFee struct {
|
||||
CreatedAndModified `xorm:"extends"`
|
||||
Deleted `xorm:"extends"`
|
||||
Id string `xorm:"varchar(120) pk not null" json:"id"`
|
||||
ParkId string `xorm:"varchar(120) not null" json:"parkId"`
|
||||
Name string `xorm:"varchar(50) not null" json:"name"`
|
||||
Fee decimal.Decimal `xorm:"numeric(8,2) not null" json:"fee"`
|
||||
Memo *string `xorm:"text" json:"memo"`
|
||||
Enabled bool `xorm:"bool not null" json:"enabled"`
|
||||
}
|
||||
|
||||
func (MaintenanceFee) TableName() string {
|
||||
return "maintenance_fee"
|
||||
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"`
|
||||
Fee decimal.Decimal `bun:",notnull" json:"fee"`
|
||||
Memo *string `bun:"type:text" json:"memo"`
|
||||
Enabled bool `bun:",notnull" json:"enabled"`
|
||||
}
|
||||
|
|
|
@ -2,23 +2,22 @@ package model
|
|||
|
||||
import (
|
||||
"github.com/shopspring/decimal"
|
||||
"github.com/uptrace/bun"
|
||||
)
|
||||
|
||||
type Meter04KV struct {
|
||||
CreatedAndModified `xorm:"extends"`
|
||||
Code string `xorm:"varchar(120) pk not null" json:"code" excel:"code"`
|
||||
ParkId string `xorm:"varchar(120) pk not null" json:"parkId"`
|
||||
Address *string `xorm:"varchar(100)" json:"address" excel:"address"`
|
||||
CustomerName *string `xorm:"varchar(100)" json:"customerName" excel:"name"`
|
||||
ContactName *string `xorm:"varchar(70)" json:"contactName" excel:"contact"`
|
||||
ContactPhone *string `xorm:"varchar(50)" json:"contactPhone" excel:"phone"`
|
||||
Ratio decimal.Decimal `xorm:"numeric(8,4) not null default 1" json:"ratio" excel:"ratio"`
|
||||
Seq int64 `xorm:"bigint not null" json:"seq" excel:"seq"`
|
||||
IsPublicMeter bool `xorm:"'public_meter' bool not null default false" json:"isPublicMeter" excel:"public"`
|
||||
WillDilute bool `xorm:"'dilute' bool not null default false" json:"willDilute" excel:"dilute"`
|
||||
Enabled bool `xorm:"bool not null default true" json:"enabled"`
|
||||
}
|
||||
|
||||
func (Meter04KV) TableName() string {
|
||||
return "meter_04kv"
|
||||
bun.BaseModel `bun:"table:meter_04kv,alias:mt"`
|
||||
CreatedAndModified `bun:",extend"`
|
||||
Code string `bun:",pk,notnull" json:"code" excel:"code"`
|
||||
ParkId string `bun:",pk,notnull" json:"parkId"`
|
||||
Address *string `json:"address" excel:"address"`
|
||||
CustomerName *string `json:"customerName" excel:"name"`
|
||||
ContactName *string `json:"contactName" excel:"contact"`
|
||||
ContactPhone *string `json:"contactPhone" excel:"phone"`
|
||||
Ratio decimal.Decimal `bun:",notnull,default:1" json:"ratio" excel:"ratio"`
|
||||
Seq int64 `bun:"type:bigint,notnull" json:"seq" excel:"seq"`
|
||||
IsPublicMeter bool `bun:"public_meter,notnull,default:false" json:"isPublicMeter" excel:"public"`
|
||||
WillDilute bool `bun:"dilute,notnull,default:false" json:"willDilute" excel:"dilute"`
|
||||
Enabled bool `bun:",notnull,default:true" json:"enabled"`
|
||||
ParkDetail *Park `bun:"rel:belongs-to,join:park_id=id" json:"-"`
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/shopspring/decimal"
|
||||
"github.com/uptrace/bun"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -18,50 +19,48 @@ const (
|
|||
)
|
||||
|
||||
type Park struct {
|
||||
CreatedAndModified `xorm:"extends"`
|
||||
Deleted `xorm:"extends"`
|
||||
Id string `xorm:"varchar(120) pk not null" json:"id"`
|
||||
UserId string `xorm:"varchar(120) not null" json:"userId"`
|
||||
Name string `xorm:"varchar(70) not null" json:"name"`
|
||||
Abbr *string `xorm:"varchar(50)" json:"abbr"`
|
||||
Area decimal.NullDecimal `xorm:"numeric(14,2)" json:"area"`
|
||||
TenementQuantity decimal.NullDecimal `xorm:"numeric(8,0)" json:"tenement"`
|
||||
Capacity decimal.NullDecimal `xorm:"numeric(16,2)" json:"capacity"`
|
||||
Category int8 `xorm:"smallint not null default 0" json:"category"`
|
||||
SubmeterType int8 `xorm:"'meter_04kv_type' smallint not null default 0" json:"meter04kvType"`
|
||||
Region *string `xorm:"varchar(10)" json:"region"`
|
||||
Address *string `xorm:"varchar(120)" json:"address"`
|
||||
Contact *string `xorm:"varchar(100)" json:"contact"`
|
||||
Phone *string `xorm:"varchar(50)" json:"phone"`
|
||||
Enabled bool `xorm:"bool not null" json:"enabled"`
|
||||
}
|
||||
|
||||
func (Park) TableName() string {
|
||||
return "park"
|
||||
bun.BaseModel `bun:"table:park,alias:p"`
|
||||
CreatedAndModified `bun:",extend"`
|
||||
Deleted `bun:",extend"`
|
||||
Id string `bun:",pk,notnull" json:"id"`
|
||||
UserId string `bun:",notnull" json:"userId"`
|
||||
Name string `bun:",notnull" json:"name"`
|
||||
Abbr *string `json:"abbr"`
|
||||
Area decimal.NullDecimal `json:"area"`
|
||||
TenementQuantity decimal.NullDecimal `json:"tenement"`
|
||||
Capacity decimal.NullDecimal `json:"capacity"`
|
||||
Category int8 `bun:"type:smallint,notnull,default:0" json:"category"`
|
||||
SubmeterType int8 `bun:"meter_04kv_type,type:smallint,notnull,default:0" json:"meter04kvType"`
|
||||
Region *string `json:"region"`
|
||||
Address *string `json:"address"`
|
||||
Contact *string `json:"contact"`
|
||||
Phone *string `json:"phone"`
|
||||
Enabled bool `bun:",notnull" json:"enabled"`
|
||||
EnterpriseIndex *User `bun:"rel:belongs-to,join:user_id=id" json:"-"`
|
||||
Enterprise *UserDetail `bun:"rel:belongs-to,join:user_id=id" json:"-"`
|
||||
MaintenanceFees []*MaintenanceFee `bun:"rel:has-many,join:id=park_id" json:"-"`
|
||||
Meters []*Meter04KV `bun:"rel:has-many,join:id=park_id" json:"-"`
|
||||
}
|
||||
|
||||
type ParkSimplified struct {
|
||||
Id string `xorm:"varchar(120) pk not null" json:"id"`
|
||||
UserId string `xorm:"varchar(120) not null" json:"userId"`
|
||||
Name string `xorm:"varchar(70) not null" json:"name"`
|
||||
Abbr *string `xorm:"varchar(50)" json:"abbr"`
|
||||
Area decimal.NullDecimal `xorm:"numeric(14,2)" json:"area"`
|
||||
TenementQuantity decimal.NullDecimal `xorm:"numeric(8,0)" json:"tenement"`
|
||||
Capacity decimal.NullDecimal `xorm:"numeric(16,2)" json:"capacity"`
|
||||
Category int8 `xorm:"smallint not null" json:"category"`
|
||||
SubmeterType int8 `xorm:"'meter_04kv_type' smallint not null" json:"meter04kvType"`
|
||||
Region *string `xorm:"varchar(10)" json:"region"`
|
||||
Address *string `xorm:"varchar(120)" json:"address"`
|
||||
Contact *string `xorm:"varchar(100)" json:"contact"`
|
||||
Phone *string `xorm:"varchar(50)" json:"phone"`
|
||||
}
|
||||
|
||||
func (ParkSimplified) TableName() string {
|
||||
return "park"
|
||||
bun.BaseModel `bun:"table:park,alias:p"`
|
||||
Id string `bun:",pk,notnull" json:"id"`
|
||||
UserId string `bun:",notnull" json:"userId"`
|
||||
Name string `bun:",notnull" json:"name"`
|
||||
Abbr *string `json:"abbr"`
|
||||
Area decimal.NullDecimal `json:"area"`
|
||||
TenementQuantity decimal.NullDecimal `json:"tenement"`
|
||||
Capacity decimal.NullDecimal `json:"capacity"`
|
||||
Category int8 `bun:"type:smallint,notnull" json:"category"`
|
||||
SubmeterType int8 `bun:"meter_04kv_type,type:smallint,notnull" json:"meter04kvType"`
|
||||
Region *string `json:"region"`
|
||||
Address *string `json:"address"`
|
||||
Contact *string `json:"contact"`
|
||||
Phone *string `json:"phone"`
|
||||
}
|
||||
|
||||
type ParkPeriodStatistics struct {
|
||||
Id string `xorm:"varchar(120) not null" json:"id"`
|
||||
Name string `xorm:"varchar(120) not null" json:"name"`
|
||||
Period *time.Time `xorm:"date" json:"period" time_format:"simple_date" time_location:"shanghai"`
|
||||
Id string `bun:",notnull" json:"id"`
|
||||
Name string `bun:",notnull" json:"name"`
|
||||
Period *time.Time `bun:"type:date" json:"period" time_format:"simple_date" time_location:"shanghai"`
|
||||
}
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
package model
|
||||
|
||||
type Region struct {
|
||||
Code string `xorm:"varchar(15) pk not null" json:"code"`
|
||||
Name string `xorm:"varchar(50) not null" json:"name"`
|
||||
Level int `xorm:"int not null default 0" json:"level"`
|
||||
Parent string `xorm:"varchar(15) not null default '0'" json:"parent"`
|
||||
}
|
||||
import "github.com/uptrace/bun"
|
||||
|
||||
func (Region) TableName() string {
|
||||
return "region"
|
||||
type Region struct {
|
||||
bun.BaseModel `bun:"table:region,alias:r"`
|
||||
Code string `bun:",pk,notnull" json:"code"`
|
||||
Name string `bun:",notnull" json:"name"`
|
||||
Level int `bun:",notnull,default:0" json:"level"`
|
||||
Parent string `bun:",notnull,default:'0'" json:"parent"`
|
||||
}
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
package model
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/uptrace/bun"
|
||||
)
|
||||
|
||||
const (
|
||||
REPORT_NOT_WITHDRAW int8 = iota
|
||||
|
@ -10,18 +14,23 @@ const (
|
|||
)
|
||||
|
||||
type Report struct {
|
||||
CreatedAndModified `xorm:"extends"`
|
||||
Id string `xorm:"varchar(120) pk not null" json:"id"`
|
||||
ParkId string `xorm:"varchar(120) not null" json:"parkId"`
|
||||
Period time.Time `xorm:"date not null" json:"period" time_format:"simple_date" time_location:"shanghai"`
|
||||
Category int8 `xorm:"smallint not null default 0" json:"category"`
|
||||
SubmeterType int8 `xorm:"'meter_04kv_type' smallint not null default 0" json:"meter04kvType"`
|
||||
StepState Steps `xorm:"text not null json" json:"stepState"`
|
||||
Published bool `xorm:"bool not null default false" json:"published"`
|
||||
PublishedAt *time.Time `xorm:"timestampz" json:"publishedAt" time_format:"simple_datetime" time_location:"shanghai"`
|
||||
Withdraw int8 `xorm:"smallint not null default 0" json:"withdraw"`
|
||||
LastWithdrawAppliedAt *time.Time `xorm:"timestampz" json:"lastWithdrawAppliedAt" time_format:"simple_datetime" time_location:"shanghai"`
|
||||
LastWithdrawAuditAt *time.Time `xorm:"timestampz" json:"lastWithdrawAuditAt" time_format:"simple_datetime" time_location:"shanghai"`
|
||||
bun.BaseModel `bun:"table:report,alias:r"`
|
||||
CreatedAndModified `bun:"extends"`
|
||||
Id string `bun:",pk,notnull" json:"id"`
|
||||
ParkId string `bun:",notnull" json:"parkId"`
|
||||
Period time.Time `bun:"type:date,notnull" json:"period" time_format:"simple_date" time_location:"shanghai"`
|
||||
Category int8 `bun:"type:smallint,notnull,default:0" json:"category"`
|
||||
SubmeterType int8 `bun:"meter_04kv_type,type:smallint,notnull,default:0" json:"meter04kvType"`
|
||||
StepState Steps `bun:"type:jsonb,notnull" json:"stepState"`
|
||||
Published bool `bun:",notnull,default:false" json:"published"`
|
||||
PublishedAt *time.Time `bun:"type:timestamptz,nullzero" json:"publishedAt" time_format:"simple_datetime" time_location:"shanghai"`
|
||||
Withdraw int8 `bun:"type:smallint,notnull,default:0" json:"withdraw"`
|
||||
LastWithdrawAppliedAt *time.Time `bun:"type:timestamptz,nullzero" json:"lastWithdrawAppliedAt" time_format:"simple_datetime" time_location:"shanghai"`
|
||||
LastWithdrawAuditAt *time.Time `bun:"type:timestamptz,nullzero" json:"lastWithdrawAuditAt" time_format:"simple_datetime" time_location:"shanghai"`
|
||||
Park *Park `bun:"rel:belongs-to,join:park_id=id" json:"-"`
|
||||
Summary *ReportSummary `bun:"rel:has-one,join:id=report_id" json:"-"`
|
||||
WillDilutedFees []*WillDilutedFee `bun:"rel:has-many,join:id=report_id" json:"-"`
|
||||
EndUsers []*EndUserDetail `bun:"rel:has-many,join:id=report_id,join:park_id=park_id" json:"-"`
|
||||
}
|
||||
|
||||
type Steps struct {
|
||||
|
@ -33,10 +42,6 @@ type Steps struct {
|
|||
Publish bool `json:"publish"`
|
||||
}
|
||||
|
||||
func (Report) TableName() string {
|
||||
return "report"
|
||||
}
|
||||
|
||||
func NewSteps() Steps {
|
||||
return Steps{
|
||||
Summary: false,
|
||||
|
@ -49,12 +54,8 @@ func NewSteps() Steps {
|
|||
}
|
||||
|
||||
type ParkNewestReport struct {
|
||||
Park Park `xorm:"extends" json:"park"`
|
||||
Report *Report `xorm:"extends" json:"report"`
|
||||
}
|
||||
|
||||
func (ParkNewestReport) TableName() string {
|
||||
return "park"
|
||||
Park Park `bun:"extends" json:"park"`
|
||||
Report *Report `bun:"extends" json:"report"`
|
||||
}
|
||||
|
||||
func (p *ParkNewestReport) AfterLoad() {
|
||||
|
@ -64,27 +65,20 @@ func (p *ParkNewestReport) AfterLoad() {
|
|||
}
|
||||
|
||||
type ReportIndexSimplified struct {
|
||||
Id string `xorm:"varchar(120) pk not null" json:"id"`
|
||||
ParkId string `xorm:"varchar(120) not null" json:"parkId"`
|
||||
Period time.Time `xorm:"date not null" json:"period" time_format:"simple_date" time_location:"shanghai"`
|
||||
StepState Steps `xorm:"text not null json" json:"stepState"`
|
||||
Published bool `xorm:"bool not null default false" json:"published"`
|
||||
PublishedAt *time.Time `xorm:"timestampz" json:"publishedAt" time_format:"simple_datetime" time_location:"shanghai"`
|
||||
Withdraw int8 `xorm:"smallint not null default 0" json:"withdraw"`
|
||||
LastWithdrawAppliedAt *time.Time `xorm:"timestampz" json:"lastWithdrawAppliedAt" time_format:"simple_datetime" time_location:"shanghai"`
|
||||
LastWithdrawAuditAt *time.Time `xorm:"timestampz" json:"lastWithdrawAuditAt" time_format:"simple_datetime" time_location:"shanghai"`
|
||||
}
|
||||
|
||||
func (ReportIndexSimplified) TableName() string {
|
||||
return "report"
|
||||
bun.BaseModel `bun:"table:report,alias:r"`
|
||||
Id string `bun:",pk,notnull" json:"id"`
|
||||
ParkId string `bun:",notnull" json:"parkId"`
|
||||
Period time.Time `bun:"type:date,notnull" json:"period" time_format:"simple_date" time_location:"shanghai"`
|
||||
StepState Steps `bun:"type:jsonb,notnull" json:"stepState"`
|
||||
Published bool `bun:",notnull,default:false" json:"published"`
|
||||
PublishedAt *time.Time `bun:"type:timestampz" json:"publishedAt" time_format:"simple_datetime" time_location:"shanghai"`
|
||||
Withdraw int8 `bun:"type:smallint,notnull,default:0" json:"withdraw"`
|
||||
LastWithdrawAppliedAt *time.Time `bun:"type:timestamptz" json:"lastWithdrawAppliedAt" time_format:"simple_datetime" time_location:"shanghai"`
|
||||
LastWithdrawAuditAt *time.Time `bun:"type:timestamptz" json:"lastWithdrawAuditAt" time_format:"simple_datetime" time_location:"shanghai"`
|
||||
}
|
||||
|
||||
type JoinedReportForWithdraw struct {
|
||||
Report Report `xorm:"extends" json:"report"`
|
||||
Park ParkSimplified `xorm:"extends" json:"park"`
|
||||
User UserDetailSimplified `xorm:"extends" json:"user"`
|
||||
}
|
||||
|
||||
func (JoinedReportForWithdraw) TableName() string {
|
||||
return "report"
|
||||
Report Report `bun:"extends" json:"report"`
|
||||
Park ParkSimplified `bun:"extends" json:"park"`
|
||||
User UserDetailSimplified `bun:"extends" json:"user"`
|
||||
}
|
||||
|
|
|
@ -4,63 +4,61 @@ import (
|
|||
"errors"
|
||||
|
||||
"github.com/shopspring/decimal"
|
||||
"github.com/uptrace/bun"
|
||||
)
|
||||
|
||||
type ReportSummary struct {
|
||||
ReportId string `xorm:"varchar(120) pk not null" json:"-"`
|
||||
Overall decimal.Decimal `xorm:"numeric(14,2) not null default 0" json:"overall"`
|
||||
OverallFee decimal.Decimal `xorm:"numeric(14,2) not null default 0" json:"overallFee"`
|
||||
ConsumptionFee decimal.NullDecimal `xorm:"numeric(14,2)" json:"consumptionFee"`
|
||||
OverallPrice decimal.NullDecimal `xorm:"numeric(16,8)" json:"overallPrice"`
|
||||
Critical decimal.Decimal `xorm:"numeric(14,2) not null default 0" json:"critical"`
|
||||
CriticalFee decimal.Decimal `xorm:"numeric(14,2) not null default 0" json:"criticalFee"`
|
||||
CriticalPrice decimal.NullDecimal `xorm:"numeric(16,8)" json:"criticalPrice"`
|
||||
Peak decimal.Decimal `xorm:"numeric(14,2) not null default 0" json:"peak"`
|
||||
PeakFee decimal.Decimal `xorm:"numeric(14,2) not null default 0" json:"peakFee"`
|
||||
PeakPrice decimal.NullDecimal `xorm:"numeric(16,8)" json:"peakPrice"`
|
||||
Flat decimal.Decimal `xorm:"numeric(14,2) not null default 0" json:"flat"`
|
||||
FlatFee decimal.Decimal `xorm:"numeric(14,2) not null default 0" json:"flatFee"`
|
||||
FlatPrice decimal.NullDecimal `xorm:"numeric(16,8)" json:"flatPrice"`
|
||||
Valley decimal.Decimal `xorm:"numeric(14,2) not null default 0" json:"valley"`
|
||||
ValleyFee decimal.Decimal `xorm:"numeric(14,2) not null default 0" json:"valleyFee"`
|
||||
ValleyPrice decimal.NullDecimal `xorm:"numeric(16,8)" json:"valleyPrice"`
|
||||
Loss decimal.NullDecimal `xorm:"numeric(14,2)" json:"loss"`
|
||||
LossFee decimal.NullDecimal `xorm:"numeric(16,2)" json:"lossFee"`
|
||||
LossProportion decimal.NullDecimal `xorm:"numeric(16,15)" json:"lossProportion"`
|
||||
CustomerConsumption decimal.NullDecimal `xorm:"numeric(16,2)" json:"customerConsumption"`
|
||||
CustomerConsumptionFee decimal.NullDecimal `xorm:"numeric(14,2)" json:"customerConsumptionFee"`
|
||||
CustomerConsumptionCritical decimal.NullDecimal `xorm:"numeric(16,2)" json:"customerConsumptionCritical"`
|
||||
CustomerConsumptionCriticalFee decimal.NullDecimal `xorm:"numeric(14,2)" json:"customerConsumptionCriticalFee"`
|
||||
CustomerConsumptionPeak decimal.NullDecimal `xorm:"numeric(16,2)" json:"customerConsumptionPeak"`
|
||||
CustomerConsumptionPeakFee decimal.NullDecimal `xorm:"numeric(14,2)" json:"customerConsumptionPeakFee"`
|
||||
CustomerConsumptionFlat decimal.NullDecimal `xorm:"numeric(16,2)" json:"customerConsumptionFlat"`
|
||||
CustomerConsumptionFlatFee decimal.NullDecimal `xorm:"numeric(14,2)" json:"customerConsumptionFlatFee"`
|
||||
CustomerConsumptionValley decimal.NullDecimal `xorm:"numeric(16,2)" json:"customerConsumptionValley"`
|
||||
CustomerConsumptionValleyFee decimal.NullDecimal `xorm:"numeric(14,2)" json:"customerConsumptionValleyFee"`
|
||||
PublicConsumption decimal.NullDecimal `xorm:"numeric(14,2)" json:"publicConsumption"`
|
||||
PublicConsumptionFee decimal.NullDecimal `xorm:"numeric(14,2)" json:"publicConsumptionFee"`
|
||||
PublicConsumptionProportion decimal.NullDecimal `xorm:"numeric(16,15)" json:"publicConsumptionProportion"`
|
||||
PublicConsumptionCritical decimal.NullDecimal `xorm:"numeric(16,2)" json:"publicConsumptionCritical"`
|
||||
PublicConsumptionCriticalFee decimal.NullDecimal `xorm:"numeric(14,2)" json:"publicConsumptionCriticalFee"`
|
||||
PublicConsumptionPeak decimal.NullDecimal `xorm:"numeric(16,2)" json:"publicConsumptionPeak"`
|
||||
PublicConsumptionPeakFee decimal.NullDecimal `xorm:"numeric(14,2)" json:"publicConsumptionPeakFee"`
|
||||
PublicConsumptionFlat decimal.NullDecimal `xorm:"numeric(16,2)" json:"publicConsumptionFlat"`
|
||||
PublicConsumptionFlatFee decimal.NullDecimal `xorm:"numeric(14,2)" json:"publicConsumptionFlatFee"`
|
||||
PublicConsumptionValley decimal.NullDecimal `xorm:"numeric(16,2)" json:"publicConsumptionValley"`
|
||||
PublicConsumptionValleyFee decimal.NullDecimal `xorm:"numeric(14,2)" json:"publicConsumptionValleyFee"`
|
||||
BasicFee decimal.Decimal `xorm:"numeric(14,2) not null default 0" json:"basicFee"`
|
||||
BasicDilutedPrice decimal.NullDecimal `xorm:"numeric(18,8)" json:"basicDilutedPrice"`
|
||||
AdjustFee decimal.Decimal `xorm:"numeric(14,2) not null default 0" json:"adjustFee"`
|
||||
AdjustDilutedPrice decimal.NullDecimal `xorm:"numeric(18,8)" json:"adjustDilutedPrice"`
|
||||
MaintenanceDilutedPrice decimal.NullDecimal `xorm:"numeric(16,8)" json:"maintencanceDilutedPrice"`
|
||||
LossDilutedPrice decimal.NullDecimal `xorm:"numeric(16,8)" json:"lossDilutedPrice"`
|
||||
PublicConsumptionDilutedPrice decimal.NullDecimal `xorm:"numeric(16,8)" json:"publicConsumptionDilutedPrice"`
|
||||
MaintenanceOverall decimal.NullDecimal `xorm:"numeric(16,8)" json:"maintenanceOverall"`
|
||||
FinalDilutedOverall decimal.NullDecimal `xorm:"numeric(14,2)" json:"finalDilutedOverall"`
|
||||
}
|
||||
|
||||
func (ReportSummary) TableName() string {
|
||||
return "report_summary"
|
||||
bun.BaseModel `bun:"table:report_summary,alias:rs"`
|
||||
ReportId string `bun:",pk,notnull" json:"-"`
|
||||
Overall decimal.Decimal `bun:",notnull,default:0" json:"overall"`
|
||||
OverallFee decimal.Decimal `bun:",notnull,default:0" json:"overallFee"`
|
||||
ConsumptionFee decimal.NullDecimal `json:"consumptionFee"`
|
||||
OverallPrice decimal.NullDecimal `json:"overallPrice"`
|
||||
Critical decimal.Decimal `bun:",notnull,default:0" json:"critical"`
|
||||
CriticalFee decimal.Decimal `bun:",notnull,default:0" json:"criticalFee"`
|
||||
CriticalPrice decimal.NullDecimal `json:"criticalPrice"`
|
||||
Peak decimal.Decimal `bun:",notnull,default:0" json:"peak"`
|
||||
PeakFee decimal.Decimal `bun:",notnull,default:0" json:"peakFee"`
|
||||
PeakPrice decimal.NullDecimal `json:"peakPrice"`
|
||||
Flat decimal.Decimal `bun:",notnull,default:0" json:"flat"`
|
||||
FlatFee decimal.Decimal `bun:",notnull,default:0" json:"flatFee"`
|
||||
FlatPrice decimal.NullDecimal `json:"flatPrice"`
|
||||
Valley decimal.Decimal `bun:",notnull,default:0" json:"valley"`
|
||||
ValleyFee decimal.Decimal `bun:",notnull,default:0" json:"valleyFee"`
|
||||
ValleyPrice decimal.NullDecimal `json:"valleyPrice"`
|
||||
Loss decimal.NullDecimal `json:"loss"`
|
||||
LossFee decimal.NullDecimal `json:"lossFee"`
|
||||
LossProportion decimal.NullDecimal `json:"lossProportion"`
|
||||
CustomerConsumption decimal.NullDecimal `json:"customerConsumption"`
|
||||
CustomerConsumptionFee decimal.NullDecimal `json:"customerConsumptionFee"`
|
||||
CustomerConsumptionCritical decimal.NullDecimal `json:"customerConsumptionCritical"`
|
||||
CustomerConsumptionCriticalFee decimal.NullDecimal `json:"customerConsumptionCriticalFee"`
|
||||
CustomerConsumptionPeak decimal.NullDecimal `json:"customerConsumptionPeak"`
|
||||
CustomerConsumptionPeakFee decimal.NullDecimal `json:"customerConsumptionPeakFee"`
|
||||
CustomerConsumptionFlat decimal.NullDecimal `json:"customerConsumptionFlat"`
|
||||
CustomerConsumptionFlatFee decimal.NullDecimal `json:"customerConsumptionFlatFee"`
|
||||
CustomerConsumptionValley decimal.NullDecimal `json:"customerConsumptionValley"`
|
||||
CustomerConsumptionValleyFee decimal.NullDecimal `json:"customerConsumptionValleyFee"`
|
||||
PublicConsumption decimal.NullDecimal `json:"publicConsumption"`
|
||||
PublicConsumptionFee decimal.NullDecimal `json:"publicConsumptionFee"`
|
||||
PublicConsumptionProportion decimal.NullDecimal `json:"publicConsumptionProportion"`
|
||||
PublicConsumptionCritical decimal.NullDecimal `json:"publicConsumptionCritical"`
|
||||
PublicConsumptionCriticalFee decimal.NullDecimal `json:"publicConsumptionCriticalFee"`
|
||||
PublicConsumptionPeak decimal.NullDecimal `json:"publicConsumptionPeak"`
|
||||
PublicConsumptionPeakFee decimal.NullDecimal `json:"publicConsumptionPeakFee"`
|
||||
PublicConsumptionFlat decimal.NullDecimal `json:"publicConsumptionFlat"`
|
||||
PublicConsumptionFlatFee decimal.NullDecimal `json:"publicConsumptionFlatFee"`
|
||||
PublicConsumptionValley decimal.NullDecimal `json:"publicConsumptionValley"`
|
||||
PublicConsumptionValleyFee decimal.NullDecimal `json:"publicConsumptionValleyFee"`
|
||||
BasicFee decimal.Decimal `bun:",notnull,default:0" json:"basicFee"`
|
||||
BasicDilutedPrice decimal.NullDecimal `json:"basicDilutedPrice"`
|
||||
AdjustFee decimal.Decimal `bun:",notnull,default:0" json:"adjustFee"`
|
||||
AdjustDilutedPrice decimal.NullDecimal `json:"adjustDilutedPrice"`
|
||||
MaintenanceDilutedPrice decimal.NullDecimal `json:"maintencanceDilutedPrice"`
|
||||
LossDilutedPrice decimal.NullDecimal `json:"lossDilutedPrice"`
|
||||
PublicConsumptionDilutedPrice decimal.NullDecimal `json:"publicConsumptionDilutedPrice"`
|
||||
MaintenanceOverall decimal.NullDecimal `json:"maintenanceOverall"`
|
||||
FinalDilutedOverall decimal.NullDecimal `json:"finalDilutedOverall"`
|
||||
}
|
||||
|
||||
func (s ReportSummary) Validate() (bool, error) {
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package model
|
||||
|
||||
import "github.com/uptrace/bun"
|
||||
|
||||
const (
|
||||
USER_TYPE_ENT int8 = iota
|
||||
USER_TYPE_SUP
|
||||
|
@ -7,29 +9,25 @@ const (
|
|||
)
|
||||
|
||||
type User struct {
|
||||
Created `xorm:"extends"`
|
||||
Id string `xorm:"varchar(120) pk not null" json:"id"`
|
||||
Username string `xorm:"varchar(30) not null" json:"username"`
|
||||
Password string `xorm:"varchar(256) not null" json:"-"`
|
||||
ResetNeeded bool `xorm:"bool not null" json:"resetNeeded"`
|
||||
Type int8 `xorm:"smallint not null" json:"type"`
|
||||
Enabled bool `xorm:"bool not null" json:"enabled"`
|
||||
}
|
||||
|
||||
func (User) TableName() string {
|
||||
return "user"
|
||||
bun.BaseModel `bun:"table:user,alias:u"`
|
||||
Created `bun:",extend"`
|
||||
Id string `bun:",pk,notnull" json:"id"`
|
||||
Username string `bun:",notnull" json:"username"`
|
||||
Password string `bun:",notnull" json:"-"`
|
||||
ResetNeeded bool `bun:",notnull" json:"resetNeeded"`
|
||||
Type int8 `bun:"type:smallint,notnull" json:"type"`
|
||||
Enabled bool `bun:",notnull" json:"enabled"`
|
||||
Detail *UserDetail `bun:"rel:has-one,join:id=id" json:"-"`
|
||||
Charges []*UserCharge `bun:"rel:has-many,join:id=user_id" json:"-"`
|
||||
}
|
||||
|
||||
type UserWithCredentials struct {
|
||||
Created `xorm:"extends"`
|
||||
Id string `xorm:"varchar(120) pk not null" json:"id"`
|
||||
Username string `xorm:"varchar(30) not null" json:"username"`
|
||||
Password string `xorm:"varchar(256) not null" json:"credential"`
|
||||
ResetNeeded bool `xorm:"bool not null" json:"resetNeeded"`
|
||||
Type int8 `xorm:"smallint not null" json:"type"`
|
||||
Enabled bool `xorm:"bool not null" json:"enabled"`
|
||||
}
|
||||
|
||||
func (UserWithCredentials) TableName() string {
|
||||
return "user"
|
||||
bun.BaseModel `bun:"table:user,alias:u"`
|
||||
Created `bun:",extend"`
|
||||
Id string `bun:",pk,notnull" json:"id"`
|
||||
Username string `bun:",notnull" json:"username"`
|
||||
Password string `bun:",notnull" json:"credential"`
|
||||
ResetNeeded bool `bun:",notnull" json:"resetNeeded"`
|
||||
Type int8 `bun:"type:smallint,notnull" json:"type"`
|
||||
Enabled bool `bun:",notnull" json:"enabled"`
|
||||
}
|
||||
|
|
|
@ -4,33 +4,28 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/shopspring/decimal"
|
||||
"github.com/uptrace/bun"
|
||||
)
|
||||
|
||||
type UserCharge struct {
|
||||
Created `xorm:"extends"`
|
||||
Seq int64 `xorm:"bigint pk not null autoincr" json:"seq"`
|
||||
UserId string `xorm:"varchar(120) not null" json:"userId"`
|
||||
Fee decimal.NullDecimal `xorm:"numeric(12,2)" json:"fee"`
|
||||
Discount decimal.NullDecimal `xorm:"numeric(5,4)" json:"discount"`
|
||||
Amount decimal.NullDecimal `xorm:"numeric(12,2)" json:"amount"`
|
||||
ChargeTo time.Time `xorm:"date not null" json:"chargeTo" time_format:"simple_date" time_location:"shanghai"`
|
||||
Settled bool `xorm:"bool not null default false" json:"settled"`
|
||||
SettledAt *time.Time `xorm:"timestampz" json:"settledAt" time_format:"simple_datetime" time_location:"shanghai"`
|
||||
Cancelled bool `xorm:"bool not null default false" json:"cancelled"`
|
||||
CancelledAt *time.Time `xorm:"timestampz" json:"cancelledAt" time_format:"simple_datetime" time_location:"shanghai"`
|
||||
Refunded bool `xorm:"bool not null default false" json:"refunded"`
|
||||
RefundedAt *time.Time `xorm:"timestampz" json:"refundedAt" time_format:"simple_datetime" time_location:"shanghai"`
|
||||
}
|
||||
|
||||
func (UserCharge) TableName() string {
|
||||
return "user_charge"
|
||||
bun.BaseModel `bun:"table:user_charge,alias:c"`
|
||||
Created `bun:"extends"`
|
||||
Seq int64 `bun:"type:bigint,pk,notnull,autoincrement" json:"seq"`
|
||||
UserId string `bun:",notnull" json:"userId"`
|
||||
Fee decimal.NullDecimal `json:"fee"`
|
||||
Discount decimal.NullDecimal `json:"discount"`
|
||||
Amount decimal.NullDecimal `json:"amount"`
|
||||
ChargeTo time.Time `bun:"type:date,notnull" json:"chargeTo" time_format:"simple_date" time_location:"shanghai"`
|
||||
Settled bool `bun:",notnull,default:false" json:"settled"`
|
||||
SettledAt *time.Time `bun:"type:timestamptz" json:"settledAt" time_format:"simple_datetime" time_location:"shanghai"`
|
||||
Cancelled bool `bun:",notnull,default:false" json:"cancelled"`
|
||||
CancelledAt *time.Time `bun:"type:timestamptz" json:"cancelledAt" time_format:"simple_datetime" time_location:"shanghai"`
|
||||
Refunded bool `bun:",notnull,default:false" json:"refunded"`
|
||||
RefundedAt *time.Time `bun:"type:timestamptz" json:"refundedAt" time_format:"simple_datetime" time_location:"shanghai"`
|
||||
Detail *UserDetail `bun:"rel:belongs-to,join:user_id=id" json:"-"`
|
||||
}
|
||||
|
||||
type ChargeWithName struct {
|
||||
UserDetail `xorm:"extends"`
|
||||
UserCharge `xorm:"extends"`
|
||||
}
|
||||
|
||||
func (ChargeWithName) TableName() string {
|
||||
return "user_detail"
|
||||
UserDetail `bun:"extends"`
|
||||
UserCharge `bun:"extends"`
|
||||
}
|
||||
|
|
|
@ -4,57 +4,44 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/shopspring/decimal"
|
||||
"github.com/uptrace/bun"
|
||||
)
|
||||
|
||||
type UserDetail struct {
|
||||
CreatedAndModifiedWithUser `xorm:"extends"`
|
||||
DeletedWithUser `xorm:"extends"`
|
||||
Id string `xorm:"varchar(120) pk not null" json:"-"`
|
||||
Name *string `xorm:"varchar(100)" json:"name"`
|
||||
Abbr *string `xorm:"varchar(50)" json:"abbr"`
|
||||
Region *string `xorm:"varchar(10)" json:"region"`
|
||||
Address *string `xorm:"varchar(120)" json:"address"`
|
||||
Contact *string `xorm:"varchar(100)" json:"contact"`
|
||||
Phone *string `xorm:"varchar(50)" json:"phone"`
|
||||
UnitServiceFee decimal.Decimal `xorm:"numeric(8,2) not null" json:"unitServiceFee"`
|
||||
ServiceExpiration time.Time `xorm:"date not null" json:"serviceExpiration" time_format:"simple_date" time_location:"shanghai"`
|
||||
}
|
||||
|
||||
func (UserDetail) TableName() string {
|
||||
return "user_detail"
|
||||
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 `xorm:"extends"`
|
||||
UserDetail `bun:"extends"`
|
||||
Id string `json:"id"`
|
||||
Username string `json:"username"`
|
||||
Type int8 `json:"type"`
|
||||
Enabled bool `json:"enabled"`
|
||||
}
|
||||
|
||||
func (JoinedUserDetail) TableName() string {
|
||||
return "user"
|
||||
}
|
||||
|
||||
type FullJoinedUserDetail struct {
|
||||
UserDetail `xorm:"extends"`
|
||||
User `xorm:"extends"`
|
||||
}
|
||||
|
||||
func (FullJoinedUserDetail) TableName() string {
|
||||
return "user_detail"
|
||||
UserDetail `bun:"extends"`
|
||||
User `bun:"extends"`
|
||||
}
|
||||
|
||||
type UserDetailSimplified struct {
|
||||
Id string `xorm:"varchar(120) pk not null" json:"id"`
|
||||
Name *string `xorm:"varchar(100)" json:"name"`
|
||||
Abbr *string `xorm:"varchar(50)" json:"abbr"`
|
||||
Region *string `xorm:"varchar(10)" json:"region"`
|
||||
Address *string `xorm:"varchar(120)" json:"address"`
|
||||
Contact *string `xorm:"varchar(100)" json:"contact"`
|
||||
Phone *string `xorm:"varchar(50)" json:"phone"`
|
||||
}
|
||||
|
||||
func (UserDetailSimplified) TableName() string {
|
||||
return "user_detail"
|
||||
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"`
|
||||
}
|
||||
|
|
|
@ -1,17 +1,18 @@
|
|||
package model
|
||||
|
||||
import "github.com/shopspring/decimal"
|
||||
import (
|
||||
"github.com/shopspring/decimal"
|
||||
"github.com/uptrace/bun"
|
||||
)
|
||||
|
||||
type WillDilutedFee struct {
|
||||
CreatedAndModified `xorm:"extends"`
|
||||
Id string `xorm:"varchar(120) pk not null" json:"diluteId"`
|
||||
ReportId string `xorm:"varchar(120) not null" json:"reportId"`
|
||||
SourceId *string `xorm:"varchar(120)" json:"sourceId"`
|
||||
Name string `xorm:"varchar(50) not null" json:"name"`
|
||||
Fee decimal.Decimal `xorm:"numeric(8,2) not null default 0" json:"fee"`
|
||||
Memo *string `xorm:"text" json:"memo"`
|
||||
}
|
||||
|
||||
func (WillDilutedFee) TableName() string {
|
||||
return "will_diluted_fee"
|
||||
bun.BaseModel `bun:"table:will_diluted_fee,alias:w"`
|
||||
CreatedAndModified `bun:"extends"`
|
||||
Id string `bun:",pk,notnull" json:"diluteId"`
|
||||
ReportId string `bun:",notnull" json:"reportId"`
|
||||
SourceId *string `json:"sourceId"`
|
||||
Name string `bun:",notnull" json:"name"`
|
||||
Fee decimal.Decimal `bun:",notnull,default:0" json:"fee"`
|
||||
Memo *string `bun:"type:text" json:"memo"`
|
||||
Origin *MaintenanceFee `bun:"rel:belongs-to,join:source_id=id"`
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user