package System import ( "github.com/beego/beego/v2/adapter/orm" "time" ) type Logs struct { Id int `orm:"column(ID);size(11);auto;pk"` Logs_class string `orm:"size(256);"` // Logs_Title string `orm:"size(256);"` // 标题 Logs_Txt string `orm:"type(text);"` // 详情 CreateTime time.Time `orm:"column(create_time);type(timestamp);auto_now_add"` //auto_now 每次 model 保存时都会对时间自动更新 UpdateTime time.Time `orm:"column(update_time);type(timestamp);auto_now"` //auto_now_add 第一次保存时才设置时间 } func (t *Logs) TableName() string { return "Logs" // 数据库名称 // ************** 替换 FormulaList ************** } func init() { //注册模型 orm.RegisterModel(new(Logs)) } // 添加 logs.Println("MqttServer","参数请求 [Rt_Parameter]","base") func Add_Logs(Logs_class string, Logs_Title string, Logs_Txt string) { o := orm.NewOrm() m := Logs{Logs_class: Logs_class, Logs_Title: Logs_Title, Logs_Txt: Logs_Txt} o.Insert(&m) }