db_err_service.go 522B

12345678910111213141516171819202122232425262728
  1. package service
  2. import (
  3. "fmt"
  4. "time"
  5. "Xcx_New/models"
  6. "Xcx_New/utils"
  7. )
  8. func CreateDBErrorRecord(orgID int64, decsFormat string, v ...interface{}) {
  9. if orgID < 0 {
  10. orgID = 0
  11. }
  12. now := time.Now()
  13. record := models.DBErrorRecord{
  14. OrgID: orgID,
  15. ErrDesc: fmt.Sprintf(decsFormat, v...),
  16. Status: 1,
  17. CreateTime: now.Unix(),
  18. ModifyTime: now.Unix(),
  19. }
  20. insertErr := writeDb.Save(&record).Error
  21. if insertErr != nil {
  22. utils.ErrorLog("插入数据库执行错误记录失败:%v", insertErr)
  23. }
  24. }