mysql.go 987 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package dao
  2. import (
  3. "context"
  4. "time"
  5. "go-common/library/log"
  6. )
  7. const (
  8. _updateJuryExpiredSQL = "UPDATE blocked_jury SET status=1, expired=? WHERE mid = ?"
  9. _selConfSQL = "SELECT config_key,content FROM blocked_config"
  10. )
  11. // UpdateJuryExpired update jury expired.
  12. func (d *Dao) UpdateJuryExpired(c context.Context, mid int64, expired time.Time) (err error) {
  13. if _, err = d.db.Exec(c, _updateJuryExpiredSQL, expired, mid); err != nil {
  14. log.Error("d.UpdateJuryExpired err(%v)", err)
  15. }
  16. return
  17. }
  18. // LoadConf load conf.
  19. func (d *Dao) LoadConf(c context.Context) (cf map[string]string, err error) {
  20. cf = make(map[string]string)
  21. rows, err := d.db.Query(c, _selConfSQL)
  22. if err != nil {
  23. log.Error("d.loadConf err(%v)", err)
  24. return
  25. }
  26. defer rows.Close()
  27. var (
  28. key string
  29. value string
  30. )
  31. for rows.Next() {
  32. if err = rows.Scan(&key, &value); err != nil {
  33. log.Error("rows.Scan err(%v)", err)
  34. continue
  35. }
  36. cf[key] = value
  37. }
  38. err = rows.Err()
  39. return
  40. }