import str from '#/utils/str'
import { del, get, post } from '../../http'

// 参数类型定义
interface VersionListParams {
  keyword?: string
  page?: number
  platform?: string
  size?: number
  status?: string
  magic?: string
}

interface VersionData {
  description?: string
  downloadUrl: string
  forceUpdate?: boolean
  id?: string
  platform: string
  version: string
  versionCode: number
}

/**
 * @description: 获取版本
 * @return {*}
 */
export const getVersionList = async (params: VersionListParams) => {
  params = {
    ...(params || {}),
    magic: str.getMagic(),
  }
  return await get<any>('/apkManagement/list', params)
}

/**
 * @description: 新增版本
 * @param {VersionData} data
 */
export const addVersion = async (data: VersionData) => {
  return await post<any>('/apkManagement', data)
}

/**
 * @description: 删除版本
 * @param {string} id
 */
export const delVersion = async (id: string) => {
  return await del(`/apkManagement/${id}`)
}
