MockApplyController.java 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. package com.zhongzheng.controller.mock;
  2. import cn.hutool.core.lang.Validator;
  3. import com.zhongzheng.common.annotation.Log;
  4. import com.zhongzheng.common.core.controller.BaseController;
  5. import com.zhongzheng.common.core.domain.AjaxResult;
  6. import com.zhongzheng.common.core.page.TableDataInfo;
  7. import com.zhongzheng.common.enums.BusinessType;
  8. import com.zhongzheng.common.utils.ServletUtils;
  9. import com.zhongzheng.common.utils.poi.ExcelUtil;
  10. import com.zhongzheng.framework.web.service.WxTokenService;
  11. import com.zhongzheng.modules.course.bo.CourseSectionQueryBo;
  12. import com.zhongzheng.modules.mock.bo.MockApplyAddBo;
  13. import com.zhongzheng.modules.mock.bo.MockApplyEditBo;
  14. import com.zhongzheng.modules.mock.bo.MockApplyQueryBo;
  15. import com.zhongzheng.modules.mock.bo.MockTimeAddBo;
  16. import com.zhongzheng.modules.mock.domain.MockMajorSubject;
  17. import com.zhongzheng.modules.mock.service.IMockApplyService;
  18. import com.zhongzheng.modules.mock.vo.MockApplyVo;
  19. import com.zhongzheng.modules.mock.vo.MockMajorSubjectVo;
  20. import com.zhongzheng.modules.mock.vo.MockTimeVo;
  21. import com.zhongzheng.modules.user.entity.ClientLoginUser;
  22. import com.zhongzheng.modules.user.vo.UserMockSubscribeVo;
  23. import io.swagger.annotations.Api;
  24. import io.swagger.annotations.ApiOperation;
  25. import lombok.RequiredArgsConstructor;
  26. import org.springframework.beans.factory.annotation.Autowired;
  27. import org.springframework.security.access.prepost.PreAuthorize;
  28. import org.springframework.web.bind.annotation.*;
  29. import java.util.Arrays;
  30. import java.util.List;
  31. /**
  32. * 模考安排Controller
  33. *
  34. * @author ruoyi
  35. * @date 2022-05-24
  36. */
  37. @Api(value = "模考安排控制器", tags = {"模考安排管理"})
  38. @RequiredArgsConstructor(onConstructor_ = @Autowired)
  39. @RestController
  40. @RequestMapping("/mock/apply")
  41. public class MockApplyController extends BaseController {
  42. private final IMockApplyService iMockApplyService;
  43. private final WxTokenService wxTokenService;
  44. /**
  45. * 查询模考安排列表
  46. */
  47. @ApiOperation("查询模考安排列表")
  48. @PreAuthorize("@ss.hasPermi('system:apply:list')")
  49. @GetMapping("/list")
  50. public TableDataInfo<MockApplyVo> list(MockApplyQueryBo bo) {
  51. startPage();
  52. List<MockApplyVo> list = iMockApplyService.queryList(bo);
  53. return getDataTable(list);
  54. }
  55. /**
  56. * 导出模考安排列表
  57. */
  58. @ApiOperation("导出模考安排列表")
  59. @PreAuthorize("@ss.hasPermi('system:apply:export')")
  60. @Log(title = "模考安排", businessType = BusinessType.EXPORT)
  61. @GetMapping("/export")
  62. public AjaxResult<MockApplyVo> export(MockApplyQueryBo bo) {
  63. List<MockApplyVo> list = iMockApplyService.queryList(bo);
  64. ExcelUtil<MockApplyVo> util = new ExcelUtil<MockApplyVo>(MockApplyVo.class);
  65. return util.exportExcel(list, "模考安排");
  66. }
  67. /**
  68. * 获取模考安排详细信息
  69. */
  70. @ApiOperation("获取模考安排详细信息")
  71. @PreAuthorize("@ss.hasPermi('system:apply:query')")
  72. @GetMapping("/{applyId}")
  73. public AjaxResult<MockApplyVo> getInfo(@PathVariable("applyId" ) Long applyId) {
  74. return AjaxResult.success(iMockApplyService.queryById(applyId));
  75. }
  76. /**
  77. * 新增模考安排
  78. */
  79. @ApiOperation("新增模考安排")
  80. @PreAuthorize("@ss.hasPermi('system:apply:add')")
  81. @Log(title = "模考安排", businessType = BusinessType.INSERT)
  82. @PostMapping()
  83. public AjaxResult<Void> add(@RequestBody MockApplyAddBo bo) {
  84. return toAjax(iMockApplyService.insertByAddBo(bo) ? 1 : 0);
  85. }
  86. /**
  87. * 修改模考安排
  88. */
  89. @ApiOperation("修改模考安排")
  90. @PreAuthorize("@ss.hasPermi('system:apply:edit')")
  91. @Log(title = "模考安排", businessType = BusinessType.UPDATE)
  92. @PutMapping()
  93. public AjaxResult<Void> edit(@RequestBody MockApplyEditBo bo) {
  94. return toAjax(iMockApplyService.updateByEditBo(bo) ? 1 : 0);
  95. }
  96. /**
  97. * 删除模考安排
  98. */
  99. @ApiOperation("删除模考安排")
  100. @PreAuthorize("@ss.hasPermi('system:apply:remove')")
  101. @Log(title = "模考安排" , businessType = BusinessType.DELETE)
  102. @DeleteMapping("/{applyIds}")
  103. public AjaxResult<Void> remove(@PathVariable Long[] applyIds) {
  104. return toAjax(iMockApplyService.deleteWithValidByIds(Arrays.asList(applyIds), true) ? 1 : 0);
  105. }
  106. /**
  107. * 查询模考安排列表
  108. */
  109. @ApiOperation("查询模考安排列表")
  110. @PreAuthorize("@ss.hasPermi('system:apply:list')")
  111. @GetMapping("/listApply")
  112. public TableDataInfo<MockApplyVo> listApply(MockApplyQueryBo bo){
  113. startPage();
  114. ClientLoginUser loginUser = wxTokenService.getLoginUser(ServletUtils.getRequest());
  115. bo.setUserId(loginUser.getUser().getUserId());
  116. List<MockApplyVo> list = iMockApplyService.queryApplyList(bo);
  117. return getDataTable(list);
  118. }
  119. /**
  120. * 查询模考预约业务层次列表
  121. */
  122. @ApiOperation("查询模考预约业务层次列表")
  123. @PreAuthorize("@ss.hasPermi('system:apply:list')")
  124. @GetMapping("/listApplyBusiness")
  125. public TableDataInfo<MockApplyVo> listApplyBusiness(MockApplyQueryBo bo) {
  126. ClientLoginUser loginUser = wxTokenService.getLoginUser(ServletUtils.getRequest());
  127. bo.setUserId(loginUser.getUser().getUserId());
  128. List<MockApplyVo> list = iMockApplyService.listApplyBusiness(bo);
  129. return getDataTable(list);
  130. }
  131. /**
  132. * 查询模考讲解直播列表
  133. */
  134. @ApiOperation("查询模考讲解直播列表")
  135. @PreAuthorize("@ss.hasPermi('system:apply:list')")
  136. @GetMapping("/listMockLive")
  137. public TableDataInfo<MockMajorSubjectVo> listMockLive(MockApplyQueryBo bo) {
  138. ClientLoginUser loginUser = wxTokenService.getLoginUser(ServletUtils.getRequest());
  139. bo.setUserId(loginUser.getUser().getUserId());
  140. Integer pageNum = 0;
  141. Integer pageSize = 0;
  142. if (Validator.isNotEmpty(bo.getPageNum()) && Validator.isNotEmpty(bo.getPageSize())) {
  143. pageNum = bo.getPageNum();
  144. pageSize = bo.getPageSize();
  145. bo.setPageNum(null);
  146. bo.setPageSize(null);
  147. }
  148. List<MockMajorSubjectVo> list = iMockApplyService.listMockLive(bo);
  149. bo.setPageNum(pageNum);
  150. bo.setPageSize(pageSize);
  151. if (Validator.isEmpty(bo.getPageNum()) || Validator.isEmpty(bo.getPageSize())) {
  152. return getDataTable(list);
  153. }
  154. return getDataTable(getPageInfo(pageNum, pageSize, list).getList());
  155. }
  156. /**
  157. * 查询是否有模考讲解直播正在进行
  158. * @return
  159. */
  160. @ApiOperation("查询是否有模考讲解直播正在进行")
  161. @PreAuthorize("@ss.hasPermi('system:apply:list')")
  162. @GetMapping("/mockLiving")
  163. public AjaxResult<CourseSectionQueryBo> mockLiving() {
  164. ClientLoginUser loginUser = wxTokenService.getLoginUser(ServletUtils.getRequest());
  165. return AjaxResult.success(iMockApplyService.mockLiving(loginUser.getUser().getUserId()));
  166. }
  167. /**
  168. * 获取模考标题
  169. */
  170. @ApiOperation("获取模考标题")
  171. @PreAuthorize("@ss.hasPermi('system:apply:list')")
  172. @GetMapping("/listApplyName")
  173. public TableDataInfo<MockMajorSubjectVo> listApplyName(MockApplyQueryBo bo) {
  174. List<MockMajorSubjectVo> list = iMockApplyService.listApplyName(bo);
  175. return getDataTable(list);
  176. }
  177. /**
  178. * 补充模考时间
  179. */
  180. @ApiOperation("补充模考时间")
  181. @PostMapping("/addMockTime")
  182. public AjaxResult<MockTimeVo> addMockTime(@RequestBody MockTimeAddBo bo) {
  183. ClientLoginUser loginUser = wxTokenService.getLoginUser(ServletUtils.getRequest());
  184. bo.setUserId(loginUser.getUser().getUserId());
  185. MockTimeVo vo = iMockApplyService.addMockTime(bo);
  186. return AjaxResult.success(vo);
  187. }
  188. }