作者主页:夜未央5788
简介:Java领域优质创作者、Java项目、学习资料、技术互助
文末获取源码
本项目包含三种角色:管理员、学生用户角色与教师角色。
管理员角色包含以下功能:
学生信息管理、教师信息管理。
用户角色包含以下功能:
查看通知公告,登录,登录后学生主页面,选择课题,选择课题后状态为等待老师去人状态,填写开题报告,提交中期检查,提交免答辩申请,上传论文等功能。
教师角色包含以下功能:
教师角色登录,教师首页,申报课题,审批学生选题,审核开题报告,审核中期检查,初审免答辩申请,审核论文是否过关,综合打分等功能。
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可
4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS;
5.数据库:5.7/8.0版本均可;
6.是否Maven项目:是;
1. 后端:Spring+SpringMVC+Mybatis
2. 前端:JSP+CSS+JavaScript+jQuery
1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;
3. 将项目中jdbc.properties配置文件中的数据库配置改为自己的配置;
4. 运行项目,输入localhost:8080/ 登录
- @Controller
- @RequestMapping("/userController")
- public class UserController {
-
- @Autowired
- private UserService userService;
-
- @ResponseBody
- @RequestMapping(value="/isuser",method=RequestMethod.POST)
- public boolean isUser(String account) {
- return userService.isUser(account);
- }
-
- @ResponseBody
- @RequestMapping(value="/ispassword",method=RequestMethod.POST)
- public boolean ispassword(@RequestParam("password")String password,HttpSession session) {
- User user = (User) session.getAttribute("user");
- if(user!=null) {
- return userService.ispassword(Utils.md5(password),user.getUserId());
- }
- return false;
- }
-
- @ResponseBody
- @RequestMapping(value="/login",method=RequestMethod.POST)
- public String login(HttpSession session,String randStr,String account,String password) {
- String randStr2=(String) session.getAttribute("randStr");
- if(randStr2!=null&&randStr2.equals(randStr)) {
- password=Utils.md5(password);
- Subject currentUser = SecurityUtils.getSubject();
- if (!currentUser.isAuthenticated()) {
- //把用户名和密码封装为UsernamePasswordToken
- UsernamePasswordToken token = new UsernamePasswordToken(account, password);
- try {
- //执行登录
- currentUser.login(token);
- return toUI(session,account,password);
- }
- //用户不存在
- catch (UnknownAccountException ae) {
- return "passwordError";
- }
- //用户被锁定
- catch (LockedAccountException e) {
- return "passwordError";
- }
- }else {
- return toUI(session,account,password);
- }
- }else {
- return "randStrError";
- }
- }
-
- private String toUI(HttpSession session,String account,String password) {
- User user = userService.login(account, password);
- if(user!=null) {
- if(2==user.getUserRoles()) {
- session.setAttribute("user", user);
- return "student/sindex.html";
- }
- if(1==user.getUserRoles()) {
- session.setAttribute("user", user);
- return "teacher/tindex.html";
- }
- if(3==user.getUserRoles()) {
- session.setAttribute("admin", user);
- return "admin/showStudent";
- }
- }
- return "passwordError";
- }
-
- @RequestMapping("/logout")
- public String logout(HttpSession session) {
- session.removeAttribute("user");
- return "redirect:login.html";
- }
-
- @ResponseBody
- @RequestMapping(value="/updateInfo",method=RequestMethod.POST)
- public boolean updateStudentInfo(User user,
- @RequestParam(value="portrait",required=false)MultipartFile portrait,HttpServletRequest request) {
- if(portrait!=null&&portrait.getSize()>0) {
- if(portrait.getSize()>(10*1024*1024)) {
- return false;
- }
- String filename=portrait.getOriginalFilename();
- String dbPath="/graduation/portrait/"+user.getUserId();
- String basePath=Thread.currentThread().getContextClassLoader().getResource("").getPath().substring(0,Thread.currentThread().getContextClassLoader().getResource("").getPath().length()-16)+"/portrait/"+user.getUserId();
- if(!new File(basePath).exists()) {
- new File(basePath).mkdirs();
- }
- File portraitFile=new File(basePath,filename);
- try {
- portrait.transferTo(portraitFile);
- user.setUserPortrait(dbPath+"/"+filename);
- return userService.updateUserInfo(user);
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- }
- return userService.updateUserInfo(user);
- }
-
- @ResponseBody
- @RequestMapping(value="/updatePwd",method=RequestMethod.PUT)
- public boolean updateStudentPwd(User user,HttpSession session) {
- String password=user.getUserPassword();
- if(password!=null&&!password.isEmpty()) {
- user.setUserPassword(Utils.md5(password));
- boolean bool = userService.updateUserInfo(user);
- if(bool==true) {
- session.removeAttribute("user");
- return true;
- }
- }
- return false;
- }
- }
- @Controller
- @RequestMapping("/lunwenController")
- public class LunwenController {
-
- @Autowired
- private LunwenService lunwenService;
- @Autowired
- private StudentService studentService;
-
- @RequestMapping("/gotoTstudentlunwen")
- public String gotoTstudentlunwen(String studentId) {
- return "redirect:http://localhost:8080/graduation/teacher/tstudentlunwen.html?studentId="+studentId;
- }
-
- @ResponseBody
- @RequestMapping("/getLunwenBySid")
- public Lunwen getLunwenBySid(String studentId,HttpSession session) {
- if(studentId!=null&&!studentId.isEmpty()) {
- Lunwen lunwen = lunwenService.getLunwenBySid(studentId);
- if(lunwen!=null) {
- return lunwen;
- }
- }else {
- User user = (User) session.getAttribute("user");
- if(user!=null) {
- Student student = studentService.getStudentByUserId(user.getUserId());
- Lunwen lunwen = lunwenService.getLunwenBySid(student.getStudentId());
- if(lunwen!=null) {
- return lunwen;
- }
- }
- }
- return new Lunwen();
- }
-
- @ResponseBody
- @RequestMapping(value="/upLunwenBySid",method=RequestMethod.PUT)
- public boolean upLunwenBySid(Lunwen lunwen) {
- return lunwenService.upLunwenBySid(lunwen);
- }
-
- @ResponseBody
- @RequestMapping(value="/upload_lunwen",method=RequestMethod.POST)
- public boolean saveProduct(@RequestParam(value="lunwen",required=true)MultipartFile lunwen,
- @RequestParam("userId")String userId,HttpServletRequest request) {
- if(lunwen!=null&&lunwen.getSize()>0) {
- if(lunwen.getSize()>(10*1024*1024)) {
- return false;
- }
- String filename = lunwen.getOriginalFilename();
- String basePath=request.getServletContext().getRealPath("/WEB-INF/lunwen/"+userId);
- new File(basePath).mkdir();
- File lunewenFile=new File(basePath,filename);
- try {
- HttpSession session = request.getSession();
- User user = (User) session.getAttribute("user");
- if(user!=null) {
- Student student = studentService.getStudentByUserId(userId);
- Lunwen lw=new Lunwen();
- lw.setLunwenDate(new Date());
- lw.setLunwenName(filename);
- lw.setLunwenPath(basePath+"/"+filename);
- lunwenService.insertOrUpdate(student.getStudentId(),lw);
- }else {
- return false;
- }
- //相同文件会覆盖
- lunwen.transferTo(lunewenFile);
- return true;
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- return false;
- }
-
- @RequestMapping("/downloadResource")
- public @ResponseBody void downloadResource(HttpServletResponse response,
- HttpServletRequest request,String studentId) throws Exception {
- if(studentId==null||studentId.isEmpty()) {
- return;
- }
- Lunwen lunwen = lunwenService.getLunwenBySid(studentId);
- if(lunwen==null) {
- return;
- }
- String dataDir=lunwen.getLunwenPath();
- String fileName=lunwen.getLunwenName();
- Path path=Paths.get(dataDir);
- if(Files.exists(path)) {
- response.setContentType("application/octet-stream");
- response.addHeader("Content-Disposition", "attachment;filename="+Utils.filenameEncoding(fileName, request));
- try {
- Files.copy(path, response.getOutputStream());
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- return;
- }
-
- }
如果也想学习本系统,下面领取。回复:116ssm