package com.zhongzheng.controller.mock; import cn.hutool.core.lang.Validator; import com.zhongzheng.common.annotation.Log; import com.zhongzheng.common.core.controller.BaseController; import com.zhongzheng.common.core.domain.AjaxResult; import com.zhongzheng.common.core.page.TableDataInfo; import com.zhongzheng.common.enums.BusinessType; import com.zhongzheng.common.utils.ServletUtils; import com.zhongzheng.common.utils.poi.ExcelUtil; import com.zhongzheng.framework.web.service.WxTokenService; import com.zhongzheng.modules.course.bo.CourseSectionQueryBo; import com.zhongzheng.modules.mock.bo.MockApplyAddBo; import com.zhongzheng.modules.mock.bo.MockApplyEditBo; import com.zhongzheng.modules.mock.bo.MockApplyQueryBo; import com.zhongzheng.modules.mock.domain.MockMajorSubject; import com.zhongzheng.modules.mock.service.IMockApplyService; import com.zhongzheng.modules.mock.vo.MockApplyVo; import com.zhongzheng.modules.mock.vo.MockMajorSubjectVo; import com.zhongzheng.modules.user.entity.ClientLoginUser; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; import java.util.Arrays; import java.util.List; /** * 模考安排Controller * * @author ruoyi * @date 2022-05-24 */ @Api(value = "模考安排控制器", tags = {"模考安排管理"}) @RequiredArgsConstructor(onConstructor_ = @Autowired) @RestController @RequestMapping("/mock/apply") public class MockApplyController extends BaseController { private final IMockApplyService iMockApplyService; private final WxTokenService wxTokenService; /** * 查询模考安排列表 */ @ApiOperation("查询模考安排列表") @PreAuthorize("@ss.hasPermi('system:apply:list')") @GetMapping("/list") public TableDataInfo list(MockApplyQueryBo bo) { startPage(); List list = iMockApplyService.queryList(bo); return getDataTable(list); } /** * 导出模考安排列表 */ @ApiOperation("导出模考安排列表") @PreAuthorize("@ss.hasPermi('system:apply:export')") @Log(title = "模考安排", businessType = BusinessType.EXPORT) @GetMapping("/export") public AjaxResult export(MockApplyQueryBo bo) { List list = iMockApplyService.queryList(bo); ExcelUtil util = new ExcelUtil(MockApplyVo.class); return util.exportExcel(list, "模考安排"); } /** * 获取模考安排详细信息 */ @ApiOperation("获取模考安排详细信息") @PreAuthorize("@ss.hasPermi('system:apply:query')") @GetMapping("/{applyId}") public AjaxResult getInfo(@PathVariable("applyId" ) Long applyId) { return AjaxResult.success(iMockApplyService.queryById(applyId)); } /** * 新增模考安排 */ @ApiOperation("新增模考安排") @PreAuthorize("@ss.hasPermi('system:apply:add')") @Log(title = "模考安排", businessType = BusinessType.INSERT) @PostMapping() public AjaxResult add(@RequestBody MockApplyAddBo bo) { return toAjax(iMockApplyService.insertByAddBo(bo) ? 1 : 0); } /** * 修改模考安排 */ @ApiOperation("修改模考安排") @PreAuthorize("@ss.hasPermi('system:apply:edit')") @Log(title = "模考安排", businessType = BusinessType.UPDATE) @PutMapping() public AjaxResult edit(@RequestBody MockApplyEditBo bo) { return toAjax(iMockApplyService.updateByEditBo(bo) ? 1 : 0); } /** * 删除模考安排 */ @ApiOperation("删除模考安排") @PreAuthorize("@ss.hasPermi('system:apply:remove')") @Log(title = "模考安排" , businessType = BusinessType.DELETE) @DeleteMapping("/{applyIds}") public AjaxResult remove(@PathVariable Long[] applyIds) { return toAjax(iMockApplyService.deleteWithValidByIds(Arrays.asList(applyIds), true) ? 1 : 0); } /** * 查询模考安排列表 */ @ApiOperation("查询模考安排列表") @PreAuthorize("@ss.hasPermi('system:apply:list')") @GetMapping("/listApply") public TableDataInfo listApply(MockApplyQueryBo bo){ startPage(); ClientLoginUser loginUser = wxTokenService.getLoginUser(ServletUtils.getRequest()); bo.setUserId(loginUser.getUser().getUserId()); List list = iMockApplyService.queryApplyList(bo); return getDataTable(list); } /** * 查询模考预约业务层次列表 */ @ApiOperation("查询模考预约业务层次列表") @PreAuthorize("@ss.hasPermi('system:apply:list')") @GetMapping("/listApplyBusiness") public TableDataInfo listApplyBusiness(MockApplyQueryBo bo) { ClientLoginUser loginUser = wxTokenService.getLoginUser(ServletUtils.getRequest()); bo.setUserId(loginUser.getUser().getUserId()); List list = iMockApplyService.listApplyBusiness(bo); return getDataTable(list); } /** * 查询模考讲解直播列表 */ @ApiOperation("查询模考讲解直播列表") @PreAuthorize("@ss.hasPermi('system:apply:list')") @GetMapping("/listMockLive") public TableDataInfo listMockLive(MockApplyQueryBo bo) { Integer pageNum = 0; Integer pageSize = 0; if (Validator.isNotEmpty(bo.getPageNum()) && Validator.isNotEmpty(bo.getPageSize())) { pageNum = bo.getPageNum(); pageSize = bo.getPageSize(); bo.setPageNum(null); bo.setPageSize(null); } List list = iMockApplyService.listMockLive(bo); bo.setPageNum(pageNum); bo.setPageSize(pageSize); if (Validator.isEmpty(bo.getPageNum()) || Validator.isEmpty(bo.getPageSize())) { return getDataTable(list); } return getDataTable(getPageInfo(pageNum, pageSize, list).getList()); } /** * 查询是否有模考讲解直播正在进行 * @return */ @ApiOperation("查询是否有模考讲解直播正在进行") @PreAuthorize("@ss.hasPermi('system:apply:list')") @GetMapping("/mockLiving") public AjaxResult mockLiving() { ClientLoginUser loginUser = wxTokenService.getLoginUser(ServletUtils.getRequest()); return AjaxResult.success(iMockApplyService.mockLiving(loginUser.getUser().getUserId())); } /** * 获取模考标题 */ @ApiOperation("获取模考标题") @PreAuthorize("@ss.hasPermi('system:apply:list')") @GetMapping("/listApplyName") public TableDataInfo listApplyName(MockApplyQueryBo bo) { List list = iMockApplyService.listApplyName(bo); return getDataTable(list); } }