import request from '@/utils/request';
import { TagVO, TagQuery, TagForm } from './types';
import { AxiosPromise } from 'axios';

/**
 * 查询标签列表
 */
export const listTag = (query: TagQuery): AxiosPromise<TagVO[]> => {
  return request({
    url: '/system/tag/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询标签详细
 */
export const getTag = (id: string | number): AxiosPromise<TagVO> => {
  return request({
    url: '/system/tag/' + id,
    method: 'get'
  });
};

/**
 * 新增标签
 */
export const addTag = (data: TagForm) => {
  return request({
    url: '/system/tag',
    method: 'post',
    data: data
  });
};

/**
 * 修改标签
 */
export const updateTag = (data: TagForm) => {
  return request({
    url: '/system/tag',
    method: 'put',
    data: data
  });
};

/**
 * 删除标签
 */
export const delTag = (id: string | number | Array<string | number>) => {
  return request({
    url: '/system/tag/' + id,
    method: 'delete'
  });
};

/**
 * 标签状态修改
 */
export const changeTagStatus = (id: string | number, status: string) => {
  const data = {
    id,
    status
  };
  return request({
    url: '/system/tag/changeStatus',
    method: 'put',
    data: data
  });
};
