package apis import ( "go-admin/app/observe/service" "go-admin/app/observe/service/dto" "go-admin/utils" "net/http" "github.com/gin-gonic/gin" ) type Stats struct { utils.OtApi } func (s Stats) SetPlatformStats(c *gin.Context) { svc := new(service.Stats) err := s.MakeContext(c).MakeDB().MakeService(&svc.OtService).Errors if err != nil { s.Error(http.StatusInternalServerError, err, err.Error()) return } result := make(map[string]interface{}) if err := svc.SetTotalStats(&result); err != nil { s.Error(http.StatusInternalServerError, err, err.Error()) return } s.OK(result, "ok") } func (s Stats) GetPlatformStats(c *gin.Context) { svc := new(service.Stats) err := s.MakeContext(c).MakeDB().MakeService(&svc.OtService).Errors if err != nil { s.Error(http.StatusInternalServerError, err, err.Error()) return } result := make(map[string]interface{}) if err := svc.GetTotalStats(&result); err != nil { s.Error(http.StatusInternalServerError, err, err.Error()) return } s.OK(result, "ok") } func (s Stats) GetApdexModelByAlias(c *gin.Context) { req := new(dto.ApdexHandlerReq) svc := new(service.Stats) err := s.MakeContext(c).MakeDB().Bind(req).MakeService(&svc.OtService).Errors if err != nil { s.Error(http.StatusInternalServerError, err, err.Error()) return } result := make(map[string]interface{}) if err := svc.GetApdexModelByAppAlias(req, &result); err != nil { s.Error(http.StatusInternalServerError, err, err.Error()) return } s.OK(result, "ok") } func (s Stats) SetApdexModelArgsByAlias(c *gin.Context) { req := new(dto.ApdexUpdateReq) svc := new(service.Stats) err := s.MakeContext(c).MakeDB().Bind(req).MakeService(&svc.OtService).Errors if err != nil { s.Error(http.StatusInternalServerError, err, err.Error()) return } result := make(map[string]interface{}) if err := svc.SetApdexModelByAppAlias(req, &result); err != nil { s.Error(http.StatusInternalServerError, err, err.Error()) return } s.OK(result, "模型更新成功") }