package services import ( "encoding/json" "fmt" "hongze/hz_crm_api/models/system" "hongze/hz_crm_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) } }) } }