dashboard.go 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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 NeckRingWarning(c *gin.Context) {
  13. res, err := middleware.Dependency(c).StoreEventHub.OpsService.NeckRingWarning(c)
  14. if err != nil {
  15. apierr.ClassifiedAbort(c, err)
  16. return
  17. }
  18. ginutil.JSONResp(c, res)
  19. }
  20. func FocusIndicators(c *gin.Context) {
  21. dimension := c.Param("dimension")
  22. if err := valid.Validate(dimension, valid.Required); err != nil {
  23. apierr.AbortBadRequest(c, http.StatusBadRequest, err)
  24. return
  25. }
  26. res, err := middleware.Dependency(c).StoreEventHub.OpsService.FocusIndicatorsList(c, dimension)
  27. if err != nil {
  28. apierr.ClassifiedAbort(c, err)
  29. return
  30. }
  31. ginutil.JSONResp(c, res)
  32. }
  33. func FocusIndicatorsSet(c *gin.Context) {
  34. var req pasturePb.IndexFocusIndicatorsSetRequest
  35. if err := ginutil.BindProto(c, &req); err != nil {
  36. apierr.AbortBadRequest(c, http.StatusBadRequest, err)
  37. return
  38. }
  39. if err := middleware.Dependency(c).StoreEventHub.OpsService.FocusIndicatorsSet(c, &req); err != nil {
  40. apierr.ClassifiedAbort(c, err)
  41. return
  42. }
  43. ginutil.JSONResp(c, &operationPb.CommonOK{
  44. Code: http.StatusOK,
  45. Msg: "ok",
  46. Data: &operationPb.Success{Success: true},
  47. })
  48. }
  49. func TodoCount(c *gin.Context) {
  50. var req pasturePb.IndexDataWarningSetRequest
  51. if err := ginutil.BindProto(c, &req); err != nil {
  52. apierr.AbortBadRequest(c, http.StatusBadRequest, err)
  53. return
  54. }
  55. res, err := middleware.Dependency(c).StoreEventHub.OpsService.CalendarToDoCount(c)
  56. if err != nil {
  57. apierr.ClassifiedAbort(c, err)
  58. return
  59. }
  60. ginutil.JSONResp(c, res)
  61. }
  62. func DataWarningSet(c *gin.Context) {
  63. var req pasturePb.IndexDataWarningSetRequest
  64. if err := ginutil.BindProto(c, &req); err != nil {
  65. apierr.AbortBadRequest(c, http.StatusBadRequest, err)
  66. return
  67. }
  68. if err := middleware.Dependency(c).StoreEventHub.OpsService.DataWarningSet(c, &req); err != nil {
  69. apierr.ClassifiedAbort(c, err)
  70. return
  71. }
  72. ginutil.JSONResp(c, &operationPb.CommonOK{
  73. Code: http.StatusOK,
  74. Msg: "ok",
  75. Data: &operationPb.Success{Success: true},
  76. })
  77. }
  78. func DataWarningList(c *gin.Context) {
  79. res, err := middleware.Dependency(c).StoreEventHub.OpsService.DataWarningList(c)
  80. if err != nil {
  81. apierr.ClassifiedAbort(c, err)
  82. return
  83. }
  84. ginutil.JSONResp(c, res)
  85. }