import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { SectionVO, SectionForm, SectionQuery } from '@/api/smarttrace/section/types';

/**
 * 查询栏目列表
 * @param query
 * @returns {*}
 */

export const listSection = (query?: SectionQuery): AxiosPromise<SectionVO[]> => {
  return request({
    url: '/smarttrace/section/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询栏目详细
 * @param id
 */
export const getSection = (id: string | number): AxiosPromise<SectionVO> => {
  return request({
    url: '/smarttrace/section/getInfo/' + id,
    method: 'get'
  });
};

/**
 * 新增栏目
 * @param data
 */
export const addSection = (data: SectionForm) => {
  return request({
    url: '/smarttrace/section/add',
    method: 'post',
    data: data
  });
};

/**
 * 修改栏目
 * @param data
 */
export const updateSection = (data: SectionForm) => {
  return request({
    url: '/smarttrace/section/edit',
    method: 'post',
    data: data
  });
};

/**
 * 删除栏目
 * @param id
 */
export const delSection = (id: string | number | Array<string | number>) => {
  return request({
    url: '/smarttrace/section/remove/' + id,
    method: 'get'
  });
};
