博主主页:猫头鹰源码
博主简介:Java领域优质创作者、博客专家、公司架构师、全网粉丝5万+、专注Java技术领域和毕业设计项目实战
主要内容:毕业设计(Javaweb项目|小程序等)、简历模板、学习资料、面试题库、技术咨询
项目介绍:
该系统创作于2022年3月,基于springboot技术,数据层为MyBatis,mysql数据库,具有完整的业务逻辑,适合选题:高校、学生选课、大学选课、课程等。
项目功能:
数据库表结构文档:
系统包含技术:
后端:springboot、mybatis
前端:layui,js,css等
开发工具:idea
数据库:mysql 5.7
JDK版本:jdk1.8
部分截图说明:
下面是登录注册
管理员-首页
管理员-学生管理
管理员-教师管理
管理员-课程管理
管理员-选课信息
学生-我的课程
学生-选课
部分代码:
拦截器
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
HttpSession session = request.getSession();
if(session.getAttribute("ad") != null){
return true;
}
// 不符合条件的给出提示信息,并转发到主页面
request.setAttribute("msg", "您还没有登录,请先登录!");
request.getRequestDispatcher("/gologin.jsp").forward(request, response);
//返回true通过,返回false拦截
return false;
}
课程操作
/**
* 分页查询
* pageIndex 当前页码
* pageSize 显示条数
*/
@RequestMapping(value = "/findCourse")
public String findCourse(Integer pageIndex, Integer pageSize,String cname, Model model,HttpServletRequest request) {
HttpSession session = request.getSession();
if(session.getAttribute("ad") == null){
session.setAttribute("msg", "对不起,请登录!");
return "login";
}
Map mp = new HashMap();
mp.put("cname",cname);
String type = (String)session.getAttribute("type");
if(type.equals("02")){
Teacher teacher = (Teacher)session.getAttribute("ad");
mp.put("tid",teacher.getId());
}
PageInfo<Course> pageList = courseService.findPageInfo(pageIndex,pageSize,mp);
model.addAttribute("pageList",pageList);
if(type.equals("02")){
Map mps = new HashMap();
Teacher teacher = (Teacher)session.getAttribute("ad");
mps.put("id",teacher.getId());
List<Teacher> teacherList = teacherService.queryFilter(mps);
model.addAttribute("teacherList",teacherList);
}else{
List<Teacher> teacherList = teacherService.getAll();
model.addAttribute("teacherList",teacherList);
}
return "CourseList";
}
/**
* 添加
*/
@RequestMapping(value = "/addCourse" ,method = RequestMethod.POST)
@ResponseBody
public String addCourse( @RequestBody Course course) {
try{
SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
course.setCreateTime(sf.format(new Date()));
courseService.addCourse(course);
return "200";
}catch (Exception e){
e.printStackTrace();
return "201";
}
}
/**
* 删除
*/
@RequestMapping( "/deleteCourse")
@ResponseBody
public String deleteCourse(String id) {
int d = courseService.deleteCourse(id);
return "CourseList";
}
/**
* 修改
*/
@RequestMapping( "/updateCourse")
@ResponseBody
public String updateCourse(@RequestBody Course course) {
try{
courseService.updateCourse(course);
return "200";
}catch (Exception e){
e.printStackTrace();
return "201";
}
}
/**
* 按照ID查询
*/
@RequestMapping( "/findCourseById")
@ResponseBody
public Course findCourseById(String id,Model model,HttpServletRequest request) {
Course course= courseService.findCourseById(id);
return course;
}
登录
/**
* 登录
* 将提交数据(username,password)写入Admin对象
*/
@RequestMapping(value = "/login")
public String login(Teacher teacher, Model model, HttpSession session, HttpServletRequest request) {
if(teacher.getUsername()==null || teacher.getUsername().length()<=0 ){
model.addAttribute("msg", "请输入登录名!");
return "login";
}
if(teacher.getPassword()==null || teacher.getPassword().length()<1){
model.addAttribute("msg", "请输入密码!");
return "login";
}
if(teacher.getType()==null || teacher.getType().length()<1){
model.addAttribute("msg", "请选择人员类型!");
return "login";
}
Map mp = new HashMap();
mp.put("username",teacher.getUsername());
mp.put("password",teacher.getPassword());
if(teacher.getType().equals("01")){
List<Admin> ad = adminService.queryFilter(mp);
if(ad!=null && ad.size()==1){
session.setAttribute("ad", ad.get(0));
session.setAttribute("type", "01");
return "homepage1";
}else{
model.addAttribute("msg", "请确定账户信息是否正确!");
return "login";
}
}else if(teacher.getType().equals("02")){
List<Teacher> ad = teacherService.queryFilter(mp);
if(ad!=null && ad.size()==1){
session.setAttribute("ad", ad.get(0));
session.setAttribute("type", "02");
return "homepage2";
}else{
model.addAttribute("msg", "请确定账户信息是否正确!");
return "login";
}
}else{
List<Student> ad = studentService.queryFilter(mp);
if(ad!=null && ad.size()==1){
session.setAttribute("ad", ad.get(0));
session.setAttribute("type", "03");
return "homepage3";
}else{
model.addAttribute("msg", "请确定账户信息是否正确!");
return "login";
}
}
}
以上就是部分功能展示,从整体上来看,本系统功能是十分完整的,界面设计简洁大方,交互友好,数据库设计也很合理,规模适中,代码工整,清晰,适合学习使用。
好了,今天就到这儿吧,小伙伴们点赞、收藏、评论,一键三连走起呀,下期见~~