import { axios } from '@/utils/request'

// 商品列表
export const goodsList = (params) => {
  const url = `/goods/query/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios.request({
    url: url,
    data: params,
    method: 'post'
  })
}
// 查分类商品列表  不分页
export const goodsListQuery = (params) => {
  const url = `/goods/queryList`
  return axios.request({
    url: url,
    data: params,
    method: 'post'
  })
}
// 保存商品
export const goodsSave = (params) => {
  return axios.request({
    url: '/goods/save',
    data: params,
    method: 'post'
  })
}
// 商品排序
export const goodsUpdateSort = (params) => {
  return axios.request({
    url: '/goods/updateSort',
    data: params,
    method: 'post'
  })
}
// 商品详情
export const goodsFind = (params) => {
  return axios.request({
    url: `/goods/findById/${params.id}`,
    method: 'get'
  })
}
// 商品删除
export const goodsDel = (params) => {
  return axios.request({
    url: `/goods/delete/${params.id}`,
    method: 'get'
  })
}
// 商品上下架
export const goodsState = (params) => {
  return axios.request({
    url: `/goods/updateState/${params.id}/${params.state}`,
    method: 'get'
  })
}

// 查询商品分类(不分页)
export const goodsType = (params) => {
  return axios.request({
    url: `/goodsType/queryList`,
    method: 'post',
    data: params
  })
}
