五、核心代码
5.1 一键生成实验
@RequestMapping(value = "/oneCreateExp", method = RequestMethod.GET) @ApiOperation(value = "一键生成实验") public Result<Object> oneCreateExp(@RequestParam String id){ ExperimentCurriculum curriculum = iExperimentCurriculumService.getById(id); if(curriculum == null) { return ResultUtil.error("实验不存在"); } // 删除原来的 QueryWrapper<Experiment> oldQw = new QueryWrapper<>(); oldQw.eq("curriculum_id",curriculum.getId()); iExperimentService.remove(oldQw); // 生成新的 QueryWrapper<User> userQw = new QueryWrapper<>(); userQw.eq("type",0); List<User> studentList = iUserService.list(userQw); for (User stu : studentList) { Experiment e = new Experiment(); e.setCurriculumId(curriculum.getId()); e.setCurriculumName(curriculum.getTitle()); e.setStudentId(stu.getId()); e.setStudentName(stu.getNickname()); e.setExpResult(""); e.setExpReport(""); e.setUploadTime(""); e.setGrade(BigDecimal.ZERO); e.setCheckFlag(false); e.setCheckTime(""); e.setCheckUser(""); iExperimentService.saveOrUpdate(e); } return ResultUtil.success(); }
5.2 提交实验
@RequestMapping(value = "/upload", method = RequestMethod.GET) @ApiOperation(value = "提交实验") public Result<Object> upload(@RequestParam String id,@RequestParam String result,@RequestParam String url){ Experiment exp = iExperimentService.getById(id); if(exp == null) { return ResultUtil.error("实验不存在"); } exp.setExpResult(result); exp.setExpReport(url); exp.setUploadTime(DateUtil.now()); iExperimentService.saveOrUpdate(exp); return ResultUtil.success(); }
5.3 批阅实验
@RequestMapping(value = "/check", method = RequestMethod.GET) @ApiOperation(value = "批阅实验") public Result<Object> check(@RequestParam String id,@RequestParam BigDecimal grade){ Experiment exp = iExperimentService.getById(id); if(exp == null) { return ResultUtil.error("实验不存在"); } User currUser = securityUtil.getCurrUser(); exp.setGrade(grade); exp.setCheckFlag(true); exp.setCheckTime(DateUtil.now()); exp.setCheckUser(currUser.getNickname()); iExperimentService.saveOrUpdate(exp); return ResultUtil.success(); }
5.4 新增实验资源
@RequestMapping(value = "/insert", method = RequestMethod.POST) @ApiOperation(value = "新增实验资源") public Result<ExperimentResources> insert(ExperimentResources experimentResources){ ExperimentCurriculum curriculum = iExperimentCurriculumService.getById(experimentResources.getCurriculumId()); if(curriculum == null) { return ResultUtil.error("实验课程不存在"); } experimentResources.setCurriculumName(curriculum.getTitle()); String fileUrl = experimentResources.getFileUrl(); if(!ZwzNullUtils.isNull(fileUrl)) { String[] split = fileUrl.split("/"); File f = iFileService.getById(split[split.length - 1]); if(f != null) { experimentResources.setFileId(f.getId()); experimentResources.setFileName(f.getName()); experimentResources.setFileSize(f.getSize()); } } iExperimentResourcesService.saveOrUpdate(experimentResources); return new ResultUtil<ExperimentResources>().setData(experimentResources); }
5.5 查询实验课程
@RequestMapping(value = "/getByPage", method = RequestMethod.GET) @ApiOperation(value = "查询实验课程") public Result<IPage<ExperimentCurriculum>> getByPage(@ModelAttribute ExperimentCurriculum experimentCurriculum ,@ModelAttribute PageVo page){ QueryWrapper<ExperimentCurriculum> qw = new QueryWrapper<>(); User currUser = securityUtil.getCurrUser(); QueryWrapper<User> userQw = new QueryWrapper<>(); userQw.eq("id",currUser.getId()); userQw.inSql("id","SELECT user_id FROM a_user_role WHERE del_flag = 0 AND (role_id = '1536606659751841795' OR role_id = '1536606659751841799')"); if(iUserService.count(userQw) < 1L) { qw.eq("teacher_id",currUser.getId()); } if(!ZwzNullUtils.isNull(experimentCurriculum.getTitle())) { qw.like("title",experimentCurriculum.getTitle()); } if(!ZwzNullUtils.isNull(experimentCurriculum.getContent1())) { qw.like("content1",experimentCurriculum.getContent1()); } if(!ZwzNullUtils.isNull(experimentCurriculum.getTeacherName())) { qw.like("teacher_name",experimentCurriculum.getTeacherName()); } IPage<ExperimentCurriculum> data = iExperimentCurriculumService.page(PageUtil.initMpPage(page),qw); return new ResultUtil<IPage<ExperimentCurriculum>>().setData(data); }
六、免责说明
- 本项目仅供个人学习使用,商用授权请联系博主,否则后果自负。
- 博主拥有本软件构建后的应用系统全部内容所有权及独立的知识产权,拥有最终解释权。
- 如有问题,欢迎在仓库 Issue 留言,看到后会第一时间回复,相关意见会酌情考虑,但没有一定被采纳的承诺或保证。
下载本系统代码或使用本系统的用户,必须同意以下内容,否则请勿下载!
- 出于自愿而使用/开发本软件,了解使用本软件的风险,且同意自己承担使用本软件的风险。
- 利用本软件构建的网站的任何信息内容以及导致的任何版权纠纷和法律争议及后果和博主无关,博主对此不承担任何责任。
- 在任何情况下,对于因使用或无法使用本软件而导致的任何难以合理预估的损失(包括但不仅限于商业利润损失、业务中断与业务信息丢失),博主概不承担任何责任。
- 必须了解使用本软件的风险,博主不承诺提供一对一的技术支持、使用担保,也不承担任何因本软件而产生的难以预料的问题的相关责任。