up_withdraw.go 1002 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package income
  2. import (
  3. "context"
  4. "fmt"
  5. model "go-common/app/admin/main/growup/model/income"
  6. "go-common/library/log"
  7. )
  8. const (
  9. // select
  10. _upWithdrawSQL = "SELECT id, mid, withdraw_income, date_version, mtime FROM up_income_withdraw WHERE id > ? AND state = 2 AND %s is_deleted = 0 LIMIT ?"
  11. )
  12. // ListUpWithdraw list up_income_withdraw by query
  13. func (d *Dao) ListUpWithdraw(c context.Context, id int64, query string, limit int) (upWithdraw []*model.UpIncomeWithdraw, err error) {
  14. upWithdraw = make([]*model.UpIncomeWithdraw, 0)
  15. rows, err := d.db.Query(c, fmt.Sprintf(_upWithdrawSQL, query), id, limit)
  16. if err != nil {
  17. log.Error("GetUpWithdraw d.db.Query error(%v)", err)
  18. return
  19. }
  20. defer rows.Close()
  21. for rows.Next() {
  22. w := &model.UpIncomeWithdraw{}
  23. err = rows.Scan(&w.ID, &w.MID, &w.WithdrawIncome, &w.DateVersion, &w.MTime)
  24. if err != nil {
  25. log.Error("GetUpWithdraw rows scan error(%v)", err)
  26. return
  27. }
  28. upWithdraw = append(upWithdraw, w)
  29. }
  30. err = rows.Err()
  31. return
  32. }