赞
踩
基于javaweb+mysql的springboot在线学生选课系统(java+springboot+vue+maven+mysql)
运行环境
Java≥8、MySQL≥5.7、Node.js≥10
开发工具
后端:eclipse/idea/myeclipse/sts等均可配置运行
前端:WebStorm/VSCode/HBuilderX等均可
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的SpringBoot在线学生选课系统(java+springboot+vue+maven+mysql)
管理员: 10001 123456 学生: 1803010028 123456 1803010039 123456 1803010045 123456 1803010046 123456 老师: 180014 123456 180019 123456
一、项目运行 环境配置:
Jdk1.8 + Tomcat8.5 + Mysql + HBuilderX(Webstorm也行)+ Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)。
项目技术:
Spring + SpringBoot+ mybatis + Maven + Vue 等等组成,B/S模式 + Maven管理等等。
/** * @Classname LoginController * @Description 登录接口(管理员/教师/学生) * @Created by SHTL */ @RestController public class LoginController { /** * 管理员账户登录接口 * **/ @Autowired UserService userService; @Autowired TokenService tokenService; @Autowired AdminUserDAO adminUserDAO; @CrossOrigin @PostMapping(value = "/api/login_admin") @ResponseBody public Object login_admin(@RequestBody AdminUser requestUser) throws Exception { Integer username = requestUser.getZhanghao(); AdminUser adminUser = adminUserDAO.findByZhanghao(username); if (adminUser == null) { ResultCode result = new ResultCode(255); JSONObject jsonObject = new JSONObject(); jsonObject.put("msg","用户不存在!"); jsonObject.put("code","255"); return jsonObject.toString(); }else { if(MD5.verify(requestUser.getPassword(),adminUser.getPassword())) { String token = tokenService.getAdminToken(requestUser); ResultCode result = new ResultCode(200);
**/ @CrossOrigin @PostMapping("/api/admin/resetpwd") public Object ResetPassword(@RequestBody Map<String, Object> json) throws Exception { String zhanghu = String.valueOf(json.get("zhanghu")); String email = String.valueOf(json.get("email")); String password = String.valueOf(json.get("password")); AdminUser adminUser = adminUserDAO.findByZhanghaoAndEmail(Integer.valueOf(zhanghu), email); if (adminUser == null) { ResultCode result = new ResultCode(255); JSONObject jsonObject = new JSONObject(); jsonObject.put("msg", "账户和邮箱数据有误 !"); jsonObject.put("code", "255"); return jsonObject.toString(); } else { adminUser.setPassword(MD5.md5(password)); AdminUser adminUser1 = adminUserDAO.saveAndFlush(adminUser); if (adminUser1 == null) { ResultCode result = new ResultCode(255); JSONObject jsonObject = new JSONObject(); jsonObject.put("msg", "重置密码失败!"); jsonObject.put("code", "255"); return jsonObject.toString(); } else { ResultCode result = new ResultCode(255); JSONObject jsonObject = new JSONObject(); jsonObject.put("msg", "重置密码成功!"); jsonObject.put("code", "200"); return jsonObject.toString(); } } } } package com.credit.shtl.controller;
@PostMapping("/api/admin/classroomcheck_curri") public List<CurriModel> classroomCheck(@RequestBody Map<String, Object> json) { String classroomname = String.valueOf(json.get("classroom")); String classweek = String.valueOf(json.get("classweek")); String startweek = String.valueOf(json.get("startweek")); String endtweek = String.valueOf(json.get("endweek")); String classsection = String.valueOf(json.get("classsection")); return curriDAO.classroomcheck_curri(classroomname, classweek, classsection, startweek, endtweek); } /** * 添加课程信息 **/ @CrossOrigin @PostMapping("/api/teacher/addcurri") public CurriModel saveCurri(@RequestBody CurriModel curriModel) { SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); curriModel.setCtime(df.format(new Date())); CurriModel curriModel1 = curriDAO.save(curriModel); Integer kechengid = curriModel1.getKechengid(); // 修改当前课程类型为必修,添加对应班级的选择该课程 String leixing = curriModel.getKechengleibie(); if (leixing.equals("必修")) { String[] list = curriModel.getOptionalclass().split(" "); String sqltext = ""; for (int i = 0; i < list.length; i++) { Integer[] list1 = studentUserDAO.findByXhinBJ(list[i]); for (int j = 0; j < list1.length; j++) { SelectionModel selectionModel = new SelectionModel(); selectionModel.setKechengid(kechengid); selectionModel.setXuehao(list1[j]); selectionModel.setCtime(df.format(new Date())); selectionDAO.save(selectionModel); } } } return curriModel1; } /** * 获取选课信息 (有对课程名称进行模糊查询和对课程类型进行筛选条件) ***/ @Autowired
if (studentUser == null) { JSONObject jsonObject = new JSONObject(); jsonObject.put("msg", "数据有误 !请检查后重试!"); jsonObject.put("code", "255"); return jsonObject.toString(); } else { studentUser.setPassword(MD5.md5(password)); StudentUser studentUser1 = studentUserDAO.saveAndFlush(studentUser); if (studentUser1 == null) { JSONObject jsonObject = new JSONObject(); jsonObject.put("msg", "重置密码失败!"); jsonObject.put("code", "255"); return jsonObject.toString(); } else { JSONObject jsonObject = new JSONObject(); jsonObject.put("msg", "重置密码成功!"); jsonObject.put("code", "200"); return jsonObject.toString(); } } } /** * 根据账户信息对密码进行更新 **/ @CrossOrigin @PutMapping("/api/student/updateselfpwd/{xuehao}") public StudentUser updateStuPwd(@PathVariable("xuehao") Integer xuehao, @RequestBody StudentUser studentUser) throws Exception { studentUser.setXuehao(xuehao); studentUser.setPassword(MD5.md5(studentUser.getPassword())); return studentUserDAO.saveAndFlush(studentUser); } /** * 获取当前学生账户所在班级的可选课程 **/ @CrossOrigin @ResponseBody @PostMapping("/api/sutdent/getselectionall") public List<Map<String, Object>> SelectionALLQuery(@RequestBody Map<String, Object> json) { String kechengleixing = String.valueOf(json.get("kechengleibie")); String like = String.valueOf(json.get("like")); Integer xuehao = Integer.valueOf((String) json.get("xuehao")); String xuefen = String.valueOf(json.get("xuefen"));
@CrossOrigin @ResponseBody @PostMapping("/api/admin/getmajorinfo/{majorid}") public Map<String, Object> findMajorByMid(@PathVariable("majorid") Integer majorid) { return majorDAO.findByMJinMid(majorid); } /** * 根据 majorid 更新当前专业信息 **/ @CrossOrigin @PutMapping("/api/admin/updatemajor/{majorid}") public MajorModel updateMajorUser(@PathVariable("majorid") Integer majorid, @RequestBody Map<String, Object> json) { String content = String.valueOf(json.get("content")); String majorname = String.valueOf(json.get("majorname")); String collegeid = String.valueOf(json.get("collegename")); int k = 1; for (int i = 0; i < collegeid.length(); i++) { if (!Character.isDigit(collegeid.charAt(i))) { k = 0; break; } } SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); MajorModel majorModel = new MajorModel(); majorModel.setMajorid(majorid); majorModel.setMajorname(majorname); majorModel.setContent(content); CollegeModel collegeModel; // 是数字 if (k == 1) { // 获取当前collegeid 的 collegename collegeModel = collegeDAO.findByCollegeid(Integer.valueOf(collegeid)); } else { // 不是数字 collegeModel = collegeDAO.findByCollegename(collegeid); }
* @Created by SHTL */ @RestController public class ResetPwdController { Code getcode = new Code(); /** * (重置密码邮件发送之前,所有验证通过) * 如果存在用户信息生成新的验证码,以及新的有效时间对原来的数据进行覆盖 * 如果是第一次进行密码重置(即重置密码信息表中没有该用户信息)则将数据信息存入到重置密码信息表中 **/ @Autowired ResetPwdDAO resetPwdDAO; ResetPwdService resetPwdService; @CrossOrigin @PostMapping(value = "/api/resetpwd/addresetpwd") @ResponseBody public ResetPwdModel addResetpwd(@RequestBody Map<String, Object> json) { Timer timer = new Timer(); Integer zhanghu = Integer.valueOf(String.valueOf(json.get("zhanghu"))); ResetPwdModel resetPwdModel = resetPwdDAO.findByZhanghu(zhanghu); Integer type = 0; String typeStr = String.valueOf(json.get("type")); switch (typeStr) { case "admin": type = 1; break; case "teacher": type = 2; break; case "student": type = 3; break; } if (resetPwdModel == null) { resetPwdModel = new ResetPwdModel(); resetPwdModel.setZhanghu(zhanghu); resetPwdModel.setType(type); } resetPwdModel.setCode(getcode.getCode()); SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); resetPwdModel.setS_time(df.format(new Date())); resetPwdModel.setState_code(0); ResetPwdModel resetPwdModel1 = resetPwdDAO.saveAndFlush(resetPwdModel); System.out.println("师傅撒离开房间开了多少发就是快递放假啊看"); // 创建/更新验证码之后执行一个定时器,实现控制验证码的有效期 MyTimerTask myTimerTask = new MyTimerTask(timer, zhanghu, type);
return curriDAO.saveAndFlush(curriModel); } /** * 根据课程ID (kechengid) 进行删除 **/ @CrossOrigin @DeleteMapping("/api/teacher/deletecurri/{kechengid}") public Integer deleteCurri(@PathVariable("kechengid") Integer kechengid) { return curriDAO.deleteByKechengid(kechengid); } /** * 添加课程信息之前 * 对教室的使用情况进行判断,避免同一教室同一时间被使用多次 **/ @CrossOrigin @ResponseBody @PostMapping("/api/admin/classroomcheck_curri") public List<CurriModel> classroomCheck(@RequestBody Map<String, Object> json) { String classroomname = String.valueOf(json.get("classroom")); String classweek = String.valueOf(json.get("classweek")); String startweek = String.valueOf(json.get("startweek")); String endtweek = String.valueOf(json.get("endweek")); String classsection = String.valueOf(json.get("classsection")); return curriDAO.classroomcheck_curri(classroomname, classweek, classsection, startweek, endtweek); } /** * 添加课程信息 **/ @CrossOrigin @PostMapping("/api/teacher/addcurri") public CurriModel saveCurri(@RequestBody CurriModel curriModel) { SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); curriModel.setCtime(df.format(new Date())); CurriModel curriModel1 = curriDAO.save(curriModel); Integer kechengid = curriModel1.getKechengid();
/** * @Classname LoginController * @Description 登录接口(管理员/教师/学生) * @Created by SHTL */ @RestController public class LoginController { /** * 管理员账户登录接口 * **/ @Autowired UserService userService; @Autowired TokenService tokenService; @Autowired AdminUserDAO adminUserDAO; @CrossOrigin @PostMapping(value = "/api/login_admin") @ResponseBody public Object login_admin(@RequestBody AdminUser requestUser) throws Exception { Integer username = requestUser.getZhanghao(); AdminUser adminUser = adminUserDAO.findByZhanghao(username); if (adminUser == null) { ResultCode result = new ResultCode(255); JSONObject jsonObject = new JSONObject(); jsonObject.put("msg","用户不存在!"); jsonObject.put("code","255"); return jsonObject.toString(); }else { if(MD5.verify(requestUser.getPassword(),adminUser.getPassword())) { String token = tokenService.getAdminToken(requestUser); ResultCode result = new ResultCode(200); JSONObject jsonObject = new JSONObject(); jsonObject.put("msg","登录成功!"); jsonObject.put("code","200"); jsonObject.put("token",token); jsonObject.put("adminname",adminUser.getName()); return jsonObject.toString(); }else {
* 管理员找回密码操作 **/ // 注入QQ发送邮件的bean @Autowired JavaMailSender mailSender; @CrossOrigin @ResponseBody @PostMapping("/api/admin/forgetepwd") public Object sendEmail(@RequestBody Map<String, Object> json) { String qq = String.valueOf(json.get("email")); Integer zhanghu = Integer.valueOf(String.valueOf(json.get("zhanghao"))); String mibao = String.valueOf(json.get("mibao")); AdminUser adminUser = adminUserDAO.findByZhanghaoAndEmailAndMibao(zhanghu, qq, mibao); // 账号不存在 if (adminUser == null) { JSONObject jsonObject = new JSONObject(); jsonObject.put("msg", "账户和邮箱数据有误!"); jsonObject.put("code", "255"); return jsonObject.toString(); } else { Object jsonStr = userService.sendEmailHanle("admin", zhanghu, adminUser.getName(), adminUser.getEmail(), qq, 1); if (jsonStr.equals("")) { JSONObject jsonObject = new JSONObject(); jsonObject.put("msg", "邮件发送失败!出现未知错误!"); jsonObject.put("code", "256"); return jsonObject.toString(); } return jsonStr; } } /** * 根据账户对密码进行重置,用于忘记密码之后找回的时候充值密码 **/ @CrossOrigin @PostMapping("/api/admin/resetpwd") public Object ResetPassword(@RequestBody Map<String, Object> json) throws Exception { String zhanghu = String.valueOf(json.get("zhanghu")); String email = String.valueOf(json.get("email")); String password = String.valueOf(json.get("password")); AdminUser adminUser = adminUserDAO.findByZhanghaoAndEmail(Integer.valueOf(zhanghu), email); if (adminUser == null) { ResultCode result = new ResultCode(255); JSONObject jsonObject = new JSONObject(); jsonObject.put("msg", "账户和邮箱数据有误 !"); jsonObject.put("code", "255");
@Autowired UserService userService; @CrossOrigin @ResponseBody @PostMapping("/api/teacher/studentlist") public Page<StudentUser> pageQuery1(@RequestBody Map<String, Object> json) { Integer pageNum = Integer.valueOf((Integer) json.get("pageNum")); Integer pageSize = Integer.valueOf((Integer) json.get("pageSize")); String college = String.valueOf((String) json.get("college")); String major = String.valueOf(json.get("major")); String banji = String.valueOf(json.get("banji")); String like = String.valueOf(json.get("query")); String sex = String.valueOf(json.get("sex")); Pageable pageable = PageRequest.of(pageNum - 1, pageSize); return userService.getStuList(like, college, major, banji, sex, pageable); } /*** * 根据学号进行查询 * **/ @CrossOrigin @GetMapping("/api/teacher/getstu/{xuehao}") public StudentUser getUserInfo(@PathVariable("xuehao") Integer xuehao) { Optional<StudentUser> optional = Optional.ofNullable(studentUserDAO.findByXuehao(xuehao)); return optional.orElseGet(StudentUser::new); } /** * 根据学号进行更新 ***/ @CrossOrigin @PutMapping("/api/teacher/updatestu/{xuehao}") public StudentUser updateStuUser(@PathVariable("xuehao") Integer xuehao, @RequestBody StudentUser studentUser) throws Exception { studentUser.setXuehao(xuehao); if (studentUser.getPassword().length() != 64) { studentUser.setPassword(MD5.md5(studentUser.getPassword())); } return studentUserDAO.saveAndFlush(studentUser); } /** * 获取学院信息 **/ @CrossOrigin @GetMapping("/api/teacher/getcollegegroup") public List<Object> findByCollegeGroup() { return studentUserDAO.getByCollegegroup();
/** * 部门管理,查询所有班级信息 * 查询条件为:like 学院 专业 **/ @Autowired BanjiDAO banjiDAO; @CrossOrigin @ResponseBody @PostMapping("/api/admin/getbjinfo") public List<Map<String, Object>> BanjiQuery(@RequestBody Map<String, Object> json) { String like = String.valueOf(json.get("like")); String collegename = String.valueOf(json.get("collegename")); String majorname = String.valueOf(json.get("majorname")); // 情况一: 没有任何筛选条件 if (StringUtils.isEmpty(collegename) && StringUtils.isEmpty(like) && StringUtils.isEmpty(majorname)) { return banjiDAO.findBJNO(); } // 情况二: like if (!StringUtils.isEmpty(like) && StringUtils.isEmpty(collegename) && StringUtils.isEmpty(majorname)) { return banjiDAO.findBJLike(like); } // 情况三: 学院 if (!StringUtils.isEmpty(collegename) && StringUtils.isEmpty(majorname) && StringUtils.isEmpty(like)) { return banjiDAO.findBJCollege(collegename); } // 情况四: 专业 if (!StringUtils.isEmpty(majorname) && StringUtils.isEmpty(like) && StringUtils.isEmpty(collegename)) { return banjiDAO.findBJMajor(majorname); } // 情况五: like 和 学院 if (!StringUtils.isEmpty(collegename) && !StringUtils.isEmpty(like) && StringUtils.isEmpty(majorname)) { return banjiDAO.findBJLikeAndCollege(like, collegename); } // 情况六:like 和 专业 if (!StringUtils.isEmpty(majorname) && !StringUtils.isEmpty(like) && StringUtils.isEmpty(collegename)) { return banjiDAO.findBJLikeAndMajor(like, majorname); }
/** * 根据 banjiid 更新当前班级信息 **/ @CrossOrigin @PutMapping("/api/admin/updatebanji/{banjiid}") public BanjiModel updateBanjiUser(@PathVariable("banjiid") Integer banjiid, @RequestBody Map<String, Object> json) { String banjiname = (String) json.get("banjiname"); String majorname = (String) json.get("majorname"); String content = (String) json.get("content"); // 获取 已知majorname 的 majorid MajorModel majorModel = majorDAO.findByMajorname(majorname); Integer majorid = majorModel.getMajorid(); BanjiModel banjiModel = new BanjiModel(); banjiModel.setBanjiid(banjiid); banjiModel.setBanjiname(banjiname); banjiModel.setMajorid(majorid); banjiModel.setContent(content); SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); banjiModel.setCtime(df.format(new Date())); return banjiDAO.saveAndFlush(banjiModel); } /** * 添加班级信息 **/ @CrossOrigin @PostMapping("/api/admin/addbanji") public BanjiModel addBanjiUser(@RequestBody Map<String, Object> json) { String banjiname = (String) json.get("banjiname"); String majorname = (String) json.get("majorname"); String content = (String) json.get("content"); // 获取 已知majorname 的 majorid MajorModel majorModel = majorDAO.findByMajorname(majorname); BanjiModel banjiModel = new BanjiModel(); banjiModel.setBanjiname(banjiname); banjiModel.setMajorid(majorModel.getMajorid()); SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); banjiModel.setCtime(df.format(new Date())); banjiModel.setContent(content); return banjiDAO.save(banjiModel); }
/** * 获取选课信息 (有对课程名称进行模糊查询和对课程类型进行筛选条件) ***/ @Autowired SelectionDAO selectionDAO; @CrossOrigin @ResponseBody @PostMapping("/api/teacher/getselection") public List<Map<String, Object>> SelectionQuery(@RequestBody Map<String, Object> json) { String kechengteacher = String.valueOf(json.get("kechengteacher")); String kechengname = String.valueOf(json.get("kechengname")); String kechengleibie = String.valueOf(json.get("kechengleibie")); // 情况一:没有筛选条件的情况 if (StringUtils.isEmpty(kechengname) && StringUtils.isEmpty(kechengleibie)) { return selectionDAO.SelectionClass(kechengteacher); } // 情况二:筛选课程类型为必修,模糊查询没有 if (StringUtils.isEmpty(kechengname) && kechengleibie.equals("必修")) { return selectionDAO.SelectionClassBixiu(kechengteacher); } // 情况三:筛选课程类型为选修,模糊查询没有 if (StringUtils.isEmpty(kechengname) && kechengleibie.equals("选修")) { return selectionDAO.SelectionClassXuanxiu(kechengteacher); } // 情况四:有模糊查询条件,无课程类别筛选 if (!StringUtils.isEmpty(kechengname) && StringUtils.isEmpty(kechengleibie)) { return selectionDAO.SelectionClassLike(kechengteacher, kechengname); } // 情况五:有模糊查询条件,课程类别筛选为 必修 if (!StringUtils.isEmpty(kechengname) && kechengleibie.equals("必修")) { return selectionDAO.SelectionClassLikeBiXiu(kechengteacher, kechengname); } // 情况五:有模糊查询条件,课程类别筛选为 选修 if (!StringUtils.isEmpty(kechengname) && kechengleibie.equals("选修")) { return selectionDAO.SelectionClassLikeXuanXiu(kechengteacher, kechengname); } return null; } /*** *获取当前课程的所有选课学生 * **/ @CrossOrigin @GetMapping("/api/teacher/getallselection/{kechengid}")
// jsobj.put("msg", "当前链接已过期或链接不正确!"); // jsobj.put("code", "233"); // return jsobj.toString(); // } else { // ResultCode result = new ResultCode(200); // // 将获取的json数据封装一层,然后在给返回 // JSONObject jsobj = new JSONObject(); // jsobj.put("msg", "验证通过!"); // jsobj.put("code", "200"); // return jsobj.toString(); // } // } } package com.credit.shtl.controller; /** * @Classname LoginController * @Description 登录接口(管理员/教师/学生) * @Created by SHTL */ @RestController public class LoginController { /** * 管理员账户登录接口 * **/ @Autowired UserService userService; @Autowired TokenService tokenService; @Autowired AdminUserDAO adminUserDAO; @CrossOrigin
public List<Map<String, Object>> SelectionQuery(@RequestBody Map<String, Object> json) { String kechengteacher = String.valueOf(json.get("kechengteacher")); String kechengname = String.valueOf(json.get("kechengname")); String kechengleibie = String.valueOf(json.get("kechengleibie")); // 情况一:没有筛选条件的情况 if (StringUtils.isEmpty(kechengname) && StringUtils.isEmpty(kechengleibie)) { return selectionDAO.SelectionClass(kechengteacher); } // 情况二:筛选课程类型为必修,模糊查询没有 if (StringUtils.isEmpty(kechengname) && kechengleibie.equals("必修")) { return selectionDAO.SelectionClassBixiu(kechengteacher); } // 情况三:筛选课程类型为选修,模糊查询没有 if (StringUtils.isEmpty(kechengname) && kechengleibie.equals("选修")) { return selectionDAO.SelectionClassXuanxiu(kechengteacher); } // 情况四:有模糊查询条件,无课程类别筛选 if (!StringUtils.isEmpty(kechengname) && StringUtils.isEmpty(kechengleibie)) { return selectionDAO.SelectionClassLike(kechengteacher, kechengname); } // 情况五:有模糊查询条件,课程类别筛选为 必修 if (!StringUtils.isEmpty(kechengname) && kechengleibie.equals("必修")) { return selectionDAO.SelectionClassLikeBiXiu(kechengteacher, kechengname); } // 情况五:有模糊查询条件,课程类别筛选为 选修 if (!StringUtils.isEmpty(kechengname) && kechengleibie.equals("选修")) { return selectionDAO.SelectionClassLikeXuanXiu(kechengteacher, kechengname); } return null; } /*** *获取当前课程的所有选课学生 * **/ @CrossOrigin @GetMapping("/api/teacher/getallselection/{kechengid}") public List<Map<String, Object>> getAllSelection(@PathVariable("kechengid") Integer kechengid) { return studentUserDAO.getAllSelection(kechengid); } /** * 根据教师账户获取该教师所有信息 **/ @Autowired TeacherUserDAO teacherUserDAO;
public Object sendEmail(@RequestBody Map<String, Object> json) { String qq = String.valueOf(json.get("email")); Integer zhanghu = Integer.valueOf(String.valueOf(json.get("zhanghao"))); String mibao = String.valueOf(json.get("mibao")); AdminUser adminUser = adminUserDAO.findByZhanghaoAndEmailAndMibao(zhanghu, qq, mibao); // 账号不存在 if (adminUser == null) { JSONObject jsonObject = new JSONObject(); jsonObject.put("msg", "账户和邮箱数据有误!"); jsonObject.put("code", "255"); return jsonObject.toString(); } else { Object jsonStr = userService.sendEmailHanle("admin", zhanghu, adminUser.getName(), adminUser.getEmail(), qq, 1); if (jsonStr.equals("")) { JSONObject jsonObject = new JSONObject(); jsonObject.put("msg", "邮件发送失败!出现未知错误!"); jsonObject.put("code", "256"); return jsonObject.toString(); } return jsonStr; } } /** * 根据账户对密码进行重置,用于忘记密码之后找回的时候充值密码 **/ @CrossOrigin @PostMapping("/api/admin/resetpwd") public Object ResetPassword(@RequestBody Map<String, Object> json) throws Exception { String zhanghu = String.valueOf(json.get("zhanghu")); String email = String.valueOf(json.get("email")); String password = String.valueOf(json.get("password")); AdminUser adminUser = adminUserDAO.findByZhanghaoAndEmail(Integer.valueOf(zhanghu), email); if (adminUser == null) { ResultCode result = new ResultCode(255); JSONObject jsonObject = new JSONObject(); jsonObject.put("msg", "账户和邮箱数据有误 !"); jsonObject.put("code", "255"); return jsonObject.toString(); } else {
* 根据选课表的ID进行删除指定ID的记录 **/ @Autowired SelectionDAO selectionDAO; @CrossOrigin @DeleteMapping("/api/student/deleteselection/{id}") public Integer deleteSelection(@PathVariable("id") Integer id) { return selectionDAO.deleteById1(id); } /** * 根据学号获取该生的选课信息,用于生成课程表 **/ @CrossOrigin @GetMapping("/api/student/getkechengbiao/{xuehao}") public List<Map<String, Object>> getKeChengBiaoInfo(@PathVariable("xuehao") Integer xuehao) { return selectionDAO.getkechengbiao(xuehao); } /*** * 获取当前账户的学生个人信息 * **/ @CrossOrigin @GetMapping("/api/student/getself/{xuehao}") public StudentUser getStuSelf(@PathVariable("xuehao") Integer xuehao) { Optional<StudentUser> optional = Optional.ofNullable(studentUserDAO.findByXuehao(xuehao)); return optional.orElseGet(StudentUser::new); } /** * 根据账户信息进行基本信息更新 **/ @CrossOrigin @PutMapping("/api/student/updateself/{xuehao}") public StudentUser updateStuSelf(@PathVariable("xuehao") Integer xuehao, @RequestBody StudentUser studentUser) { studentUser.setXuehao(Integer.valueOf(xuehao)); return studentUserDAO.saveAndFlush(studentUser); } /** * 根据学号对密码进行重置,用于忘记密码之后找回的时候充值密码
jsonObject.put("code", "255"); return jsonObject.toString(); } else { Object jsonStr = userService.sendEmailHanle("teacher", zhanghu, teacherUser.getName(), teacherUser.getEmail(), qq, 2); if (jsonStr.equals("")) { JSONObject jsonObject = new JSONObject(); jsonObject.put("msg", "邮件发送失败!出现未知错误!"); jsonObject.put("code", "256"); return jsonObject.toString(); } return jsonStr; } } /** * 根据账户对密码进行重置,用于忘记密码之后找回的时候充值密码 **/ @CrossOrigin @PostMapping("/api/teacher/resetpwd") public Object ResetPassword(@RequestBody Map<String, Object> json) throws Exception { String zhanghu = String.valueOf(json.get("zhanghu")); String password = String.valueOf(json.get("password")); TeacherUser teacherUser = teacherUserDAO.findByZhanghu(Integer.valueOf(zhanghu)); if (teacherUser == null) { JSONObject jsonObject = new JSONObject(); jsonObject.put("msg", "数据有误 !请检查后重试!"); jsonObject.put("code", "255"); return jsonObject.toString(); } else { teacherUser.setPassword(MD5.md5(password)); TeacherUser teacherUser1 = teacherUserDAO.saveAndFlush(teacherUser); if (teacherUser1 == null) { JSONObject jsonObject = new JSONObject(); jsonObject.put("msg", "重置密码失败!"); jsonObject.put("code", "255"); return jsonObject.toString(); } else { JSONObject jsonObject = new JSONObject(); jsonObject.put("msg", "重置密码成功!"); jsonObject.put("code", "200"); return jsonObject.toString(); } } } } package com.credit.shtl.controller;
resetPwdModel.setCode(getcode.getCode()); return resetPwdDAO.saveAndFlush(resetPwdModel); } /** * 检查当前账户的状态码 **/ @CrossOrigin @PostMapping(value = "/api/resetpwd/checkstatus") @ResponseBody public Object checkStatus(@RequestBody Map<String, Object> json) { Integer zhanghu = Integer.valueOf(String.valueOf(json.get("zhanghu"))); Integer type = Integer.valueOf(String.valueOf(json.get("typevalue"))); String code = String.valueOf(json.get("code")); ResetPwdModel resetPwdModel = resetPwdDAO.findByZhanghuAndTypeAndCode(zhanghu, type, code); if (resetPwdModel == null) { // 用户不存在,url链接错误 JSONObject jsonObject = new JSONObject(); jsonObject.put("msg", "url有误!请输入正确的url地址!"); jsonObject.put("code", "256"); return jsonObject.toString(); } else { if (resetPwdModel.getState_code() == 1) { JSONObject jsonObject = new JSONObject(); // 验证码在有效期之内 jsonObject.put("msg", "url验证通过!"); jsonObject.put("code", "200"); return jsonObject.toString(); } else { // 验证码已经失效 JSONObject jsonObject = new JSONObject(); jsonObject.put("msg", "该链接已失效!请重新获取链接!"); jsonObject.put("code", "256"); return jsonObject.toString(); } } } // @CrossOrigin // @PostMapping(value = "/api/resetpwd/checkstatus") // @ResponseBody // public Object checkStatus(@RequestBody Map<String, Object> json) { // Integer zhanghu = Integer.valueOf(String.valueOf(json.get("zhanghu"))); // ResetPwdModel resetPwdModel = resetPwdDAO.findByZhanghu(zhanghu); // int state_code = resetPwdModel.getState_code(); // String code = resetPwdModel.getCode(); // if (state_code == 0) { // ResultCode result = new ResultCode(233); // // 将获取的json数据封装一层,然后在给返回 // JSONObject jsobj = new JSONObject(); // jsobj.put("msg", "当前链接已过期!");
return jsonObject.toString(); } else { studentUser.setPassword(MD5.md5(password)); StudentUser studentUser1 = studentUserDAO.saveAndFlush(studentUser); if (studentUser1 == null) { JSONObject jsonObject = new JSONObject(); jsonObject.put("msg", "重置密码失败!"); jsonObject.put("code", "255"); return jsonObject.toString(); } else { JSONObject jsonObject = new JSONObject(); jsonObject.put("msg", "重置密码成功!"); jsonObject.put("code", "200"); return jsonObject.toString(); } } } /** * 根据账户信息对密码进行更新 **/ @CrossOrigin @PutMapping("/api/student/updateselfpwd/{xuehao}") public StudentUser updateStuPwd(@PathVariable("xuehao") Integer xuehao, @RequestBody StudentUser studentUser) throws Exception { studentUser.setXuehao(xuehao); studentUser.setPassword(MD5.md5(studentUser.getPassword())); return studentUserDAO.saveAndFlush(studentUser); } /** * 获取当前学生账户所在班级的可选课程 **/ @CrossOrigin @ResponseBody @PostMapping("/api/sutdent/getselectionall") public List<Map<String, Object>> SelectionALLQuery(@RequestBody Map<String, Object> json) { String kechengleixing = String.valueOf(json.get("kechengleibie")); String like = String.valueOf(json.get("like")); Integer xuehao = Integer.valueOf((String) json.get("xuehao")); String xuefen = String.valueOf(json.get("xuefen")); // 情况一: 没有任何筛选条件 if (StringUtils.isEmpty(kechengleixing) && StringUtils.isEmpty(like) && StringUtils.isEmpty(xuefen)) { return curriDAO.findCurriNo(xuehao); } // 情况二: 模糊查询 if (!StringUtils.isEmpty(like) && StringUtils.isEmpty(kechengleixing) && StringUtils.isEmpty(xuefen)) { return curriDAO.findCurriLike(xuehao, like); }
/** * 对课程信息进行分动态查询 **/ //分页查询 @Autowired CurriDAO curriDAO; @Autowired CurriService curriService; @CrossOrigin @ResponseBody @PostMapping("/api/teacher/currilist") public Page<CurriModel> pageQuery2(@RequestBody Map<String, Object> json) { Integer pageNum = Integer.valueOf((Integer) json.get("pageNum")); Integer pageSize = Integer.valueOf((Integer) json.get("pageSize")); Integer kechengteacher = Integer.valueOf((String) json.get("kechengteacher")); String kechengleibie = String.valueOf((String) json.get("kechengleibie")); String like = String.valueOf((String) json.get("query")); Pageable pageable = PageRequest.of(pageNum - 1, pageSize); return curriService.getCurriList(kechengteacher, like, kechengleibie, pageable); } /** * 根据课程ID进行查询 **/ @CrossOrigin @GetMapping("/api/teacher/getcurri/{kechengid}") public CurriModel getCurriInfo(@PathVariable("kechengid") Integer kechengid) { Optional<CurriModel> optional = Optional.ofNullable(curriDAO.findByKechengid(kechengid)); return optional.orElseGet(CurriModel::new); } /** * 获取所有上课教室信息 **/ @Autowired ClassDAO classDAO; @CrossOrigin @GetMapping("/api/teacher/getclassroomall") public List<Object> getClassroomAll() { return classDAO.getByClassroom(); }
return curriDAO.classroomcheck_curri(classroomname, classweek, classsection, startweek, endtweek); } /** * 添加课程信息 **/ @CrossOrigin @PostMapping("/api/teacher/addcurri") public CurriModel saveCurri(@RequestBody CurriModel curriModel) { SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); curriModel.setCtime(df.format(new Date())); CurriModel curriModel1 = curriDAO.save(curriModel); Integer kechengid = curriModel1.getKechengid(); // 修改当前课程类型为必修,添加对应班级的选择该课程 String leixing = curriModel.getKechengleibie(); if (leixing.equals("必修")) { String[] list = curriModel.getOptionalclass().split(" "); String sqltext = ""; for (int i = 0; i < list.length; i++) { Integer[] list1 = studentUserDAO.findByXhinBJ(list[i]); for (int j = 0; j < list1.length; j++) { SelectionModel selectionModel = new SelectionModel(); selectionModel.setKechengid(kechengid); selectionModel.setXuehao(list1[j]); selectionModel.setCtime(df.format(new Date())); selectionDAO.save(selectionModel); } } } return curriModel1; } /** * 获取选课信息 (有对课程名称进行模糊查询和对课程类型进行筛选条件) ***/ @Autowired SelectionDAO selectionDAO; @CrossOrigin @ResponseBody @PostMapping("/api/teacher/getselection") public List<Map<String, Object>> SelectionQuery(@RequestBody Map<String, Object> json) {
/** * 根据账户信息进行基本信息更新 **/ @CrossOrigin @PutMapping("/api/teacher/updateself/{zhanghu}") public TeacherUser updateTeacherSelf(@PathVariable("zhanghu") Integer zhanghu, @RequestBody TeacherUser teacherUser) { teacherUser.setZhanghu(zhanghu); return teacherUserDAO.saveAndFlush(teacherUser); } /** * 根据账户信息对密码进行更新 **/ @CrossOrigin @PutMapping("/api/teacher/updateselfpwd/{zhanghu}") public TeacherUser updateTeacherPwd(@PathVariable("zhanghu") Integer zhanghu, @RequestBody TeacherUser teacherUser) throws Exception { teacherUser.setZhanghu(zhanghu); teacherUser.setPassword(MD5.md5(teacherUser.getPassword())); return teacherUserDAO.saveAndFlush(teacherUser); } /** * 获取所有学院信息 **/ @Autowired CollegeDAO collegeDAO; @CrossOrigin @GetMapping("/api/teacher/getcollege") public List<CollegeModel> getCollege() { return collegeDAO.findAll(); } /** * 根据学院名称获取所有该学院下的专业信息 **/ @Autowired MajorDAO majorDAO; @CrossOrigin @PostMapping("/api/teacher/getmajor/{collegename}") public List<Map<String, Object>> getMajorByCollegeName(@PathVariable("collegename") String collegename) { return majorDAO.getMajorByCollegename(collegename); } /** * 根据专业名称 获取该专业下的所有班级信息 **/ @Autowired BanjiDAO banjiDAO; @CrossOrigin
/** * 根据当前登录的教师账号,获取该教师开设的所有课程以及每门课程的选课人数 ***/ @CrossOrigin @PostMapping("/api/teacher/getselectionnum/{zhanghu}") List<Map<String, Object>> getSelectionNum(@PathVariable("zhanghu") Integer zhanghu) { return curriDAO.getSelectionNum(zhanghu); } /** * 教师找回密码操作 **/ @CrossOrigin @ResponseBody @PostMapping("/api/teacher/forgetepwd") public Object sendEmail(@RequestBody Map<String, Object> json) { String qq = String.valueOf(json.get("email")); Integer zhanghu = Integer.valueOf(String.valueOf(json.get("zhanghao"))); String mibao = String.valueOf(json.get("mibao")); // TeacherUser teacherUser = teacherUserDAO.findByZhanghu(zhanghu); TeacherUser teacherUser = teacherUserDAO.findByZhanghuAndEmailAndMibao(zhanghu, qq, mibao); // 账号不存在 if (teacherUser == null) { JSONObject jsonObject = new JSONObject(); jsonObject.put("msg", "账户和邮箱数据有误!"); jsonObject.put("code", "255"); return jsonObject.toString(); } else { Object jsonStr = userService.sendEmailHanle("teacher", zhanghu, teacherUser.getName(), teacherUser.getEmail(), qq, 2); if (jsonStr.equals("")) { JSONObject jsonObject = new JSONObject(); jsonObject.put("msg", "邮件发送失败!出现未知错误!"); jsonObject.put("code", "256"); return jsonObject.toString(); } return jsonStr; } } /**
@PostMapping({"/api/admin/getallrooms", "/api/admin/getallcr"}) public List<Classroom> findAllRooms(@RequestBody Map<String, Object> json) { String like1 = String.valueOf(json.getOrDefault("like","")); String like2 = String.valueOf(json.getOrDefault("query","")); return classDAO.findAllRooms(like1+like2); } /** * 获取每个学院的学生和教师人数数量 **/ @CrossOrigin @ResponseBody @GetMapping("/api/admin/getnums") public List<Map<String, Object>> getAllNums() { return collegeDAO.getAllNums(); } /** * 管理员找回密码操作 **/ // 注入QQ发送邮件的bean @Autowired JavaMailSender mailSender; @CrossOrigin @ResponseBody @PostMapping("/api/admin/forgetepwd") public Object sendEmail(@RequestBody Map<String, Object> json) { String qq = String.valueOf(json.get("email")); Integer zhanghu = Integer.valueOf(String.valueOf(json.get("zhanghao"))); String mibao = String.valueOf(json.get("mibao")); AdminUser adminUser = adminUserDAO.findByZhanghaoAndEmailAndMibao(zhanghu, qq, mibao); // 账号不存在 if (adminUser == null) { JSONObject jsonObject = new JSONObject(); jsonObject.put("msg", "账户和邮箱数据有误!"); jsonObject.put("code", "255"); return jsonObject.toString(); } else { Object jsonStr = userService.sendEmailHanle("admin", zhanghu, adminUser.getName(), adminUser.getEmail(), qq, 1); if (jsonStr.equals("")) { JSONObject jsonObject = new JSONObject(); jsonObject.put("msg", "邮件发送失败!出现未知错误!"); jsonObject.put("code", "256"); return jsonObject.toString(); } return jsonStr;
TeacherUser teacherUser = teacherUserDAO.findByZhanghu(Integer.valueOf(zhanghu)); if (teacherUser == null) { JSONObject jsonObject = new JSONObject(); jsonObject.put("msg", "数据有误 !请检查后重试!"); jsonObject.put("code", "255"); return jsonObject.toString(); } else { teacherUser.setPassword(MD5.md5(password)); TeacherUser teacherUser1 = teacherUserDAO.saveAndFlush(teacherUser); if (teacherUser1 == null) { JSONObject jsonObject = new JSONObject(); jsonObject.put("msg", "重置密码失败!"); jsonObject.put("code", "255"); return jsonObject.toString(); } else { JSONObject jsonObject = new JSONObject(); jsonObject.put("msg", "重置密码成功!"); jsonObject.put("code", "200"); return jsonObject.toString(); } } } } package com.credit.shtl.controller;
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。