当前位置: 首页 > 编程日记 > 正文

Java项目:教务管理系统(java+JSP+Spring+SpringBoot+layui+maven)

源码获取:博客首页 "资源" 里下载!

一、项目简述


功能包括:
三角色教师 管理员,学生教务管理系统,包括院系管理,课题综合管理,信息管理,以及差旅管理,学生选题等等。

二、项目运行

环境配置:

Jdk1.8 + Tomcat8.5 + mysql + Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)

项目技术:

JSP +Spring + SpringBoot + MyBatis + html+ css + JavaScript + JQuery + Ajax + layui+ maven等等


教师管理控制层:

@Authority(roles = {Role.TEACHER})
@Controller
@RequestMapping("/teacher")
public class TeacherController {@AutowiredTeacherService teacherService;@AutowiredSubjectService subjectService;@RequestMapping(value = {"", "/loginPage"})public String loginPage() {return "teacher/login";}@GetMapping("/index")public String homePage() {return "teacher/public-teacher-index";}@GetMapping("/updatePwd")public String updatePwd() {return "teacher/teacherInfo/updatePwd";}@GetMapping("/teacherInfo")public String teacherInfo() {return "teacher/teacherInfo/teacherinfo";}@GetMapping("/modifyinfo")public String modifyInfo() {return "teacher/teacherInfo/updateinfo";}@GetMapping("/workapprovalinfo")public String workInfo() {return "teacher/workapproval/winfo";}@GetMapping("/workapprovaldata")public String workData() {return "teacher/workapproval/wdata";}@GetMapping("/seeworkdata")public String seeWorkData() {return "teacher/workapproval/seewdata";}//填写表格页面@GetMapping("/term_debriefing")public String termDebriefing() {return "teacher/fillouttable/termdebriefing";}@GetMapping("/year_debriefing")public String yearDebriefing() {return "teacher/fillouttable/yeardebriefing";}@GetMapping("/annual_assessment")public String annualAssessment() {return "teacher/fillouttable/annualassessment";}@GetMapping("/work_load")public String workLoad() {return "teacher/fillouttable/workload";}@GetMapping("/technical_personnel")public String technicalPersonnel() {return "teacher/fillouttable/technicalpersonnel";}@GetMapping("/term_business")public String termBusiness() {return "teacher/fillouttable/termbusiness";}//查看表格页面@GetMapping("/show_year_debriefing")public String showYearDebriefing() {return "teacher/showtable/yeardebriefing";}@GetMapping("/show_term_debriefing")public String showTermDebriefing() {return "teacher/showtable/termdebriefing";}@GetMapping("/show_annual_assessment")public String showAnnualAssessment() {return "teacher/showtable/annualassessment";}@GetMapping("/show_technical_personnel")public String showTechnicalPersonnel() {return "teacher/showtable/technicalpersonnel";}@GetMapping("/show_workload")public String showWorkLoad() {return "teacher/showtable/workload";}@GetMapping("/exit")public String exit(HttpServletResponse response) {//将Cookie 中的token 置空Cookie cookie = new Cookie("token", null);cookie.setPath("/");response.addCookie(cookie);return "redirect:/";}//打印页面@GetMapping("/print_term_debriefing")public String printYearDebriefing(Long year, String term, Model model) {model.addAttribute("year", year);model.addAttribute("term", term);return "teacher/showtable/print/termdebriefing";}@GetMapping("/print_year_debriefing")public String printTermDebriefing(Long year, Model model) {model.addAttribute("year", year);return "teacher/showtable/print/yeardebriefing";}@GetMapping("/login")@ResponseBodypublic Msg login(String name, String pwd, HttpSession httpSession, HttpServletResponse response) throws ParseException {name = name.trim();int flag = teacherService.teacherDL(name, pwd);if (flag == 200) {User user = new User();//-1表示为超管user.setId(0L);user.setRole("teacher");user.setUserName(name);//生成Token 存到 CookieCookie cookie = new Cookie("token", TokenUtil.createToken(user));//该Cookie无法被js读取cookie.setHttpOnly(true);cookie.setPath("/");response.addCookie(cookie);Teacher teacher = teacherService.selectTeacher(name);httpSession.setAttribute("teacherInfo", teacher);httpSession.setMaxInactiveInterval(3600);}return Msg.success().add("info", flag);}//教师信息修改//修改教师密码@PostMapping("/teacherupdetpwd")@ResponseBodypublic Msg fun6(String oldpwd, String newpwd, HttpSession httpSession) {Teacher teacher = (Teacher) httpSession.getAttribute("teacherInfo");int flag = teacherService.teacherUpdetpwd(teacher.getUsername(), oldpwd, newpwd);return Msg.success().add("flag", flag);}//修改教师信息@PostMapping("/teacherupdeteinfo")@ResponseBodypublic Msg updateinfo(String name, String gender, HttpSession httpSession) {TeacherWithBLOBs teacher = (TeacherWithBLOBs) httpSession.getAttribute("teacherInfo");teacher.setName(name);teacher.setGender(gender);teacherService.teacherupdateInfo(teacher);return Msg.success();}//教师出差模块//查询所有教师出差申请信息@GetMapping("/select_work_all")@ResponseBodypublic Msg fun1(HttpSession httpSession) {TeacherWithBLOBs teacher = (TeacherWithBLOBs) httpSession.getAttribute("teacherInfo");List<WorkapprovalWithBLOBs> list = teacherService.selectTeacherWorkAll(teacher.getId());return Msg.success().add("workinfo", list);}//查询申请成功教师出差申请@GetMapping("/select_work_success")@ResponseBodypublic Msg fun2(HttpSession httpSession) {TeacherWithBLOBs teacher = (TeacherWithBLOBs) httpSession.getAttribute("teacherInfo");List<WorkapprovalWithBLOBs> list = teacherService.selectWorkSuccess(teacher.getId());return Msg.success().add("workinfo", list);}//查询申请失败教师出差申请@GetMapping("/select_work_failed")@ResponseBodypublic Msg fun3(HttpSession httpSession) {TeacherWithBLOBs teacher = (TeacherWithBLOBs) httpSession.getAttribute("teacherInfo");List<WorkapprovalWithBLOBs> list = teacherService.selectWorkFailed(teacher.getId());return Msg.success().add("workinfo", list);}//查询已提交教师出差申请@GetMapping("/select_work_submitted")@ResponseBodypublic Msg fun4(HttpSession httpSession) {TeacherWithBLOBs teacher = (TeacherWithBLOBs) httpSession.getAttribute("teacherInfo");List<WorkapprovalWithBLOBs> list = teacherService.selectWorkSubmitted(teacher.getId());return Msg.success().add("workinfo", list);}//删除申请失败的教师出差@PostMapping("/delete_work")@ResponseBodypublic Msg deleteWork(Long id) {teacherService.deleteWorkById(id);return Msg.success();}//加载报告填写页面@GetMapping("/fillworkapproval")public String fun5(Long id, Model model) throws ParseException {WorkapprovalWithBLOBs workapproval = teacherService.selectWorkById(id);SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");String start = sdf.format(workapproval.getBeginDate());String end = sdf.format(workapproval.getEndDate());String time = start + " - " + end;model.addAttribute("workapproval", workapproval);model.addAttribute("time", time);return "teacher/workapproval/fillwdata";}//上传出差报告@PostMapping("/fill_in_w")@ResponseBodypublic Msg fun7(@RequestParam("id_work") Long idWork, @RequestParam("news") String news, @RequestParam("flag") Integer flag,@RequestParam("file") MultipartFile file) throws IOException {//判断file的值是否为空if (file.isEmpty()) {return Msg.error();}String fileName = file.getOriginalFilename();// 获取上传文件的原名int size = (int) file.getSize();System.out.println(fileName + "-->" + size);File path = new File(ResourceUtils.getURL("target").getPath());String savePath = path.getAbsolutePath() + "\\classes\\static\\model";String saveFileName = savePath + "\\" + fileName;//        String path = "D:/test";//文件保存路径File targetFile = new File(savePath);if (!targetFile.getParentFile().exists()) { //判断文件父目录是否存在targetFile.getParentFile().mkdir();}file.transferTo(new File(targetFile, fileName)); // 开始接受文件Workapprovaldata workapprovaldata = new Workapprovaldata();workapprovaldata.setIdWorkapproval(idWork);workapprovaldata.setNews(news);workapprovaldata.setDatarar(saveFileName);//flag == 0 公有  flag == 1私有workapprovaldata.setFlag(flag);teacherService.insertWordData(workapprovaldata);return Msg.success();}//查看出差报告@GetMapping("/select_work_data")@ResponseBodypublic Msg fun8(Integer pn, HttpSession httpSession) {Teacher teacher = (Teacher) httpSession.getAttribute("teacherInfo");PageHelper.startPage(pn, 9);List<Workapprovaldata> list = teacherService.selectWorkData(teacher.getIdSection());PageInfo page = new PageInfo(list, 5);return Msg.success().add("dataInfo", page);}//出差附件下载@RequestMapping(value = "/file_download")public ResponseEntity<byte[]> downloadFile(String dataId, HttpServletRequest req, HttpServletResponse response) throws IOException {Workapprovaldata workapprovaldata = null;if (dataId != null) {Long id = Long.valueOf(dataId);workapprovaldata = teacherService.selectWorkDataById(id);}if (workapprovaldata != null) {String filePath = workapprovaldata.getDatarar();//设置文件路径File file = new File(filePath);if (!file.exists()) {file.mkdirs();}String fileName = file.getName();HttpHeaders headers = new HttpHeaders();headers.setContentType(MediaType.MULTIPART_FORM_DATA);String encodeFilename = URLEncoder.encode(fileName, StandardCharsets.UTF_8.toString());headers.setContentDispositionFormData("attachment", encodeFilename);return new ResponseEntity<byte[]>(FileUtils.readFileToByteArray(file),headers, HttpStatus.CREATED);}return null;}//学期述职@PostMapping("/upload_term_debriefing")@ResponseBodypublic Msg fun9(String year, String term, String teachingTask, String scientificResearch,String otherWork, String winAward, String summary, HttpSession httpSession) {Teacher teacher = (Teacher) httpSession.getAttribute("teacherInfo");DebriefingWithBLOBs debriefingWithBLOBs = new DebriefingWithBLOBs();debriefingWithBLOBs.setIdTeacher(teacher.getId());debriefingWithBLOBs.setYear(Long.parseLong(year));debriefingWithBLOBs.setTerm(term);debriefingWithBLOBs.setTeachingtask(teachingTask);debriefingWithBLOBs.setAchievementsinscientificresearch(scientificResearch);debriefingWithBLOBs.setOtherwork(otherWork);debriefingWithBLOBs.setWinaward(winAward);debriefingWithBLOBs.setSummary(summary);int flag = teacherService.selectTermDebriefingFlag(teacher.getId(), Long.parseLong(year), term);if (flag == 1) {teacherService.updateTermDebriefing(debriefingWithBLOBs);} else {int i = teacherService.insertTermDebriefing(debriefingWithBLOBs);}return Msg.success();}// 工作量表相关@GetMapping("/wordload")public String wordloadPage() {return "teacher/table/workload";}@GetMapping("/wordloadData")@ResponseBodypublic Msg wordloadData(@RequestParam("year") String year,@RequestParam("trem") String trem) {Teacher teacher = (Teacher) request.getSession().getAttribute("teacherInfo");return Msg.success().add("teacher", teacher).add("workloadDTO", teacherService.getWorkload(teacher.getId(), year, trem));}private static final Logger LOGGER = LoggerFactory.getLogger(TeacherController.class);@AutowiredHttpServletRequest request;@PostMapping("/wordload")@ResponseBodypublic Msg wordloadSave(@RequestBody WorkloadDTO workloadDTO) {Teacher teacher = (Teacher) request.getSession().getAttribute("teacherInfo");
//        LOGGER.info("{}",workloadDTO);teacherService.saveWorkload(workloadDTO, teacher);return Msg.success();}// 教师业务表@GetMapping("/business")public String businessPage() {return "teacher/table/business";}@GetMapping("/businessData")@ResponseBodypublic Msg businessData(@RequestParam("year") String year,@RequestParam("trem") String trem) {Teacher teacher = (Teacher) request.getSession().getAttribute("teacherInfo");return teacherService.getBusiness(teacher.getId(), year, trem).add("teacher", teacher);}@PostMapping("/business")@ResponseBodypublic Msg saveBusiness(@RequestBody BusinessDTO businessDTO) {Teacher teacher = (Teacher) request.getSession().getAttribute("teacherInfo");return Msg.sqlChange((int) teacherService.saveBusiness(businessDTO, teacher));}//年度述职@PostMapping("/upload_year_debriefing")@ResponseBodypublic Msg fun10(String year, String teachingTask, String scientificResearch,String otherWork, String winAward, String summary, HttpSession httpSession) {Teacher teacher = (Teacher) httpSession.getAttribute("teacherInfo");DebriefingYearWithBLOBs debriefingYear = new DebriefingYearWithBLOBs();debriefingYear.setIdTeacher(teacher.getId());debriefingYear.setYear(Long.parseLong(year));debriefingYear.setTeachingtask(teachingTask);debriefingYear.setAchievementsinscientificresearch(scientificResearch);debriefingYear.setOtherwork(otherWork);debriefingYear.setWinaward(winAward);debriefingYear.setSummary(summary);Long flag = teacherService.selectYearDebriefingFlag(teacher.getId(), Long.parseLong(year));if (flag == 1) {teacherService.updateYearDebriefing(debriefingYear);} else {int i = teacherService.insertYearDebriefing(debriefingYear);}return Msg.success();}//查询年度述职中年份@GetMapping("/select_debriefing_year")@ResponseBodypublic Msg fun11() {List<DebriefingYear> list = teacherService.selectDebriefingByYear();//         把年份排序Collections.sort(list, new Comparator<DebriefingYear>() {@Overridepublic int compare(DebriefingYear o1, DebriefingYear o2) {return (int) (o2.getYear() - o1.getYear());}});return Msg.success().add("year", list);}//查询指定年份的年度述职信息@GetMapping("/select_debriefing_year_info")@ResponseBodypublic Msg fun12(Long year, HttpSession httpSession) {Teacher teacher = (Teacher) httpSession.getAttribute("teacherInfo");DebriefingYearWithBLOBs debriefingYear = teacherService.selectYearDebriefingInfo(teacher.getId(), year);return Msg.success().add("debriefingInfo", debriefingYear);}//查询学期述职中年份@GetMapping("select_debriefing_term")@ResponseBodypublic Msg fun13() {List<Debriefing> list = teacherService.selectDebriefingTermByYear();List<Long> temp = new ArrayList<>();//去除重复的年份for (Debriefing s : list) {if (!temp.contains(s.getYear())) {temp.add(s.getYear());}}return Msg.success().add("year", temp);}//查询指定年份的学期述职信息@GetMapping("/select_debriefing_term_info")@ResponseBodypublic Msg fun14(Long year, String term, HttpSession httpSession) {Teacher teacher = (Teacher) httpSession.getAttribute("teacherInfo");DebriefingWithBLOBs debriefing = teacherService.selectTermDebriefingInfo(teacher.getId(), year, term);return Msg.success().add("debriefingInfo", debriefing);}//年度考核@PostMapping("/upload_annual_assessment")@ResponseBodypublic Msg fun15(String personalSummary, String year, String remark, HttpSession httpSession) {Teacher teacher = (Teacher) httpSession.getAttribute("teacherInfo");AnnualAssessmentWithBLOBs assessment = new AnnualAssessmentWithBLOBs();assessment.setIdTeacher(teacher.getId());assessment.setPersonalsummary(personalSummary);assessment.setYear(year);assessment.setRemark(remark);Long flag = teacherService.selectAnnualAssessmentFlag(teacher.getId(), year);if (flag == 1) {int i = teacherService.updateAnnualAssessment(assessment);} else {int i = teacherService.insertAnnualAssessment(assessment);}return Msg.success();}//年度专业技术人员考核表@PostMapping("/upload_technical_personnel")@ResponseBodypublic Msg fun16(String year, String mainAchievements, String attendance, String rewardsAndPunishments, HttpSession httpSession) {Teacher teacher = (Teacher) httpSession.getAttribute("teacherInfo");TechnicalPersonnelWithBLOBs technicalPersonnelWithBLOBs = new TechnicalPersonnelWithBLOBs();technicalPersonnelWithBLOBs.setIdTeacher(teacher.getId());technicalPersonnelWithBLOBs.setYear(year);technicalPersonnelWithBLOBs.setMainachievements(mainAchievements);technicalPersonnelWithBLOBs.setAttendance(attendance);technicalPersonnelWithBLOBs.setRewardsandpunishments(rewardsAndPunishments);Long flag = teacherService.selectTechnicalPersonnelFlag(teacher.getId(), Long.parseLong(year));if (flag == 1) {int i = teacherService.updateTechnicalPersonnel(technicalPersonnelWithBLOBs);} else {int i = teacherService.insertTechnicalPersonnel(technicalPersonnelWithBLOBs);}return Msg.success();}//查询年度考核年份@GetMapping("/select_annual_assessment")@ResponseBodypublic Msg fun17(HttpSession httpSession) {Teacher teacher = (Teacher) httpSession.getAttribute("teacherInfo");List<AnnualAssessment> list = teacherService.selectAnnualAssessmentByYear(teacher.getId());if (list.isEmpty()) {return Msg.fail();} else {return Msg.success().add("year", list);}}//查询指定年度考核信息@GetMapping("/select_annualassessment_year_info")@ResponseBodypublic Msg fun18(Long year, HttpSession httpSession) {Teacher teacher = (Teacher) httpSession.getAttribute("teacherInfo");AnnualAssessmentWithBLOBs assessment = teacherService.selectAnnualAssessmentInfo(teacher.getId(), year);return Msg.success().add("assessmentInfo", assessment);}//查询度专业技术人员考核表年份@GetMapping("/select_technical_personnel_year")@ResponseBodypublic Msg fun18(HttpSession httpSession) {Teacher teacher = (Teacher) httpSession.getAttribute("teacherInfo");List<TechnicalPersonnel> list = teacherService.selectTechnicalPersonnelByYear(teacher.getId());if (list.isEmpty()) {return Msg.fail();} else {return Msg.success().add("year", list);}}//查询度专业技术人员考核表信息@GetMapping("/select_technicalpersonnel_year_info")@ResponseBodypublic Msg fun19(Long year, HttpSession httpSession) {Teacher teacher = (Teacher) httpSession.getAttribute("teacherInfo");TechnicalPersonnelWithBLOBs technicalPersonnelWithBLOBs = teacherService.selectTechnicalPersonnelInfo(teacher.getId(), year);return Msg.success().add("technicalPersonnel", technicalPersonnelWithBLOBs);}// 毕业设计内容// 加载上传课题页面@GetMapping("/upload_topic_page")public String uploadTopic(ModelMap modelMap, HttpSession httpSession) {TeacherWithBLOBs teacher = (TeacherWithBLOBs) httpSession.getAttribute("teacherInfo");List<Projecttype> projecttypes = teacherService.select_allProjecttype();List<Projectsource> projectsources = teacherService.select_allProjectsource();List<Specialty> specialties = teacherService.select_allSpecialty(teacher.getIdSection());modelMap.addAttribute("projecttypes", projecttypes);modelMap.addAttribute("projectsources", projectsources);modelMap.addAttribute("specialties", specialties);return "teacher/graduation/upload";}// 上传课题@PostMapping("/up_project")@ResponseBodypublic Msg fun20(String projectName, Long idProjecttype, Long idProjectsource, String marchspecialty, String teachernames, @RequestParam("file") MultipartFile file, HttpServletRequest request, HttpSession httpSession) throws IOException {if (file == null) {return Msg.fail().add("msg","文件上传失败");}if(teacherService.selectProjectByName(projectName).size()>0){System.out.println("上传失败");return Msg.fail().add("msg","课题名已存在");}Teacher teacher = (Teacher) httpSession.getAttribute("teacherInfo");ServletContext servletContext = request.getSession().getServletContext();String uploadFileName = file.getOriginalFilename(); // 获取上传文件的原名System.out.println(uploadFileName);uploadFileName = uploadFileName.substring(uploadFileName.lastIndexOf(File.separator) + 1);System.out.println(uploadFileName);File path = new File(ResourceUtils.getURL("target").getPath());String savePath =path.getAbsolutePath() + File.separator+"classes+"+File.separator+"static"+File.separator+"model"+File.separator + teacher.getId();String saveFileName = savePath +File.separator + uploadFileName;File dirs = new File(savePath);//判断路径是否存在,如果不存在就创建一个if (!dirs.exists()) {dirs.mkdirs();}file.transferTo(new File(dirs, uploadFileName)); // 开始接受文件System.out.println(teachernames);ProjectWithBLOBs project = new ProjectWithBLOBs();project.setProjectname(projectName);project.setIdProjecttype(idProjecttype);project.setIdProjectsource(idProjectsource);project.setIdTeacher(teacher.getId());project.setFilepath(saveFileName);project.setMarchspecialty(marchspecialty.trim());project.setTeachernames(teachernames);project.setSelectcount(0);project.setSelectFlag(0);project.setVerifyprojectFlag(0);project.setReleaseFlag(0);int i = teacherService.insert_project(project);return Msg.success();}//查看自己的课题发布记录@GetMapping("/cxmyProject")public String fun21(ModelMap modelMap, HttpSession httpSession)  {TeacherWithBLOBs teacher = (TeacherWithBLOBs) httpSession.getAttribute("teacherInfo");List<Projecttype> projecttypes = teacherService.select_allProjecttype();List<Projectsource> projectsources = teacherService.select_allProjectsource();List<Specialty> specialties = teacherService.select_allSpecialty(teacher.getIdSection());modelMap.addAttribute("projecttypes", projecttypes);modelMap.addAttribute("projectsources", projectsources);modelMap.addAttribute("specialties", specialties);List<Project> projects = teacherService.selectTeacherProject(teacher.getName());for (int i = 0; i < projects.size(); i++) {if (projects.get(i).getVerifyprojectFlag() == 0) projects.get(i).setProjectZT("未审核");else if (projects.get(i).getVerifyprojectFlag() == 1) projects.get(i).setProjectZT("审核未通过");else projects.get(i).setProjectZT("审核通过");}modelMap.addAttribute("Myproject", projects);return "teacher/graduation/section_xq/index";}// 发布或取消发布已审核通过的课题@PostMapping("/fb_project")@ResponseBodypublic String fun8(Long project_id, String pd,HttpSession httpSession) {int s = Integer.parseInt(pd);teacherService.updateProjectFB(project_id, s);if (s == 0) {teacherService.deleteSelectedAll(project_id);teacherService.updateProjectCount(project_id);}Map<String, String> map = new HashMap<String, String>();map.put("pd", "" + 1);return JSONObject.toJSONString(map);}@PostMapping("del_project")@ResponseBodypublic Msg deleteProject(Long id) {teacherService.deleteProject(id);return Msg.success();}@PostMapping("/updateSubject")@ResponseBodypublic Msg updateProject(Long id, String projectName, Long idProjecttype, Long idProjectsource, String marchspecialty, String teachernames, @RequestParam(value = "file", required = false) MultipartFile file, HttpServletRequest request, HttpSession httpSession) throws IOException {//拼接 teacherNames 字段TeacherWithBLOBs teacher = (TeacherWithBLOBs) request.getSession().getAttribute("teacherInfo");String teacherName = teacher.getName();if (teachernames == null || teachernames.trim().length() == 0) {teachernames = teacherName;} else {teachernames = teacherName + "&" + teachernames;}SubjectWithBLOBs subject = null;//文件大小 为 0 则表示 文件没上传long size = file.getSize();//不更新课题文件情况if (file == null || size == 0) {subject = new SubjectWithBLOBs();subject.setId(id);subject.setProjectname(projectName);subject.setIdProjecttype(idProjecttype);subject.setIdProjectsource(idProjectsource);subject.setMarchspecialty(marchspecialty);subject.setTeachernames(teachernames);//修改后状态置 0subject.setSelectFlag(0);subject.setVerifyprojectFlag(0);subject.setReleaseFlag(0);subjectService.updateSubjectByid(subject);return Msg.success();} else {//获取课题SubjectWithBLOBs subject1 = subjectService.getSubjectByID(id);//获取课题路径String oldPath = subject1.getFilepath();File oldFile = new File(oldPath);//如果文件存在则删除if (oldFile.exists()) {//删除成功if (oldFile.delete()) {} else {return Msg.fail();}}ServletContext servletContext = request.getSession().getServletContext();String uploadFileName = file.getOriginalFilename(); // 获取上传文件的原名uploadFileName = uploadFileName.substring(uploadFileName.lastIndexOf(File.separator) + 1);File path = new File(ResourceUtils.getURL("target").getPath());
//            String savePath = path.getAbsolutePath() + "\\classes\\static\\model\\" + teacher.getId();
//            String saveFileName = savePath + "\\" + uploadFileName;String savePath =path.getAbsolutePath() + File.separator+"classes+"+File.separator+"static"+File.separator+"model"+File.separator + teacher.getId();String saveFileName = savePath +File.separator + uploadFileName;File dirs = new File(savePath);//判断路径是否存在,如果不存在就创建一个if (!dirs.exists()) {dirs.mkdirs();}file.transferTo(new File(dirs, uploadFileName)); // 开始接受文件SubjectWithBLOBs project = subject1;project.setProjectname(projectName);project.setIdProjecttype(idProjecttype);project.setIdProjectsource(idProjectsource);project.setFilepath(saveFileName);project.setMarchspecialty(marchspecialty.trim());project.setTeachernames(teachernames);//修改后状态置 0project.setSelectFlag(0);project.setVerifyprojectFlag(0);project.setReleaseFlag(0);int i = subjectService.updateSubjectByid(project);return Msg.success();}}@GetMapping("/getSubjectById")@ResponseBodypublic Msg getss(Long id) {SubjectWithBLOBs subject = subjectService.getSubjectByID(id);System.out.println(subject);subject.setFilepath(subject.getFilepath().substring(subject.getFilepath().lastIndexOf("\\") + 1));String[] teachers = subject.getTeachernames().split("&");String teacher2 = "";if (teachers.length >= 2) {teacher2 = teachers[teachers.length - 1];}subject.setTeachernames(teacher2);return Msg.success().add("subject", subject);}//查看自己所在教研室的课题发布记录@GetMapping("/cxallProject")public String fun7(ModelMap modelMap, HttpSession httpSession) {Teacher teacher = (Teacher) httpSession.getAttribute("teacherInfo");List<Project> projects = teacherService.selecSectionProject(teacher.getSectionName());for (int i = 0; i < projects.size(); i++) {if (projects.get(i).getVerifyprojectFlag() == 0) projects.get(i).setProjectZT("未审核");else if (projects.get(i).getVerifyprojectFlag() == 1) projects.get(i).setProjectZT("审核未通过");else projects.get(i).setProjectZT("审核通过");}modelMap.addAttribute("allproject", projects);return "teacher/graduation/section_xq/subjectinfoto";}
}

学生管理控制层:

@Authority(roles = {Role.STUDENT})
@Controller
@RequestMapping("/student")
public class StudentController {private static final Logger LOGGER = LoggerFactory.getLogger(StudentController.class);@Autowiredprivate StudentService studentService;@Autowiredprivate HttpServletRequest request;@Autowiredprivate LoginServiceImpl loginService;@AutowiredIndexServiceImpl indexService;@AutowiredAdminService adminService;@AutowiredTopicsService topicsService;//Session过期时间private final Integer SAVE_TIME = 60*60*24;@GetMapping("/login")public String login(){return "student/login";}@PostMapping(value = "/login")@ResponseBodypublic String login(String name, String pwd, Model model, HttpServletResponse response) {name = name.trim();List<Student> student = studentService.selectByName(name);if (student.size() >= 1) {if (student.get(0).getPwd().equals(pwd)) {request.getSession().setAttribute("student",student.get(0));request.getSession().setMaxInactiveInterval(SAVE_TIME);User user = new User();//-1表示为超管user.setId(1L);user.setRole("student");user.setUserName(name);//生成Token 存到 CookieCookie cookie = new Cookie("token", TokenUtil.createToken(user));//该Cookie无法被js读取cookie.setHttpOnly(true);cookie.setPath("/");response.addCookie(cookie);model.addAttribute("student", student.get(0));return "200";}else {return "0";}} else {return "300";}}@RequestMapping("/index")public String index(Model model, HttpSession httpSession) {Student student = (Student) request.getSession().getAttribute("student");Subject project = indexService.indexinfo(student.getId());String str = null;Long flag = null;if (project == null) {model.addAttribute("projectName", "未选课题");model.addAttribute("flag", "未选题");model.addAttribute("teacher", "无");httpSession.removeAttribute("");} else {httpSession.setAttribute("XZproject", project.getProjectname());model.addAttribute("XZproject", project.getProjectname());model.addAttribute("projectName", project.getProjectname());flag = indexService.projectselectedstuflag(student.getId());if (flag == 0L) {str = "未选题";} else if (flag == 1L) {str = "选题待审核";} else if (flag == 2L) {str = "选题未通过";} else if (flag == 3L) {str = "选题通过";}model.addAttribute("flag", str);model.addAttribute("teacher", project.getTeachernames());request.getSession().setAttribute("filePath",project.getFilepath());}//用来判断当前页是否为首页model.addAttribute("path","1");//判断是否修改了个人信息
//        request.getSession().setAttribute("modifyFlag",0);return "student/index";}/*** 查看个人信息*/@RequestMapping("/studentinfo")public String studentinfo(Model model) {Student student = (Student) request.getSession().getAttribute("student");MyClass idclass = indexService.studentinfo(student.getIdClass());model.addAttribute("tclass", idclass);return "student/studentinfo";}/*** 将查看的个人信息放到信息修改页面*/@RequestMapping("/modifyinfo")public String modifyinfo(Model model) {Student student = (Student) request.getSession().getAttribute("student");MyClass idclass = indexService.studentinfo(student.getIdClass());model.addAttribute("tclass", idclass);return "student/modifyinfo";}/*** 修改个人信息* 根据班级(className)修改**//*@RequestMapping(value = "/modifyinfodao", method = RequestMethod.PUT)@ResponseBodypublic String modifyinfodao(Student student, String className, Model model) {Student Tstudent = (Student) request.getSession().getAttribute("student");MyClass Tclass = indexService.selectByclassName(className);int count = -1;student.setIdClass(Tclass.getId());System.out.println("******"+Tstudent.toString());System.out.println("******"+student.toString());if (student.getStunum().equals(Tstudent.getStunum())) {student.setStunum(null);}if (student.getIdClass().equals(Tstudent.getIdClass())) {student.setIdClass(null);}if (student.getName().equals(Tstudent.getName())) {student.setName(null);}if (student.getGender().equals(Tstudent.getGender())) {student.setGender(null);}if (student.getGender() == null && student.getName() == null && student.getIdClass() == null && student.getStunum() == null) {} else {student.setId(Tstudent.getId());count = indexService.updateBymodifyinfo(student);student = indexService.selectByid(Tstudent.getId());model.addAttribute("student", student);}if (count > 0) {request.getSession().setAttribute("student",student);request.getSession().setAttribute("modifyFlag",1);return "200";} else {request.getSession().setAttribute("modifyFlag",0);return "201";}}*//***   跳转页面(修改密码)*/@RequestMapping("/changepsw")public String changepsw() {return "student/changepsw";}/*** 200修改成功* 201对不起密码错误* 202对不起输入框为空* 203新密码不一致* 204修改失败*/@RequestMapping(value = "/changepassword", method = RequestMethod.PUT)@ResponseBodypublic String changepswdao(String oldpassword, String newpassword, String newpassword1) {if(!verifypassword(newpassword)){return "206";}if(!verifypassword(newpassword1)){return "206";}Student student = (Student) request.getSession().getAttribute("student");Student studentdao = loginService.selectByName(student.getUsername());int result;if (newpassword.equals(newpassword1) && !newpassword.equals("") && !newpassword1.equals("")) {if (studentdao.getPwd().equals(oldpassword)) {if(oldpassword.equals(newpassword)){return "205";}else{result = indexService.updatepassword(newpassword, student.getId());if (result > 0) {return "200";}else{return "204";}}} else {return "201";}} else if (newpassword.equals("") && newpassword1.equals("")) {return "202";}return "203";}//密码验证public boolean verifypassword(String password){if(password.length() < 6 || password.length() > 16){return false;}for(int i = 0;i < password.length();i++){if(!(password.charAt(i)>='A' && password.charAt(i)<='Z')){if(!(password.charAt(i)>='a' && password.charAt(i)<='z')){if(!(password.charAt(i)>='0' && password.charAt(i)<='9')){return false;}}}}return true;}//退出//清除Session数据@RequestMapping("/exit")public String exit(HttpServletResponse response,HttpSession httpSession) {
//        httpSession.setAttribute("XZproject", null);
//       清除SessionEnumeration em = request.getSession().getAttributeNames();while(em.hasMoreElements()){request.getSession().removeAttribute(em.nextElement().toString());}//将Cookie 中的token 置空Cookie cookie = new Cookie("token", null);cookie.setPath("/");response.addCookie(cookie);return "student/login";}/*** 查看班级选报信息*/@RequestMapping("/classinfo")public String classinfo(Model model,HttpSession httpSession) {Student student = (Student) request.getSession().getAttribute("student");removeSession();List<Static_student> list =  adminService.select_student(null, null, student.getIdClass(), null, null);System.out.println(list);model.addAttribute("list", list);return "student/classinfo";}/*** 查看课题*/@RequestMapping("/topics")public String Topics(Model model,HttpSession httpSession) {Student student = (Student) request.getSession().getAttribute("student");removeSession();List<topicsinfo> topicsinfolist = topicsService.topics(student.getIdClass());System.out.println(topicsinfolist);model.addAttribute("topicsinfolist", topicsinfolist);return "student/topicsinfo";}/*** 课题具体信息*/@RequestMapping("/topicsto")public String Topicsto(Long project_id,int selectFlag,String projectName, Model model, HttpSession httpSession) {List<topicsto> topicstos = topicsService.topicsinfo(project_id);Student student = (Student) request.getSession().getAttribute("student");Long flag = topicsService.state(student);Long flagto = topicsService.flag(project_id);if (flagto != 0) {flag = 3L;}model.addAttribute("selectFlag",selectFlag);model.addAttribute("flag", flag);model.addAttribute("topicstos", topicstos);model.addAttribute("projectName", projectName);model.addAttribute("project_id", project_id);model.addAttribute("XZproject", httpSession.getAttribute("XZproject"));return "student/topicsinfoto";}/*** 选报课题*/@AutowiredSubjectselectedMapper subjectselectedMapper;@RequestMapping("/enroll")@ResponseBodypublic String enroll(Long project_id, HttpSession httpSession) {String projectName = topicsService.selectprojectname(project_id);Student student = (Student) request.getSession().getAttribute("student");List<Subjectselected> subjectselected = subjectselectedMapper.selectBystudentid(student.getId());if(subjectselected.size() == 0){studentService.updateselectnumAdd(projectName);topicsService.insertproject(projectName, student.getId());httpSession.setAttribute("XZproject", projectName);return "200";}else {return "201";}}/*** 取消选报*/@RequestMapping("/cancel")@ResponseBody()public String cancel(Long project_id, Model model, HttpSession httpSession) {System.out.println(1);String projectName = topicsService.selectprojectname(project_id);Student student = (Student) request.getSession().getAttribute("student");List<Subjectselected> subjectselected = subjectselectedMapper.selectBystudentid(student.getId());if (subjectselected != null && subjectselected.size() != 0 && subjectselected.get(0).getStuselectFlag() != 3&& project_id.equals(subjectselected.get(0).getIdProject())) {topicsService.deleteprojectselectedid(student.getId());httpSession.removeAttribute("XZproject");model.addAttribute("XZproject", null);httpSession.setAttribute("XZproject", null);studentService.updateselectnumReduce(projectName);return "200";} else {return "203";}}/*** 清除session中存的项目名*/public void removeSession(){Student student = (Student) request.getSession().getAttribute("student");Subject project = indexService.indexinfo(student.getId());if(project==null){request.getSession().removeAttribute("XZproject");}}}

登录控制层:

@Controller
public class LoginController {private static final Logger LOGGER = LoggerFactory.getLogger(LoginController.class);@AutowiredAdminService adminService;@GetMapping("/cs")public String cs() {return "cs";}@GetMapping("/login")public String login() {return "login";}@PostMapping("/login")@ResponseBodypublic Msg login(String name, String pwd, HttpSession httpSession) {name = name.trim();
//        LOGGER.info("{}--{}",name,pwd);return adminService.login(name, pwd, httpSession);}
}

源码获取:博客首页 "资源" 里下载!

相关文章:

jsp 环境配置记录

1. jdk&#xff0c;下载地址1 环境变量配置&#xff1a; 1&#xff09;新建 JAVA_HOME 变量 。 变量值填写jdk的安装目录&#xff08;本人是 C:\Java\jdk1.7.0) 2) 系统变量→寻找 Path 变量→编辑 在变量值最后输入 %JAVA_HOME%\bin;%JAVA_HOME%\jre\bin; &#xff08;注意原…

一些关于找工作的书籍

技术类 算法导论&#xff1a;不要纠缠太难的部分&#xff08;红黑树、斐波那契额堆、NP、近似算法&#xff09;&#xff1b; 编程之美&#xff1a;仔细阅读&#xff0c;包括上面的智力题&#xff0c;纸上手写代码&#xff1b; 编程珠玑&#xff1a;建议仔细阅读&#xff0c;尤其…

最快地复制一张表

1.mysqldump方法 一种方法是&#xff0c;使用mysqldump命令将数据导出成一组INSERT语句。你可以使用下面的命令&#xff1a; mysqldump -h$host -P$port -u$user --add-locks --no-create-info --single-transaction --set-gtid-purgedOFF db1 t --where"a>900" …

Linux下C++开发工具介绍

概述 就C&#xff0b;&#xff0b;开发工具而言&#xff0c;与Windows下微软&#xff08;VC&#xff0c; VS2005等&#xff09;一统天下相比&#xff0c;Linux/Unix下C&#xff0b;&#xff0b;开发&#xff0c;可谓五花八门&#xff0c;各式各样。Emacs, vi, eclipse, anj…

Linked List Cycle II

Given a linked list, return the node where the cycle begins. If there is no cycle, return null. Follow up:Can you solve it without using extra space? 分析&#xff1a;和Linked List Cycle类似&#xff0c;还是用map。 用时&#xff1a;60ms 1 /**2 * Definition …

Java项目:考试管理系统(java+Springboot+Maven+Jpa+Vue+Mysql)

源码获取&#xff1a;博客首页 "资源" 里下载&#xff01; 一、项目简述本系统功能包括&#xff1a; 支持单选题、多选题、判断题支持学生(student)、教师(teacher)、管理员(admin)三种角色学生&#xff1a;参加考试和查看我的考试教师&#xff1a;学生的所有权限创建…

[物理学与PDEs]第1章第7节 媒质中的 Maxwell 方程组 7.2 媒质交界面上的条件

通过 Maxwell 方程组的积分形式易在交界面上各量应满足交界面条件: $$\beex \bea \sez{{\bf D}}\cdot{\bf n}\omega_f,&\sex{\omega_f:\ \mbox{交界面上自由电荷密度}};\\ \sez{{\bf B}}\cdot{\bf n}0,&\sex{\ra\mbox{ 磁感应强度法向分量在交界面上连续}};\\ \sez{{\b…

第十二周编程总结

这个作业属于的课程C语言程序设计2这个作业要求在哪里https://edu.cnblogs.com/campus/zswxy/MS/homework/3239我在这个课程的目标是使用编程实现简单的游戏设计这个作业在哪个具体方面帮助我实现目标使用指针解决问题&#xff0c;熟悉指针与函数之间的关系和指针作为函数返回值…

什么是交叉编译

在一种计算机环境中运行的编译程序&#xff0c;能编译出在另外一种环境下运行的代码&#xff0c;我们就称这种编译器支持交叉编译。这个编译过程就叫交叉编译。简单地说&#xff0c;就是在一个平台上生成另一个平台上的可执行代码。这里需要注意的是所谓平台&#xff0c;实际上…

树形结构在关系数据库中的设计

在程序设计中&#xff0c;经常以树形结构表示数据的层次关系&#xff0c;如菜单的结构、商品的分类等。 这样的层次结构在关系数据库中难以直观地表示。常见的一种做法是用一个字段指向上级节点来表示记录的上下级关系。 fidpidfname 1 Food 2 1 Fruit 3 2 Red 4 3…

Java项目:在线课程会员系统(java+Springboot+Maven+JSP+Spring+Mysql+layui)

一、项目简述 功能包括&#xff1a; 用户管理&#xff0c;课程管理&#xff0c;在线视频观看&#xff0c;评论&#xff0c;会员展示&#xff0c;会员充值等等。 二、项目运行 环境配置&#xff1a; Jdk1.8 Tomcat8.5 mysql Eclispe&#xff08;IntelliJ IDEA,Eclispe,MyEc…

职场观察:高薪需要什么?

标签&#xff1a;职场高薪原创作品&#xff0c;允许转载&#xff0c;转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。http://xjsunjie.blog.51cto.com/999372/1378547新的一年&#xff0c;看到别人跳槽或涨薪&#xff0c;你是否也蠢蠢欲动…

Excel-姓名列中同一个人汇总金额列,得出总金额

8、姓名列中同一个人求和金额列&#xff0c;得出总金额。 方法一&#xff1a; P2处公式SUMPRODUCT(($M$2:$M$20$M2)*($N$2:$N$20)) 解释函数&#xff1a; 引用&#xff1a;https://zhinan.sogou.com/guide/detail/?id1610011625 PS&#xff1a;这个只是单条件求和&#xff0c;…

C语言编译全过程(转贴)

C语言编译全过程 编译的概念&#xff1a;编译程序读取源程序&#xff08;字符流&#xff09;&#xff0c;对之进行词法和语法的分析&#xff0c;将高级语言指令转换为功能等效的汇编代码&#xff0c;再由汇编程序转换为机器语言&#xff0c;并且按照操作系统对可执行文件…

Java项目:家教管理系统(java+SSM+MyBatis+MySQL+Maven+Jsp)

源码获取&#xff1a;博客首页 "资源" 里下载&#xff01; 该系统分为前台和后台 前台功能有&#xff1a;登录、注册、查看学员、查看教师、个人中心等。 后台功能有&#xff1a;用户管理、学员管理、教师管理、审核管理、公告管理、新闻管理、简历管理等。前台注册…

ecshop /api/client/api.php、/api/client/includes/lib_api.php SQL Injection Vul

catalog 1. 漏洞描述 2. 漏洞触发条件 3. 漏洞影响范围 4. 漏洞代码分析 5. 防御方法 6. 攻防思考 1. 漏洞描述 ECShop存在一个盲注漏洞&#xff0c;问题存在于/api/client/api.php文件中&#xff0c;提交特制的恶意POST请求可进行SQL注入攻击&#xff0c;可获得敏感信息或操作…

C++ 检测内存泄露

本文描述了如何检测内存泄露。最主要的是纯C&#xff0c;C的程序如何检测内存泄露。 现在有很多专业的检测工具&#xff0c;比如比较有名的BoundsCheck, 但是这类工具也有他的缺点&#xff0c;我认为首先BoundsCheck是商业软件&#xff0c;呵呵。然后呢需要安装&#xff0c;使用…

Java 学习笔记(4)——java 常见类

上次提前说了java中的面向对象&#xff0c;主要是为了使用这些常见类做打算&#xff0c;毕竟Java中一切都是对象&#xff0c;要使用一些系统提供的功能必须得通过类对象调用方法。其实Java相比于C来说强大的另一个原因是Java中提供了大量可用的标准库 字符串 字符串可以说是任何…

浅谈GCC预编译头技术

浅谈GCC预编译头技术 文/jorge ——谨以此文&#xff0c;悼念我等待MinGW编译时逝去的那些时间。 其 实刚开始编程的时候&#xff0c;我是丝毫不重视编译速度之类的问题的&#xff0c;原因很简单&#xff0c;因为那时我用BASICA。后来一直用到C Builder&#xff0c;尽管Borl…

Java项目:慢病报销管理信息系统(java+MySQL+Jdbc+Servlet+Jsp)

源码获取&#xff1a;博客首页 "资源" 里下载&#xff01; 一、项目简述 功能&#xff1a; 慢病管理&#xff0c;医疗机构管理&#xff0c;家庭管理&#xff0c;费用交纳&#xff0c;费用报销&#xff0c;报表统计等等功能。 二、项目运行 环境配置&#xff1a; Jd…

Jetty Cross Origin Filter解决jQuery Ajax跨域访问的方法

当使用jQuery Ajax post请求时可能会遇到类似这样的错误提示 XMLHttpRequest cannot load http://xxxxxx. Origin http://xxxxxx is not allowed by Access-Control-Allow-Origin. 这是Ajax跨域访问权限的问题&#xff0c;服务器端不接受来自另一个不同IP地址的由脚本文件发出的…

php 遍历所有的文件

<?php prin_r(glob($path)); 2 转载于:https://www.cnblogs.com/zqk8553/p/3640071.html

Oracle数据库物理存储结构管理

1、实验目的 &#xff08;1&#xff09;掌握Oracle数据库数据文件的管理。 &#xff08;2&#xff09;掌握Oracle数据库控制文件的管理。 &#xff08;3&#xff09;掌握Oracle数据库重做日志文件的管理。 &#xff08;4&#xff09;掌握Oracle数据库归档管理。 2、实验环境 Wi…

KDE与GNOME的战争史(转载)

虽然在商业方面存在竞争&#xff0c;GNOME与KDE两大阵营的开发者关系并没有变得更糟&#xff0c;相反他们都意识到支持对方的重要性—如果KDE和GNOME无法实现应用程序的共享&#xff0c;那不仅是巨大的资源浪费&#xff0c;而且将导致Linux出现根本上的分裂。 KDE与GNOME是…

[ActionScript 3.0] AS向php发送二进制数据方法之——在URLRequest中构造HTTP协议发送数据...

主类 HTTPSendPHP.as 1 package 2 {3 import com.JPEGEncoder.JPGEncoder;4 import com.fylib.httpRequest.HttpRequestBuilder;5 import com.fylib.httpRequest.HttpRequestBuilderConsts;6 import flash.display.Bitmap;7 import flash.display.BitmapDa…

Java项目:校园招聘平台系统(java+MySQL+Jdbc+Servlet+SpringMvc+Jsp)

源码获取&#xff1a;博客首页 "资源" 里下载&#xff01; 一、项目简述 功能&#xff1a; 用户和企业用户的注册登录&#xff0c;简历的筛选查看搜索&#xff0c;应聘信息互动等等。 二、项目运行 环境配置&#xff1a; Jdk1.8 Tomcat8.5 mysql Eclispe&#xf…

静态资源(StaticResource)和动态资源(DynamicResource)

静态资源&#xff08;StaticResource&#xff09;和动态资源&#xff08;DynamicResource&#xff09; 资源可以作为静态资源或动态资源进行引用。这是通过使用 StaticResource 标记扩展或 DynamicResource 标记扩展完成的。 StaticResource 通过替换已定义资源的值来为 XAML 属…

如何在 Kaggle 首战中进入前 10%(转)

如何在 Kaggle 首战中进入前 10%&#xff08;转&#xff09; 来源&#xff1a;https://dnc1994.com/2016/04/rank-10-percent-in-first-kaggle-competition/ Introduction 本文采用署名 - 非商业性使用 - 禁止演绎 3.0 中国大陆许可协议进行许可。著作权由章凌豪所有。 Kaggle …

一.Timesten安装

一&#xff0c;安装timesten IMDB并测试 1. 创建数据库相关用户和组 groupadd timestenuseradd -g timesten -G dba timestenpasswd timesten2. 创建相关目录 mkdir /etc/TimesTenchmod 775 /etc/TimesTenchown timesten:timesten /etc/TimesTenmkdir /u01/app/timesTen chmod …

linux 入门-1

刚开始接触linux&#xff0c;总有些简单的问题不知道怎么搞定&#xff0c;先将目前汇总的解决方法叫做"linux入门&#xff0d;1",后续在使用过程中逐步总结。 1. 连接 ADSL &#xff1a; sudo pon dsl-provider 断开 ADSL&#xff1a; sudo poff 查看 ADSL 状态&a…