logs.go 984 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package models
  2. import (
  3. "eta_gn/eta_api/utils"
  4. "time"
  5. _ "github.com/go-sql-driver/mysql"
  6. "github.com/go-xorm/xorm"
  7. )
  8. type OperateLogs struct {
  9. Id int `xorm:"int pk autoincr 'id'"`
  10. AdminId int `xorm:"int 'admin_id'"`
  11. SysUserRealName string `xorm:"varchar(1000) 'sys_user_real_name'"`
  12. OperateTime time.Time `xorm:"timestamp null 'operate_time'"`
  13. Request string `xorm:"text null 'request'"`
  14. Response string `xorm:"text null 'response'"`
  15. OperateIp string `xorm:"varchar(1000) null 'operate_ip'"`
  16. Model string `xorm:"varchar(1000) null 'model'"`
  17. }
  18. type OprateTimeLogs struct {
  19. Uid int
  20. OperationTime time.Time
  21. }
  22. var engine *xorm.Engine
  23. func init() {
  24. var err error
  25. log := utils.MYSQL_LOG_URL
  26. engine, err = xorm.NewEngine("mysql", log)
  27. if err != nil {
  28. panic(err.Error())
  29. }
  30. }
  31. func AddLogs(m *OperateLogs) (id int64, err error) {
  32. id, err = engine.InsertOne(m)
  33. return
  34. }