Logs.go 1014 B

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