import request from '@/config/axios'
import { id } from 'element-plus/es/locale'

// 店铺 VO
export interface ShopVO {
  // 店铺id
  id: number
  // 店铺名称
  name: string
  // 店铺状态
  status: number
  // 商户id
  merchantId: number
  // 主页图片
  logoUrl: string
}

// 店铺 API
export const ShopApi = {
  // 查询店铺分页
  getShopPage: async (params: any) => {
    return await request.get({ url: `/sale/shop/page`, params })
  },

  // 查询店铺详情
  getShop: async (id: number) => {
    return await request.get({ url: `/sale/shop/get?id=` + id })
  },

  // 新增店铺
  createShop: async (data: ShopVO) => {
    return await request.post({ url: `/sale/shop/create`, data })
  },

  // 修改店铺
  updateShop: async (data: ShopVO) => {
    return await request.put({ url: `/sale/shop/update`, data })
  },

  // 删除店铺
  deleteShop: async (id: number) => {
    return await request.delete({ url: `/sale/shop/delete?id=` + id })
  },

  // 导出店铺 Excel
  exportShop: async (params) => {
    return await request.download({ url: `/sale/shop/export-excel`, params })
  },
  // 获得商户下所有店铺
  getAllUserByMer: async (id: number) => {
    return await request.get({ url: `/sale/shop/getAllShop?merId=` + id })
  },
  // 获得当前用户店铺id
  getCurrentShop: async () => {
    return await request.put({ url: `/sale/shop/get_current_shop` })
  },
  //获取当前用户下的所有店铺
  getAllShopByUserId: async () => {
    return await request.get({ url: `/sale/shop/getAllShopByUserId` })
  },
  // 切换当前用户的店铺
  ChangeShop: async (id: number) => {
    return await request.put({ url: `/sale/shop/change_shop?shopId=`+id })
  },
}