G2AReport.go 829 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package model
  2. import (
  3. "crawler/config"
  4. "crawler/service"
  5. )
  6. type G2AReportInterface interface {
  7. Insert(row G2AReport)
  8. }
  9. type G2AReportModel struct {
  10. G2AReport
  11. }
  12. type G2AReport struct {
  13. TotalCnt int
  14. InsertCnt int
  15. UpdateCnt int
  16. ProcessAt float64
  17. LastPage int
  18. CreatedAt string
  19. }
  20. func (this *G2AReportModel) Insert(row G2AReport) error {
  21. var (
  22. db = service.DB_PLAYR
  23. conn = db.SQLDB
  24. )
  25. sql := `
  26. INSERT INTO tb_g2a_report
  27. SET
  28. total_cnt = ?,
  29. insert_cnt = ?,
  30. update_cnt = ?,
  31. process_at = ?,
  32. last_page = ?,
  33. created_at = NOW();
  34. `
  35. _, err := conn.Exec(sql,
  36. row.TotalCnt, row.InsertCnt, row.UpdateCnt, row.ProcessAt, row.LastPage,
  37. )
  38. if err != nil {
  39. db.SetErrorLog(err, sql)
  40. return err
  41. }
  42. db.SetGeneralLog(config.GL_ACTION_WRITE, sql, "insert g2a report")
  43. return nil
  44. }