package models import ( "eta/eta_api/utils" "time" _ "github.com/go-sql-driver/mysql" "github.com/go-xorm/xorm" ) type OperateLogs struct { Id int `xorm:"int pk autoincr 'id'"` AdminId int `xorm:"int 'admin_id'"` SysUserRealName string `xorm:"varchar(1000) 'sys_user_real_name'"` OperateTime time.Time `xorm:"timestamp null 'operate_time'"` Request string `xorm:"text null 'request'"` Response string `xorm:"text null 'response'"` OperateIp string `xorm:"varchar(1000) null 'operate_ip'"` Model string `xorm:"varchar(1000) null 'model'"` } type OprateTimeLogs struct { Uid int OperationTime time.Time } var engine *xorm.Engine func init() { var err error log := utils.MYSQL_LOG_URL engine, err = xorm.NewEngine("mysql", log) if err != nil { panic(err.Error()) } } // AddLogs insert a new Logs into database and returns // last inserted Id on success. func AddLogs(m *OperateLogs) (id int64, err error) { id, err = engine.InsertOne(m) return }