package monitorApi import ( "stat/api/proto" "stat/common/stdLog" "stat/service/monitorSer" "github.com/gin-gonic/gin" ) // @Tags 应用监控 // @Summary 分组分页获取应用监控 // @Description 分组分页获取应用监控 // @Accept json // @Produce json // @Param param body proto.MonitorSearch true "参数列表" // @Success 200 {object} proto.MonitorSearchResp "成功" // @Failure 400 {string} string "获取失败的返回结果" // @Security ApiKeyAuth // @Router /api/stat/monitor/list [POST] func SearchMonitor(ctx *gin.Context) { var req = &proto.MonitorSearch{} if err := ctx.ShouldBind(req); err != nil { stdLog.ServerJSON(ctx, stdLog.ParamError, err) return } resp, serr := monitorSer.SearchMonitor(ctx, req) if serr != nil { stdLog.ServerJSON(ctx, stdLog.Failure, serr) return } stdLog.ServerJSON(ctx, stdLog.Success, resp) } // @Tags 应用监控 // @Summary 添加一个应用监控 // @Description 添加一个应用监控 // @Accept json // @Produce json // @Param param body proto.MonitorAddReq true "参数列表" // @Success 200 {string} string "成功" // @Failure 400 {string} string "获取失败的返回结果" // @Security ApiKeyAuth // @Router /api/stat/monitor/add [POST] func AddMonitor(ctx *gin.Context) { var req = &proto.MonitorAddReq{} if err := ctx.ShouldBind(req); err != nil { stdLog.ServerJSON(ctx, stdLog.ParamError, err) return } serr := monitorSer.AddMonitor(ctx, req) if serr != nil { stdLog.ServerJSON(ctx, stdLog.Failure, serr) return } stdLog.ServerJSON(ctx, stdLog.Success, "") } // @Tags 应用监控 // @Summary 删除一个应用监控 // @Description 删除一个应用监控 // @Accept json // @Produce json // @Param param body proto.MonitorDelReq true "参数列表" // @Failure 400 {string} string "获取失败的返回结果" // @Security ApiKeyAuth // @Router /api/stat/monitor/del [DELETE] func DelMonitor(ctx *gin.Context) { var req = &proto.MonitorDelReq{} if err := ctx.ShouldBind(req); err != nil { stdLog.ServerJSON(ctx, stdLog.ParamError, err) return } serr := monitorSer.DelMonitor(ctx, req.Id) if serr != nil { stdLog.ServerJSON(ctx, stdLog.Failure, serr) return } stdLog.ServerJSON(ctx, stdLog.Success, "") } // @Tags 应用监控 // @Summary 更新一个应用监控 // @Description 更新一个应用监控 // @Accept json // @Produce json // @Param param body proto.MonitorUpdateReq true "参数列表" // @Success 200 {string} string "成功" // @Failure 400 {string} string "获取失败的返回结果" // @Security ApiKeyAuth // @Router /api/stat/monitor/update [POST] func UpdateMonitor(ctx *gin.Context) { var req = &proto.MonitorUpdateReq{} if err := ctx.ShouldBind(req); err != nil { stdLog.ServerJSON(ctx, stdLog.ParamError, nil) return } serr := monitorSer.UpdateMonitor(ctx, req) if serr != nil { stdLog.ServerJSON(ctx, stdLog.Failure, serr) return } stdLog.ServerJSON(ctx, stdLog.Success, "") }