import Content from '@/sheep/layouts/content.vue';
import { request } from '@/sheep/request';
import { CRUD } from '@/sheep/request/crud';

const route = {
  path: 'goods',
  name: 'shop.admin.goods',
  component: Content,
  meta: {
    title: '商品管理',
  },
  children: [
    {
      path: 'goods',
      name: 'shop.admin.goods.goods',
      component: () => import('./goods/index.vue'),
      meta: {
        title: '商品库',
      },
    },
    {
      path: 'category',
      name: 'shop.admin.goods.category',
      component: () => import('./category/index.vue'),
      meta: {
        title: '商品分类',
      },
    },
  ],
};

const api = {
  goods: {
    ...CRUD('mall/product'),
    // 批量上下架
    batchShowStatus: (data) =>
      request({
        url: 'mall/product/batchShowStatus',
        method: 'POST',
        params: data,
      }),
    // 获取商品状态数量
    getStatusNum: () =>
      request({
        url: 'mall/product/status/num',
        method: 'GET',
      }),
  },
  rule: {
    ...CRUD('mall/product/rule'),
  },
  category: {
    ...CRUD('mall/category'),
    select: (params) => SELECT('shop/admin/category_tag', params),
  },
};

export { route, api };
