import request from '@/utils/request'
// 查询
export function getQuestionnaire(query) {
  return request({
    url: `/survey/list`,
    method: 'get',
    params: query
  })
}

// 新增
export function addQuestionnaire(data) {
  return request({
    url: `/survey/info`,
    method: 'post',
    data: data
  })
}

// 修改
export function updateQuestionnaire(data) {
  return request({
    url: `/survey/info/${data.surveyId}`,
    method: 'put',
    data: data
  })
}

// 删除
export function delQuestionnaire(data) {
  return request({
    url: `/survey/info`,
    method: 'delete',
    data
  })
}
// 修改状态
export function setQuestionnaireStatus(data) {
  return request({
    url: `/survey/status`,
    method: 'post',
    data
  })
}



// 问题
// 查询
export function getQuestion(query) {
  return request({
    url: `/survey/question`,
    method: 'get',
    params: query
  })
}

// 新增
export function addQuestion(data) {
  return request({
    url: `/survey/question`,
    method: 'post',
    data: data
  })
}

// 修改
export function updateQuestion(data) {
  return request({
    url: `/survey/question/${data.questionId}`,
    method: 'put',
    data: data
  })
}

// 删除
export function delQuestion(data) {
  return request({
    url: `/survey/question`,
    method: 'delete',
    data
  })
}

// 详情
export function getQuestionFach(query) {
  return request({
    url: `/survey/question/${query.questionId}`,
    method: 'delete',
    params: query
  })
}


// 记录
// 查询
export function getRecord(query) {
  return request({
    url: `/survey/record`,
    method: 'get',
    params: query
  })
}
// 删除
export function delRecord(recordId) {
  return request({
    url: `/survey/record/${recordId}`,
    method: 'delete'
  })
}

// 获取调查问卷问题及问题选项信息
export function getDetail(surveyId) {
  return request({
    url: `/survey/detail/${surveyId}`,
    method: 'get'
  })
}

// 获取调查问卷填写结果
export function getResult(query) {
  return request({
    url: `/survey/result/${query.surveyId}`,
    method: 'get',
    params: query
  })
}