GoodsController.java 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. package com.zhongzheng.controller.goods;
  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.bo.QuestionChapterExamQueryBo;
  10. import com.zhongzheng.modules.bank.bo.QuestionModuleChapterQueryBo;
  11. import com.zhongzheng.modules.bank.service.IQuestionChapterExamService;
  12. import com.zhongzheng.modules.bank.service.IQuestionModuleChapterService;
  13. import com.zhongzheng.modules.bank.vo.ExamVo;
  14. import com.zhongzheng.modules.bank.vo.QuestionChapterVo;
  15. import com.zhongzheng.modules.collect.bo.CollectQuestionQueryBo;
  16. import com.zhongzheng.modules.collect.service.ICollectQuestionService;
  17. import com.zhongzheng.modules.course.bo.CourseQueryBo;
  18. import com.zhongzheng.modules.goods.bo.*;
  19. import com.zhongzheng.modules.goods.service.IGoodsAttachedService;
  20. import com.zhongzheng.modules.goods.service.IGoodsAuditionConfigService;
  21. import com.zhongzheng.modules.goods.service.IGoodsService;
  22. import com.zhongzheng.modules.goods.vo.GoodsAttachedVo;
  23. import com.zhongzheng.modules.goods.vo.GoodsVo;
  24. import com.zhongzheng.modules.user.bo.UserExamRecordQueryBo;
  25. import com.zhongzheng.modules.user.bo.UserExamWrongRecordQueryBo;
  26. import com.zhongzheng.modules.user.entity.ClientLoginUser;
  27. import com.zhongzheng.modules.user.service.IUserExamRecordService;
  28. import com.zhongzheng.modules.user.service.IUserExamWrongRecordService;
  29. import io.swagger.annotations.Api;
  30. import io.swagger.annotations.ApiOperation;
  31. import io.swagger.models.auth.In;
  32. import lombok.RequiredArgsConstructor;
  33. import org.springframework.beans.factory.annotation.Autowired;
  34. import org.springframework.security.access.prepost.PreAuthorize;
  35. import org.springframework.web.bind.annotation.*;
  36. import java.util.*;
  37. /**
  38. * 商品Controller
  39. *
  40. * @author hjl
  41. * @date 2021-10-12
  42. */
  43. @Api(value = "商品控制器", tags = {"商品管理"})
  44. @RequiredArgsConstructor(onConstructor_ = @Autowired)
  45. @RestController
  46. @RequestMapping("/goods")
  47. public class GoodsController extends BaseController {
  48. private final IGoodsService iGoodsService;
  49. private final IGoodsAttachedService iGoodsAttachedService;
  50. private final WxTokenService wxTokenService;
  51. private final IUserExamRecordService iUserExamRecordService;
  52. private final IUserExamWrongRecordService iUserExamWrongRecordService;
  53. private final ICollectQuestionService iCollectQuestionService;
  54. private final IQuestionModuleChapterService iQuestionModuleChapterService;
  55. private final IQuestionChapterExamService iQuestionChapterExamService;
  56. /**
  57. * 获取商品详细信息
  58. */
  59. @ApiOperation("获取商品详细信息")
  60. @GetMapping("/{goodsId}")
  61. public AjaxResult<GoodsVo> getInfo(@PathVariable("goodsId" ) Long goodsId) {
  62. CourseQueryBo bo = new CourseQueryBo();
  63. ClientLoginUser loginUser = wxTokenService.getLoginUser(ServletUtils.getRequest());
  64. bo.setUserId(loginUser.getUser().getUserId());
  65. bo.setGoodsId(goodsId);
  66. return AjaxResult.success(iGoodsService.selectUserDetail(bo));
  67. }
  68. /**
  69. * 获取商品详细信息
  70. */
  71. @ApiOperation("获取题库商品题目数统计信息")
  72. @GetMapping("/bank/questionNum/{goodsId}")
  73. public AjaxResult<Map<String,Object>> questionNum(@PathVariable("goodsId" ) Long goodsId) {
  74. ClientLoginUser loginUser = wxTokenService.getLoginUser(ServletUtils.getRequest());
  75. Map<String,Object> numMap = new HashMap<>();
  76. UserExamWrongRecordQueryBo wBo = new UserExamWrongRecordQueryBo();
  77. wBo.setGoodsId(goodsId);
  78. wBo.setUserId(loginUser.getUser().getUserId());
  79. Long wrongNum = iUserExamWrongRecordService.recordNum(wBo);
  80. numMap.put("wrongNum",wrongNum);
  81. CollectQuestionQueryBo collectQuestionQueryBo = new CollectQuestionQueryBo();
  82. collectQuestionQueryBo.setGoodsId(goodsId);
  83. collectQuestionQueryBo.setUserId(loginUser.getUser().getUserId());
  84. Integer collectNum = iCollectQuestionService.collectNum(collectQuestionQueryBo);
  85. numMap.put("collectNum",collectNum);
  86. UserExamRecordQueryBo userExamRecordQueryBo = new UserExamRecordQueryBo();
  87. userExamRecordQueryBo.setGoodsId(goodsId);
  88. userExamRecordQueryBo.setUserId(loginUser.getUser().getUserId());
  89. Long doNum = iUserExamRecordService.selectDoNum(userExamRecordQueryBo);
  90. numMap.put("doNum",doNum);
  91. userExamRecordQueryBo.setGoodsId(goodsId);
  92. userExamRecordQueryBo.setUserId(loginUser.getUser().getUserId());
  93. Long rightNum = iUserExamRecordService.selectRightNum(userExamRecordQueryBo);
  94. numMap.put("rightNum",rightNum);
  95. Long totalNum = iGoodsService.getQuestionNum(goodsId);
  96. numMap.put("totalNum",totalNum);
  97. return AjaxResult.success(numMap);
  98. }
  99. @ApiOperation("查询商品题库目录列表")
  100. @GetMapping("/bank/list")
  101. public AjaxResult<List<GoodsAttachedVo>> bankList(GoodsAttachedQueryBo bo) {
  102. ClientLoginUser loginUser = wxTokenService.getLoginUser(ServletUtils.getRequest());
  103. bo.setUserId(loginUser.getUser().getUserId());
  104. List<GoodsAttachedVo> list = iGoodsAttachedService.selectList(bo);
  105. return AjaxResult.success(list);
  106. }
  107. @ApiOperation("查询商品题库做过目录列表")
  108. @GetMapping("/bank/dolist")
  109. public AjaxResult<List<GoodsAttachedVo>> bankDoList(GoodsAttachedQueryBo bo) {
  110. ClientLoginUser loginUser = wxTokenService.getLoginUser(ServletUtils.getRequest());
  111. bo.setUserId(loginUser.getUser().getUserId());
  112. List<GoodsAttachedVo> list = iGoodsAttachedService.selectDoList(bo);
  113. return AjaxResult.success(list);
  114. }
  115. /**
  116. * 查询关联章卷列表
  117. */
  118. @ApiOperation("查询模块卷关联章卷做过列表")
  119. @GetMapping("/chapter/dolist")
  120. public AjaxResult<List<QuestionChapterVo>> chapterDoList(QuestionModuleChapterQueryBo bo) {
  121. List<QuestionChapterVo> list = iQuestionModuleChapterService.getDoList(bo);
  122. return AjaxResult.success(list);
  123. }
  124. /**
  125. * 查询关联试卷列表
  126. */
  127. @ApiOperation("查询章卷关联试卷做过列表")
  128. @GetMapping("/exam/dolist")
  129. public AjaxResult<List<ExamVo>> examDoList(QuestionChapterExamQueryBo bo) {
  130. List<ExamVo> list = iQuestionChapterExamService.getDoList(bo);
  131. return AjaxResult.success(list);
  132. }
  133. }