import { RequestParams } from './http-client'
import { ContentType, HttpClient } from './http-client'
import type {
  CultureProtocolDto,
  CultureProtocolPageInput,
  CultureProtocolPageResponse,
  CultureProtocolOutput,
  CultureProtocolAddInput,
  CultureProtocolUpdateInput
} from '/@/api/types/cultureprotocol'

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

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

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

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

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

  /**
   * 复制培养方案
   */
  copy = (params: { id: number; reactorId: number }, requestParams: RequestParams = {}) =>
    this.request<any>({
      path: `/api/admin/culture-protocol/copy`,
      method: 'POST',
      body: params,
      type: ContentType.Json,
      ...requestParams,
    })

  /**
   * 切换培养方案状态
   */
  toggleStatus = (params: { id: number; isEnabled: boolean }, requestParams: RequestParams = {}) =>
    this.request<any>({
      path: `/api/admin/culture-protocol/toggle-status`,
      method: 'POST',
      query: params,
      ...requestParams,
    })
} 