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