import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { TenantCategoriesVO, TenantCategoriesForm, TenantCategoriesQuery, SysTenantCategoriesOnStoreVo } from '@/api/system/tenantCategories/types';

/**
 * 查询商户分类列表
 * @param query
 * @returns {*}
 */

export const listTenantCategories = (query?: TenantCategoriesQuery): AxiosPromise<TenantCategoriesVO[]> => {
  return request({
    url: '/system/tenantCategories/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询商户分类详细
 * @param id
 */
export const getTenantCategories = (id: string | number): AxiosPromise<TenantCategoriesVO> => {
  return request({
    url: '/system/tenantCategories/' + id,
    method: 'get'
  });
};

/**
 * 新增商户分类
 * @param data
 */
export const addTenantCategories = (data: TenantCategoriesForm) => {
  return request({
    url: '/system/tenantCategories',
    method: 'post',
    data: data
  });
};

/**
 * 修改商户分类
 * @param data
 */
export const updateTenantCategories = (data: TenantCategoriesForm) => {
  return request({
    url: '/system/tenantCategories',
    method: 'put',
    data: data
  });
};

/**
 * 删除商户分类
 * @param id
 */
export const delTenantCategories = (id: string | number | Array<string | number>) => {
  return request({
    url: '/system/tenantCategories/' + id,
    method: 'delete'
  });
};

/**
 * 获取商户分类的列表
 * @Author Huanyi
 */
export const listOnStore = (query: PageQuery): AxiosPromise<SysTenantCategoriesOnStoreVo[]> => {
  return request({
    url: '/system/tenantCategories/listOnStore',
    method: 'GET',
    params: query
  });
};
