diff --git a/cmd/migrate/migration/version/1789257600000_shopee_product_page.go b/cmd/migrate/migration/version/1789257600000_shopee_product_page.go new file mode 100644 index 0000000..8708066 --- /dev/null +++ b/cmd/migrate/migration/version/1789257600000_shopee_product_page.go @@ -0,0 +1,30 @@ +package version + +import ( + "fmt" + "go-admin/app/admin/models" + "go-admin/cmd/migrate/migration" + common "go-admin/common/models" + "gorm.io/gorm" +) + +func init() { migration.Migrate.SetVersion("1789257600000", migrateShopeeProductPage) } +func migrateShopeeProductPage(db *gorm.DB, version string) error { + if err := db.AutoMigrate(&models.ShopeeProduct{}); err != nil { + return err + } + return db.Transaction(func(tx *gorm.DB) error { + var parent models.SysMenu + if err := tx.Where("title = ? AND menu_type = ?", "系统管理", "M").First(&parent).Error; err != nil { + return err + } + menu := models.SysMenu{MenuName: "ShopeeProductManagement", Title: "Shopee 商品", Icon: "shopping", Path: "/admin/shopee-products", MenuType: "C", ParentId: parent.MenuId, Component: "/admin/shopee-product/index", Visible: "0", NoCache: true, Sort: 91, IsFrame: "1"} + if err := tx.Where("menu_name = ?", menu.MenuName).FirstOrCreate(&menu).Error; err != nil { + return err + } + if err := tx.Model(&menu).Update("paths", fmt.Sprintf("%s/%d", parent.Paths, menu.MenuId)).Error; err != nil { + return err + } + return tx.Create(&common.Migration{Version: version}).Error + }) +} diff --git a/tickets/LOCAL-006-shopee-product-page.md b/tickets/LOCAL-006-shopee-product-page.md new file mode 100644 index 0000000..18e1362 --- /dev/null +++ b/tickets/LOCAL-006-shopee-product-page.md @@ -0,0 +1,28 @@ +# LOCAL-006:Shopee 商品查询页面 + +- 状态:进行中 +- 来源:2026-09-12 用户「建006工单,做」 +- 前置:LOCAL-004、LOCAL-005 + +## 目标 +在 Admin 中查询和查看已保存的 Shopee 商品,并提供按 Shopee ID 从货憨憨同步的入口。 + +## 范围 +- Shopee ID 查询; +- 查询结果落库并在列表显示; +- 商品详情和原始 JSON 查看; +- 标题、店铺、状态、价格、主图和更新时间展示; +- 加载、空结果、错误和重复查询反馈。 + +## 非目标 +商品编辑、图片上传、视频上传、批量操作和定时同步。 + +## 验收 +- Admin 菜单可访问; +- 有效 Shopee ID 查询成功并可在列表和详情中查看; +- 重复查询更新已有记录; +- 无效 ID、认证失败和网络错误有明确提示; +- `go test ./app/admin/...` 和前端编译通过。 + +## 证据 +实施中。 diff --git a/web/src/api/admin/shopee-product.js b/web/src/api/admin/shopee-product.js new file mode 100644 index 0000000..0d5467c --- /dev/null +++ b/web/src/api/admin/shopee-product.js @@ -0,0 +1,4 @@ +import request from '@/utils/request' + +export const listProducts = shopeeId => request({ url: '/api/v1/shopee/products', method: 'get', params: shopeeId ? { shopeeId } : {} }) +export const syncProduct = shopeeId => request({ url: `/api/v1/shopee/products/${encodeURIComponent(shopeeId)}`, method: 'get' }) diff --git a/web/src/views/admin/shopee-product/index.vue b/web/src/views/admin/shopee-product/index.vue new file mode 100644 index 0000000..5545921 --- /dev/null +++ b/web/src/views/admin/shopee-product/index.vue @@ -0,0 +1,61 @@ + + + + +