column_charge.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. package income
  2. import (
  3. "context"
  4. "time"
  5. model "go-common/app/job/main/growup/model/income"
  6. "go-common/library/log"
  7. xtime "go-common/library/time"
  8. )
  9. const (
  10. _columnChargeSQL = "SELECT id,aid,title,mid,tag_id,upload_time,inc_charge,view_c,date FROM column_daily_charge WHERE id > ? AND date = ? AND inc_charge > 0 ORDER BY id LIMIT ?"
  11. )
  12. // ColumnDailyCharge get column daily charge by date
  13. func (d *Dao) ColumnDailyCharge(c context.Context, date time.Time, id int64, limit int) (columns []*model.ColumnCharge, err error) {
  14. columns = make([]*model.ColumnCharge, 0)
  15. rows, err := d.db.Query(c, _columnChargeSQL, id, date, limit)
  16. if err != nil {
  17. log.Error("ColumnDailyCharge d.db.Query error(%v)", err)
  18. return
  19. }
  20. defer rows.Close()
  21. for rows.Next() {
  22. column := &model.ColumnCharge{}
  23. var uploadTime int64
  24. err = rows.Scan(&column.ID, &column.ArticleID, &column.Title, &column.MID, &column.TagID, &uploadTime, &column.IncCharge, &column.IncViewCount, &column.Date)
  25. if err != nil {
  26. log.Error("ColumnDailyCharge rows.Scan error(%v)", err)
  27. return
  28. }
  29. column.UploadTime = xtime.Time(uploadTime)
  30. columns = append(columns, column)
  31. }
  32. return
  33. }