import request from '@/utils/request'

// 查询专家列表
export function listExpert(query) {
  return request({
    url: '/resources/experts/list',
    method: 'get',
    params: query
  })
}

// 根据专长领域查询专家
export function listExpertBySpecialty(specialty, query) {
  return request({
    url: '/resources/experts/specialty/' + encodeURIComponent(specialty),
    method: 'get',
    params: query
  })
}

// 获取专家详情
export function getExpert(id) {
  return request({
    url: '/resources/experts/' + id,
    method: 'get'
  })
}

// 获取专家专长字典
export function getSpecialtyDict() {
  return request({
    url: '/resources/experts/specialty/dict',
    method: 'get'
  })
}

// 新增专家
export function addExpert(data) {
  return request({
    url: '/resources/experts',
    method: 'post',
    data: data
  })
}

// 修改专家
export function updateExpert(data) {
  return request({
    url: '/resources/experts',
    method: 'put',
    data: data
  })
}

// 删除专家
export function delExpert(ids) {
  return request({
    url: '/resources/experts/' + ids,
    method: 'delete'
  })
}

// 启用专家
export function activateExpert(id) {
  return request({
    url: `/resources/experts/${id}/activate`,
    method: 'post'
  })
}

// 停用专家
export function deactivateExpert(id) {
  return request({
    url: `/resources/experts/${id}/deactivate`,
    method: 'post'
  })
}

// 加入黑名单
export function blacklistExpert(id) {
  return request({
    url: `/resources/experts/${id}/blacklist`,
    method: 'post'
  })
}

// 解除黑名单
export function unblacklistExpert(id) {
  return request({
    url: `/resources/experts/${id}/unblacklist`,
    method: 'post'
  })
}

// 更新专家评分
export function rateExpert(id, data) {
  return request({
    url: `/resources/experts/${id}/rate`,
    method: 'post',
    data: data
  })
}