基于javaweb+mysql的ssm+maven驾校预约管理系统(java+ssm+html+layui+bootstrap+mysql)

基于javaweb+mysql的ssm+maven驾校预约管理系统(java+ssm+html+layui+bootstrap+mysql)

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

基于javaweb+mysql的SSM+Maven驾校预约管理系统(java+ssm+html+layui+bootstrap+mysql)

项目介绍

本项目分为管理员、教练、学员三种角色, 管理员角色包含以下功能: 学员管理、教练管理、车辆管理、关系管理、车辆维修管理、个人中心等功能。

教练角色包含以下功能: 我的课程、我的学员、车辆中心、个人中心等功能。

学员角色包含以下功能: 预约课程等功能。

环境需要

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.数据库:MySql 5.7版本; 6.是否Maven项目:是;

技术栈

  1. 后端:Spring+SpringMVC+Mybatis 2. 前端:HTML+LayUI+bootstrap+jQuery

使用说明

  1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven; 若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中spring-database.xml配置文件中的数据库配置改为自己的配置; 4. 运行项目,在浏览器中输入http://localhost:8080/ 登录

}

/**
 * Created with IntelliJ IDEA.
 * User: lishuai
 * Description:
 * Version: V1.0
 */
@Controller
@RequestMapping(value = "/repair")
public class RepairController {
    private RepairService repairService;
    @Autowired
    public RepairController(RepairService repairService) {
        this.repairService = repairService;
    }

    /**
     * 获得当前车辆
     * @return
     */
    @RequestMapping(value = "/getlocalCart")
    @ResponseBody
    public Map<String,Object> getloaclCart(@RequestBody (required = false) Map map,HttpServletRequest request){

        return  repairService.getloaclCar(request);
    }

        }
        map.put("teacherId", teacher.getTeaid());

        Map<String, Object> mapjson = new HashMap<>();
        List<Map<String, Object>> data;
        data = detailMapper.selectDetailList(map);
        if (data.size() > 0) {
            mapjson.put("code", 200);
            mapjson.put("data", data);
        } else {
            mapjson.put("code", 201);
            mapjson.put("data", "无数据");
        }
        return mapjson;
    }

    /**
     * 课程的添加
     *
     * @param map
     * @param request
     * @return
     */
    public Map<String, Object> addDetail(Map map, HttpServletRequest request) {
        Teacher teacher = (Teacher) request.getSession().getAttribute("user");
        Map<String, Object> mapjson = new HashMap<>();
        //判断当前是否有车
        Map<String, Object> maprela = new HashMap<>();
        maprela.put("teacherId", teacher.getTeaid());
        Relationship relationship = relationshipMapper.contant(maprela).get(0);

        if (relationship == null) {
            mapjson.put("code", 201);
            mapjson.put("msg", "当前无车辆,请联系管理员分配车辆");
            return mapjson;
        }

        if (map == null) {
            map = new HashMap();
        }
        List<Detail> detailList = new ArrayList<>();
        Date courseDate = null;
//        课程时间转换
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

    /**
     * 课程预定
     * @param
     * @param request
     * @return
     */
    public Map<String, Object> orderCourse(Detail detail,HttpServletRequest request){
        Map<String, Object> mapjson = new HashMap<>();
//        先检查课程是否被预定
        Detail detailTmp=detailMapper.selectById(detail.getDetailid());
        Student student= (Student) request.getSession().getAttribute("user");

        Map map=new HashMap();
        map.put("studentId",student.getStuid());
        map.put("courseDate",detailTmp.getCourseDate().toString());
        System.out.println(">>>>>>>>>>>>>>>>>>>>>>>"+map);
        if(ordersMapper.getMyOrderDate(map).size()>0){
            mapjson.put("code",201);
            mapjson.put("msg","当前日期已有预约请选择其他时间");
            return mapjson;
        }

        if(detailTmp.getStusta().equals("1")){
            mapjson.put("code",201);
            mapjson.put("msg","此课程已被预约");
            return mapjson;
        }
//        检查预定课程时间有没有预定的课程

        detailTmp.setStusta("1");
        if(detailMapper.updateById(detailTmp)>0){
            //添加数据

           Orders orders=new Orders();
           orders.setStuid(student.getStuid());
           orders.setDetailid(detailTmp.getDetailid());
           orders.setStates(0);
           orders.setExtend1(new Timestamp(System.currentTimeMillis()));
            ordersMapper.insertByNull(orders);
            mapjson.put("code",200);
            mapjson.put("msg","添加成功");
        mapjson.put("code", 200);
        mapjson.put("data", teacherList);
        return mapjson;
    }

    /**
     * 通过id查找
     * @param teacher
     * @return
     */
    public Map<String, Object> getTeacher(Teacher teacher) {
        Map<String, Object> mapjson = new HashMap<>();
        Teacher teacherjson=teacherMapper.selectByTeaId(teacher.getTeaid());
        mapjson.put("code", 200);
        mapjson.put("data", teacherjson);
        return mapjson;
    }

    /**
     * 修改教练信息
     * @param teacher
     * @return
     */
    public Map<String, Object> updateTeacher(Teacher teacher){
        Map<String, Object> mapjson = new HashMap<>();
        if(teacherMapper.update(teacher)>0){
            mapjson.put("code",200);
            mapjson.put("msg","修改成功");
        }
        return mapjson;
    }
    /**
     * 离职
     * @param
     * @return
     */
    public Map<String, Object> getaway(Map map,HttpServletRequest request){
        Map<String, Object> mapjson = new HashMap<>();

        //获取总记录数
        map.put("studyLevel",1);
        if(studentMapper.selectforTeacherCount(map)>0){
            mapjson.put("code",201);
            mapjson.put("msg","当前有关联的学员");

        }else {
                flag = true;
            }
        }
//        if (flag&& Send.sendCode(mobileCode,phone)){
        if (flag) {
            //发送手机号到手机
            mapjson.put("code", 200);
            mapjson.put("number", mobileCode);
            mapCode.put("time", System.currentTimeMillis());
            mapCode.put("role", role);
            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)
    @ResponseBody
    public 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()+"");
     * 课程预定
     * @param
     * @param request
     * @return
     */
    public Map<String, Object> orderCourse(Detail detail,HttpServletRequest request){
        Map<String, Object> mapjson = new HashMap<>();
//        先检查课程是否被预定
        Detail detailTmp=detailMapper.selectById(detail.getDetailid());
        Student student= (Student) request.getSession().getAttribute("user");

        Map map=new HashMap();
        map.put("studentId",student.getStuid());
        map.put("courseDate",detailTmp.getCourseDate().toString());
        System.out.println(">>>>>>>>>>>>>>>>>>>>>>>"+map);
        if(ordersMapper.getMyOrderDate(map).size()>0){
            mapjson.put("code",201);
            mapjson.put("msg","当前日期已有预约请选择其他时间");
            return mapjson;
        }

        if(detailTmp.getStusta().equals("1")){
            mapjson.put("code",201);
            mapjson.put("msg","此课程已被预约");
            return mapjson;
        }
//        检查预定课程时间有没有预定的课程

        detailTmp.setStusta("1");
        if(detailMapper.updateById(detailTmp)>0){
            //添加数据

           Orders orders=new Orders();
           orders.setStuid(student.getStuid());
           orders.setDetailid(detailTmp.getDetailid());
           orders.setStates(0);
           orders.setExtend1(new Timestamp(System.currentTimeMillis()));
            ordersMapper.insertByNull(orders);
            mapjson.put("code",200);
            mapjson.put("msg","添加成功");
        }

        return mapjson;
    }
}

        return mapjson;
    }

    @RequestMapping(value = "/updatePasswordTeacher", method = RequestMethod.POST)
    @ResponseBody
    public Map<String, Object> updatePasswordTeacher(@RequestBody Map map, HttpServletRequest request) {
        Map<String, Object> mapjson = new HashMap<>();
        Teacher teacher = (Teacher) request.getSession().getAttribute("user");
        //判断原密码是否正确
        Teacher teacherTmp=teacherService.selectByPone(teacher);
        System.out.println(teacherTmp.getTeapwd());
        if(map.get("oldpassword").toString().equals(teacherTmp.getTeapwd())){
            //修改session的的密码
            teacherTmp.setTeapwd(map.get("newpassword").toString());

            request.getSession().setAttribute("user",teacherTmp);
            //修改数据库中的
            return teacherService.updateTeacher(teacherTmp);
        }
        else{
            mapjson.put("code",201);
            mapjson.put("msg","原密码错误");
            return mapjson;
        }

    }

    /**
     * 修改密码 学生
     * @param map
     * @param request
     * @return
     */
    @RequestMapping(value = "/updatePasswordStudent", method = RequestMethod.POST)
    @ResponseBody
    public Map<String, Object> updatePasswordStudent(@RequestBody Map map, HttpServletRequest request) {
        Map<String, Object> mapjson = new HashMap<>();
        Student student = (Student) request.getSession().getAttribute("user");
        //判断原密码是否正确
        Student studentTmp=studentService.getByPhone(student.getStuphone().toString());
        System.out.println(studentTmp.getStupwd());
        if(map.get("oldpassword").toString().equals(studentTmp.getStupwd())){
            //修改session的的密码
            studentTmp.setStupwd(map.get("newpassword").toString());

            request.getSession().setAttribute("user",studentTmp);
            //修改数据库中的
            return studentService.updateStudent(studentTmp);
        }

/**
 * Created with IntelliJ IDEA.
 * User: lishuai
 * Description:
 * Version: V1.0
 */
@Service
public class RepairService {
    final private RepairMapper repairMapper;
    final private CartMapper cartMapper;
    final private DetailMapper detailMapper;
    final private RelationshipMapper relationshipMapper;

    @Autowired
    public RepairService(RepairMapper repairMapper, CartMapper cartMapper, DetailMapper detailMapper, RelationshipMapper relationshipMapper) {
        this.repairMapper = repairMapper;
        this.cartMapper = cartMapper;
        this.detailMapper = detailMapper;
        this.relationshipMapper = relationshipMapper;
    }

    /**
     * 查询当前关联的车辆
     *
     * @param request
     * @return
     */
    public Map<String, Object> getloaclCar(HttpServletRequest request) {

        Map<String, Object> mapjson = new HashMap<>();
        Teacher teacher = (Teacher) request.getSession().getAttribute("user");
        Map<String, Object> map = new HashMap<>();
        map.put("teaId", teacher.getTeaid());
        List<Map<String, Object>> mapList = repairMapper.getlocalCart(map);
                flag = true;
                request.getSession().setAttribute("user", teacherRe);
            }

        }
        Map<String, Object> mapjson = new HashMap<>();
        if (flag) {
            mapjson.put("code", 200);
            mapjson.put("role", role);
        } else {
            mapjson.put("code", 201);
        }
        return mapjson;

    }

    /**
     * 教练 管理员的修改用户信息
     *
     * @param request
     * @return
     */

    @RequestMapping(value = "/teacherInfo", method = RequestMethod.POST)
    @ResponseBody
    public 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
     */
        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 (role.equals("student")) {
            if (studentService.getByPhone(phone) != null) {
                flag = true;
            }

        } else {
            Integer roleTmp = role.equals("admin") ? 1 : 0;
            teacher.setTearole(roleTmp);
            if (teacherService.selectByPone(teacher) != null) {
                flag = true;
            }
        }
//        if (flag&& Send.sendCode(mobileCode,phone)){
        if (flag) {
            //发送手机号到手机
            mapjson.put("code", 200);
            mapjson.put("number", mobileCode);
            mapCode.put("time", System.currentTimeMillis());
            mapCode.put("role", role);
            request.getSession().setAttribute("smscode", mapCode);
        } else {
            mapjson.put("code", 201);
            mapjson.put("msg", "手机号不存在,请查证");
        }
        return mapjson;
    }

    /**
     * 获得验证码 公用
     *
     * @param map
     * @param request
     * @return
     */

/**
 * Created with IntelliJ IDEA.
 * User: lishuai
 * Description:
 * Version: V1.0
 */
@Controller
@RequestMapping("/driver")
public class DriverController {
    private DriverService driverService;

    @Autowired
    public DriverController(DriverService driverService) {
        this.driverService = driverService;
    }

    @ResponseBody
    @RequestMapping(value = "getDriverList")
    public Map<String,Object> getDriverList(){
        Map<String,Object> mapjson=new HashMap<>();
        List<Driver> driverList=driverService.getDirverList();
        if(driverList.size()>0){
            mapjson.put("code",200);
            mapjson.put("data",driverList);
        }
        else {
            mapjson.put("code",201);
            mapjson.put("data","数据不存在");
        }
        return mapjson;

    }

    @ResponseBody
    public Map<String, Object> orderCourse(@RequestBody Detail detail, HttpServletRequest request){

        return detailService.orderCourse(detail,request);
    }
}

/**
 * Created with IntelliJ IDEA.
 * User: lishuai
 * Description:
 * Version: V1.0
 */
public class Interceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object o) throws Exception {

        HttpSession session = request.getSession();

//如果是登录页面则放行
        if (request.getRequestURI().equals("/login/login")|| request.getRequestURI().equals("/login/getCode")
        ||(request.getRequestURI().equals("/login/resetPassword")&&session.getAttribute("smscode")!=null)
        ) {
            return true;
        }

//如果用户已登录也放行
        if (session.getAttribute("user") != null) {
            return true;
        }
//用户没有登录挑转到登录页面
        response.sendRedirect("/index.html");
        return mapjson;

    }

    /**
     * 教练 管理员的修改用户信息
     *
     * @param request
     * @return
     */

    @RequestMapping(value = "/teacherInfo", method = RequestMethod.POST)
    @ResponseBody
    public 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 "redirect:/index.html";
    }

    /**
     * @param request
     * @return
     */
    @RequestMapping(value = "/getStudentInfo", method = RequestMethod.POST)
    @ResponseBody
    public Map<String, Object> getStudentInfo(HttpServletRequest request) {
        Map<String, Object> mapjson = new HashMap<>();
        Student student = (Student) request.getSession().getAttribute("user");
        mapjson.put("code", 200);
        mapjson.put("data", student);
        return mapjson;
    }

    /**
     * 获得验证码
     *
     * @param map
     * @param request
     * @return
     */
    @RequestMapping(value = "/getCode", method = RequestMethod.POST)
    @ResponseBody
    public Map<String, Object> getCode(@RequestBody Map<String, String> map, HttpServletRequest request) {
        String phone = map.get("phone");
        String role = map.get("role");
        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 (role.equals("student")) {
            if (studentService.getByPhone(phone) != null) {
                flag = true;
            }

        } else {
            Integer roleTmp = role.equals("admin") ? 1 : 0;
            teacher.setTearole(roleTmp);
            if (teacherService.selectByPone(teacher) != null) {
                flag = true;
            }
        }
//        if (flag&& Send.sendCode(mobileCode,phone)){
        if (flag) {
            //发送手机号到手机
            mapjson.put("code", 200);
            mapjson.put("number", mobileCode);
            mapCode.put("time", System.currentTimeMillis());
            mapCode.put("role", role);
            request.getSession().setAttribute("smscode", mapCode);
        } else {
            mapjson.put("code", 201);
            mapjson.put("msg", "手机号不存在,请查证");
        }

        return mapjson;
    }

    /**
     * 获得空闲车辆
     *
     * @param request
     * @return
     */
    public Map<String, Object> getNullCart(HttpServletRequest request) {
        Map map = new HashMap();
        Map mapjson = new HashMap();

        Teacher teacher = (Teacher) request.getSession().getAttribute("user");
        map.put("driverId", teacher.getTeadriver());
        List<Cart> carts = repairMapper.getNullCar(map);
        if (carts.size() > 0) {
            mapjson.put("code", 200);
            mapjson.put("data", carts);
        } else {
            mapjson.put("code", 201);
            mapjson.put("msg", "当前无备用车辆,请联系管理员");
        }
        return mapjson;
    }

    /**
     * 获得空闲车辆
     *
     * @param request
     * @return
     */
    public Map<String, Object> addReparir(Map map, HttpServletRequest request) {
        Map mapjson = new HashMap();
        //获得修改前的课程信息
        Map mapRelationship = new HashMap();
        Teacher teacher = (Teacher) request.getSession().getAttribute("user");
        mapRelationship.put("teacherId", teacher.getTeaid());
        List<Map<String, Object>> detailList = repairMapper.getDetail(mapRelationship);

        //1,取消当前关联记录
        Relationship relationship = relationshipMapper.contant(mapRelationship).get(0);
        relationship.setEndtime(new Timestamp(System.currentTimeMillis()));
        relationshipMapper.update(relationship);
        //添加新关系
        Relationship newrelationship = new Relationship();
        newrelationship.setStarttime(new Timestamp(System.currentTimeMillis()));
        newrelationship.setCartid(Integer.parseInt(map.get("newCarId").toString()));
        newrelationship.setTeacherid(teacher.getTeaid());
        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)
    @ResponseBody
    public Map<String, Object> updatePhone(HttpServletRequest request) {

        Map<String, Object> mapjson = new HashMap<>();

        Object object=request.getSession().getAttribute("user");
        //判断验证码手机是否合法
           orders.setStates(0);
           orders.setExtend1(new Timestamp(System.currentTimeMillis()));
            ordersMapper.insertByNull(orders);
            mapjson.put("code",200);
            mapjson.put("msg","添加成功");
        }

        return mapjson;
    }
}

/**
 * Created with IntelliJ IDEA.
 * User: lishuai
 * Description:
 * Version: V1.0
 */
@Service
public class RepairService {
    final private RepairMapper repairMapper;
    final private CartMapper cartMapper;
    final private DetailMapper detailMapper;
    final private RelationshipMapper relationshipMapper;

    @Autowired
    public RepairService(RepairMapper repairMapper, CartMapper cartMapper, DetailMapper detailMapper, RelationshipMapper relationshipMapper) {
        this.repairMapper = repairMapper;
    /**
     * 通过电话返回员工信息
     *
     * @param teacher
     * @return
     */
    public Teacher selectByPone(Teacher teacher) {

        return teacherMapper.selectByPhone(teacher);
    }

    /**
     * 修改密码
     *
     * @param phone
     * @param password
     * @param role
     * @return
     */
    public boolean updatePassword(String phone, String password, Integer role) {
        Teacher teacher = new Teacher();
        teacher.setTeaphone(phone);
        teacher.setTeapwd(password);
        teacher.setTearole(role);
        return teacherMapper.updatePassword(teacher) > 0;

    }

    /**
     * 教练添加
     *
     * @param teacher
     * @return
     */
    public Map<String, Object> addTeacher(Teacher teacher) {
        Map<String, Object> map = new HashMap<>();
        if (selectByPone(teacher) != null) {
            map.put("code", 201);
            map.put("msg", "手机号已存在");
            return map;

        }
        if (teacherMapper.insert(teacher) > 0) {
            map.put("code", 200);
            map.put("msg", "添加成功");
        } else {
            map.put("code", 201);

请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值