LearnQuestionsController.java 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. package com.ruoyi.web.controller.learn;
  2. import java.util.List;
  3. import javax.servlet.http.HttpServletResponse;
  4. import io.swagger.annotations.Api;
  5. import io.swagger.annotations.ApiOperation;
  6. import org.springframework.security.access.prepost.PreAuthorize;
  7. import org.springframework.beans.factory.annotation.Autowired;
  8. import org.springframework.web.bind.annotation.GetMapping;
  9. import org.springframework.web.bind.annotation.PostMapping;
  10. import org.springframework.web.bind.annotation.PutMapping;
  11. import org.springframework.web.bind.annotation.DeleteMapping;
  12. import org.springframework.web.bind.annotation.PathVariable;
  13. import org.springframework.web.bind.annotation.RequestBody;
  14. import org.springframework.web.bind.annotation.RequestMapping;
  15. import org.springframework.web.bind.annotation.RestController;
  16. import com.ruoyi.common.annotation.Log;
  17. import com.ruoyi.common.core.controller.BaseController;
  18. import com.ruoyi.common.core.domain.AjaxResult;
  19. import com.ruoyi.common.enums.BusinessType;
  20. import com.ruoyi.learn.domain.LearnQuestions;
  21. import com.ruoyi.learn.service.ILearnQuestionsService;
  22. import com.ruoyi.common.utils.poi.ExcelUtil;
  23. import com.ruoyi.common.core.page.TableDataInfo;
  24. /**
  25. * 试题Controller
  26. *
  27. * @author ruoyi
  28. * @date 2025-09-18
  29. */
  30. @RestController
  31. @RequestMapping("/learn/questions")
  32. @Api(tags = "后台-学习 - 题")
  33. public class LearnQuestionsController extends BaseController
  34. {
  35. @Autowired
  36. private ILearnQuestionsService learnQuestionsService;
  37. /**
  38. * 查询试题列表
  39. */
  40. @PreAuthorize("@ss.hasPermi('learn:questions:list')")
  41. @GetMapping("/list")
  42. @ApiOperation("查询列表")
  43. public TableDataInfo list(LearnQuestions learnQuestions)
  44. {
  45. startPage();
  46. List<LearnQuestions> list = learnQuestionsService.selectLearnQuestionsList(learnQuestions);
  47. return getDataTable(list);
  48. }
  49. /**
  50. * 导出试题列表
  51. */
  52. @PreAuthorize("@ss.hasPermi('learn:questions:export')")
  53. @Log(title = "试题", businessType = BusinessType.EXPORT)
  54. @PostMapping("/export")
  55. public void export(HttpServletResponse response, LearnQuestions learnQuestions)
  56. {
  57. List<LearnQuestions> list = learnQuestionsService.selectLearnQuestionsList(learnQuestions);
  58. ExcelUtil<LearnQuestions> util = new ExcelUtil<LearnQuestions>(LearnQuestions.class);
  59. util.exportExcel(response, list, "试题数据");
  60. }
  61. /**
  62. * 获取试题详细信息
  63. */
  64. @PreAuthorize("@ss.hasPermi('learn:questions:query')")
  65. @GetMapping(value = "/{id}")
  66. public AjaxResult getInfo(@PathVariable("id") Long id)
  67. {
  68. return success(learnQuestionsService.selectLearnQuestionsById(id));
  69. }
  70. /**
  71. * 新增试题
  72. */
  73. @PreAuthorize("@ss.hasPermi('learn:questions:add')")
  74. @Log(title = "试题", businessType = BusinessType.INSERT)
  75. @PostMapping
  76. public AjaxResult add(@RequestBody LearnQuestions learnQuestions)
  77. {
  78. return toAjax(learnQuestionsService.insertLearnQuestions(learnQuestions));
  79. }
  80. /**
  81. * 修改试题
  82. */
  83. @PreAuthorize("@ss.hasPermi('learn:questions:edit')")
  84. @Log(title = "试题", businessType = BusinessType.UPDATE)
  85. @PutMapping
  86. public AjaxResult edit(@RequestBody LearnQuestions learnQuestions)
  87. {
  88. return toAjax(learnQuestionsService.updateLearnQuestions(learnQuestions));
  89. }
  90. /**
  91. * 删除试题
  92. */
  93. @PreAuthorize("@ss.hasPermi('learn:questions:remove')")
  94. @Log(title = "试题", businessType = BusinessType.DELETE)
  95. @DeleteMapping("/{ids}")
  96. public AjaxResult remove(@PathVariable Long[] ids)
  97. {
  98. return toAjax(learnQuestionsService.deleteLearnQuestionsByIds(ids));
  99. }
  100. }