const UNKNOW = 'UNKNOW'
const BADPARAM = 'BADPARAM'
const NETWORK = 'NETWORK'
const JSON_ERROR = 'JSON_ERROR'
const USER_NOT_EXIST = 'USER_NOT_EXIST'
const BAD_PASSWORD = 'BAD_PASSWORD'
const NOT_LOGIN = 'NOT_LOGIN'
const ACCESS_DENIED = 'ACCESS_DENIED'
const DATA_NOT_EXIST = 'DATA_NOT_EXIST'
const DATA_EXISTED = 'DATA_EXISTED'
const DATA_INVALID = 'DATA_INVALID'
const VERIFYCODE_INVALID = 'VERIFYCODE_INVALID'
const SERVICE_FAULT = 'SERVICE_FAULT'
const DATABASE_FAULT = 'DATABASE_FAULT'
const FILE_FAULT = 'FILE_FAULT'
const USER_NOT_BIND = 'USER_NOT_BIND'
const BUSINESS = 'BUSINESS'

const ErrorCode = {
  [UNKNOW]: -1,
  [BADPARAM]: -2,
  [NETWORK]: -3,
  [JSON_ERROR]: -4,
  [USER_NOT_EXIST]: -5,
  [BAD_PASSWORD]: -6,
  [NOT_LOGIN]: -7,
  [ACCESS_DENIED]: -8,
  [DATA_NOT_EXIST]: -9,
  [DATA_EXISTED]: -10,
  [DATA_INVALID]: -11,
  [VERIFYCODE_INVALID]: -12,
  [SERVICE_FAULT]: -13,
  [DATABASE_FAULT]: -14,
  [FILE_FAULT]: -15,
  [USER_NOT_BIND]: -16,
  [BUSINESS]: -100
}

const errmsg = () => {
  return {
    UNKNOW: 'unknow',
    BADPARAM: 'bad param',
    NETWORK: 'network',
    JSON_ERROR: 'json error',
    USER_NOT_EXIST: 'user not exist',
    BAD_PASSWORD: 'bad password',
    NOT_LOGIN: 'not login',
    ACCESS_DENIED: 'access denied',
    DATA_NOT_EXIST: 'data not exist',
    DATA_EXISTED: 'data existed',
    DATA_INVALID: 'data invalid',
    VERIFYCODE_INVALID: 'verifycode invalid',
    SERVICE_FAULT: 'service fault',
    DATABASE_FAULT: 'database fault',
    FILE_FAULT: 'file fault',
    USER_NOT_BIND: 'user not bind',
    BUSINESS: 'business error'
  }
}

export { ErrorCode, errmsg }
