package Company import ( "Cold_DeductionNotice/logs" _ "github.com/astaxie/beego/cache/redis" "github.com/beego/beego/v2/adapter/orm" _ "github.com/go-sql-driver/mysql" "time" ) type CompanyBill struct { Id int `orm:"column(ID);size(11);auto;pk"` T_pid int `orm:"index;size(256);"` // Account.Company 绑定公司 T_type string `orm:"size(256);"` // 扣费/充值 T_project string `orm:"size(256);"` // 项目 T_bill string `orm:"type(text);"` // 说明 T_charging float32 `orm:"digits(12);decimals(2)"` // 金额 T_balance float32 `orm:"digits(12);decimals(2)"` // 余额(扣费后) CreateTime time.Time `orm:"column(create_time);type(timestamp);null;auto_now_add"` //auto_now_add 第一次保存时才设置时间 } func (t *CompanyBill) TableName() string { return "company_bill" // 数据库名称 // ************** 替换 DesignDeviceNotice ************** } func init() { //注册模型 orm.RegisterModel(new(CompanyBill)) } // 添加 func Add_CompanyBill(m CompanyBill) { o := orm.NewOrm() _, err := o.Insert(&m) if err != nil { logs.PrintlnError("Add_CompanyBill err:", err) } return }