feat: list shopee sync task history

This commit is contained in:
QiuSW
2026-09-14 09:29:02 +08:00
parent 62e8fd7e9b
commit bf55497c5c
2 changed files with 21 additions and 0 deletions
+20
View File
@@ -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, "查询成功")
}
+1
View File
@@ -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)
}