// src/lib/services/productService.ts import api from '@/lib/api'; export interface ProductListParams { page?: number; size?: number; page_size?: number; keyword?: string; is_active?: boolean; category?: string; [key: string]: any; } export const productService = { /** * 获取已启用的产品列表 (客户端前台) */ async listEnabled(params?: ProductListParams) { const res = await api.get('/api/vas/product/list-enable', { params }); return res.data; }, /** * 分页查询产品列表 (后台) */ async listAll(params?: ProductListParams) { const res = await api.get('/api/vas/product/list', { params }); return res.data; }, /** * 获取产品详情 */ async getDetail(productId: number) { const res = await api.get('/api/vas/product/detail', { params: { product_id: productId }, }); return res.data; }, /** * 新建产品 */ async create(payload: Record) { const res = await api.post('/api/vas/product/create', payload); return res.data; }, /** * 更新产品 */ async update(productId: number, payload: Record) { const res = await api.post('/api/vas/product/update', payload, { params: { product_id: productId }, }); return res.data; }, /** * 删除产品 */ async delete(productId: number) { const res = await api.delete('/api/vas/product/delete', { params: { product_id: productId }, }); return res.data; }, /** * 查询所有表单 Schema 列表 */ async listSchemas(params?: { page?: number; size?: number; page_size?: number; keyword?: string }) { const res = await api.get('/api/vas/schema/list', { params }); return res.data; }, /** * 获取指定 Schema 详情 */ async getSchemaDetail(schemaId: number) { const res = await api.get('/api/vas/schema/detail', { params: { schema_id: schemaId }, }); return res.data; }, /** * 新增动态表单 Schema */ async createSchema(payload: Record) { const res = await api.post('/api/vas/schema/create', payload); return res.data; }, /** * 更新动态表单 Schema */ async updateSchema(schemaId: number, payload: Record) { const res = await api.post('/api/vas/schema/update', payload, { params: { schema_id: schemaId }, }); return res.data; }, /** * 删除表单 Schema */ async deleteSchema(schemaId: number) { const res = await api.delete('/api/vas/schema/delete', { params: { id: schemaId, schema_id: schemaId }, }); return res.data; }, /** * 获取产品的路由配置列表 */ async listRoutings(productId: number) { const res = await api.get('/api/vas/product_routing/list_by_product', { params: { product_id: productId }, }); return res.data; }, /** * 创建产品路由配置 */ async createRouting(payload: Record) { const res = await api.post('/api/vas/product_routing/create', payload); return res.data; }, /** * 更新产品路由配置 */ async updateRouting(id: number, payload: Record) { const res = await api.post('/api/vas/product_routing/update', payload, { params: { id }, }); return res.data; }, /** * 删除产品路由配置 */ async deleteRouting(id: number) { const res = await api.delete('/api/vas/product_routing/delete', { params: { id }, }); return res.data; }, };