import { request } from '@/api/_service'

/**
 * 账号登录
 * @param {Object} data
 * @param {string} data.username
 * @param {string} data.password
 */
export function loginAdminUser (data) {
  return request({
    url: 'login',
    method: 'post',
    data: {
      method: 'login',
      platform: 'background',
      ...data
    }
  })
}

/**
 * 注销当前已登录的账号
 */
export function logoutAdminUser () {
  return request({
    url: 'logout',
    method: 'post',
    data: {
      method: 'logout',
      platform: 'background'
    }
  })
}

export function getAuthTime (data) {
  return request({
    url: 'auth/get/time',
    method: 'post',
    data: {
      method: 'get.auth.time',
      platform: 'admin',
      ...data
    }
  })
}

export function getAuthNearTime (data) {
  return request({
    url: 'auth/get/nearTime',
    method: 'post',
    data: {
      method: 'get.auth.nearTime',
      platform: 'admin',
      ...data
    }
  })
}

export function getAuthTimeByUpload (data) {
  return request({
    url: 'auth/get/timeByUpload',
    method: 'post',
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    data
  })
}
