Java项目:122SpringBoot驾校预约管理系统

2024-01-17 19:04

本文主要是介绍Java项目:122SpringBoot驾校预约管理系统,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

博主主页:Java旅途
简介:分享计算机知识、学习路线、系统源码及教程
文末获取源码

一、项目介绍

驾校预约管理系统使用SpringBoot+Mybatis进行开发,系统提供三种角色,功能如下:

管理员:

  • 学员管理
  • 教练管理
  • 车辆管理
  • 教练车辆绑定
  • 车辆维修

教练:

  • 我的课程
  • 我的学员
  • 车辆报修

学员:

  • 预约练车
  • 我的预约
  • 取消预约
  • 练车记录

二、技术框架

  • 后端:SpringBoot,Mybatis
  • 前端:layui

三、安装教程

  1. 用idea打开项目
  2. 在idea中配置jdk环境
  3. 配置maven环境并下载依赖
  4. 新建数据库,导入数据库文件
  5. 在application.yml文件中将数据库账号密码改成自己本地的
  6. 启动运行。管理员账号密码 18811111111/123456,教练账号密码 15712345678/123456,学员账号密码 18888888888/123456

四、项目截图

image-20230720151747612

image-20230720151716684

image-20230720151804573

image-20230720152328820

五、相关代码

LoginController

package com.singulee.carschool.controller;import com.singulee.carschool.pojo.Student;
import com.singulee.carschool.pojo.Teacher;
import com.singulee.carschool.pojo.User;
import com.singulee.carschool.service.StudentService;
import com.singulee.carschool.service.TeacherService;
import com.singulee.carschool.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;/*** Created with IntelliJ IDEA.* User: lishuai* Date: 2019/03/19* Description:* Version: V1.0*/
@Controller
@RequestMapping("/login")
public class LoginController {final private StudentService studentService;final private TeacherService teacherService;final private UserService userService;@Autowiredpublic LoginController(StudentService studentService, TeacherService teacherService, UserService userService) {this.studentService = studentService;this.teacherService = teacherService;this.userService = userService;}/*** 登录  返回格式** @param map* @param request* @return*/@RequestMapping(value = "/login", method = RequestMethod.POST)@ResponseBodypublic Map<String, Object> login(@RequestBody Map<String, String> map, HttpServletRequest request) {boolean flag = false;String phone = map.get("phone");String password = map.get("password");User user = userService.findByUsername(phone);if (null != user && user.getPassword().equals(password)) {Integer userType = user.getUserType();if (userType == 1) {Student student = studentService.getByPhone(phone);if (student != null) {flag = true;student.setStupwd(user.getPassword());request.getSession().setAttribute("user", student);}} else {Teacher teacher = new Teacher();teacher.setTeaphone(phone);Integer roleTmp = user.getUserType() == 3 ? 1 : 0;teacher.setTearole(roleTmp);Teacher teacherRe = teacherService.selectByPone(teacher);if (teacherRe != null) {flag = true;teacher.setTeapwd(user.getPassword());request.getSession().setAttribute("user", teacherRe);}}}Map<String, Object> mapjson = new HashMap<>();if (flag) {mapjson.put("code", 200);mapjson.put("role", user.getUserType());} else {mapjson.put("code", 201);}return mapjson;}/*** 教练 管理员的修改用户信息** @param request* @return*/@RequestMapping(value = "/teacherInfo", method = RequestMethod.POST)@ResponseBodypublic Map<String, Object> teacherInfo(HttpServletRequest request) {Map<String, Object> mapjson = new HashMap<>();Teacher teacher = (Teacher) request.getSession().getAttribute("user");teacher.setTeapwd("");mapjson.put("code", 200);mapjson.put("data", teacher);return mapjson;}/*** 注销登录** @param request* @return*/@RequestMapping(value = "/logout")public String loginOut(HttpServletRequest request) {request.getSession().removeAttribute("user");return "/login.html";}/*** @param request* @return*/@RequestMapping(value = "/getStudentInfo", method = RequestMethod.POST)@ResponseBodypublic Map<String, Object> getStudentInfo(HttpServletRequest request) {Map<String, Object> mapjson = new HashMap<>();Student student = (Student) request.getSession().getAttribute("user");student.setStupwd("");mapjson.put("code", 200);mapjson.put("data", student);return mapjson;}/*** 获得验证码** @param map* @param request* @return*/@RequestMapping(value = "/getCode", method = RequestMethod.POST)@ResponseBodypublic Map<String, Object> getCode(@RequestBody Map<String, String> map, HttpServletRequest request) {String phone = map.get("phone");Map<String, Object> mapCode = new HashMap<>();Map<String, Object> mapjson = new HashMap<>();int mobileCode = (int) ((Math.random() * 9 + 1) * 100000);mapCode.put("number", mobileCode + "");mapCode.put("phone", phone);boolean flag = false;User user = userService.findByUsername(phone);if (user != null) {flag = true;}
//        if (flag&& Send.sendCode(mobileCode,phone)){if (flag) {//发送手机号到手机mapjson.put("code", 200);mapjson.put("number", mobileCode);mapCode.put("time", System.currentTimeMillis());System.out.println(mobileCode);request.getSession().setAttribute("smscode", mapCode);} else {mapjson.put("code", 201);mapjson.put("msg", "手机号不存在,请查证");}return mapjson;}/*** 获得验证码 公用** @param map* @param request* @return*/@RequestMapping(value = "/getPhoneCode", method = RequestMethod.POST)@ResponseBodypublic Map<String, Object> getPhoneCode(@RequestBody Map<String, String> map, HttpServletRequest request) {String phone = map.get("phone");Teacher teacher = new Teacher();teacher.setTeaphone(phone);Map<String, Object> mapCode = new HashMap<>();Map<String, Object> mapjson = new HashMap<>();int mobileCode = (int) ((Math.random() * 9 + 1) * 100000);mapCode.put("number", mobileCode + "");mapCode.put("phone", phone);boolean flag = false;
//        if (flag&& Send.sendCode(mobileCode,phone)){mapCode.put("time", System.currentTimeMillis() + "");mapjson.put("code", 200);mapjson.put("number", mobileCode + "");request.getSession().setAttribute("smscode", mapCode);
//    }return mapjson;}@RequestMapping(value = "/updatePhone", method = RequestMethod.POST)@ResponseBodypublic Map<String, Object> updatePhone(@RequestBody Map<String, String> map, HttpServletRequest request) {String phone = map.get("phone");String number = map.get("number");Map<String, Object> mapjson = new HashMap<>();Object object = request.getSession().getAttribute("user");//判断验证码手机是否合法Map<String, Object> mapSession = (Map<String, Object>) request.getSession().getAttribute("smscode");System.out.println(mapSession);System.out.println(map);if (mapSession.get("phone").toString().equals(phone) && mapSession.get("number").toString().equals(number) &&System.currentTimeMillis() - Long.parseLong(mapSession.get("time").toString()) < 60 * 1000) {if (object instanceof Student) {Student student = (Student) object;Student studenttmp = studentService.getByPhone(student.getStuphone());studenttmp.setStuphone(phone);request.getSession().setAttribute("user", studenttmp);return studentService.updateStudent(studenttmp);} else {Teacher teacher = (Teacher) object;Teacher teachertmp = teacherService.selectByPone(teacher);teachertmp.setTeaphone(phone);request.getSession().setAttribute("user", teachertmp);return teacherService.updateTeacher(teachertmp);}} else {mapjson.put("code", 201);mapjson.put("msg", "时间超时重新发送");}return mapjson;}/*** 获得用户的信息** @param request* @return*/@RequestMapping(value = "/getUserInfo", method = RequestMethod.POST)@ResponseBodypublic Map<String, Object> updatePhone(HttpServletRequest request) {Map<String, Object> mapjson = new HashMap<>();Object object = request.getSession().getAttribute("user");//判断验证码手机是否合法if (object instanceof Student) {Student student = (Student) object;mapjson.put("img", student.getStuimg());mapjson.put("name", student.getStuname());} else {Teacher teacher = (Teacher) object;mapjson.put("img", teacher.getTeaimg());mapjson.put("name", teacher.getTeaname());}return mapjson;}/*** 验证手机号和验证码** @param map* @param request* @return*/@RequestMapping(value = "/resetPassword", method = RequestMethod.POST)@ResponseBodypublic Map<String, Object> checkCode(@RequestBody Map<String, String> map, HttpServletRequest request) {Map<String, Object> mapjson = new HashMap<>();String phone = map.get("phone");String number = map.get("number");String password = map.get("password");Map<String, Object> mapSession = (Map<String, Object>) request.getSession().getAttribute("smscode");if (mapSession.get("phone").equals(phone) && mapSession.get("number").equals(number) &&System.currentTimeMillis() - Long.parseLong(mapSession.get("time").toString()) < 60 * 1000) {boolean action;action = userService.updatePassword(phone, password);if (action) {mapjson.put("code", 200);} else {mapjson.put("code", 202);}} else {request.getSession().removeAttribute("smscode");mapjson.put("code", 201);}return mapjson;}@RequestMapping(value = "/updatePasswordTeacher", method = RequestMethod.POST)@ResponseBodypublic Map<String, Object> updatePasswordTeacher(@RequestBody Map map, HttpServletRequest request) {Map<String, Object> mapjson = new HashMap<>();Teacher teacher = (Teacher) request.getSession().getAttribute("user");//判断原密码是否正确User user = userService.findByUsername(teacher.getTeaphone());System.out.println(user.getPassword());if (map.get("oldpassword").toString().equals(user.getPassword())) {//修改session的的密码teacher.setTeapwd(map.get("newpassword").toString());request.getSession().setAttribute("user", teacher);//修改数据库中的boolean flag = userService.updatePassword(user.getUsername(), teacher.getTeapwd());if (flag) {mapjson.put("code", 200);mapjson.put("msg", "修改成功!");return mapjson;} else {mapjson.put("code", 201);mapjson.put("msg", "修改失败!");return mapjson;}} else {mapjson.put("code", 201);mapjson.put("msg", "原密码错误");return mapjson;}}/*** 修改密码 学生** @param map* @param request* @return*/@RequestMapping(value = "/updatePasswordStudent", method = RequestMethod.POST)@ResponseBodypublic Map<String, Object> updatePasswordStudent(@RequestBody Map map, HttpServletRequest request) {Map<String, Object> mapjson = new HashMap<>();Student student = (Student) request.getSession().getAttribute("user");//判断原密码是否正确User user = userService.findByUsername(student.getStuphone());System.out.println(user.getPassword());if (map.get("oldpassword").toString().equals(user.getPassword())) {//修改session的的密码student.setStupwd(map.get("newpassword").toString());request.getSession().setAttribute("user", student);//修改数据库中的//修改数据库中的boolean flag = userService.updatePassword(user.getUsername(), student.getStupwd());if (flag) {mapjson.put("code", 200);mapjson.put("msg", "修改成功!");return mapjson;} else {mapjson.put("code", 201);mapjson.put("msg", "修改失败!");return mapjson;}} else {mapjson.put("code", 201);mapjson.put("msg", "原密码错误");return mapjson;}}@ResponseBody@RequestMapping(value = "/upload", method = RequestMethod.POST)public Map<String, Object> upload(HttpServletRequest request, @RequestParam("file") MultipartFile file) {Map<String, Object> map = new HashMap<>();//        String path=request.getSession().getServletContext().getRealPath("/");String path = request.getSession().getServletContext().getRealPath("/img");System.out.println(path);String fileName = UUID.randomUUID().toString().replaceAll("-", "") + file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));System.out.println(fileName);System.out.println(path);File targetFile = new File(path, fileName);if (!targetFile.exists()) {targetFile.mkdirs();}// 保存try {file.transferTo(targetFile);map.put("code", 200);map.put("data", fileName);} catch (Exception e) {e.printStackTrace();map.put("code", 201);}return map;}
}

大家点赞、收藏、关注、评论啦 、👇🏻点开下方卡片👇🏻关注后回复 105

这篇关于Java项目:122SpringBoot驾校预约管理系统的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/616909

相关文章

详解Java如何向http/https接口发出请求

《详解Java如何向http/https接口发出请求》这篇文章主要为大家详细介绍了Java如何实现向http/https接口发出请求,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 用Java发送web请求所用到的包都在java.net下,在具体使用时可以用如下代码,你可以把它封装成一

SpringBoot使用Apache Tika检测敏感信息

《SpringBoot使用ApacheTika检测敏感信息》ApacheTika是一个功能强大的内容分析工具,它能够从多种文件格式中提取文本、元数据以及其他结构化信息,下面我们来看看如何使用Ap... 目录Tika 主要特性1. 多格式支持2. 自动文件类型检测3. 文本和元数据提取4. 支持 OCR(光学

Java内存泄漏问题的排查、优化与最佳实践

《Java内存泄漏问题的排查、优化与最佳实践》在Java开发中,内存泄漏是一个常见且令人头疼的问题,内存泄漏指的是程序在运行过程中,已经不再使用的对象没有被及时释放,从而导致内存占用不断增加,最终... 目录引言1. 什么是内存泄漏?常见的内存泄漏情况2. 如何排查 Java 中的内存泄漏?2.1 使用 J

JAVA系统中Spring Boot应用程序的配置文件application.yml使用详解

《JAVA系统中SpringBoot应用程序的配置文件application.yml使用详解》:本文主要介绍JAVA系统中SpringBoot应用程序的配置文件application.yml的... 目录文件路径文件内容解释1. Server 配置2. Spring 配置3. Logging 配置4. Ma

Java 字符数组转字符串的常用方法

《Java字符数组转字符串的常用方法》文章总结了在Java中将字符数组转换为字符串的几种常用方法,包括使用String构造函数、String.valueOf()方法、StringBuilder以及A... 目录1. 使用String构造函数1.1 基本转换方法1.2 注意事项2. 使用String.valu

java脚本使用不同版本jdk的说明介绍

《java脚本使用不同版本jdk的说明介绍》本文介绍了在Java中执行JavaScript脚本的几种方式,包括使用ScriptEngine、Nashorn和GraalVM,ScriptEngine适用... 目录Java脚本使用不同版本jdk的说明1.使用ScriptEngine执行javascript2.

Spring MVC如何设置响应

《SpringMVC如何设置响应》本文介绍了如何在Spring框架中设置响应,并通过不同的注解返回静态页面、HTML片段和JSON数据,此外,还讲解了如何设置响应的状态码和Header... 目录1. 返回静态页面1.1 Spring 默认扫描路径1.2 @RestController2. 返回 html2

Spring常见错误之Web嵌套对象校验失效解决办法

《Spring常见错误之Web嵌套对象校验失效解决办法》:本文主要介绍Spring常见错误之Web嵌套对象校验失效解决的相关资料,通过在Phone对象上添加@Valid注解,问题得以解决,需要的朋... 目录问题复现案例解析问题修正总结  问题复现当开发一个学籍管理系统时,我们会提供了一个 API 接口去

Java操作ElasticSearch的实例详解

《Java操作ElasticSearch的实例详解》Elasticsearch是一个分布式的搜索和分析引擎,广泛用于全文搜索、日志分析等场景,本文将介绍如何在Java应用中使用Elastics... 目录简介环境准备1. 安装 Elasticsearch2. 添加依赖连接 Elasticsearch1. 创

Spring核心思想之浅谈IoC容器与依赖倒置(DI)

《Spring核心思想之浅谈IoC容器与依赖倒置(DI)》文章介绍了Spring的IoC和DI机制,以及MyBatis的动态代理,通过注解和反射,Spring能够自动管理对象的创建和依赖注入,而MyB... 目录一、控制反转 IoC二、依赖倒置 DI1. 详细概念2. Spring 中 DI 的实现原理三、