query.go 630 B

12345678910111213141516171819202122
  1. package future_good_edb_data
  2. import "hongze/hongze_yb/global"
  3. func GetFutureGoodEdbDataListByDate(futureGoodEdbInfoId int, startDate, endDate string) (list []*FutureGoodEdbData, err error) {
  4. var pars []interface{}
  5. sql := `SELECT * FROM future_good_edb_data WHERE 1=1 AND future_good_edb_info_id = ? `
  6. pars = append(pars, futureGoodEdbInfoId)
  7. if startDate != "" {
  8. sql += ` AND data_time>=? `
  9. pars = append(pars, startDate)
  10. }
  11. if endDate != "" {
  12. sql += ` AND data_time<=? `
  13. pars = append(pars, endDate)
  14. }
  15. sql += ` ORDER BY data_time ASC `
  16. err = global.MYSQL["data"].Raw(sql, pars...).Scan(&list).Error
  17. return
  18. }