import apiClient from './apiClient'
import { buildApiUrl } from '@/config/cad'

class PdmsApiService {
  constructor() {
    this.softwareName = 'pdms'
  }

  /**
   * 测试PDMS连接
   * @returns {Promise<{success: boolean, data?: any, error?: string}>}
   */
  async testConnection() {
    const url = buildApiUrl(this.softwareName, 'connect')

    return await apiClient.get(url, {
      operationContext: {
        software: 'PDMS',
        operation: '连接测试'
      }
    })
  }

  /**
   * 获取当前模型状态
   * @returns {Promise<{success: boolean, data?: any, error?: string}>}
   */
  async getCurrentModel() {
    const url = buildApiUrl(this.softwareName, 'status')

    return await apiClient.get(url, {
      operationContext: {
        software: 'PDMS',
        operation: '获取当前模型'
      }
    })
  }
}

export const pdmsApi = new PdmsApiService()

export default pdmsApi