java实战之课程在线学习系统的实现-亚博电竞手机版

目录

  • 一、前言
    • 项目介绍
    • 项目运行
  • 二、效果图展示
  • 三、核心代码
    • 用户管理控制层
    • 角色管理控制层
    • 课程管理控制层

一、前言

项目介绍

采用springboot spring mybatis thyeleaf实现的在线学习系统,一共2个身份。

管理员登录系统后可以管理所有用户信息,管理角色信息,添加修改管理课件信息,学生学习培训批次管理,成绩导入管理

学生登录系统后可以查询自己的个人信息,查询课件列表学习,查询我的培训记录,查询自己的成绩

采用springboot框架实现 前台模板用的thymeleaf 数据库层采用mybatis框架 注解模式

upload文件夹放入d盘根目录!

项目运行

登录地址: http://localhost:8080/th/login

管理员账号和密码: admin admin

学生登录账号: 1314 密码: 123456

二、效果图展示

三、核心代码

用户管理控制层

@controller @requestmapping("/user") public class usercontroller { @autowired private userservice userservice; @autowired private powerservice powerservice; @autowired private roleservice roleservice; @autowired private noticeservice noticeservice; @requestmapping("/main") public string res(httpservletrequest request){ string time = dateutil.getstringtoday(); request.getsession().setattribute("time", time); notice notice = new notice(); list list = noticeservice.queryall(notice); notice = list.get(0); user user = userservice.selectbyprimarykey(notice.getuserid()); notice.setuserid(user.getname()); request.getsession().setattribute("notice", notice); return "main"; } @requestmapping("/changepa") public string res1(){ return "changepass"; } @requestmapping("/login") public modelandview login(httpservletrequest request,string id,string password) throws exception{ modelandview mav = new modelandview(); user user1 = userservice.selectbyprimarykey(id); if(user1 == null || !password.equals(user1.getpassword())){ mav.setviewname("index"); request.getsession().setattribute("info", "error"); return mav; }else{ role role = new role(); role.setroleid(user1.getroleid()); list list =roleservice.queryall(role); role =list.get(0); request.getsession().setattribute("rolename", role.getrolename()); power power = powerservice.selectbyprimarykey(role.getpowerid()); if(!stringutil.isnullorempty(power.getpower())){ request.getsession().setattribute("power", power.getpower()); } string time = dateutil.getstringtoday(); request.getsession().setattribute("time", time); request.getsession().setattribute("user", user1); mav.setviewname("redirect:/user/main"); } return mav; } @requestmapping("/updatestudent") public string update(user user){ userservice.updatebyprimarykey(user); return "redirect:/user/student"; } @requestmapping("/updateteacher") public string updatet(user user){ userservice.updatebyprimarykey(user); return "redirect:/user/teacher"; } @requestmapping("/updatepa") public string updatepa(string userid,string password){ user user = new user(); system.out.println(userid); user user1 = userservice.selectbyprimarykey(userid); user1.setpassword(password); userservice.updatebyprimarykey(user1); return "main"; } @requestmapping("/delete") public string delete(string id){ userservice.deletebyprimarykey(id); return "redirect:/user/queryall"; } @requestmapping("/teacher") public string queryallteacher(httpservletrequest request,user user){ list list = userservice.queryallteacher(user); request.setattribute("list", list); if(null != user.getname()){ request.setattribute("name", user.getname()); } if(null != user.getmobile()){ request.setattribute("mobile", user.getmobile()); } return "teacher"; } @responsebody @requestmapping("/jsonteacher") public string queryallteacherjson(httpservletrequest request,user user){ list list = userservice.queryallteacher(user); jsonobject json = new jsonobject(); return json.tojsonstring(list); } @requestmapping("/student") public string queryallstudent(httpservletrequest request,user user){ list list = userservice.queryallstudent(user); request.setattribute("list", list); if(null != user.getname()){ request.setattribute("name", user.getname()); } if(null != user.getmobile()){ request.setattribute("mobile", user.getmobile()); } return "student"; } @requestmapping("/addteacher") public string adduser(user user){ string password = "123456"; user.setpassword(password); user.settype(constans.teacher); userservice.insert(user); return "redirect:/user/teacher"; } @requestmapping("/addstudent") public string addstudent(user user){ string password = "123456"; user.setpassword(password); user.settype(constans.student); userservice.insert(user); return "redirect:/user/student"; } @responsebody @requestmapping("/queryone") public string queryone(string id){ user user = new user(); user.setid(id); list list = userservice.queryall(user); user = list.get(0); jsonobject json = new jsonobject(); string data = json.tojsonstring(user); return data; } @requestmapping("/quit") public modelandview quit(httpservletrequest request) throws exception{ modelandview mav = new modelandview(); httpsession session1 = request.getsession(); session1.invalidate(); request.getsession().setattribute("info", "quit"); mav.setviewname("index"); return mav; } }

角色管理控制层

@controller @requestmapping("/role") public class rolecontroller { @autowired private roleservice depotservice; @autowired private powerservice powerservice; @requestmapping("/update") public string update(string id,string rolename,string powercontent){ role role = new role(); role.setroleid(id); role.setrolename(rolename); depotservice.update(role); list list = depotservice.queryall(role); role role1 = list.get(0); power power = new power(); if(powercontent.indexof("110") != -1){ powercontent = powercontent ",1100"; } if(powercontent.indexof("120") != -1){ powercontent = powercontent ",1200"; } if(powercontent.indexof("130") != -1){ powercontent = powercontent ",1300"; } if(powercontent.indexof("140") != -1){ powercontent = powercontent ",1400"; } if(powercontent.indexof("150") != -1){ powercontent = powercontent ",1500"; } power.setpower(powercontent); power.setroleid(role1.getpowerid()); powerservice.update(power); return "redirect:/role/queryall"; } @requestmapping("/delete") public string delete(string id){ depotservice.deletebyprimarykey(id); return "redirect:/role/queryall"; } @requestmapping("/queryall") public string queryall(httpservletrequest request,role role){ list list = depotservice.queryall(role); request.setattribute("list", list); if(null != role.getrolename()){ request.setattribute("rolename", role.getrolename()); } return "role"; } @requestmapping("/add") public string add(string roleid,string rolename,string powercontent){ power power1 = new power(); role role = new role(); string powerid = string.valueof(math.random()).substring(2, 8); role.setroleid(string.valueof(math.random()).substring(2, 6)); role.setpowerid(powerid); role.setrolename(rolename); power1.setpower(powercontent); power1.setroleid(powerid); power1.setid(string.valueof(math.random()).substring(2, 8)); powerservice.insert(power1); depotservice.insert(role); return "redirect:/role/queryall"; } @responsebody @requestmapping("/queryone") public string queryone(string id){ jsonobject json = new jsonobject(); role depot = new role(); power power = new power(); power.setid(id); system.out.println(id); depot.setroleid(id); list list = depotservice.queryall(depot); role role1 = list.get(0); power power1 = powerservice.selectbyprimarykey(role1.getpowerid()); string name = role1.getrolename(); role1.setpowerid(power1.getpower()); string data = json.tojsonstring(role1); return data; } @responsebody @requestmapping("/getall") public string getall(role role){ jsonobject json = new jsonobject(); list list = depotservice.queryall(role); string jsonq = json.tojsonstring(list); system.out.println(jsonq); return jsonq; } }

课程管理控制层

@controller @requestmapping("/course") public class coursecontroller { @autowired private courseservice courseservice; @autowired private curelationservice curelationservice; @autowired private coursecommentservice coursecommentservice; @responsebody @requestmapping("/queryonecom") public string queryonecom(string id){ coursecomment course = new coursecomment(); course.setid(id); system.out.println("====================================" id); list list = coursecommentservice.queryall(course); course = list.get(0); jsonobject json = new jsonobject(); return json.tojsonstring(course); } @requestmapping("addcomment") public string addcomment(httpservletrequest request, coursecomment coursecomment){ user user = (user) request.getsession().getattribute("user"); coursecomment.setcreatetime(dateutil.getstringtoday()); coursecomment.setuserid(user.getname()); coursecomment.setid(string.valueof(math.random()).substring(2,10)); coursecommentservice.insert(coursecomment); return "redirect:/course/suggeetion"; } @responsebody @requestmapping("jsoncourse") public strwww.cppcns.coming jsoncourse(httpservletrequest request, curelation course){ user user = (user) request.getsession().getattribute("user"); /*string type = "1"; if ("1".equals(user.gettype())){ type="2"; } course.settype(type); course.setuserid(user.getid());*/ list curelationlist = curelationservice.queryall(course); list datalist = new arraylist<>(); for (int i = 0; i < curelationlist.size(); i ) { course curelation = courseservice.selectbyprimarykey(curelationlist.get(i).getcourseid()); datalist.add(curelation); } jsonobject json = new jsonobject(); return json.tojsonstring(datalist); } @requestmapping("suggeetion") public string suggeetion(httpservletrequest request, coursecomment coursecomment){ list coursecomments = coursecommentservice.queryall(coursecomment); request.setattribute("list",coursecomments); return "suggeetion"; } @requestmapping("view") public string view(httpservletrequest request){ user user = (user) request.getsession().getattribute("user"); string type = "1"; if ("1".equals(user.gettype())){ type="2"; } list> list=curelationservice.courseview(type,user.getid()); request.setattribute("list",list); return "courseview"; } @requestmapping("deletecomment") public string deletecomment(string id){ coursecommentservice.deletebyprimarykey(id); return "redirect:/course/suggeetion"; } @requestmapping("queryall") public string queryall(httpservletrequest request, course course){ list list = courseservice.queryall(course); request.setattribute("list",list); return "course"; } @requestmapping("/receive") public string receive(httpservletrequest request, httpservletresponse response, multipartfile file){ try { //也可以用request获取上传文件 //multipartfile filefile = request.getfile("file"); //这里是页面的name属性 //转换成输入流 inputstream is = file.getinputstream(); //得到excel workbook workbook = workbook.getworkbook(is); //得到sheet sheet sheet = workbook.getsheet(0); //得到列数 int colsnum = sheet.getcolumns(); //得到行数 int rowsnum = sheet.getrows(); //单元格 cell cell; cell cell1; list

以上就是java实战之课程在线学习系统的实现的详细内容,更多关于java课程在线学习系统的资料请关注亚博电竞手机版其它相关文章!

展开全文
内容来源于互联网和用户投稿,文章中一旦含有亚博电竞手机版的联系方式务必识别真假,本站仅做信息展示不承担任何相关责任,如有侵权或涉及法律问题请联系亚博电竞手机版删除

最新文章

网站地图