import * as constant from './constant'


// 公共处理
export const getMapValueByKey = (key: string, map: Map<string, string>) => {
  if (key && map) {
    let value = map.get(key);
    if (value) {
      return value;
    }
  }
  return key
}

// 岗位管理
export const filterPosition = (key: 'IM_SERVICE' | 'REPAIR' | 'STAFF' | '') => {
  if (key && constant.position && constant.position[key]) {
    return constant.position[key]
  } else {
    return key
  }
}

// 员工状态
export const filterEmployee = (key: 'LOCKED' | 'ACTIVATION' | '') => {
  if (key && constant.employee && constant.employee[key]) {
    return constant.employee[key]
  } else {
    return key
  }
}

// 办学性质
export const filterSchoolNature = (key: 'PRIVATE' | 'PUBLIC' | '') => {
  if (key && constant.schoolNature && constant.schoolNature[key]) {
    return constant.schoolNature[key]
  } else {
    return key
  }
}

// 学年制
export const filterSchoolSystem = (key: 'fiveYearSystem' | 'sixYearSystem' | '') => {
  if (key && constant.schoolSystem && constant.schoolSystem[key]) {
    return constant.schoolSystem[key]
  } else {
    return key
  }
}

// 支付服务提供方
export const filterOpenType = (key: 'ORIGINAL' | 'ADAPAY' | 'OTHER' | '') => {
  if (key && constant.openType && constant.openType[key]) {
    return constant.openType[key]
  } else {
    return key
  }
}

// 客户端类型
export const filterClientType = (
    key: 'BACKEND' | 'SCHOOL' | 'TEACHER' | 'STUDENT' | 'REPAIR' | ''
) => {
  if (key && constant.clientType && constant.clientType[key]) {
    return constant.clientType[key]
  } else {
    return key
  }
}

// 协议类型
export const filterProtocolType = (key: 'BUY_ORDER' | 'WITHDRAW' | 'REGISTER' | '') => {
  if (key && constant.protocolType && constant.protocolType[key]) {
    return constant.protocolType[key]
  } else {
    return key
  }
}

// 消息组
export const filterMessageGroup = (key: 'SYSTEM' | 'COURSE' | '') => {
  if (key && constant.messageGroup && constant.messageGroup[key]) {
    return constant.messageGroup[key]
  } else {
    return key
  }
}

// 平台建议
export const filterSuggestionType = (key: 'APP' | 'SMART_PRACTICE' | '') => {
  if (key && constant.suggestionType && constant.suggestionType[key]) {
    return constant.suggestionType[key]
  } else {
    return key
  }
}

// 内容分类
export const filterContentCategory = (
    key: 'HOT_CONSULTATION' | 'OPEN_SCREEN_AD' | 'FLASH_PAGE' | 'ROTATION_CHART' | 'MUSIC' | ''
) => {
  if (key && constant.contentCategory && constant.contentCategory[key]) {
    return constant.contentCategory[key]
  } else {
    return key
  }
}

// 交付团类型  filterGroupType
export const filterGroupType = (
    key: 'SINGLE_DELIVERY' | 'MULTIPLE_DELIVERY' | 'MULTIPLE_DELIVERY_SCHOOL'
) => {
  if (key && constant.orchestraTypes && constant.orchestraTypes[key]) {
    return constant.orchestraTypes[key]
  }
}

// 乐团类型
export const filterOrchestraType = (key: 'DELIVERY' | 'PROMOTION') => {
  if (key && constant.orchestraType && constant.orchestraType[key]) {
    return constant.orchestraType[key]
  }
}

// 乐团状态  SUBJECT_CONFIG
export const filterGroupStatus = (
    key: 'INITIATION_SURVEY' | 'PRE_REGISTER' | 'REGISTER' | 'DOING' | 'DONE' | 'CLOSE'
) => {
  if (key && constant.musicStatus && constant.musicStatus[key]) {
    return constant.musicStatus[key]
  }
}

// 播放类型
export const filterAudioType = (key: 'MP3' | 'MIDI' | '') => {
  if (key && constant.audioType && constant.audioType[key]) {
    return constant.audioType[key]
  } else {
    return key
  }
}

// 伴奏类型
export const filterAccompanimentType = (key: 'HOMEMODE' | 'COMMON' | '') => {
  if (key && constant.accompanimentType && constant.accompanimentType[key]) {
    return constant.accompanimentType[key]
  } else {
    return key
  }
}

// 课程类型
export const filterCourseEmnu = (
    key:
        | 'PERCUSSION_SINGLE'
        | 'FLUTE_SINGLE'
        | 'SAX_SINGLE'
        | 'CLARINET_SINGLE'
        | 'TRUMPET_SINGLE'
        | 'TROMBONE_SINGLE'
        | 'HORN_SINGLE'
        | 'BARITONE_TUBA_SINGLE'
        | 'EUPHONIUM_SINGLE'
        | 'TUBA_SINGLE'
        | 'MUSIC_THEORY'
        | 'INSTRUMENTAL_ENSEMBLE'
        | ''
) => {
  if (key && constant.courseEmnu && constant.courseEmnu[key]) {
    return constant.courseEmnu[key]
  } else {
    return key
  }
}

// 课程状态  courseStatus
export const filterCourseStatus = (key: 'NOT_START' | 'ING' | 'COMPLETE') => {
  if (key && constant.courseStatus && constant.courseStatus[key]) {
    return constant.courseStatus[key]
  } else {
    return key
  }
}
// 学生状态

export const filterStudentStatusEmnu = (key: 'REGISTER' | 'LEARNING' | 'OUTOF_ORCHESTRA') => {
  if (key && constant.studentStatusEmnu && constant.studentStatusEmnu[key]) {
    return constant.studentStatusEmnu[key]
  } else {
    return key
  }
}

// 订单状态
export const filterOrderStatus = (
    key:
        | 'WAIT_PAY'
        | 'PAYING'
        | 'PAID'
        | 'TIMEOUT'
        | 'FAIL'
        | 'CLOSED'
        | 'REFUNDING'
        | 'REFUNDED'
        | ''
) => {
  if (key && constant.orderStatus && constant.orderStatus[key]) {
    return constant.orderStatus[key]
  } else {
    return key
  }
}

// 订单类型
export const filterOrderType = (key: 'VIP' | 'ORCHESTRA' | '') => {
  if (key && constant.orderType && constant.orderType[key]) {
    return constant.orderType[key]
  } else {
    return key
  }
}

// 审核交易状态
export const filterReportStatus = (key: 'SUCCESSED' | 'FAILED' | 'PENDDING' | '') => {
  if (key && constant.reportStatus && constant.reportStatus[key]) {
    return constant.reportStatus[key]
  } else {
    return key
  }
}

// 交易状态
export const filterTradeStatus = (key: 'SUCCESSED' | 'FAILED' | 'PENDDING' | '') => {
  if (key && constant.tradeStatus && constant.tradeStatus[key]) {
    return constant.tradeStatus[key]
  } else {
    return key
  }
}

// 交易状态
export const filterRefundStatus = (key: 'PASS' | 'REJECT' | 'ING' | 'CLOSED' | '') => {
  if (key && constant.refundStatus && constant.refundStatus[key]) {
    return constant.refundStatus[key]
  } else {
    return key
  }
}

// 学生考勤类型  attendanceStatus
export const filterAttendanceStatus = (
    key: 'LATE' | 'NORMAL' | 'LEAVE' | 'TRUANCY' | 'UNCALLED' | ''
) => {
  if (key && constant.attendanceStatus && constant.attendanceStatus[key]) {
    return constant.attendanceStatus[key]
  } else {
    return key
  }
}

// 老师考勤类型
export const filterTeacherAttendanceStatus = (
    key: 'NORMAL' | 'EXCEPTION' | 'LATE' | 'EARLY' | 'TRUANCY' | 'NO_SIGN' | 'LOCATION_EXCEPTION' | ''
) => {
  if (key && constant.teacherAttendanceStatus && constant.teacherAttendanceStatus[key]) {
    return constant.teacherAttendanceStatus[key]
  } else {
    return key
  }
}

// 审核状态
export const filterAuthStatus = (key: 'DOING' | 'PASS' | 'UNPASS') => {
  if (key && constant.authStatus && constant.authStatus[key]) {
    return constant.authStatus[key]
  } else {
    return key
  }
}

// 结算状态
export const filterWithdrawalStatus = (
    key: 'WAIT' | 'SETTLED' | 'PART_SETTLED' | 'SETTLE_FAIL'
) => {
  if (key && constant.withdrawalStatus && constant.withdrawalStatus[key]) {
    return constant.withdrawalStatus[key]
  } else {
    return key
  }
}

// 补助类型 salaryType
export const filterSalaryType = (key: 'MANAGE' | 'COURSE' | 'TRAINING') => {
  if (key && constant.salaryType && constant.salaryType[key]) {
    return constant.salaryType[key]
  } else {
    return key
  }
}
