question.js 849 B

12345678910111213141516171819202122232425262728293031323334353637
  1. import axios from '@/plugins/axios'
  2. import { useQuestionServer } from '@/config/server-info'
  3. export function getQuestionList({
  4. stem,
  5. size,
  6. page,
  7. sort
  8. }) {
  9. const params = { stem, size, page, sort }
  10. return axios
  11. .get(useQuestionServer(), { params })
  12. .then(res => res.data)
  13. }
  14. export function getQuestionById(questionId) {
  15. return axios
  16. .get(useQuestionServer(`/${questionId}`))
  17. .then(res => res.data)
  18. }
  19. export function createQuestion(questionBody) {
  20. return axios
  21. .post(useQuestionServer(), questionBody)
  22. .then(res => res.data)
  23. }
  24. export function updateQuestion({ questionId, questionBody }) {
  25. return axios
  26. .post(useQuestionServer(`/${questionId}`), questionBody)
  27. .then(res => res.data)
  28. }
  29. export function deleteQuestion(questionId) {
  30. return axios
  31. .delete(useQuestionServer(`/${questionId}`))
  32. }