import { RequestParams } from './http-client'
import { ContentType, HttpClient } from './http-client'
import type {
  UspBatchDto,
  UspBatchPageInput,
  UspBatchPageResponse,
  UspBatchOutput,
  UspBatchAddInput,
  UspBatchUpdateInput
} from '/@/api/types/uspBatchType'

export class UspBatchApi extends HttpClient {
  /**
   * 获取分页列表
   */
  getPage = (data: UspBatchPageInput, params: RequestParams = {}) =>
    this.request<UspBatchPageResponse>({
      path: `/api/admin/pre-batch/get-page`,
      method: 'POST',
      body: data,
      type: ContentType.Json,
      ...params,
    })

  /**
   * 获取单条数据
   */
  get = (params: { id: number }, requestParams: RequestParams = {}) =>
    this.request<UspBatchOutput>({
      path: `/api/admin/pre-batch/get`,
      method: 'GET',
      query: { id: params.id },
      ...requestParams,
    })

  /**
   * 新增
   */
  add = (data: UspBatchAddInput, params: RequestParams = {}) =>
    this.request<any>({
      path: `/api/admin/pre-batch/add`,
      method: 'POST',
      body: data,
      type: ContentType.Json,
      ...params,
    })

  /**
   * 更新
   */
  update = (data: UspBatchUpdateInput, params: RequestParams = {}) =>
    this.request<any>({
      path: `/api/admin/pre-batch/update`,
      method: 'PUT',
      body: data,
      type: ContentType.Json,
      ...params,
    })

  /**
   * 软删除
   */
  softDelete = (params: { id: number }, requestParams: RequestParams = {}) =>
    this.request<any>({
      path: `/api/admin/pre-batch/soft-delete`,
      method: 'DELETE',
      query: params,
      ...requestParams,
    })
}