forked from free-lancers/electricity_bill_calc_service
		
	refactor(deps):ORM库切换为Xorm,同时增加保证数据库连接的配置。
This commit is contained in:
		
							
								
								
									
										19
									
								
								model/maintenance_fee.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								model/maintenance_fee.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,19 @@ | ||||
| package model | ||||
|  | ||||
| import ( | ||||
| 	"github.com/shopspring/decimal" | ||||
| ) | ||||
|  | ||||
| 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:"decimal(8,2) notnull" json:"fee"` | ||||
| 	Memo               string          `xorm:"text" json:"memo"` | ||||
| 	Enabled            bool            `xorm:"bool notnull" json:"enabled"` | ||||
| } | ||||
|  | ||||
| func (MaintenanceFee) TableName() string { | ||||
| 	return "maintenance_fee" | ||||
| } | ||||
							
								
								
									
										23
									
								
								model/meter_04kv.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								model/meter_04kv.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,23 @@ | ||||
| package model | ||||
|  | ||||
| import ( | ||||
| 	"github.com/shopspring/decimal" | ||||
| ) | ||||
|  | ||||
| type Meter04KV struct { | ||||
| 	CreatedAndModified `xorm:"extends"` | ||||
| 	Code               string          `xorm:"varchar(120) pk notnull" json:"code"` | ||||
| 	ParkId             string          `xorm:"varchar(120) notnull" 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:"decimal(8,4) notnull" json:"ratio"` | ||||
| 	IsPublicMeter      bool            `xorm:"'public_meter' bool notnull" json:"isPublicMeter"` | ||||
| 	WillDilute         bool            `xorm:"'dilute' bool notnull" json:"willDilute"` | ||||
| 	Enabled            bool            `xorm:"bool notnull" json:"enabled"` | ||||
| } | ||||
|  | ||||
| func (Meter04KV) TableName() string { | ||||
| 	return "meter_04kv" | ||||
| } | ||||
							
								
								
									
										26
									
								
								model/park.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								model/park.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,26 @@ | ||||
| package model | ||||
|  | ||||
| import ( | ||||
| 	"github.com/shopspring/decimal" | ||||
| ) | ||||
|  | ||||
| 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"` | ||||
| 	Abbr               string              `xorm:"varchar(50)" json:"abbr"` | ||||
| 	Area               decimal.NullDecimal `xorm:"decimal(14,2)" json:"area"` | ||||
| 	TenementQuantity   decimal.NullDecimal `xorm:"decimal(8,0)" json:"tenementQuantity"` | ||||
| 	Capacity           decimal.NullDecimal `xorm:"decimal(16,2)" json:"capacity"` | ||||
| 	Category           int8                `xorm:"smallint notnull" 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"` | ||||
| } | ||||
|  | ||||
| func (Park) TableName() string { | ||||
| 	return "park" | ||||
| } | ||||
							
								
								
									
										19
									
								
								model/report.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								model/report.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,19 @@ | ||||
| package model | ||||
|  | ||||
| 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"` | ||||
| 	PublishedAt           time.Time  `xorm:"timestampz" json:"publishedAt"` | ||||
| 	Withdraw              byte       `xorm:"smallint notnull default(0)" json:"withdraw"` | ||||
| 	LastWithdrawAppliedAt *time.Time `xorm:"timestampz" json:"lastWithdrawAppliedAt"` | ||||
| 	LastWithdrawAuditAt   *time.Time `xorm:"timestampz" json:"lastWithdrawAuditAt"` | ||||
| } | ||||
|  | ||||
| func (Report) TableName() string { | ||||
| 	return "report" | ||||
| } | ||||
							
								
								
									
										38
									
								
								model/report_summary.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								model/report_summary.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,38 @@ | ||||
| package model | ||||
|  | ||||
| import "github.com/shopspring/decimal" | ||||
|  | ||||
| type ReportSummary struct { | ||||
| 	ReportId                      string              `xorm:"varchar(120) pk notnull" json:"reportId"` | ||||
| 	Overall                       decimal.Decimal     `xorm:"decimal(14,2) notnull" json:"overall"` | ||||
| 	OverallFee                    decimal.Decimal     `xorm:"decimal(14,2) notnull" json:"overallFee"` | ||||
| 	OverallPrice                  decimal.Decimal     `xorm:"decimal(16,8)" json:"overallPrice"` | ||||
| 	Critical                      decimal.Decimal     `xorm:"decimal(14,2) notnull" json:"critial"` | ||||
| 	CriticalFee                   decimal.Decimal     `xorm:"decimal(14,2) notnull" json:"criticalFee"` | ||||
| 	CriticalPrice                 decimal.NullDecimal `xorm:"decimal(16,8)" json:"criticalPrice"` | ||||
| 	Peek                          decimal.Decimal     `xorm:"decimal(14,2) notnull" json:"peek"` | ||||
| 	PeekFee                       decimal.Decimal     `xorm:"decimal(14,2) notnull" json:"peekFee"` | ||||
| 	PeekPrice                     decimal.NullDecimal `xorm:"decimal(16,8)" json:"peekPrice"` | ||||
| 	Flat                          decimal.NullDecimal `xorm:"decimal(14,2)" json:"flat"` | ||||
| 	FlatFee                       decimal.Decimal     `xorm:"decimal(14,2) notnull" json:"flatFee"` | ||||
| 	FlatPrice                     decimal.NullDecimal `xorm:"decimal(16,8)" json:"flatPrice"` | ||||
| 	Valley                        decimal.Decimal     `xorm:"decimal(14,2) notnull" json:"valley"` | ||||
| 	ValleyFee                     decimal.Decimal     `xorm:"decimal(14,2) notnull" json:"valleyFee"` | ||||
| 	ValleyPrice                   decimal.NullDecimal `xorm:"decimal(16,8)" json:"valleyPrice"` | ||||
| 	Loss                          decimal.NullDecimal `xorm:"decimal(14,2)" json:"loss"` | ||||
| 	LossFee                       decimal.NullDecimal `xorm:"decimal(16,2)" json:"lossFee"` | ||||
| 	PublicConsumption             decimal.NullDecimal `xorm:"decimal(14,2)" json:"publicConsumption"` | ||||
| 	PublicConsumptionFee          decimal.NullDecimal `xorm:"decimal(14,2)" json:"publicConsumptionFee"` | ||||
| 	BasicFee                      decimal.Decimal     `xorm:"decimal(14,2) notnull" json:"basicFee"` | ||||
| 	BasicDilutedPrice             decimal.NullDecimal `xorm:"decimal(18,8)" json:"basicDilutedPrice"` | ||||
| 	AdjustFee                     decimal.Decimal     `xorm:"decimal(14,2) notnull" json:"adjustFee"` | ||||
| 	AdjustDilutedPrice            decimal.NullDecimal `xorm:"decimal(18,8)" json:"adjustDilutedPrice"` | ||||
| 	MaintenanceDilutedPrice       decimal.NullDecimal `xorm:"decimal(16,8)" json:"maintencanceDilutedPrice"` | ||||
| 	LossDilutedPrice              decimal.NullDecimal `xorm:"decimal(16,8)" json:"lossDilutedPrice"` | ||||
| 	PublicConsumptionDilutedPrice decimal.NullDecimal `xorm:"decimal(16,8)" json:"publicConsumptionDilutedPrice"` | ||||
| 	ServiceDilutedPrice           decimal.NullDecimal `xorm:"decimal(16,8)" json:"serviceDilutedPrice"` | ||||
| } | ||||
|  | ||||
| func (ReportSummary) TableName() string { | ||||
| 	return "report_summary" | ||||
| } | ||||
							
								
								
									
										23
									
								
								model/shared.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								model/shared.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,23 @@ | ||||
| package model | ||||
|  | ||||
| import "time" | ||||
|  | ||||
| type Created struct { | ||||
| 	CreatedAt time.Time `xorm:"timestampz  notnull created" json:"createdAt"` | ||||
| } | ||||
|  | ||||
| type CreatedWithUser struct { | ||||
| 	Created   `xorm:"extends"` | ||||
| 	CreatedBy string `xorm:"varchar(100)" json:"createdBy"` | ||||
| } | ||||
|  | ||||
| type CreatedAndModified struct { | ||||
| 	Created        `xorm:"extends"` | ||||
| 	LastModifiedAt *time.Time `xorm:"timestampz updated" json:"lastModifiedAt"` | ||||
| } | ||||
|  | ||||
| type CreatedAndModifiedWithUser struct { | ||||
| 	CreatedAndModified `xorm:"extends"` | ||||
| 	CreatedBy          string `xorm:"varchar(100)" json:"createdBy"` | ||||
| 	LastModifiedBy     string `xorm:"varchar(100)" json:"lastModifiedBy"` | ||||
| } | ||||
							
								
								
									
										15
									
								
								model/user.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								model/user.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,15 @@ | ||||
| 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"` | ||||
| } | ||||
|  | ||||
| func (User) TableName() string { | ||||
| 	return "user" | ||||
| } | ||||
							
								
								
									
										23
									
								
								model/user_charges.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								model/user_charges.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,23 @@ | ||||
| package model | ||||
|  | ||||
| import ( | ||||
| 	"time" | ||||
|  | ||||
| 	"github.com/shopspring/decimal" | ||||
| ) | ||||
|  | ||||
| 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:"decimal(12,2) notnull" json:"fee"` | ||||
| 	Discount  decimal.Decimal `xorm:"decimal(5,4) notnull" json:"discount"` | ||||
| 	Amount    decimal.Decimal `xorm:"decimal(12,2) notnull" json:"amount"` | ||||
| 	Settled   bool            `xorm:"bool notnull" json:"settled"` | ||||
| 	SettledAt *time.Time      `xorm:"timestampz" json:"settledAt"` | ||||
| } | ||||
|  | ||||
| func (UserCharge) TableName() string { | ||||
| 	return "user_charge" | ||||
| } | ||||
							
								
								
									
										24
									
								
								model/user_detail.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								model/user_detail.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,24 @@ | ||||
| package model | ||||
|  | ||||
| import ( | ||||
| 	"time" | ||||
|  | ||||
| 	"github.com/shopspring/decimal" | ||||
| ) | ||||
|  | ||||
| type UserDetail struct { | ||||
| 	CreatedAndModifiedWithUser `xorm:"extends"` | ||||
| 	Id                         string          `xorm:"varchar(120) pk notnull" 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:"decimal(8,2) notnull" json:"unitServiceFee"` | ||||
| 	ServiceExpiration          time.Time       `xorm:"date notnull" json:"serviceExpiration"` | ||||
| } | ||||
|  | ||||
| func (UserDetail) TableName() string { | ||||
| 	return "user_detail" | ||||
| } | ||||
							
								
								
									
										16
									
								
								model/will_diluted_fee.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								model/will_diluted_fee.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,16 @@ | ||||
| package model | ||||
|  | ||||
| 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:"decimal(8,2) notnull" json:"fee"` | ||||
| 	Memo               string          `xorm:"text" json:"memo"` | ||||
| } | ||||
|  | ||||
| func (WillDilutedFee) TableName() string { | ||||
| 	return "will_diluted_fee" | ||||
| } | ||||
		Reference in New Issue
	
	Block a user