package services import ( "encoding/json" "fmt" "eta/eta_api/models/system" "eta/eta_api/utils" "time" ) // the service for log func AutoInsertAdminOperateRecordToDB() { defer func() { if err := recover(); err != nil { fmt.Println("[AutoInsertAdminOperateRecordToDB]", err) } }() for { utils.Rc.Brpop(utils.CACHE_KEY_ADMIN_OPERATE_RECORD, func(b []byte) { record := new(system.AdminOperateRecord) if err := json.Unmarshal(b, &record); err != nil { fmt.Println("json unmarshal wrong!") } record.CreateTime = time.Now() if err := record.Insert(); err != nil { fmt.Println("AutoInsertAdminOperateRecordToDB Err:", err.Error(), record) } }) } }