feat: 增加商品目录导入记录 (#134)
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"cmautobuy/admin/config"
|
||||
"cmautobuy/admin/repository"
|
||||
"cmautobuy/admin/service"
|
||||
)
|
||||
|
||||
@@ -23,6 +24,20 @@ func Register(r *gin.Engine, db *sql.DB, cfg config.CatalogIntegrationConfig) {
|
||||
h := &Handler{db: db}
|
||||
g := r.Group("/api/v1/integrations/catalog", RequireCatalogToken(cfg))
|
||||
g.POST("/batches", h.CreateBatch)
|
||||
g.GET("/batches/:batch_id", h.GetBatch)
|
||||
}
|
||||
|
||||
func (h *Handler) GetBatch(c *gin.Context) {
|
||||
run, err := repository.GetCatalogImportRun(h.db, integrationSource(c), c.Param("batch_id"))
|
||||
if errors.Is(err, repository.ErrCatalogImportRunNotFound) {
|
||||
integrationError(c, 404, "BATCH_NOT_FOUND", "批次不存在", false, nil)
|
||||
return
|
||||
}
|
||||
if err != nil {
|
||||
integrationError(c, 500, "INTERNAL_ERROR", "查询批次失败", true, nil)
|
||||
return
|
||||
}
|
||||
c.JSON(200, gin.H{"source": run.Source, "batch_id": run.BatchID, "status": run.Status, "request_count": run.RequestCount, "conflict_count": run.ConflictCount, "observed_at": run.ObservedAt, "created_at": run.CreatedAt, "finished_at": run.FinishedAt, "counts": gin.H{"shopee_created": run.ShopeeCreated, "shopee_updated": run.ShopeeUpdated, "sku_created": run.SKUCreated, "sku_updated": run.SKUUpdated, "pdd_created": run.PddCreated, "pdd_updated": run.PddUpdated, "association_created": run.AssociationCreated, "association_unchanged": run.AssociationUnchanged}, "failure_count": run.FailureCount, "error_summary": run.ErrorSummary})
|
||||
}
|
||||
|
||||
func (h *Handler) CreateBatch(c *gin.Context) {
|
||||
|
||||
Reference in New Issue
Block a user