MockApplyController.java 6.8 KB

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