| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153 |
- // 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<string, any>) {
- const res = await api.post('/api/vas/product/create', payload);
- return res.data;
- },
- /**
- * 更新产品
- */
- async update(productId: number, payload: Record<string, any>) {
- 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<string, any>) {
- const res = await api.post('/api/vas/schema/create', payload);
- return res.data;
- },
- /**
- * 更新动态表单 Schema
- */
- async updateSchema(schemaId: number, payload: Record<string, any>) {
- 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<string, any>) {
- const res = await api.post('/api/vas/product_routing/create', payload);
- return res.data;
- },
- /**
- * 更新产品路由配置
- */
- async updateRouting(id: number, payload: Record<string, any>) {
- 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;
- },
- };
|