query.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package future_good_edb_data
  2. import (
  3. "hongze/hongze_yb/global"
  4. )
  5. func GetFutureGoodEdbDataListByDate(futureGoodEdbInfoId int, startDate, endDate string) (list []*FutureGoodEdbData, err error) {
  6. var pars []interface{}
  7. sql := `SELECT * FROM future_good_edb_data WHERE 1=1 AND future_good_edb_info_id = ? `
  8. pars = append(pars, futureGoodEdbInfoId)
  9. if startDate != "" {
  10. sql += ` AND data_time>=? `
  11. pars = append(pars, startDate)
  12. }
  13. if endDate != "" {
  14. sql += ` AND data_time<=? `
  15. pars = append(pars, endDate)
  16. }
  17. sql += ` ORDER BY data_time ASC `
  18. err = global.MYSQL["data"].Raw(sql, pars...).Scan(&list).Error
  19. return
  20. }
  21. func GetFutureGoodEdbDataListByIdsAndDate(futureGoodEdbInfoIds []int, startDate, endDate string) (list []*FutureGoodEdbData, err error) {
  22. var pars []interface{}
  23. sql := `SELECT * FROM future_good_edb_data WHERE 1=1 AND future_good_edb_info_id in (?) `
  24. pars = append(pars, futureGoodEdbInfoIds)
  25. if startDate != "" {
  26. sql += ` AND data_time>=? `
  27. pars = append(pars, startDate)
  28. }
  29. if endDate != "" {
  30. sql += ` AND data_time<=? `
  31. pars = append(pars, endDate)
  32. }
  33. sql += ` ORDER BY data_time ASC `
  34. err = global.MYSQL["data"].Raw(sql, pars...).Scan(&list).Error
  35. return
  36. }