CollectQuestionController.java 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. package com.zhongzheng.controller.collect;
  2. import com.zhongzheng.common.annotation.Log;
  3. import com.zhongzheng.common.core.controller.BaseController;
  4. import com.zhongzheng.common.core.domain.AjaxResult;
  5. import com.zhongzheng.common.core.page.TableDataInfo;
  6. import com.zhongzheng.common.enums.BusinessType;
  7. import com.zhongzheng.common.utils.ServletUtils;
  8. import com.zhongzheng.framework.web.service.WxTokenService;
  9. import com.zhongzheng.modules.bank.vo.QuestionVo;
  10. import com.zhongzheng.modules.collect.bo.CollectQuestionAddBo;
  11. import com.zhongzheng.modules.collect.bo.CollectQuestionQueryBo;
  12. import com.zhongzheng.modules.collect.domain.CollectQuestion;
  13. import com.zhongzheng.modules.collect.service.ICollectQuestionService;
  14. import com.zhongzheng.modules.user.entity.ClientLoginUser;
  15. import io.swagger.annotations.Api;
  16. import io.swagger.annotations.ApiOperation;
  17. import lombok.RequiredArgsConstructor;
  18. import org.springframework.beans.factory.annotation.Autowired;
  19. import org.springframework.web.bind.annotation.*;
  20. import java.util.Arrays;
  21. import java.util.List;
  22. /**
  23. * 收藏题目Controller
  24. *
  25. * @author ruoyi
  26. * @date 2021-06-24
  27. */
  28. @Api(value = "收藏题目控制器", tags = {"收藏题目管理"})
  29. @RequiredArgsConstructor(onConstructor_ = @Autowired)
  30. @RestController
  31. @RequestMapping("/collect/question")
  32. public class CollectQuestionController extends BaseController {
  33. private final ICollectQuestionService iCollectQuestionService;
  34. private final WxTokenService wxTokenService;
  35. /**
  36. * 查询收藏题目列表
  37. */
  38. @ApiOperation("查询收藏题目列表,按题型")
  39. @GetMapping("/list")
  40. public TableDataInfo<QuestionVo> list(CollectQuestionQueryBo bo) {
  41. ClientLoginUser loginUser = wxTokenService.getLoginUser(ServletUtils.getRequest());
  42. bo.setUserId(loginUser.getUser().getUserId());
  43. startPage();
  44. List<QuestionVo> list = iCollectQuestionService.selectList(bo);
  45. return getDataTable(list);
  46. }
  47. /**
  48. * 查询收藏题目列表
  49. */
  50. @ApiOperation("查询收藏题目列表,按试卷")
  51. @GetMapping("/exam_list")
  52. public TableDataInfo<QuestionVo> exam_list(CollectQuestionQueryBo bo) {
  53. ClientLoginUser loginUser = wxTokenService.getLoginUser(ServletUtils.getRequest());
  54. bo.setUserId(loginUser.getUser().getUserId());
  55. startPage();
  56. List<QuestionVo> list = iCollectQuestionService.selectExamList(bo);
  57. return getDataTable(list);
  58. }
  59. /**
  60. * 获取收藏题目详细信息
  61. */
  62. @ApiOperation("获取收藏题目详细信息")
  63. @GetMapping("/getInfo")
  64. public AjaxResult<CollectQuestion> getInfo(Long questionId,Long examId,Long goodsId) {
  65. ClientLoginUser loginUser = wxTokenService.getLoginUser(ServletUtils.getRequest());
  66. return AjaxResult.success(iCollectQuestionService.queryQuestionById(loginUser.getUser().getUserId(),questionId,examId,goodsId));
  67. }
  68. /**
  69. * 新增收藏题目
  70. */
  71. @ApiOperation("新增收藏题目")
  72. @Log(title = "收藏题目", businessType = BusinessType.INSERT)
  73. @PostMapping()
  74. public AjaxResult<Void> add(@RequestBody CollectQuestionAddBo bo) {
  75. ClientLoginUser loginUser = wxTokenService.getLoginUser(ServletUtils.getRequest());
  76. bo.setUserId(loginUser.getUser().getUserId());
  77. return toAjax(iCollectQuestionService.insertByAddBo(bo) ? 1 : 0);
  78. }
  79. /**
  80. * 删除收藏题目
  81. */
  82. @ApiOperation("删除收藏题目")
  83. @Log(title = "收藏题目" , businessType = BusinessType.DELETE)
  84. @PostMapping("/delete/{collectQuestionIds}")
  85. public AjaxResult<Void> remove(@PathVariable Long[] collectQuestionIds) {
  86. return toAjax(iCollectQuestionService.deleteWithValidByIds(Arrays.asList(collectQuestionIds), true) ? 1 : 0);
  87. }
  88. }