package server import ( "github.com/gofiber/fiber/v3" "haitao_watcher/pkg/model" "haitao_watcher/pkg/options" "haitao_watcher/pkg/pusher" ) type PusherSvc struct { ctl *pusher.Controller } func NewPusherSvcController(ctl *pusher.Controller) *PusherSvc { return &PusherSvc{ ctl: ctl, } } func (s *PusherSvc) RegistryRouter(r fiber.Router) { r.Get("pushers", s.ListPusherInfo) r.Post("pushers", s.CreatePusher) } func (s *PusherSvc) ListPusherInfo(ctx fiber.Ctx) error { var req pusher.ListPusherInfoRequest if err := ctx.Bind().Query(&req); err != nil { return err } resp, err := s.ctl.List(req) if err != nil { return err } return ctx.JSON(resp) } func (s *PusherSvc) CreatePusher(ctx fiber.Ctx) error { var opt model.Pusher[options.AnPushOption] if err := ctx.Bind().JSON(&opt); err != nil { return err } return s.ctl.AddPusher(&opt) }