dashboard.go 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. package dashboard
  2. import (
  3. "kpt-pasture/http/middleware"
  4. "net/http"
  5. operationPb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/operation"
  6. pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
  7. "gitee.com/xuyiping_admin/pkg/valid"
  8. "gitee.com/xuyiping_admin/pkg/apierr"
  9. "gitee.com/xuyiping_admin/pkg/ginutil"
  10. "github.com/gin-gonic/gin"
  11. )
  12. func Bar(c *gin.Context) {
  13. res, err := middleware.Dependency(c).StoreEventHub.OpsService.Bar(c)
  14. if err != nil {
  15. apierr.ClassifiedAbort(c, err)
  16. return
  17. }
  18. ginutil.JSONResp(c, res)
  19. }
  20. func NeckRingWarning(c *gin.Context) {
  21. res, err := middleware.Dependency(c).StoreEventHub.OpsService.NeckRingWarning(c)
  22. if err != nil {
  23. apierr.ClassifiedAbort(c, err)
  24. return
  25. }
  26. ginutil.JSONResp(c, res)
  27. }
  28. func FocusIndicators(c *gin.Context) {
  29. dimension := c.Param("dimension")
  30. if err := valid.Validate(dimension, valid.Required); err != nil {
  31. apierr.AbortBadRequest(c, http.StatusBadRequest, err)
  32. return
  33. }
  34. res, err := middleware.Dependency(c).StoreEventHub.OpsService.FocusIndicatorsList(c, dimension)
  35. if err != nil {
  36. apierr.ClassifiedAbort(c, err)
  37. return
  38. }
  39. ginutil.JSONResp(c, res)
  40. }
  41. func FocusIndicatorsSet(c *gin.Context) {
  42. var req pasturePb.IndexFocusIndicatorsSetRequest
  43. if err := ginutil.BindProto(c, &req); err != nil {
  44. apierr.AbortBadRequest(c, http.StatusBadRequest, err)
  45. return
  46. }
  47. if err := middleware.Dependency(c).StoreEventHub.OpsService.FocusIndicatorsSet(c, &req); err != nil {
  48. apierr.ClassifiedAbort(c, err)
  49. return
  50. }
  51. ginutil.JSONResp(c, &operationPb.CommonOK{
  52. Code: http.StatusOK,
  53. Msg: "ok",
  54. Data: &operationPb.Success{Success: true},
  55. })
  56. }
  57. func DataWarningSet(c *gin.Context) {
  58. var req pasturePb.IndexDataWarningSetRequest
  59. if err := ginutil.BindProto(c, &req); err != nil {
  60. apierr.AbortBadRequest(c, http.StatusBadRequest, err)
  61. return
  62. }
  63. if err := middleware.Dependency(c).StoreEventHub.OpsService.DataWarningSet(c, &req); err != nil {
  64. apierr.ClassifiedAbort(c, err)
  65. return
  66. }
  67. ginutil.JSONResp(c, &operationPb.CommonOK{
  68. Code: http.StatusOK,
  69. Msg: "ok",
  70. Data: &operationPb.Success{Success: true},
  71. })
  72. }
  73. func DataWarningList(c *gin.Context) {
  74. res, err := middleware.Dependency(c).StoreEventHub.OpsService.DataWarningList(c)
  75. if err != nil {
  76. apierr.ClassifiedAbort(c, err)
  77. return
  78. }
  79. ginutil.JSONResp(c, res)
  80. }