import request from '@/utils/request'

// 查询推荐列表
export function listRecommend(query) {
  return request({
    url: '/back/re/list',
    method: 'get',
    params: query
  })
}

// 查询推荐详细
export function getRecommend(id) {
  return request({
    url: '/back/re/' + id,
    method: 'get'
  })
}

// 新增推荐
export function addRecommend(data) {
  return request({
    url: '/back/re',
    method: 'post',
    data: {
      name: data.name,
      desc: data.desc,
      backImg: data.backImg
    },
    headers: {
      'Content-Type': 'application/json'
    }
  })
}

// 修改推荐
export function updateRecommend(data) {
  return request({
    url: '/back/re',
    method: 'put',
    data: {
      id: data.id,
      name: data.name,
      desc: data.desc,
      backImg: data.backImg
    },
    headers: {
      'Content-Type': 'application/json'
    }
  })
}

// 删除推荐
export function delRecommend(id) {
  return request({
    url: '/back/re/' + id,
    method: 'delete'
  })
}

// 获取推荐已绑定的音乐
export function getRecommendBoundMusic(recommendId) {
  return request({
    url: `/back/re/music/${recommendId}`,
    method: 'get'
  })
}

// 绑定音乐到推荐
export function bindMusicToRecommend(recommendId, musicIds) {
  return request({
    url: `/back/re/bind/${recommendId}/${musicIds.join(',')}`,
    method: 'put',
  })
} 