From 6d247632b70929b51469095e7979c46e7f74bd90 Mon Sep 17 00:00:00 2001 From: timerzz Date: Tue, 14 May 2024 17:22:10 +0800 Subject: [PATCH] =?UTF-8?q?feat=20=E5=90=AF=E5=8A=A8=E6=97=B6=E6=8A=93?= =?UTF-8?q?=E5=8F=96=E4=B8=80=E6=AC=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- product/controller.go | 7 +++++++ 1 file changed, 7 insertions(+) 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 {