123456789101112131415161718192021222324252627282930 |
- package services
- import (
- "encoding/json"
- "eta_gn/eta_api/models/system"
- "eta_gn/eta_api/utils"
- "fmt"
- "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)
- }
- })
- }
- }
|