package com.zhongzheng.controller.exam; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; import com.baomidou.mybatisplus.core.toolkit.StringUtils; 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.exception.CustomException; import com.zhongzheng.common.utils.poi.EasyPoiUtil; import com.zhongzheng.modules.base.bo.UserProfileQueryBo; import com.zhongzheng.modules.exam.bo.*; import com.zhongzheng.modules.exam.service.IExamApplyGoodsService; import com.zhongzheng.modules.exam.service.IExamApplyService; import com.zhongzheng.modules.exam.service.IExamApplySiteService; import com.zhongzheng.modules.exam.service.IExamApplyUserService; import com.zhongzheng.modules.exam.vo.*; 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 org.springframework.web.multipart.MultipartFile; import java.util.List; /** * 考试安排Controller * * @author ruoyi * @date 2021-12-07 */ @Api(value = "考试安排控制器", tags = {"考试安排管理"}) @RequiredArgsConstructor(onConstructor_ = @Autowired) @RestController @RequestMapping("/system/apply") public class ExamApplyController extends BaseController { private final IExamApplyService iExamApplyService; private final IExamApplySiteService iExamApplySiteService; private final IExamApplyGoodsService iExamApplyGoodsService; private final IExamApplyUserService iExamApplyUserService; /** * 查询考试安排列表 */ @ApiOperation("查询考试安排列表") @PreAuthorize("@ss.hasPermi('system:apply:list')") @GetMapping("/list") public TableDataInfo list(ExamApplyQueryBo bo) { startPage(); List list = iExamApplyService.queryList(bo); return getDataTable(list); } /** * 查询考场列表 */ @ApiOperation("查询考场列表") @GetMapping("/place") public TableDataInfo placeList(ExamApplyRoomQueryBo bo) { startPage(); List list = iExamApplyService.getPlaceList(bo); return getDataTable(list); } /** * 获取七大员考前需知 */ @ApiOperation("获取七大员考前需知") @GetMapping("/before/know") public AjaxResult getBeforeKnow() { return AjaxResult.success(iExamApplyService.getBeforeKnow()); } /** * 七大员考前需知新增/修改 */ @ApiOperation("七大员考前需知新增/修改") @PostMapping("/saveorup/before/know") public AjaxResult saveOrUpBeforeKnow(@RequestBody ExamBeforeKnowBo bo) { return toAjax(iExamApplyService.saveOrUpBeforeKnow(bo)? 1 : 0); } /** * 考场邮件信息 */ @ApiOperation("考场邮件地址") @GetMapping("/sendmail") public AjaxResult getSendmailUrl(ExamApplyQueryBo bo) { String url = iExamApplyService.getSendmailUrl(bo.getIds()); return AjaxResult.success(url); } /** * 考场邮件发送 */ @ApiOperation("考场邮件发送") @PostMapping("/send") public AjaxResult sendmail(@RequestBody ExamApplySendmailBo bo) { return toAjax(iExamApplyService.sendmail(bo)? 1 : 0); } /** * 获取考试安排详细信息 */ @ApiOperation("获取考试安排详细信息") @PreAuthorize("@ss.hasPermi('system:apply:query')") @GetMapping("/{applyId}") public AjaxResult getInfo(@PathVariable("applyId" ) Long applyId) { return AjaxResult.success(iExamApplyService.queryById(applyId)); } /** * 获取考试地点 考培地点 */ @ApiOperation("获取考试地点 考培地点") @PreAuthorize("@ss.hasPermi('system:apply:query')") @GetMapping("/siteInfo") public TableDataInfo getSiteInfo(ExamApplyQueryBo bo) { List examApplySiteVo = iExamApplyService.getSiteInfo(bo); return getDataTable(examApplySiteVo); } /** * 新增考试安排 */ @ApiOperation("新增考试安排") @PreAuthorize("@ss.hasPermi('system:apply:add')") @Log(title = "考试安排", businessType = BusinessType.INSERT) @PostMapping() public AjaxResult add(@RequestBody ExamApplyAddBo bo) { return toAjax(iExamApplyService.insertByAddBo(bo) ? 1 : 0); } /** * 新增考试安排 */ @ApiOperation("新增考试安排") @PostMapping("/save") public AjaxResult saveExamApply(MultipartFile file, String param) { if (StringUtils.isBlank(param)){ throw new CustomException("参数有误!"); } ExamApplyAddBo addBo = JSONObject.parseObject(param, ExamApplyAddBo.class); if (ObjectUtils.isNotNull(file)){ //学员资料解析 List applyUsers = EasyPoiUtil.importExcel(file,0,1,ExamApplyUserImportBo.class); addBo.setApplyUsers(applyUsers); } return toAjax(iExamApplyService.saveExamApply(addBo) ? 1 : 0); } /** * 修改考试安排 */ @ApiOperation("修改考试安排") @PreAuthorize("@ss.hasPermi('system:apply:edit')") @Log(title = "考试安排", businessType = BusinessType.UPDATE) @PostMapping("edit") public AjaxResult edit(@RequestBody ExamApplyEditBo bo) { return toAjax(iExamApplyService.updateByEditBo(bo) ? 1 : 0); } /** * 修改考试安排 */ @ApiOperation("修改考试安排") @PostMapping("/editApply") public AjaxResult editExamApply(MultipartFile file, String param) { if (StringUtils.isBlank(param)){ throw new CustomException("参数有误!"); } ExamApplyEditBo editBo = JSONObject.parseObject(param, ExamApplyEditBo.class); if (ObjectUtils.isNotNull(file)){ //学员资料解析 List applyUsers = EasyPoiUtil.importExcel(file,0,1,ExamApplyUserImportBo.class); editBo.setApplyUsers(applyUsers); } return toAjax(iExamApplyService.editExamApply(editBo) ? 1 : 0); } /** * 新增考试安排地点 */ @ApiOperation("新增考试安排地点") @PreAuthorize("@ss.hasPermi('system:site:add')") @Log(title = "考试安排地点", businessType = BusinessType.INSERT) @PostMapping("addSite") public AjaxResult addSite(@RequestBody List bo) { return toAjax(iExamApplySiteService.addSite(bo) ? 1 : 0); } /** * 新增考试安排绑定商品 */ @ApiOperation("新增考试安排绑定商品") @PreAuthorize("@ss.hasPermi('system:goods:add')") @Log(title = "考试安排绑定商品", businessType = BusinessType.INSERT) @PostMapping("addGoods") public AjaxResult addGoods(@RequestBody ExamApplyGoodsAddBo bo) { return toAjax(iExamApplyGoodsService.addGoods(bo) ? 1 : 0); } /** * 获取考试地点 考培地点 */ @ApiOperation("查看考试安排绑定商品") @PreAuthorize("@ss.hasPermi('system:apply:query')") @GetMapping("/goodsInfo") public AjaxResult getGoodsInfo(ExamApplyQueryBo bo) { ExamApplyVo examApplyVos = iExamApplyService.getGoodsInfo(bo); return AjaxResult.success(examApplyVos); } /** * 查看考试安排被预约数量 */ @ApiOperation("查看考试安排被预约数量") @PreAuthorize("@ss.hasPermi('system:apply:query')") @GetMapping("/countApplySubscribe") public AjaxResult countApplySubscribe(ExamApplyQueryBo bo) { Integer subNum = iExamApplyService.countApplySubscribe(bo); return AjaxResult.success(subNum); } /** * 查询考试配置绑定商品列表 */ @ApiOperation("查询考试安排商品列表") @PreAuthorize("@ss.hasPermi('system:goods:list')") @GetMapping("/listGoods") public TableDataInfo listGoods(ExamNumberGoodsQueryBo bo) { startPage(); List list = iExamApplyService.listGoods(bo); return getDataTable(list); } /** * 查询考试配置绑定用户列表 */ @ApiOperation("查询考试配置绑定用户列表") @PreAuthorize("@ss.hasPermi('system:goods:list')") @GetMapping("/listUser") public TableDataInfo listUser(ExamApplyUserQueryBo bo) { startPage(); List list = iExamApplyUserService.listUser(bo); return getDataTable(list); } /** * 获取考试关联的前培安排 */ @ApiOperation("获取考试关联的前培安排") @GetMapping("/getBefore/{applyId}") public AjaxResult getBeforeByApplyId(@PathVariable("applyId" ) Long applyId) { ExamBeforeVo vo = iExamApplyUserService.getBeforeByApplyId(applyId); return AjaxResult.success(vo); } @ApiOperation("七大员学员资料批量变更") @PostMapping("/user/profile") public AjaxResult updateExamUserProfile(MultipartFile file) { iExamApplyService.updateExamUserProfile(file); return AjaxResult.success(); } @ApiOperation("七大员学员资料导出") @PostMapping("/user/profile/export") public AjaxResult examUserProfileExport(@RequestBody UserProfileQueryBo bo) { return AjaxResult.success(iExamApplyService.examUserProfileExport(bo)); } @ApiOperation("修改考场人数") @PostMapping ("/update/applyNum") public AjaxResult updateApplyNum(@RequestBody UpdateApplyNumBo bo) { return toAjax(iExamApplyService.updateApplyNum(bo) ? 1 : 0); } }