comment.js 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import {
  2. useCommentServer
  3. } from '@/config/server-info'
  4. import axios from '@/plugins/axios'
  5. export function createComment ({ slideId, pageNumber, title, content }) {
  6. const data = {
  7. slideId,
  8. pageNumber,
  9. title,
  10. content
  11. }
  12. return axios
  13. .post(useCommentServer(), data)
  14. .then(res => res.data)
  15. }
  16. export function removeComment ({ commentId }) {
  17. return axios
  18. .delete(useCommentServer('/' + commentId))
  19. .then(res => {})
  20. }
  21. export function topComment ({ commentId }) {
  22. return axios
  23. .post(useCommentServer('/' + commentId + '/top'))
  24. .then(res => {})
  25. }
  26. export function unTopComment ({ commentId }) {
  27. return axios
  28. .post(useCommentServer('/' + commentId + '/unTop'))
  29. .then(res => {})
  30. }
  31. export function getComments ({ slideId, pageNumber, key = '', page = 0, size = 10, sort = '' }) {
  32. return axios
  33. .get(useCommentServer('/slide/' + slideId), {
  34. params: {
  35. pageNumber,
  36. key,
  37. page,
  38. size,
  39. sort
  40. }
  41. })
  42. .then(res => res.data)
  43. }