import { del, get, post, put } from '../../http'

/**
 * @description: 获取关卡列表
 * @param {*} params
 * @return {*}
 */
export async function getLevelListApi(
  params: Record<string, any>,
): Promise<any> {
  return await get<any>('/level/list', params)
}
/**
 * @description: 获取关卡详情
 * @param {*} id
 * @return {*}
 */
export async function getLevelDetailApi(id: string): Promise<any> {
  return await get<any>(`/level/detail/${id}`)
}
/**
 * @description: 新增关卡单词
 * @param {*} params
 * @return {*}
 */
export async function addLevelWord(data: Record<string, any>) {
  return await post<any>('/level/levelWord', data)
}
/**
 * @description: 删除关卡单词
 * @param {*} params
 * @return {*}
 */
export async function deleteLevelWord(id: string) {
  return await del(`/level/${id}`)
}
/**
 * @description: 新增关卡
 * @param {*} params
 * @return {*}
 */
export async function addLevel(data: Record<string, any>) {
  return await post<any>('/level', data)
}
/**
 * @description: 更新关卡
 * @param {*} params
 * @return {*}
 */
export async function updateLevel(data: Record<string, any>) {
  return await put('/level', data)
}
/**
 * @description: 删除关卡
 * @param {*} params
 * @return {*}
 */
export async function deleteLevel(id: string) {
  return await del(`/level/${id}`)
}
/**
 * @description: 获取主题列表
 */
export async function getTopiclList() {
  return await get<any>('/level/getTopicList')
}
/**
 * @description: 获取辞典单词列表
 * @param {*} params
 * @return {*}
 */
export async function getVocabularyWordList(params: Record<string, any>) {
  return await get<any>('/level/getVocabularyWordList', params)
}
/**
 * @description: 根据前缀，获取辞典单词列表
 * @param {*} params
 * @return {*}
 */
export async function getVocabularyWordListByPrefix(
  params: Record<string, any>,
) {
  return await get<any>('/level/getVocabularyWordListByPrefix', params)
}
/**
 * @description: 在编辑关卡时，强制移动单词
 * @param {*} params
 * @return {*}
 */
export async function forceMove(data: Record<string, any>) {
  return await post<any>('/level/levelWord/forceMove', data)
}
/**
 * @description: 插入关卡
 * @param {*} params
 * @return {*}
 */
export async function insertLevel(data: Record<string, any>) {
  return await post<any>('/level/insertLevel', data)
}
/**
 * @description: 交换关卡数
 * @param {*} params
 * @return {*}
 */
export async function exchangeLevel(data: Record<string, any>) {
  return await post<any>('/level/exchangeLevel', data)
}

export type ExchangeMeaningApi = {
  levelId: any
  originMeaningId: any
  targetMeaningId: any
}
export async function exchangeMeaningApi(data: ExchangeMeaningApi) {
  return await post<any>('/level/levelWord/forceReplace', data)
}
