You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

105 lines
1.9 KiB

  1. import request from '@/utils/request'
  2. // 查询答复列表
  3. export function listAnswers(query) {
  4. return request({
  5. url: '/system/answers/list',
  6. method: 'get',
  7. params: query
  8. })
  9. }
  10. // 查询答复详细
  11. export function getAnswers(id) {
  12. return request({
  13. url: '/system/answers/' + id,
  14. method: 'get'
  15. })
  16. }
  17. // 新增答复
  18. export function addAnswers(data) {
  19. return request({
  20. url: '/system/answers',
  21. method: 'post',
  22. data: data
  23. })
  24. }
  25. // 修改答复
  26. export function updateAnswers(data) {
  27. return request({
  28. url: '/system/answers',
  29. method: 'put',
  30. data: data
  31. })
  32. }
  33. // 删除答复
  34. export function delAnswers(id) {
  35. return request({
  36. url: '/system/answers/' + id,
  37. method: 'delete'
  38. })
  39. }
  40. // 以下是新增的回复相关API
  41. // 查询顶级答复列表
  42. export function listRootAnswers(questionId, query) {
  43. return request({
  44. url: `/system/answers/question/${questionId}/roots`,
  45. method: 'get',
  46. params: query
  47. })
  48. }
  49. // 查询答复树形结构
  50. export function getAnswerTree(questionId) {
  51. return request({
  52. url: `/system/answers/question/${questionId}/tree`,
  53. method: 'get'
  54. })
  55. }
  56. // 查询子回复列表
  57. export function listChildrenAnswers(parentId, query) {
  58. return request({
  59. url: `/system/answers/parent/${parentId}/children`,
  60. method: 'get',
  61. params: query
  62. })
  63. }
  64. // 新增回复
  65. export function addReply(data) {
  66. return request({
  67. url: '/system/answers/reply',
  68. method: 'post',
  69. data: data
  70. })
  71. }
  72. // 点赞答复
  73. export function likeAnswer(id) {
  74. return request({
  75. url: `/system/answers/${id}/like`,
  76. method: 'post'
  77. })
  78. }
  79. // 取消点赞答复
  80. export function unlikeAnswer(id) {
  81. return request({
  82. url: `/system/answers/${id}/unlike`,
  83. method: 'post'
  84. })
  85. }
  86. // 获取问题的答案数量
  87. export function countAnswersByQuestionId(questionId) {
  88. return request({
  89. url: `/system/answers/count/${questionId}`,
  90. method: 'get'
  91. })
  92. }