Java 实战项目之毕业设计管理系统的实现流程
程序员文章站
2022-08-06 17:53:09
一、项目简述功能包括: 该系统不错分为学生,教师,管理员,教导主任四种角 色,包括学生管理,教师管理,学生选题,教师选题,主 任审核,管理员审核,开题报告,中期检查,论文提交, 文件管理等等非常不错。...
一、项目简述
功能包括: 该系统不错分为学生,教师,管理员,教导主任四种角 色,包括学生管理,教师管理,学生选题,教师选题,主 任审核,管理员审核,开题报告,中期检查,论文提交, 文件管理等等非常不错。
二、项目运行
环境配置: jdk1.8 + tomcat8.5 + mysql + eclispe (intellij idea,eclispe,myeclispe,sts 都支持)
项目技术: jsp +spring + springmvc + mybatis + html+ css + javascript + jquery + ajax + layui+ maven等等。
用户管理操作控制层:
/** * 用户管理操作 */ @controller @requestmapping("/user") public class usercontroller { @autowired private userservice userservice; /** * 用户添加页面 * @return */ @getmapping("/add") public string create() { return "user/add"; } /** * 用户添加操作 * @param user * @return */ @postmapping("/add") @responsebody public map<string, object> add(@requestbody user user) { if(stringutils.isempty(user.getusername())){ return mapcontrol.getinstance().error("请填写用户名").getmap(); } if(stringutils.isempty(user.getname())){ return mapcontrol.getinstance().error("请填写名称").getmap(); } if(stringutils.isempty(user.getuserpwd())){ return mapcontrol.getinstance().error("请填写密码").getmap(); } int result = userservice.create(user); if (result <= 0) { return mapcontrol.getinstance().error().getmap(); } return mapcontrol.getinstance().success().getmap(); } /** * 根据id删除 * @param id * @return */ @postmapping("/delete/{id}") @responsebody public map<string, object> delete(@pathvariable("id") integer id) { int result = userservice.delete(id); if (result <= 0) { return mapcontrol.getinstance().error().getmap(); } return mapcontrol.getinstance().success().getmap(); } //批量删除 @postmapping("/delete") @responsebody public map<string, object> delete(string ids) { int result = userservice.delete(ids); if (result <= 0) { return mapcontrol.getinstance().error().getmap(); } return mapcontrol.getinstance().success().getmap(); } /** * 编辑用户信息操作 * @param user * @return */ @postmapping("/edit") @responsebody public map<string, object> edit(@requestbody user user) { if(stringutils.isempty(user.getusername())){ return mapcontrol.getinstance().error("请填写用户名").getmap(); } if(stringutils.isempty(user.getname())){ return mapcontrol.getinstance().error("请填写名称").getmap(); } if(stringutils.isempty(user.getuserpwd())){ return mapcontrol.getinstance().error("请填写密码").getmap(); } int result = userservice.update(user); if (result <= 0) { return mapcontrol.getinstance().error().getmap(); } return mapcontrol.getinstance().success().getmap(); } /** * 根据id查询,跳转修改页面 * @param id * @param modelmap * @return */ @getmapping("/edit/{id}") public string edit(@pathvariable("id") integer id, modelmap modelmap) { user user = userservice.detail(id); modelmap.addattribute("user", user); return "user/edit"; } //查询所有 @postmapping("/query") @responsebody public map<string, object> query(@requestbody user user) { list<user> list = userservice.query(user); integer count = userservice.count(user); return mapcontrol.getinstance().success().page(list, count).getmap(); } //跳转列表页面 @getmapping("/list") public string list() { return "user/list"; } }
跳转首页判断以及数据展示图表:
@controller public class indexcontroller { @autowired userservice userservice; @autowired teacherservice teacherservice; @autowired studentservice studentservice; @autowired clazzservice clazzservice; @autowired subjectservice subjectservice; @autowired courseservice courseservice; @autowired sectionservice sectionservice; @autowired scoreservice scoreservice; //跳转系统主页 @getmapping("/index") public string login() { return "index"; } //跳转用户基本信息页面 @getmapping("/info") public string info() { return "info"; } //跳转修改密码页面 @getmapping("/pwd") public string pwd() { return "pwd"; } //修改密码 根据旧密码来修改密码 @postmapping("/pwd") @responsebody public map<string,object> pwd(string sourcepwd,string newpwd,string type,integer id) { //先判断类型 if("1".equals(type)) { user user = userservice.detail(id); //比较原密码是否相同 注意:原密码也要加密后再进行比较,因为数据库中存储的是加密后的密码 if(user.getuserpwd().equals(md5utils.getmd5(sourcepwd))) { user entity = new user(); entity.setid(id); entity.setuserpwd(md5utils.getmd5(newpwd)); //主要要加密 int result = userservice.update(entity); if(result <= 0) { return mapcontrol.getinstance().error().getmap(); } else { return mapcontrol.getinstance().success().getmap(); } } else { return mapcontrol.getinstance().error("原密码错误").getmap(); } } if("2".equals(type)) { teacher teacher = teacherservice.detail(id); //比较原密码 if(teacher.getteacherpwd().equals(md5utils.getmd5(sourcepwd))) { teacher entity = new teacher(); entity.setid(id); entity.setteacherpwd(md5utils.getmd5(newpwd)); int result = teacherservice.update(entity); if(result <= 0) { return mapcontrol.getinstance().error().getmap(); } else { return mapcontrol.getinstance().success().getmap(); } } else { return mapcontrol.getinstance().error("原密码错误").getmap(); } } if("3".equals(type)) { student student = studentservice.detail(id); //比较原密码 if(student.getstupwd().equals(md5utils.getmd5(sourcepwd))) { student entity = new student(); entity.setid(id); entity.setstupwd(md5utils.getmd5(newpwd)); int result = studentservice.update(entity); if(result <= 0) { return mapcontrol.getinstance().error().getmap(); } else { return mapcontrol.getinstance().success().getmap(); } } else { return mapcontrol.getinstance().error("原密码错误").getmap(); } } return mapcontrol.getinstance().error().getmap(); } //跳转系统主页(数据概览) @getmapping("/main") public string main(modelmap modelmap) { //1.系统数据概览 list<clazz> clazzes = clazzservice.query(null); list<subject> subjects = subjectservice.query(null); list<teacher> teachers = teacherservice.query(null); list<course> courses = courseservice.query(null); list<section> sections = sectionservice.query(null); list<student> students = studentservice.query(null); modelmap.addattribute("clazzcnt",clazzes.size()); modelmap.addattribute("subjectcnt",subjects.size()); modelmap.addattribute("teachercnt",teachers.size()); modelmap.addattribute("coursecnt",courses.size()); modelmap.addattribute("studentcnt",students.size()); modelmap.addattribute("sectioncnt",sections.size()); //2.班级学生数量 list<map<string,object>> maplist = new arraylist<>(); for(clazz clazz : clazzes) { map<string,object> map = new hashmap<>(); map.put("name",clazz.getclazzname()); //设置班级名称 int cnt = 0; //统计学生数量 for(student student : students) { if(student.getclazzid() == clazz.getid()) { cnt++; } } map.put("cnt",cnt); //设置学生数量 maplist.add(map); } modelmap.addattribute("maplist",maplist); //3.查询各科平均成绩(根据专业查询各科平均成绩) list<hashmap> maplist2 = scoreservice.queryavgscorebysection(); modelmap.addattribute("maplist2",maplist2); return "main"; } }
公告管理控制器:
/** * 公告管理控制器 */ @controller @requestmapping("/notice") public class noticecontroller { @autowired private noticeservice noticeservice; //跳转添加页面 @getmapping("/add") public string add() { return "notice/add"; } /** * 公告添加 * @param notice * @return */ @postmapping("/add") @responsebody public map<string, object> add(notice notice, httpservletrequest request) { if(stringutils.isempty(notice.gettitle())){ return mapcontrol.getinstance().error("请填写公告标题").getmap(); } if(stringutils.isempty(notice.getcontent())){ return mapcontrol.getinstance().error("请填写公告内容").getmap(); } user user = (user) request.getsession().getattribute("user"); notice.setauthor(user.getusername()); notice.setauth("1"); int result = noticeservice.create(notice); if (result <= 0) { //新增失败 return mapcontrol.getinstance().error().getmap(); } return mapcontrol.getinstance().success().getmap(); } //根据id删除 @postmapping("/delete/{id}") @responsebody public map<string, object> delete(@pathvariable("id") integer id) { int result = noticeservice.delete(id); if (result <= 0) { return mapcontrol.getinstance().error().getmap(); } return mapcontrol.getinstance().success().getmap(); } //批量删除 @postmapping("/delete") @responsebody public map<string, object> delete(string ids) { int result = noticeservice.delete(ids); if (result <= 0) { return mapcontrol.getinstance().error().getmap(); } return mapcontrol.getinstance().success().getmap(); } /** * 修改公告操作 * @param notice * @return */ @postmapping("/edit") @responsebody public map<string, object> edit(@requestbody notice notice) { if(stringutils.isempty(notice.gettitle())){ return mapcontrol.getinstance().error("请填写公告标题").getmap(); } if(stringutils.isempty(notice.getcontent())){ return mapcontrol.getinstance().error("请填写公告内容").getmap(); } int result = noticeservice.update(notice); if (result <= 0) { return mapcontrol.getinstance().error().getmap(); } return mapcontrol.getinstance().success().getmap(); } //根据id查询,跳转修改页面 @getmapping("/edit/{id}") public string edit(@pathvariable integer id, modelmap modelmap) { //查询要修改的老师 notice notice = noticeservice.detail(id); modelmap.addattribute("notice", notice); return "notice/edit"; } //根据id查询,跳转添加页面 @getmapping("/look/{id}") public string look(@pathvariable integer id, modelmap modelmap) { notice notice = noticeservice.detail(id); modelmap.addattribute("notice", notice); return "notice/look"; } //查询所有 @postmapping("/query") @responsebody public map<string, object> query(@requestbody notice notice) { list<notice> list = noticeservice.query(notice); integer count = noticeservice.count(notice); return mapcontrol.getinstance().success().put("data", list).put("count", count).getmap(); } //跳转列表页面 @getmapping("/list") public string list() { return "notice/list"; } }
登陆用户判断业务控制层:
@controller public class logincontroller { @autowired private userservice userservice; @autowired private teacherservice teacherservice; @autowired private studentservice studentservice; //跳转登录页面 @getmapping("/login") public string login() { return "login"; } //登录操作 @postmapping("/login") @responsebody public map<string, object> login(string username, string password, string captcha, string type, httpsession session) { //判断用户名、密码、用户类型、验证码是否为空 if (stringutils.isempty(username) || stringutils.isempty(password) || stringutils.isempty(captcha) || stringutils.isempty(type)) { return mapcontrol.getinstance().error("用户名或密码不能为空").getmap(); } //获取系统生成的验证码 string _captcha = (string) session.getattribute("captcha"); //先判断验证码是否正确 if (!(captcha.tolowercase()).equals(_captcha.tolowercase())) { //验证码错误 return mapcontrol.getinstance().error("验证码错误").getmap(); } //判断用户类型 if ("1".equals(type)) { //管理员验证登录 user user = userservice.login(username, md5utils.getmd5(password)); //对密码进行加密处理,因为数据库中存储的是加密后的密码 if (user != null) { session.setattribute("user", user); session.setattribute("type", 1); return mapcontrol.getinstance().success().add("data", user).getmap(); } else { return mapcontrol.getinstance().error("用户名或密码错误").getmap(); } } if ("2".equals(type)) { //老师验证登录 teacher teacher = teacherservice.login(username, md5utils.getmd5(password)); if (teacher != null) { session.setattribute("user", teacher); session.setattribute("type", "2"); return mapcontrol.getinstance().success().add("data", teacher).getmap(); } else { return mapcontrol.getinstance().error("用户名或密码错误").getmap(); } } if ("3".equals(type)) { //学生验证登录 student student = studentservice.login(username, md5utils.getmd5(password)); if (student != null) { session.setattribute("user", student); session.setattribute("type", "3"); return mapcontrol.getinstance().success().add("data", student).getmap(); } else { return mapcontrol.getinstance().error("用户名或密码错误").getmap(); } } return mapcontrol.getinstance().getmap(); } }
到此这篇关于java 实战项目之毕业设计管理系统的实现流程的文章就介绍到这了,更多相关java 毕业设计管理系统内容请搜索以前的文章或继续浏览下面的相关文章希望大家以后多多支持!