import { axios } from '@/utils/request'
import { stringify } from 'qs'

/**
 * page func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function getTicketPage (parameter) {
    return axios({
        url: '/ticket/tickets/page?' + stringify(parameter),
        method: 'get',
        headers: {
            'Content-Type': 'application/json;charset=UTF-8'
        }
    })
}

/**
 * add func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function addTicket (parameter) {
    return axios({
        url: '/ticket/tickets',
        method: 'POST',
        headers: {
            'Accept': 'application/json',
            'Content-Type': 'application/json;charset=UTF-8'
        },
        data: parameter
    })
}

/**
 * update func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function updateTicket (parameter) {
    return axios({
        url: '/ticket/tickets/' + parameter.id,
        method: 'PUT',
        data: parameter
    })
}

/**
 * fetch single func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function fetchTicket (parameter) {
    return axios({
        url: '/ticket/tickets/' + parameter.id,
        method: 'get',
        headers: {
            'Content-Type': 'application/json;charset=UTF-8'
        }
    })
}

/**
 * query list func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function queryTicket (parameter) {
    return axios({
        url: '/ticket/tickets?' + stringify(parameter),
        method: 'get',
        headers: {
            'Content-Type': 'application/json;charset=UTF-8'
        }
    })
}

/**
 * delete batch func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function deleteTickets (parameter) {
    return axios({
        url: '/ticket/tickets',
        method: 'DELETE',
        data: parameter
    })
}

/**
 * delete single func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function deleteTicket (parameter) {
    return axios({
        url: '/ticket/tickets/' + parameter.id,
        method: 'DELETE',
        data: parameter
    })
}


/**
 * export file
 * parameter: { }
 * @param parameter :
 * @returns {*}
 */
export function exportTicket (parameter) {
    return axios({
        url: '/ticket/tickets/export?' + stringify(parameter),
        method: 'get',
        headers: {
            'Content-Type': 'application/json;charset=UTF-8'
        },
        responseType: 'blob'
    })
}
