audit.go 639 B

1234567891011121314151617181920212223242526272829303132333435
  1. package show
  2. import (
  3. "context"
  4. "go-common/library/log"
  5. )
  6. var (
  7. _auditSQL = "SELECT mobi_app,build FROM audit"
  8. )
  9. // Audit get audit.
  10. func (d *Dao) Audit(c context.Context) (res map[string][]int, err error) {
  11. res = make(map[string][]int)
  12. rows, err := d.db.Query(c, _auditSQL)
  13. if err != nil {
  14. log.Error("d.audit error(%v)", err)
  15. return
  16. }
  17. defer rows.Close()
  18. for rows.Next() {
  19. var (
  20. mobiApp string
  21. build int
  22. )
  23. if err = rows.Scan(&mobiApp, &build); err != nil {
  24. log.Error("d.audit rows.Scan error(%v)", err)
  25. res = nil
  26. return
  27. }
  28. res[mobiApp] = append(res[mobiApp], build)
  29. }
  30. err = rows.Err()
  31. return
  32. }