统一管理学生 教师 管理员信息:
@RestController public class UserController { @Resource(name = "userService") private IUserService userService; @RequestMapping(value = "/user/qryUserInfo", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) public Result管理员控制器:qryUserInfo() { return userService.qryUserInfo(); } @RequestMapping(value = "/user/update", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) public Result update(HttpRequest request) { User user = new User(); user.setUserId(request.getString("user_id")); user.setName(request.getString("name")); user.setSex(request.getInteger("sex")); user.setType(User.UserType.get(request.getInteger("type"))); return userService.update(user, ImageUtil.stringToBytes(request.getString("user_image"))); } @RequestMapping(value = "/user/updatePwd", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) public Result updatePwd(HttpRequest request) { return userService.updatePwd(request.getString("old_pwd"), request.getString("pwd")); } }
@RestController public class AdminController { @Resource(name = "adminService") private IAdminService adminService; @RequestMapping(value = "/admin/qryPage", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) @RoleAnnotation(types = {RoleEnum.admin}) public ListResult qryPage(HttpRequest request) { Map考试管理控制器:param = new HashMap<>(); int pageNo = request.containsKey("page_no") ? request.getInteger("page_no") : 1; int pageSize = request.containsKey("page_size") ? request.getInteger("page_size") : 20; if (request.containsKey("login_name")) { param.put("login_name", request.getString("login_name")); } if (request.containsKey("name")) { param.put("name", request.getString("name")); } return adminService.qryPage(param, pageNo, pageSize); } @RequestMapping(value = "/admin/add", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) @RoleAnnotation(types = {RoleEnum.admin}) public Result insert(HttpRequest request) { Admin admin = new Admin(); admin.setLoginName(request.getString("login_name")); admin.setName(request.getString("admin_name")); admin.setPwd(request.getString("login_name")); admin.setSex(request.getInteger("sex")); admin.setUpdateTime(new Date()); return adminService.insert(admin, ImageUtil.stringToBytes(request.getString("admin_image"))); } @RequestMapping(value = "/admin/update", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) @RoleAnnotation(types = {RoleEnum.admin}) public Result update(HttpRequest request) { Admin admin = new Admin(); admin.setLoginName(request.getString("login_name")); admin.setName(request.getString("admin_name")); admin.setPwd(request.getString("login_name")); admin.setSex(request.getInteger("sex")); admin.setUpdateTime(new Date()); return adminService.update(admin, ImageUtil.stringToBytes(request.getString("admin_image"))); } @RequestMapping(value = "/admin/del", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) @RoleAnnotation(types = {RoleEnum.admin}) public Result del(HttpRequest request) { List adminIdList = new ArrayList<>(); JSonArray array = request.getJSonArray("admin_id_list"); for (int i = 0; i < array.size(); i++) { adminIdList.add(array.getString(i)); } return adminService.del(adminIdList); } }
@RestController public class ExamInfoController { @Resource(name = "examInfoService") private IExamInfoService examInfoService; @RequestMapping(value = "/examinfo/qryPage", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) @RoleAnnotation(types = {RoleEnum.teacher}) public ListResult登录控制层:exam(HttpRequest request) { Map param = new HashMap<>(); int pageNo = request.containsKey("page_no") ? request.getInteger("page_no") : 1; int pageSize = request.containsKey("page_size") ? request.getInteger("page_size") : 20; return examInfoService.qryPage(param, pageNo, pageSize); } @RequestMapping(value = "/examinfo/add", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) @RoleAnnotation(types = {RoleEnum.teacher}) public Result insert(HttpRequest request) { ExamInfo exam = new ExamInfo(); exam.setTestPaperId(request.getInteger("test_paper_id")); exam.setClassId(request.getString("class_id")); exam.setState(1); exam.setTime(request.getInteger("time")); exam.setEffTime(DateUtils.toDate(request.getString("eff_time"), DateConst.DATE_TIME_FORMAT_YYYY_MM_DD_HH_MI)); exam.setExpTime(DateUtils.toDate(request.getString("exp_time"), DateConst.DATE_TIME_FORMAT_YYYY_MM_DD_HH_MI)); exam.setUpdateTime(new Date()); return examInfoService.insert(exam); } @RequestMapping(value = "/examinfo/update", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) @RoleAnnotation(types = {RoleEnum.teacher}) public Result update(HttpRequest request) { ExamInfo exam = new ExamInfo(); exam.setExamId(request.getInteger("exam_id")); exam.setTestPaperId(request.getInteger("test_paper_id")); exam.setClassId(request.getString("class_id")); exam.setState(1); exam.setTime(request.getInteger("time")); exam.setEffTime(DateUtils.toDate(request.getString("eff_time"), DateConst.DATE_TIME_FORMAT_YYYY_MM_DD_HH_MI)); exam.setExpTime(DateUtils.toDate(request.getString("exp_time"), DateConst.DATE_TIME_FORMAT_YYYY_MM_DD_HH_MI)); exam.setUpdateTime(new Date()); exam.setUpdateTime(new Date()); return examInfoService.update(exam); } @RequestMapping(value = "/examinfo/del", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) @RoleAnnotation(types = {RoleEnum.teacher}) public Result del(HttpRequest request) { List examIdList = new ArrayList<>(); JSonArray array = request.getJSonArray("exam_id_list"); for (int i = 0; i < array.size(); i++) { examIdList.add(array.getInteger(i)); } return examInfoService.del(examIdList); } @RequestMapping(value = "/examinfo/release", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) @RoleAnnotation(types = {RoleEnum.teacher}) public Result updateState(HttpRequest request) { return examInfoService.release(request.getInteger("exam_id")); } @RequestMapping(value = "/examinfo/qryExamQueGroupList", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) @RoleAnnotation(types = {RoleEnum.student, RoleEnum.teacher}) public Result qryExamQueGroupList(HttpRequest request) { return examInfoService.qryExamQueGroupList(request.getInteger("exam_id")); } @RequestMapping(value = "/examinfo/qryExamQuestionList", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) @RoleAnnotation(types = {RoleEnum.student}) public Result qryExamQuestionList(HttpRequest request) { return examInfoService.qryExamQuestionList(request.getInteger("exam_id"), request.getString("student_id"), request.getInteger("question_group_id")); } @RequestMapping(value = "/examinfo/qryMarkQueList", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) @RoleAnnotation(types = {RoleEnum.teacher}) public Result qryMarkQueList(HttpRequest request) { return examInfoService.qryMarkQueList(request.getInteger("exam_id"), request.getString("student_id"), request.getInteger("question_group_id")); } @RequestMapping(value = "/examinfo/updateQueScore", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) @RoleAnnotation(types = {RoleEnum.teacher}) public Result updateQueScore(HttpRequest request) { StudentExamQuestionRecord record = new StudentExamQuestionRecord(); record.setExamId(request.getInteger("exam_id")); record.setStudentId(request.getString("student_id")); record.setQuestionGroupId(request.getInteger("question_group_id")); record.setQuestionId(request.getLong("question_id")); record.setScore(request.getFloat("score")); record.setCorrect(request.getBoolean("correct")); return examInfoService.updateQueScore(record); } @RequestMapping(value = "/examinfo/complete", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) @RoleAnnotation(types = {RoleEnum.teacher}) public Result complete(HttpRequest request) { return examInfoService.complete(request.getInteger("exam_id"), request.getString("student_id")); } }
@RestController public class LoginController { @Resource(name = "loginService") private ILoginService loginService; @RequestMapping(value = "/login/login", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) public Resultlogin(HttpRequest request) { return loginService.login(request.getString("login_name"), request.getString("pwd")); } @RequestMapping(value = "/login/check", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) public Result check() { return new Result<>(); } @RequestMapping(value = "/login/refresh", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) public Result refresh(HttpRequest request) { String refreshToken = request.getString("refresh_token"); String urlId = request.getString("url_id"); Token token = TokenCache.getInstance().get(urlId); if(token == null){ ExceptionHelper.error(ErrorCode.ERROR_CODE_0003); } try { Claims claims = TokenUtils.parseToken(refreshToken); if (StringUtils.isNotEmpty((String.valueOf(claims.getOrDefault("student_id", ""))))) { claims.put("student_id", SessionContext.get("student_id")); } if (StringUtils.isNotEmpty((String.valueOf(claims.getOrDefault("teacher_id", ""))))) { claims.put("teacher_id", SessionContext.get("teacher_id")); } if (StringUtils.isNotEmpty((String.valueOf(claims.getOrDefault("login_name", ""))))) { claims.put("login_name", SessionContext.get("login_name")); } claims.put("name", claims.get("name")); token.setToken(TokenUtils.createToken(claims, TokenUtils.expireTime)); token.setRefreshToken(TokenUtils.createToken(claims, TokenUtils.long_expireTime)); TokenCache.getInstance().add(token); } catch (Exception e) { ExceptionHelper.error(ErrorCode.ERROR_CODE_0003); } return new Result<>(token); } @RequestMapping(value = "/login/exit", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) public Result exit(HttpRequest request) { String urlId = request.getString("url_id"); if (StringUtils.isNotEmpty(urlId)) { TokenCache.getInstance().remove(urlId); } return new Result<>(); } }
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)