/** * 添加考试 * * @param exam * @return */ @RequestMapping(value = "admin/exam/add-exam", method = RequestMethod.POST) public @ResponseBody Message addExam(@RequestBody Exam exam) { UserInfo userInfo = (UserInfo) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); Message msg = new Message(); try { exam.setCreator(userInfo.getUserid()); exam.setCreatorId(userInfo.getUsername()); exam.setApproved(1); examService.addExam(exam); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); msg.setResult(e.getClass().getName()); } return msg; }
/** * 添加模拟考试 * * @param exam * @return */ @RequestMapping(value = "admin/exam/add-model-test", method = RequestMethod.POST) public @ResponseBody Message addModelTest(@RequestBody Exam exam) { UserInfo userInfo = (UserInfo) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); Message msg = new Message(); try { Calendar c = Calendar.getInstance(); c.add(Calendar.YEAR, 10); exam.setCreator(userInfo.getUserid()); exam.setApproved(1); exam.setEffTime(new Date()); exam.setExpTime(c.getTime()); examService.addExam(exam); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); msg.setResult(e.getClass().getName()); } return msg; }