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

/** 键盘用户信息 */
export interface KeyboardUser {
          id: number; // 主键
          uid?: number; // 用户 Id
          nickName?: string; // 用户昵称
          gender: number; // 性别
          avatarUrl: string; // 头像地址
          createdAt: string | Dayjs; // 创建时间
          updatedAt: string | Dayjs; // 更新时间
          email: string; // 邮箱地址
          status: boolean; // 是否禁用
          password: string; // 密码
          subjectId: string; // 苹果登录subjectId
          emailVerified: boolean; // 邮箱是否验证
          isVip: boolean; // 是否是 VIP
          vipExpiry: string | Dayjs; // VIP 过期时间
  }

// 键盘用户 API
export const KeyboardUserApi = {
  // 查询键盘用户分页
  getKeyboardUserPage: async (params: any) => {
    return await request.get({ url: `/keyboard-server/keyboard-user/page`, params })
  },

  // 查询键盘用户详情
  getKeyboardUser: async (id: number) => {
    return await request.get({ url: `/keyboard-server/keyboard-user/get?id=` + id })
  },

  // 新增键盘用户
  createKeyboardUser: async (data: KeyboardUser) => {
    return await request.post({ url: `/keyboard-server/keyboard-user/create`, data })
  },

  // 修改键盘用户
  updateKeyboardUser: async (data: KeyboardUser) => {
    return await request.put({ url: `/keyboard-server/keyboard-user/update`, data })
  },

  // 删除键盘用户
  deleteKeyboardUser: async (id: number) => {
    return await request.delete({ url: `/keyboard-server/keyboard-user/delete?id=` + id })
  },

  /** 批量删除键盘用户 */
  deleteKeyboardUserList: async (ids: number[]) => {
    return await request.delete({ url: `/keyboard-server/keyboard-user/delete-list?ids=${ids.join(',')}` })
  },

  // 导出键盘用户 Excel
  exportKeyboardUser: async (params) => {
    return await request.download({ url: `/keyboard-server/keyboard-user/export-excel`, params })
  }
}