import request from '@/config/axios'
import type { Dayjs } from 'dayjs';

/** 键盘人设国际化内容信息 */
export interface CharacterI18n {
          id: number; // 主键 Id
          characterId?: number; // 角色主表id
          locale?: string; // 语言标识，如 zh-CN/en-US/ja-JP
          characterName: string; // 标题
          characterBackground: string; // 背景描述
          createdAt: string | Dayjs; // 创建时间
          updatedAt: string | Dayjs; // 更新时间
}

/** 键盘人设信息 */
export interface Character {
          id: number; // 主键 Id
          characterName: string; // 标题
          characterBackground: string; // 背景描述
          avatarUrl: string; // 角色头像
          download: string; // 下载次数
          tag: number; // 标签id
          createdAt: string | Dayjs; // 创建时间
          updatedAt: string | Dayjs; // 更新时间
          prompt: string; // 人设提示词
          rank: number; // 排名顺序
          emoji: string; // emoji 标签
  }

// 键盘人设 API
export const CharacterApi = {
  // 查询键盘人设分页
  getCharacterPage: async (params: any) => {
    return await request.get({ url: `/keyboard/character/page`, params })
  },

  // 查询键盘人设详情
  getCharacter: async (id: number) => {
    return await request.get({ url: `/keyboard/character/get?id=` + id })
  },

  // 新增键盘人设
  createCharacter: async (data: Character) => {
    return await request.post({ url: `/keyboard/character/create`, data })
  },

  // 修改键盘人设
  updateCharacter: async (data: Character) => {
    return await request.put({ url: `/keyboard/character/update`, data })
  },

  // 删除键盘人设
  deleteCharacter: async (id: number) => {
    return await request.delete({ url: `/keyboard/character/delete?id=` + id })
  },

  /** 批量删除键盘人设 */
  deleteCharacterList: async (ids: number[]) => {
    return await request.delete({ url: `/keyboard/character/delete-list?ids=${ids.join(',')}` })
  },

  // 导出键盘人设 Excel
  exportCharacter: async (params) => {
    return await request.download({ url: `/keyboard/character/export-excel`, params })
  },

// ==================== 子表（键盘人设国际化内容） ====================

  // 获得键盘人设国际化内容分页
  getCharacterI18nPage: async (params) => {
    return await request.get({ url: `/keyboard/character/character-i18n/page`, params })
  },
  // 新增键盘人设国际化内容
  createCharacterI18n: async (data: CharacterI18n) => {
    return await request.post({ url: `/keyboard/character/character-i18n/create`, data })
  },

  // 修改键盘人设国际化内容
  updateCharacterI18n: async (data: CharacterI18n) => {
    return await request.put({ url: `/keyboard/character/character-i18n/update`, data })
  },

  // 删除键盘人设国际化内容
  deleteCharacterI18n: async (id: number) => {
    return await request.delete({ url: `/keyboard/character/character-i18n/delete?id=` + id })
  },

  /** 批量删除键盘人设国际化内容 */
  deleteCharacterI18nList: async (ids: number[]) => {
    return await request.delete({ url: `/keyboard/character/character-i18n/delete-list?ids=${ids.join(',')}` })
  },

  // 获得键盘人设国际化内容
  getCharacterI18n: async (id: number) => {
    return await request.get({ url: `/keyboard/character/character-i18n/get?id=` + id })
  }
}