/*
 * @Author: Do not edit
 * @Date: 2024-01-09 09:55:17
 * @LastEditTime: 2024-01-29 16:56:22
 * @LastEditors: DY
 * @Description: cookie
 */

// ========== 租户相关 ==========

const TenantIdKey = 'TENANT_ID'
// const TenantNameKey = 'TENANT_NAME'

export function setTenantId (username) {
  localStorage.setItem(TenantIdKey, username)
}

export function getTenantId () {
  return localStorage.getItem(TenantIdKey)
}

const AccessTokenKey = 'ACCESS_TOKEN'
const RefreshTokenKey = 'REFRESH_TOKEN'

// ========== Token 相关 ==========

export function getAccessToken () {
  return localStorage.getItem(AccessTokenKey)
}

export function getUserId () {
  return localStorage.getItem('UserId')
}

export function getRefreshToken () {
  return localStorage.getItem(RefreshTokenKey)
}

export function setToken (token) {
  localStorage.setItem(AccessTokenKey, token.accessToken)
  localStorage.setItem(RefreshTokenKey, token.refreshToken)
  localStorage.setItem('UserId', token.userId)
}

export function removeToken () {
  localStorage.removeItem(AccessTokenKey)
  localStorage.removeItem(RefreshTokenKey)
}
