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

const route = {
  path: 'content',
  name: 'shop.admin.content',
  component: Content,
  meta: {
    title: '内容',
  },
  children: [
    {
      path: 'adv',
      name: 'shop.admin.content.adv',
      component: () => import('./adv/index.vue'),
      meta: {
        title: '广告位',
      },
    },
    {
      path: 'notification',
      name: 'shop.admin.content.notification',
      component: () => import('./notification/index.vue'),
      meta: {
        title: '消息推送',
      },
    },
    {
      path: 'sms',
      name: 'shop.admin.content.sms',
      component: () => import('./sms/index.vue'),
      meta: {
        title: '短信',
      },
    },
  ],
};

const api = {
  // 广告位相关 API
  adv: {
    // 分页查询
    list: (params) =>
      request({
        url: 'mall/adv/page',
        method: 'GET',
        params,
      }),
    // 新增
    add: (data) =>
      request({
        url: 'mall/adv/save',
        method: 'POST',
        data,
      }),
    // 详情
    detail: (id) =>
      request({
        url: `mall/adv/info/${id}`,
        method: 'GET',
      }),
    // 更新
    edit: (id, data) =>
      request({
        url: `mall/adv/update/${id}`,
        method: 'PATCH',
        data,
      }),
    // 删除
    delete: (id) =>
      request({
        url: `mall/adv/delete/${id}`,
        method: 'DELETE',
      }),
  },

  // 消息推送相关 API
  notification: {
    // 使用新版本CRUD规范（V2）
    ...CRUD_V2('mall/notice'),
    sendNotice: (data) =>
      request({
        url: 'mall/notice/sendNotice',
        method: 'POST',
        data,
      }),
  },

  // 短信相关 API
  sms: {
    ...CRUD('shop/admin/sms_template'),
    select: (params) => SELECT('shop/admin/sms_template', params),
  },
};

export { route, api };
