es.go 999 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package http
  2. import (
  3. "strconv"
  4. "go-common/app/job/main/search/model"
  5. "go-common/library/ecode"
  6. bm "go-common/library/net/http/blademaster"
  7. )
  8. func action(c *bm.Context) {
  9. var (
  10. params = c.Request.Form
  11. recoverID int64
  12. writeEntityIndex bool
  13. )
  14. appid := params.Get("appid")
  15. action := params.Get("action")
  16. if appid == "" || action == "" {
  17. c.JSON(nil, ecode.RequestErr)
  18. return
  19. }
  20. if !model.ExistsAction[action] {
  21. c.JSON(nil, ecode.RequestErr)
  22. return
  23. }
  24. if params.Get("recover_id") != "" {
  25. if rid, err := strconv.ParseInt(params.Get("recover_id"), 10, 64); err == nil {
  26. recoverID = rid
  27. }
  28. }
  29. if params.Get("entity") == "1" {
  30. writeEntityIndex = true
  31. } else {
  32. writeEntityIndex = false
  33. }
  34. c.JSON(svr.HTTPAction(ctx, appid, action, recoverID, writeEntityIndex))
  35. }
  36. func stat(c *bm.Context) {
  37. var (
  38. params = c.Request.Form
  39. )
  40. appid := params.Get("appid")
  41. if appid == "" {
  42. c.JSON(nil, ecode.RequestErr)
  43. return
  44. }
  45. c.JSON(svr.Stat(ctx, appid))
  46. }