LearnKnowledgeQuestionController.java 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. package com.ruoyi.web.controller.learn;
  2. import java.util.List;
  3. import javax.servlet.http.HttpServletResponse;
  4. import com.ruoyi.learn.domain.LearnKnowledgeTree;
  5. import com.ruoyi.learn.domain.LearnQuestions;
  6. import com.ruoyi.learn.service.ILearnKnowledgeTreeService;
  7. import com.ruoyi.learn.service.ILearnQuestionsService;
  8. import org.springframework.security.access.prepost.PreAuthorize;
  9. import org.springframework.beans.factory.annotation.Autowired;
  10. import org.springframework.web.bind.annotation.GetMapping;
  11. import org.springframework.web.bind.annotation.PostMapping;
  12. import org.springframework.web.bind.annotation.PutMapping;
  13. import org.springframework.web.bind.annotation.DeleteMapping;
  14. import org.springframework.web.bind.annotation.PathVariable;
  15. import org.springframework.web.bind.annotation.RequestBody;
  16. import org.springframework.web.bind.annotation.RequestMapping;
  17. import org.springframework.web.bind.annotation.RestController;
  18. import com.ruoyi.common.annotation.Log;
  19. import com.ruoyi.common.core.controller.BaseController;
  20. import com.ruoyi.common.core.domain.AjaxResult;
  21. import com.ruoyi.common.enums.BusinessType;
  22. import com.ruoyi.learn.domain.LearnKnowledgeQuestion;
  23. import com.ruoyi.learn.service.ILearnKnowledgeQuestionService;
  24. import com.ruoyi.common.utils.poi.ExcelUtil;
  25. import com.ruoyi.common.core.page.TableDataInfo;
  26. /**
  27. * 知识点题关系Controller
  28. *
  29. * @author ruoyi
  30. * @date 2025-09-25
  31. */
  32. @RestController
  33. @RequestMapping("/learn/knowledgeQuestion")
  34. public class LearnKnowledgeQuestionController extends BaseController
  35. {
  36. @Autowired
  37. private ILearnKnowledgeQuestionService learnKnowledgeQuestionService;
  38. @Autowired
  39. private ILearnKnowledgeTreeService knowledgeTreeService;
  40. @Autowired
  41. private ILearnQuestionsService questionsService;
  42. /**
  43. * 查询知识点题关系列表
  44. */
  45. @PreAuthorize("@ss.hasPermi('learn:knowledgeQuestion:list')")
  46. @GetMapping("/list")
  47. public TableDataInfo list(LearnKnowledgeQuestion learnKnowledgeQuestion)
  48. {
  49. startPage();
  50. List<LearnKnowledgeQuestion> list = learnKnowledgeQuestionService.selectLearnKnowledgeQuestionList(learnKnowledgeQuestion);
  51. return getDataTable(list);
  52. }
  53. /**
  54. * 导出知识点题关系列表
  55. */
  56. @PreAuthorize("@ss.hasPermi('learn:knowledgeQuestion:export')")
  57. @Log(title = "知识点题关系", businessType = BusinessType.EXPORT)
  58. @PostMapping("/export")
  59. public void export(HttpServletResponse response, LearnKnowledgeQuestion learnKnowledgeQuestion)
  60. {
  61. List<LearnKnowledgeQuestion> list = learnKnowledgeQuestionService.selectLearnKnowledgeQuestionList(learnKnowledgeQuestion);
  62. ExcelUtil<LearnKnowledgeQuestion> util = new ExcelUtil<LearnKnowledgeQuestion>(LearnKnowledgeQuestion.class);
  63. util.exportExcel(response, list, "知识点题关系数据");
  64. }
  65. /**
  66. * 获取知识点题关系详细信息
  67. */
  68. @PreAuthorize("@ss.hasPermi('learn:knowledgeQuestion:query')")
  69. @GetMapping(value = "/{id}")
  70. public AjaxResult getInfo(@PathVariable("id") Long id)
  71. {
  72. return success(learnKnowledgeQuestionService.selectLearnKnowledgeQuestionById(id));
  73. }
  74. /**
  75. * 新增知识点题关系
  76. */
  77. @PreAuthorize("@ss.hasPermi('learn:knowledgeQuestion:add')")
  78. @Log(title = "知识点题关系", businessType = BusinessType.INSERT)
  79. @PostMapping
  80. public AjaxResult add(@RequestBody LearnKnowledgeQuestion learnKnowledgeQuestion)
  81. {
  82. return toAjax(learnKnowledgeQuestionService.insertLearnKnowledgeQuestion(learnKnowledgeQuestion));
  83. }
  84. /**
  85. * 修改知识点题关系
  86. */
  87. @PreAuthorize("@ss.hasPermi('learn:knowledgeQuestion:edit')")
  88. @Log(title = "知识点题关系", businessType = BusinessType.UPDATE)
  89. @PutMapping
  90. public AjaxResult edit(@RequestBody LearnKnowledgeQuestion learnKnowledgeQuestion)
  91. {
  92. //处理科目关联(是否有修改)
  93. LearnKnowledgeTree knowledgeTree = knowledgeTreeService.selectLearnKnowledgeTreeById(learnKnowledgeQuestion.getKnowledgeId());
  94. if (knowledgeTree != null ) {
  95. LearnQuestions q = questionsService.selectLearnQuestionsById(learnKnowledgeQuestion.getQuestionId());
  96. if (q != null && !q.getSubjectId().equals(knowledgeTree.getSubjectId())) {
  97. q.setSubjectId(knowledgeTree.getSubjectId());
  98. questionsService.updateLearnQuestions(q);
  99. }
  100. }
  101. return toAjax(learnKnowledgeQuestionService.updateLearnKnowledgeQuestion(learnKnowledgeQuestion));
  102. }
  103. /**
  104. * 删除知识点题关系
  105. */
  106. @PreAuthorize("@ss.hasPermi('learn:knowledgeQuestion:remove')")
  107. @Log(title = "知识点题关系", businessType = BusinessType.DELETE)
  108. @DeleteMapping("/{ids}")
  109. public AjaxResult remove(@PathVariable Long[] ids)
  110. {
  111. return toAjax(learnKnowledgeQuestionService.deleteLearnKnowledgeQuestionByIds(ids));
  112. }
  113. }