import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { RecipeCategoryVO, RecipeCategoryForm, RecipeCategoryQuery } from '@/api/system/recipeCategory/types';

/**
 * 查询食谱分类管理列表
 * @param query
 * @returns {*}
 */

export const listRecipeCategory = (query?: RecipeCategoryQuery): AxiosPromise<RecipeCategoryVO[]> => {
  return request({
    url: '/system/recipeCategory/list',
    method: 'get',
    params: query
  });
};

export const queryRecipeCategoryList = (query?: RecipeCategoryQuery): AxiosPromise<RecipeCategoryVO[]> => {
  return request({
    url: '/system/recipeCategory/queryList',
    method: 'get',
    params: query
  });
};

/**
 * 查询食谱分类管理详细
 * @param recipeCategoryId
 */
export const getRecipeCategory = (recipeCategoryId: string | number): AxiosPromise<RecipeCategoryVO> => {
  return request({
    url: '/system/recipeCategory/' + recipeCategoryId,
    method: 'get'
  });
};

/**
 * 新增食谱分类管理
 * @param data
 */
export const addRecipeCategory = (data: RecipeCategoryForm) => {
  return request({
    url: '/system/recipeCategory',
    method: 'post',
    data: data
  });
};

/**
 * 修改食谱分类管理
 * @param data
 */
export const updateRecipeCategory = (data: RecipeCategoryForm) => {
  return request({
    url: '/system/recipeCategory',
    method: 'put',
    data: data
  });
};

/**
 * 删除食谱分类管理
 * @param recipeCategoryId
 */
export const delRecipeCategory = (recipeCategoryId: string | number | Array<string | number>) => {
  return request({
    url: '/system/recipeCategory/' + recipeCategoryId,
    method: 'delete'
  });
};
