feat: harden phase one workflows

This commit is contained in:
王鹏
2026-07-14 16:04:51 +08:00
parent 47f4a24760
commit 767534df48
103 changed files with 4849 additions and 388 deletions

View File

@@ -1,8 +1,28 @@
import type { Product, ProductCategory, ProductSku } from '../types'
import type { PageResponse, Product, ProductCategory, ProductSku } from '../types'
import { apiGet, apiPost, apiPut } from './http'
export function listProducts() {
return apiGet<Product[]>('/api/admin/products')
export interface ProductQuery {
keyword?: string
categoryId?: number
merchantId?: number
pageNo?: number
pageSize?: number
}
export function buildProductQuery(query: ProductQuery = {}) {
const params: Record<string, string | number> = {
pageNo: query.pageNo || 1,
pageSize: query.pageSize || 20
}
if (query.keyword) params.keyword = query.keyword
if (query.categoryId) params.categoryId = query.categoryId
if (query.merchantId) params.merchantId = query.merchantId
return params
}
export async function listProducts(query: ProductQuery = {}) {
const page = await apiGet<PageResponse<Product>>('/api/admin/products/page', buildProductQuery(query))
return page.records
}
export function createProduct(data: Partial<Product>) {