api_statsinfo.go 723 B

123456789101112131415161718192021222324252627282930313233
  1. package admin
  2. import (
  3. "errors"
  4. "net/http"
  5. "github.com/bjdgyc/anylink/dbdata"
  6. )
  7. func StatsInfoList(w http.ResponseWriter, r *http.Request) {
  8. var ok bool
  9. _ = r.ParseForm()
  10. action := r.FormValue("action")
  11. scope := r.FormValue("scope")
  12. ok = dbdata.StatsInfoIns.ValidAction(action)
  13. if !ok {
  14. RespError(w, RespParamErr, errors.New("不存在的图表类别"))
  15. return
  16. }
  17. ok = dbdata.StatsInfoIns.ValidScope(scope)
  18. if !ok {
  19. RespError(w, RespParamErr, errors.New("不存在的日期范围"))
  20. return
  21. }
  22. datas, err := dbdata.StatsInfoIns.GetData(action, scope)
  23. if err != nil {
  24. RespError(w, RespInternalErr, err)
  25. return
  26. }
  27. data := make(map[string]interface{})
  28. data["datas"] = datas
  29. RespSucess(w, data)
  30. }