enhance(model):调整数据模型设计。

This commit is contained in:
徐涛 2022-08-11 15:16:21 +08:00
parent 57ea1bd69a
commit 279fb32f4d
11 changed files with 81 additions and 63 deletions

View File

@ -4,26 +4,28 @@ import "github.com/shopspring/decimal"
type EndUserDetail struct {
CreatedAndModified `xorm:"extends"`
ReportId string `xorm:"varchar(120) pk notnull" json:"-"`
MeterId string `xorm:"meter_04kv_id varchar(120) pk notnull" json:"meterId"`
ReportId string `xorm:"varchar(120) pk not null" json:"-"`
MeterId string `xorm:"meter_04kv_id varchar(120) pk not null" json:"meterId"`
Seq int64 `xorm:"bigint not null" json:"seq"`
Ratio decimal.Decimal `xorm:"numeric(8,4) not null" json:"ratio"`
LastPeriodCritical decimal.NullDecimal `xorm:"numeric(14,2)" json:"lastPeriodCritical"`
LastPeriodPeek decimal.NullDecimal `xorm:"numeric(14,2)" json:"lastPeriodPeek"`
LastPeriodFlat decimal.Decimal `xorm:"numeric(14,2) notnull" json:"lastPeriodFlat"`
LastPeriodFlat decimal.Decimal `xorm:"numeric(14,2) not null" json:"lastPeriodFlat"`
LastPeriodValley decimal.NullDecimal `xorm:"numeric(14,2)" json:"lastPeriodValley"`
CurrentPeriodCritical decimal.NullDecimal `xorm:"numeric(14,2)" json:"currentPeriodCritical"`
CurrentPeriodPeek decimal.NullDecimal `xorm:"numeric(14,2)" json:"currentPeriodPeek"`
CurrentPeriodFlat decimal.Decimal `xorm:"numeric(14,2) notnull" json:"currentPeriodFlat"`
CurrentPeriodFlat decimal.Decimal `xorm:"numeric(14,2) not null" json:"currentPeriodFlat"`
CurrentPeriodValley decimal.NullDecimal `xorm:"numeric(14,2)" json:"currentPeriodValley"`
AdjustCritical decimal.NullDecimal `xorm:"numeric(14,2)" json:"adjustCritical"`
AdjustPeek decimal.NullDecimal `xorm:"numeric(14,2)" json:"adjustPeek"`
AdjustFlat decimal.Decimal `xorm:"numeric(14,2) notnull" json:"adjustFlat"`
AdjustFlat decimal.Decimal `xorm:"numeric(14,2) not null" json:"adjustFlat"`
AdjustValley decimal.NullDecimal `xorm:"numeric(14,2)" json:"adjustValley"`
Critical decimal.NullDecimal `xorm:"numeric(14,2)" json:"critical"`
CriticalFee decimal.NullDecimal `xorm:"numeric(18,8)" json:"criticalFee"`
Peek decimal.NullDecimal `xorm:"numeric(14,2)" json:"peek"`
PeekFee decimal.NullDecimal `xorm:"numeric(18,8)" json:"peekFee"`
Flat decimal.Decimal `xorm:"numeric(14,2) notnull" json:"flat"`
FlatFee decimal.Decimal `xorm:"numeric(18,8) notnull" json:"flatFee"`
Flat decimal.Decimal `xorm:"numeric(14,2) not null" json:"flat"`
FlatFee decimal.Decimal `xorm:"numeric(18,8) not null" 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"`

View File

@ -6,12 +6,13 @@ import (
type MaintenanceFee struct {
CreatedAndModified `xorm:"extends"`
Id string `xorm:"varchar(120) pk notnull" json:"id"`
ParkId string `xorm:"varchar(120) notnull" json:"parkId"`
Name string `xorm:"varchar(50) notnull" json:"name"`
Fee decimal.Decimal `xorm:"numeric(8,2) notnull" json:"fee"`
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 notnull" json:"enabled"`
Enabled bool `xorm:"bool not null" json:"enabled"`
}
func (MaintenanceFee) TableName() string {

View File

@ -6,16 +6,17 @@ import (
type Meter04KV struct {
CreatedAndModified `xorm:"extends"`
Code string `xorm:"varchar(120) pk notnull" json:"code"`
ParkId string `xorm:"varchar(120) notnull" json:"parkId"`
Code string `xorm:"varchar(120) pk not null" json:"code"`
ParkId string `xorm:"varchar(120) not null" json:"parkId"`
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"`
Ratio decimal.Decimal `xorm:"numeric(8,4) notnull default(1)" json:"ratio"`
IsPublicMeter bool `xorm:"'public_meter' bool notnull default(false)" json:"isPublicMeter"`
WillDilute bool `xorm:"'dilute' bool notnull default(false)" json:"willDilute"`
Enabled bool `xorm:"bool notnull default(true)" json:"enabled"`
Ratio decimal.Decimal `xorm:"numeric(8,4) not null default 1" json:"ratio"`
Seq int64 `xorm:"bigint not null" json:"seq"`
IsPublicMeter bool `xorm:"'public_meter' bool not null default false" json:"isPublicMeter"`
WillDilute bool `xorm:"'dilute' bool not null default false" json:"willDilute"`
Enabled bool `xorm:"bool not null default true" json:"enabled"`
}
func (Meter04KV) TableName() string {

View File

@ -6,19 +6,20 @@ import (
type Park struct {
CreatedAndModified `xorm:"extends"`
Id string `xorm:"varchar(120) pk notnull" json:"id"`
UserId string `xorm:"varchar(120) notnull" json:"userId"`
Name string `xorm:"vachar(70) notnull" json:"name"`
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:"vachar(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:"tenementQuantity"`
Capacity decimal.NullDecimal `xorm:"numeric(16,2)" json:"capacity"`
Category int8 `xorm:"smallint notnull" json:"category"`
Category int8 `xorm:"smallint not null" json:"category"`
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 notnull" json:"enabled"`
Enabled bool `xorm:"bool not null" json:"enabled"`
}
func (Park) TableName() string {

View File

@ -4,12 +4,13 @@ import "time"
type Report struct {
CreatedAndModified `xorm:"extends"`
Id string `xorm:"varchar(120) pk notnull" json:"id"`
ParkId string `xorm:"varchar(120) notnull" json:"parkId"`
Period time.Time `xorm:"date notnull" json:"period"`
Published bool `xorm:"bool notnull default(false)" json:"published"`
Deleted `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"`
Published bool `xorm:"bool not null default false" json:"published"`
PublishedAt *time.Time `xorm:"timestampz" json:"publishedAt"`
Withdraw byte `xorm:"smallint notnull default(0)" json:"withdraw"`
Withdraw byte `xorm:"smallint not null default 0" json:"withdraw"`
LastWithdrawAppliedAt *time.Time `xorm:"timestampz" json:"lastWithdrawAppliedAt"`
LastWithdrawAuditAt *time.Time `xorm:"timestampz" json:"lastWithdrawAuditAt"`
}

View File

@ -3,29 +3,29 @@ package model
import "github.com/shopspring/decimal"
type ReportSummary struct {
ReportId string `xorm:"varchar(120) pk notnull" json:"-"`
Overall decimal.Decimal `xorm:"numeric(14,2) notnull" json:"overall"`
OverallFee decimal.Decimal `xorm:"numeric(14,2) notnull" json:"overallFee"`
ReportId string `xorm:"varchar(120) pk not null" json:"-"`
Overall decimal.Decimal `xorm:"numeric(14,2) not null" json:"overall"`
OverallFee decimal.Decimal `xorm:"numeric(14,2) not null" json:"overallFee"`
OverallPrice decimal.Decimal `xorm:"numeric(16,8)" json:"overallPrice"`
Critical decimal.Decimal `xorm:"numeric(14,2) notnull" json:"critial"`
CriticalFee decimal.Decimal `xorm:"numeric(14,2) notnull" json:"criticalFee"`
Critical decimal.Decimal `xorm:"numeric(14,2) not null" json:"critial"`
CriticalFee decimal.Decimal `xorm:"numeric(14,2) not null" json:"criticalFee"`
CriticalPrice decimal.NullDecimal `xorm:"numeric(16,8)" json:"criticalPrice"`
Peek decimal.Decimal `xorm:"numeric(14,2) notnull" json:"peek"`
PeekFee decimal.Decimal `xorm:"numeric(14,2) notnull" json:"peekFee"`
Peek decimal.Decimal `xorm:"numeric(14,2) not null" json:"peek"`
PeekFee decimal.Decimal `xorm:"numeric(14,2) not null" json:"peekFee"`
PeekPrice decimal.NullDecimal `xorm:"numeric(16,8)" json:"peekPrice"`
Flat decimal.NullDecimal `xorm:"numeric(14,2)" json:"flat"`
FlatFee decimal.Decimal `xorm:"numeric(14,2) notnull" json:"flatFee"`
FlatFee decimal.Decimal `xorm:"numeric(14,2) not null" json:"flatFee"`
FlatPrice decimal.NullDecimal `xorm:"numeric(16,8)" json:"flatPrice"`
Valley decimal.Decimal `xorm:"numeric(14,2) notnull" json:"valley"`
ValleyFee decimal.Decimal `xorm:"numeric(14,2) notnull" json:"valleyFee"`
Valley decimal.Decimal `xorm:"numeric(14,2) not null" json:"valley"`
ValleyFee decimal.Decimal `xorm:"numeric(14,2) not null" 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"`
PublicConsumption decimal.NullDecimal `xorm:"numeric(14,2)" json:"publicConsumption"`
PublicConsumptionFee decimal.NullDecimal `xorm:"numeric(14,2)" json:"publicConsumptionFee"`
BasicFee decimal.Decimal `xorm:"numeric(14,2) notnull" json:"basicFee"`
BasicFee decimal.Decimal `xorm:"numeric(14,2) not null" json:"basicFee"`
BasicDilutedPrice decimal.NullDecimal `xorm:"numeric(18,8)" json:"basicDilutedPrice"`
AdjustFee decimal.Decimal `xorm:"numeric(14,2) notnull" json:"adjustFee"`
AdjustFee decimal.Decimal `xorm:"numeric(14,2) not null" 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"`

View File

@ -3,7 +3,7 @@ package model
import "time"
type Created struct {
CreatedAt time.Time `xorm:"timestampz notnull created" json:"createdAt"`
CreatedAt time.Time `xorm:"timestampz not null created" json:"createdAt"`
}
type CreatedWithUser struct {
@ -11,6 +11,15 @@ type CreatedWithUser struct {
CreatedBy *string `xorm:"varchar(100)" json:"createdBy"`
}
type Deleted struct {
DeletedAt *time.Time `xorm:"timestampz deleted" json:"deletedAt"`
}
type DeletedWithUser struct {
Deleted `xorm:"extends"`
DeletedBy *string `xorm:"varchar(120)" json:"deletedBy"`
}
type CreatedAndModified struct {
Created `xorm:"extends"`
LastModifiedAt *time.Time `xorm:"timestampz updated" json:"lastModifiedAt"`

View File

@ -2,12 +2,12 @@ package model
type User struct {
Created `xorm:"extends"`
Id string `xorm:"varchar(120) pk notnull" json:"id"`
Username string `xorm:"varchar(30) notnull" json:"username"`
Password string `xorm:"varchar(120) notnull" json:"-"`
ResetNeeded bool `xorm:"bool notnull" json:"resetNeeded"`
Type byte `xorm:"smallint notnull" json:"type"`
Enabled bool `xorm:"bool notnull" json:"enabled"`
Id string `xorm:"varchar(120) pk not null" json:"id"`
Username string `xorm:"varchar(30) not null" json:"username"`
Password string `xorm:"varchar(120) not null" json:"-"`
ResetNeeded bool `xorm:"bool not null" json:"resetNeeded"`
Type byte `xorm:"smallint not null" json:"type"`
Enabled bool `xorm:"bool not null" json:"enabled"`
}
func (User) TableName() string {

View File

@ -7,15 +7,17 @@ import (
)
type UserCharge struct {
Created `xorm:"extends"`
Seq int64 `xorm:"bigint pk notnull " json:"seq"`
CreatedAt time.Time `xorm:"timestampz notnull" json:"createdAt"`
UserId string `xorm:"varchar(120) notnull" json:"userId"`
Fee decimal.Decimal `xorm:"numeric(12,2) notnull" json:"fee"`
Discount decimal.Decimal `xorm:"numeric(5,4) notnull" json:"discount"`
Amount decimal.Decimal `xorm:"numeric(12,2) notnull" json:"amount"`
Settled bool `xorm:"bool notnull" json:"settled"`
SettledAt *time.Time `xorm:"timestampz" json:"settledAt"`
Created `xorm:"extends"`
Seq int64 `xorm:"bigint pk not null " json:"seq"`
CreatedAt time.Time `xorm:"timestampz not null" json:"createdAt"`
UserId string `xorm:"varchar(120) not null" json:"userId"`
Fee decimal.Decimal `xorm:"numeric(12,2) not null" json:"fee"`
Discount decimal.Decimal `xorm:"numeric(5,4) not null" json:"discount"`
Amount decimal.Decimal `xorm:"numeric(12,2) not null" json:"amount"`
Settled bool `xorm:"bool not null default false" json:"settled"`
SettledAt *time.Time `xorm:"timestampz" json:"settledAt"`
Refunded bool `xorm:"bool not null default false" json:"refunded"`
RefundedAt *time.Time `xorm:"timestampz" json:"refundedAt"`
}
func (UserCharge) TableName() string {

View File

@ -8,15 +8,16 @@ import (
type UserDetail struct {
CreatedAndModifiedWithUser `xorm:"extends"`
Id string `xorm:"varchar(120) pk notnull" json:"id"`
DeletedWithUser `xorm:"extends"`
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"`
UnitServiceFee decimal.Decimal `xorm:"numeric(8,2) notnull" json:"unitServiceFee"`
ServiceExpiration time.Time `xorm:"date notnull" json:"serviceExpiration"`
UnitServiceFee decimal.Decimal `xorm:"numeric(8,2) not null" json:"unitServiceFee"`
ServiceExpiration time.Time `xorm:"date not null" json:"serviceExpiration"`
}
func (UserDetail) TableName() string {

View File

@ -4,10 +4,10 @@ import "github.com/shopspring/decimal"
type WillDilutedFee struct {
CreatedAndModified `xorm:"extends"`
Id string `xorm:"varchar(120) pk notnull" json:"id"`
ReportId string `xorm:"varchar(120) notnull" json:"reportId"`
Name string `xorm:"varchar(50) notnull" json:"name"`
Fee decimal.Decimal `xorm:"numeric(8,2) notnull" json:"fee"`
Id string `xorm:"varchar(120) pk not null" json:"id"`
ReportId string `xorm:"varchar(120) not null" json:"reportId"`
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"`
}