From bf55497c5c8dc09fc0feae1bfa3fcadf36c8b283 Mon Sep 17 00:00:00 2001 From: QiuSW <105186638@qq.com> Date: Mon, 14 Sep 2026 09:29:02 +0800 Subject: [PATCH] feat: list shopee sync task history --- app/admin/apis/shopee_product.go | 20 ++++++++++++++++++++ app/admin/router/shopee_product.go | 1 + 2 files changed, 21 insertions(+) diff --git a/app/admin/apis/shopee_product.go b/app/admin/apis/shopee_product.go index 7e87334..e0cf73e 100644 --- a/app/admin/apis/shopee_product.go +++ b/app/admin/apis/shopee_product.go @@ -381,3 +381,23 @@ func (e ShopeeProduct) List(c *gin.Context) { } e.OK(rows, "查询成功") } + +// ListSyncTasks returns recent synchronization history for the Admin console. +func (e ShopeeProduct) ListSyncTasks(c *gin.Context) { + e.MakeContext(c) + rows := make([]models.ShopeeSyncTask, 0) + db := primaryDB() + if db == nil { + e.Error(500, fmt.Errorf("database is not initialized"), "数据库未初始化") + return + } + q := db.Order("id desc").Limit(100) + if id := strings.TrimSpace(c.Query("shopeeId")); id != "" { + q = q.Where("shopee_id = ?", id) + } + if err := q.Find(&rows).Error; err != nil { + e.Error(500, err, "读取同步任务失败") + return + } + e.OK(rows, "查询成功") +} diff --git a/app/admin/router/shopee_product.go b/app/admin/router/shopee_product.go index 988ab73..5c21828 100644 --- a/app/admin/router/shopee_product.go +++ b/app/admin/router/shopee_product.go @@ -21,5 +21,6 @@ func registerShopeeProductAdminRouter(v1 *gin.RouterGroup, auth *jwt.GinJWTMiddl a := apis.ShopeeProduct{} r := v1.Group("/shopee/products").Use(auth.MiddlewareFunc()).Use(middleware.AuthCheckRole()) r.GET("", a.List) + r.GET("/sync-tasks", a.ListSyncTasks) r.GET("/sync/:shopeeId", a.GetByShopeeIDAdmin) }