/** * 班级主任自动完成数据 * * @param search * @return */ @RequestMapping("/maintainer/grade/gradeHead") @ResponseBody public List<AutoCompleteData> gradeHead(String search) { List<AutoCompleteData> autoCompleteDatas = new ArrayList<>(); // 通过用户类型获取系表ID Record record = usersService.findAll(usersService.getUserName()); int tieId = 0; if (!ObjectUtils.isEmpty(record)) { tieId = record.getValue(Tables.TIE.ID); } Result<Record4<Integer, Integer, String, String>> teachers = teacherService.findByTieIdAndTeacherName(search, tieId); if (teachers.isNotEmpty()) { teachers.forEach( teacherRecord -> { AutoCompleteData data = new AutoCompleteData(); data.setValue(teacherRecord.getValue(Tables.TEACHER.TEACHER_JOB_NUMBER)); data.setTitle(teacherRecord.getValue(Tables.USERS.REAL_NAME)); data.setUrl("#"); data.setText("账号:" + teacherRecord.getValue(Tables.TEACHER.TEACHER_JOB_NUMBER)); autoCompleteDatas.add(data); }); } return autoCompleteDatas; }
/** * 检查教师编号是否存在 * * @param teacherJobNum * @return */ @RequestMapping(value = "/maintainer/grade/checkTeacherNum", method = RequestMethod.POST) @ResponseBody public Map<String, Object> checkTeacherNum( @RequestParam(value = "gradeHeadID") String teacherJobNum) { Map<String, Object> map = new HashMap<>(); if (StringUtils.hasLength(teacherJobNum)) { List<Teacher> teachers = teacherService.findByTeacherJobNumber(teacherJobNum); if (teachers.isEmpty()) { map.put("error", "教师不存在!"); } else { map.put("ok", ""); } } else { map.put("error", "教师编号为空!"); } return map; }