/
charge.go
41 lines (31 loc) · 1.09 KB
/
charge.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package models
import (
"time"
)
type ResourceName string
const (
Mem ResourceName = "mem"
Cpu ResourceName = "cpu"
TableNameCharge = "charge"
)
type chargeModel struct{}
type Charge struct {
Id int64 `orm:"auto" json:"id,omitempty"`
Namespace string `orm:"size(1024)" json:"namespace,omitempty"`
App string `orm:"index;size(1024)" json:"app,omitempty"`
Name string `orm:"size(1024)" json:"name,omitempty"`
Type string `orm:"index;size(1024)" json:"type,omitempty"`
UnitPrice float64 `orm:"digits(12);decimals(4)" json:"unitPrice,omitempty"`
Quantity int `orm:"int(11)" json:"quantity,omitempty"`
Amount float64 `orm:"digits(12);decimals(4)" json:"amount,omitempty"`
ResourceName ResourceName `orm:"size(1024)" json:"resourceName,omitempty"`
StartTime *time.Time `orm:"type(datetime)" json:"startTime,omitempty"`
CreateTime *time.Time `orm:"auto_now_add;type(datetime)" json:"createTime,omitempty"`
}
func (*Charge) TableName() string {
return TableNameCharge
}
func (a *chargeModel) Insert(b *Charge) error {
_, err := Ormer().Insert(b)
return err
}