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

@ -6,6 +6,8 @@ type EndUserDetail struct {
CreatedAndModified `xorm:"extends"` CreatedAndModified `xorm:"extends"`
ReportId string `xorm:"varchar(120) pk not null" json:"-"` ReportId string `xorm:"varchar(120) pk not null" json:"-"`
MeterId string `xorm:"meter_04kv_id varchar(120) pk not null" json:"meterId"` 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"` LastPeriodCritical decimal.NullDecimal `xorm:"numeric(14,2)" json:"lastPeriodCritical"`
LastPeriodPeek decimal.NullDecimal `xorm:"numeric(14,2)" json:"lastPeriodPeek"` LastPeriodPeek decimal.NullDecimal `xorm:"numeric(14,2)" json:"lastPeriodPeek"`
LastPeriodFlat decimal.Decimal `xorm:"numeric(14,2) not null" json:"lastPeriodFlat"` LastPeriodFlat decimal.Decimal `xorm:"numeric(14,2) not null" json:"lastPeriodFlat"`

View File

@ -6,6 +6,7 @@ import (
type MaintenanceFee struct { type MaintenanceFee struct {
CreatedAndModified `xorm:"extends"` CreatedAndModified `xorm:"extends"`
Deleted `xorm:"extends"`
Id string `xorm:"varchar(120) pk not null" json:"id"` Id string `xorm:"varchar(120) pk not null" json:"id"`
ParkId string `xorm:"varchar(120) not null" json:"parkId"` ParkId string `xorm:"varchar(120) not null" json:"parkId"`
Name string `xorm:"varchar(50) not null" json:"name"` Name string `xorm:"varchar(50) not null" json:"name"`

View File

@ -12,10 +12,11 @@ type Meter04KV struct {
CustomerName *string `xorm:"varchar(100)" json:"customerName"` CustomerName *string `xorm:"varchar(100)" json:"customerName"`
ContactName *string `xorm:"varchar(70)" json:"contactName"` ContactName *string `xorm:"varchar(70)" json:"contactName"`
ContactPhone *string `xorm:"varchar(50)" json:"contactPhone"` ContactPhone *string `xorm:"varchar(50)" json:"contactPhone"`
Ratio decimal.Decimal `xorm:"numeric(8,4) notnull default(1)" json:"ratio"` Ratio decimal.Decimal `xorm:"numeric(8,4) not null default 1" json:"ratio"`
IsPublicMeter bool `xorm:"'public_meter' bool notnull default(false)" json:"isPublicMeter"` Seq int64 `xorm:"bigint not null" json:"seq"`
WillDilute bool `xorm:"'dilute' bool notnull default(false)" json:"willDilute"` IsPublicMeter bool `xorm:"'public_meter' bool not null default false" json:"isPublicMeter"`
Enabled bool `xorm:"bool notnull default(true)" json:"enabled"` 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 { func (Meter04KV) TableName() string {

View File

@ -6,6 +6,7 @@ import (
type Park struct { type Park struct {
CreatedAndModified `xorm:"extends"` CreatedAndModified `xorm:"extends"`
Deleted `xorm:"extends"`
Id string `xorm:"varchar(120) pk not null" json:"id"` Id string `xorm:"varchar(120) pk not null" json:"id"`
UserId string `xorm:"varchar(120) not null" json:"userId"` UserId string `xorm:"varchar(120) not null" json:"userId"`
Name string `xorm:"vachar(70) not null" json:"name"` Name string `xorm:"vachar(70) not null" json:"name"`

View File

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

View File

@ -11,6 +11,15 @@ type CreatedWithUser struct {
CreatedBy *string `xorm:"varchar(100)" json:"createdBy"` 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 { type CreatedAndModified struct {
Created `xorm:"extends"` Created `xorm:"extends"`
LastModifiedAt *time.Time `xorm:"timestampz updated" json:"lastModifiedAt"` LastModifiedAt *time.Time `xorm:"timestampz updated" json:"lastModifiedAt"`

View File

@ -14,8 +14,10 @@ type UserCharge struct {
Fee decimal.Decimal `xorm:"numeric(12,2) not null" json:"fee"` Fee decimal.Decimal `xorm:"numeric(12,2) not null" json:"fee"`
Discount decimal.Decimal `xorm:"numeric(5,4) not null" json:"discount"` Discount decimal.Decimal `xorm:"numeric(5,4) not null" json:"discount"`
Amount decimal.Decimal `xorm:"numeric(12,2) not null" json:"amount"` Amount decimal.Decimal `xorm:"numeric(12,2) not null" json:"amount"`
Settled bool `xorm:"bool notnull" json:"settled"` Settled bool `xorm:"bool not null default false" json:"settled"`
SettledAt *time.Time `xorm:"timestampz" json:"settledAt"` 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 { func (UserCharge) TableName() string {

View File

@ -8,6 +8,7 @@ import (
type UserDetail struct { type UserDetail struct {
CreatedAndModifiedWithUser `xorm:"extends"` CreatedAndModifiedWithUser `xorm:"extends"`
DeletedWithUser `xorm:"extends"`
Id string `xorm:"varchar(120) pk not null" json:"id"` Id string `xorm:"varchar(120) pk not null" json:"id"`
Name *string `xorm:"varchar(100)" json:"name"` Name *string `xorm:"varchar(100)" json:"name"`
Abbr *string `xorm:"varchar(50)" json:"abbr"` Abbr *string `xorm:"varchar(50)" json:"abbr"`