package controller import ( "github.com/gin-gonic/gin" "gitlab.wodcloud.com/smart-operation/so-operation-api/src/bean/vo/request" "gitlab.wodcloud.com/smart-operation/so-operation-api/src/pkg/beagle/resp" "gitlab.wodcloud.com/smart-operation/so-operation-api/src/service" ) // AddMetricConfig 新增任务 func AddMetricConfig(c *gin.Context) { var req request.AddMetricConfig if err := c.ShouldBindJSON(&req); err != nil { SendJsonResponse(c, resp.InvalidParam.TranslateError(err), nil) return } svc := service.MetricConfigSvc{} err := svc.Add(req) if err != nil { SendJsonResponse(c, err, nil) return } SendJsonResponse(c, resp.OK, nil) } func UpdateMetricConfig(c *gin.Context) { var req request.UpdateMetricConfig if err := c.ShouldBindJSON(&req); err != nil { SendJsonResponse(c, resp.InvalidParam.TranslateError(err), nil) return } svc := service.MetricConfigSvc{} err := svc.Update(req) if err != nil { SendJsonResponse(c, err, nil) return } SendJsonResponse(c, resp.OK, nil) } func DetailMetricConfig(c *gin.Context) { var req request.GetMetricConfig if err := c.ShouldBindJSON(&req); err != nil { SendJsonResponse(c, resp.InvalidParam.TranslateError(err), nil) return } svc := service.MetricConfigSvc{} data, err := svc.GetDataById(req) if err != nil { SendJsonResponse(c, err, nil) return } SendJsonResponse(c, resp.OK, data) } func DeleteMetricConfig(c *gin.Context) { var req request.DeleteMetricConfig if err := c.ShouldBindJSON(&req); err != nil { SendJsonResponse(c, resp.InvalidParam.TranslateError(err), nil) return } svc := service.MetricConfigSvc{} err := svc.DeleteDataById(req) if err != nil { SendJsonResponse(c, err, nil) return } SendJsonResponse(c, resp.OK, nil) }