diff --git a/product/controller.go b/product/controller.go index 1dda645..3274f4b 100644 --- a/product/controller.go +++ b/product/controller.go @@ -38,6 +38,12 @@ func (c *Controller) AutoMigrate() { func (c *Controller) Run(ctx context.Context) { c.ctx = ctx ticker := time.NewTicker(c.Interval) + if err := c.Crawl(); err != nil { + slog.Error(err.Error()) + } else { + slog.Info("抓取信息成功") + c.updateTime = time.Now() + } for { select { case <-ctx.Done(): @@ -55,6 +61,7 @@ func (c *Controller) Run(ctx context.Context) { } func (c *Controller) Crawl() error { + slog.Info("开始抓取信息") for page, totalPage := 1, -1; page <= totalPage || totalPage == -1; page++ { resp, err := c.client.ViewAllBags(c.ctx, page) if err != nil {