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('shop/admin/goods/goods'),
    select: (params, type = 'page') =>
      request({
        url: `shop/admin/goods/goods/select?type=${type}`,
        method: 'GET',
        params,
      }),
    getType: () =>
      request({
        url: '/shop/admin/goods/goods/getType',
        method: 'GET',
      }),
    getGoodsDetail: (id) =>
      request({
        url: `/shop/admin/goods/goods/detail/${id}`,
        method: 'GET',
      }),
  },
  category: {
    ...CRUD('shop/admin/category_tag'),
    select: (params) => SELECT('shop/admin/category_tag', params),
  },
};

export { route, api };
