import request from '@/router/axios';

export const getList = (current, size, params) => {
  return request({
    url: '/api/mall/categoryinfo/list',
    method: 'get',
    params: {
      ...params,
      current,
      size,
    }
  })
}

export const getDetail = (id) => {
  return request({
    url: '/api/mall/categoryinfo/detail',
    method: 'get',
    params: {
      id
    }
  })
}

export const remove = (ids) => {
  return request({
    url: '/api/mall/categoryinfo/remove',
    method: 'post',
    params: {
      ids,
    }
  })
}

export const add = (row) => {
  return request({
    url: '/api/mall/categoryinfo/submit',
    method: 'post',
    data: row
  })
}

export const update = (row) => {
  return request({
    url: '/api/mall/categoryinfo/submit',
    method: 'post',
    data: row
  })
}

export const getByParentId = (parentId) => {
  return request({
    url: '/api/mall/categoryinfo/getByParentId/' + parentId,
    method: 'get'
  })
}

export const getLazyList = (parentId, params) => {
  return request({
    url: '/api/mall/categoryinfo/lazy-list',
    method: 'get',
    params: {
      ...params,
      parentId
    }
  })
}

export const getCategoryTree = (tenantId) => {
  return request({
    url: '/api/mall/categoryinfo/tree',
    method: 'get',
    params: {
      tenantId,
    }
  })
}
