赞
踩
源码获取:博客首页 "资源" 里下载!
学生信息 班级 专业 学号 姓名 在线考试 成绩查询 个人信息 密码修改 教师管理 教师编号 姓名 所教科目 题库管理 单选题 多选题 填空题 判断题,简答题(人工阅卷) 试卷管理 新建试卷 在试库中选择试题 试卷设置 发布试卷 考试管理 发布考试计划 学生考试 自动阅卷 人工阅卷 个人信息 密码修改 管理员 学生管理 教师管理 管理员管理 院系管理 班级管理 个人信息 密码修改。
- /**
- * 统一管理学生 教师 管理员信息
- */
- @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<User> qryUserInfo() {
- return userService.qryUserInfo();
- }
-
- /**
- * 更新用户信息
- */
- @RequestMapping(value = "/user/update", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
- public Result<User> 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<User> updatePwd(HttpRequest request) {
- return userService.updatePwd(request.getString("old_pwd"), request.getString("pwd"));
- }
- }
- @RestController
- public class LoginController {
-
- @Resource(name = "loginService")
- private ILoginService loginService;
-
- /**
- * 用户登录调用 在登陆成功生成两个token 同时返回各自首页
- * * 学生 student/student
- * * 老师 teacher/teacher
- * * 管理员 admin/admin
- */
- @RequestMapping(value = "/login/login", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
- public Result<Token> login(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<Token> check() {
- return new Result<>();
- }
-
- /**
- * token 续约
- */
- @RequestMapping(value = "/login/refresh", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
- public Result<Token> 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<Token> exit(HttpRequest request) {
- String urlId = request.getString("url_id");
- if (StringUtils.isNotEmpty(urlId)) {
- TokenCache.getInstance().remove(urlId);
- }
- return new Result<>();
- }
- }
- /**
- * 院系管理控制器
- */
- @RestController
- public class DepartmentController {
-
- @Resource(name = "departmentService")
- private IDepartmentService departmentService;
-
- /**
- * 查询所有院系
- */
- @RequestMapping(value = "/department/qryAllList", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
- @RoleAnnotation(types = {RoleEnum.admin})
- public ListResult<Department> qryAllList() {
- return departmentService.qryAllList();
- }
-
- /**
- * 管理员 查询院系列表
- */
- @RequestMapping(value = "/department/qryPage", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
- @RoleAnnotation(types = {RoleEnum.admin})
- public ListResult<Department> qryPage(HttpRequest request) {
- Map<String, Object> 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("department_id")) {
- param.put("department_id", request.getString("department_id"));
- }
- if (request.containsKey("department_name")) {
- param.put("department_name", request.getString("department_name"));
- }
- return departmentService.qryPage(param, pageNo, pageSize);
- }
-
- /**
- * 管理员 添加院系
- */
- @RequestMapping(value = "/department/add", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
- @RoleAnnotation(types = {RoleEnum.admin})
- public Result<Department> insert(HttpRequest request) {
- Department department = new Department();
- department.setDepartmentId(request.getString("department_id"));
- department.setDepartmentName(request.getString("department_name"));
- department.setUpdateTime(new Date());
- return departmentService.insert(department);
- }
-
- /**
- * 管理员 更新院系
- */
- @RequestMapping(value = "/department/update", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
- @RoleAnnotation(types = {RoleEnum.admin})
- public Result<Department> update(HttpRequest request) {
- Department department = new Department();
- department.setDepartmentId(request.getString("department_id"));
- department.setDepartmentName(request.getString("department_name"));
- department.setUpdateTime(new Date());
- return departmentService.update(department);
- }
-
- /**
- * 管理员 删除院系
- */
- @RequestMapping(value = "/department/del", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
- @RoleAnnotation(types = {RoleEnum.admin})
- public Result<Department> del(HttpRequest request) {
- List<String> departmentIdList = new ArrayList<>();
- JSONArray array = request.getJSONArray("department_id_list");
- for (int i = 0; i < array.size(); i++) {
- departmentIdList.add(array.getString(i));
- }
- return departmentService.del(departmentIdList);
- }
- }
源码获取:博客首页 "资源" 里下载!
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。