/**
 * 所有跟自定义查询保存相关的
 */

import { HttpResponse } from '@/@types'
import Axios from './axios'

interface CustomQuerySaveModel {
  Id: number
  Code: string
  Name: string
  SelectList: string
}

/**
 * 封装API调用
 */
class CustomQueryService {
  /**
   * 保存自定义对象
   * @param data 自定义对象
   * @returns 成功或失败
   */
  static async saveCustom(data: CustomQuerySaveModel): Promise<HttpResponse> {
    return Axios('/QYCustomer/SaveCustomQuery', {
      method: 'post',
      responseType: 'json',
      data
    })
  }
  /**
   * 删除指定自定义信息
   * @param id 编号
   * @returns 成功或失败
   */
  static async deleteCustom(id: number): Promise<HttpResponse> {
    const data = { id }
    return Axios('/QYCustomer/DeleteCustomQuery', {
      method: 'post',
      responseType: 'json',
      data
    })
  }
  /**
   * 查询指定Code的自定义内容
   * @param code 页面编号
   * @returns 自定义集合
   */
  static async queryMyCustom(code: string): Promise<HttpResponse> {
    const data = { code }
    return Axios('/QYCustomer/GetUserCustomQuery', {
      method: 'post',
      responseType: 'json',
      data
    })
  }

  /**
   * 查询指定编号的自定义信息
   * @param id 编号
   * @returns 指定编号的详情
   */
  static async queryCustomById(id: number): Promise<HttpResponse> {
    const data = { id }
    return Axios('/QYCustomer/GetCustomQueryById', {
      method: 'post',
      responseType: 'json',
      data
    })
  }
}

export { CustomQuerySaveModel }
export default CustomQueryService
