import { http } from '../http'

interface PersonalConfigData {
  oldPassword?: string
  newPassword?: string
  confirmPassword?: string
  [key: string]: any
}

interface CheckPasswordData {
  oldPassword: string
}

interface ChangeLoginAccData {
  account: string
}

interface DeleteDeviceRelateAccData {
  id?: any
  [key: string]: any
}

const settingApi = {
  /**
   * 获取个人设置
   */
  getPersonalConfigApi: () => {
    return http.request({
      url: '/personal/getPersonalConfig',
    })
  },

  /**
   * 修改个人设置
   */
  modifyPersonalConfigApi: (data: PersonalConfigData) => {
    return http.request({
      url: '/personal/modifyPersonalConfig',
      method: 'PUT',
      data,
    })
  },

  /**
   * 检验旧密码是否输入正确
   */
  checkPasswordApi: (data: CheckPasswordData) => {
    return http.request({
      url: '/personal/checkPassword',
      method: 'POST',
      data,
    })
  },

  /**
   * 当前设备登录过的账号
   */
  getCurrentDeviceRelateAccApi: () => {
    return http.request({
      url: '/personal/queryCurrentDeviceRelateAcc',
    })
  },

  /**
   * 切换账号
   */
  changeLoginAccApi: (data: ChangeLoginAccData) => {
    return http.request({
      url: '/personal/changeLoginAcc',
      method: 'POST',
      data,
    })
  },

  /**
   * 删除设备关联账号
   */
  deleteDeviceRelateAccApi: (data: DeleteDeviceRelateAccData) => {
    return http.request({
      url: '/userDeviceAccountRecord',
      method: 'PUT',
      data,
    })
  },
}

export default settingApi
