基于javaweb+mysql的springboot教室预订管理系统(java+springboot+maven+vue+mysql)

基于javaweb+mysql的springboot教室预订管理系统(java+springboot+maven+vue+mysql)

运行环境

Java≥8、MySQL≥5.7、Node.js≥10

开发工具

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

前端:WebStorm/VSCode/HBuilderX等均可

适用

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

功能说明

基于javaweb+mysql的SpringBoot教室预订管理系统(java+springboot+maven+vue+mysql)

一、项目运行 环境配置:

Jdk1.8 + Tomcat8.5 + Mysql + HBuilderX(Webstorm也行)+ Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)。

项目技术:

Spring + SpringBoot+ mybatis + Maven + Vue 等等组成,B/S模式 + Maven管理等等。

            // 4.抛出异常
            throw new LoginFailException(CrowdConstant.MESSAGE_ACCESS_FORBIDEN);
        }
        return true;
    }
}

/**
 * @Description
 */
@RestController
public class ScheduleController {
    @Autowired
    ScheduleService scheduleService;

    @RequestMapping(value = "/schedule",method = RequestMethod.GET)
    public Msg getALLSchedules(){
        List<Schedule> schedules=scheduleService.getAllSchedules();
        return Msg.success().data("schedule",schedules);
    }
}

public class ScheduleController {
    @Autowired
    ScheduleService scheduleService;

    @RequestMapping(value = "/schedule",method = RequestMethod.GET)
    public Msg getALLSchedules(){
        List<Schedule> schedules=scheduleService.getAllSchedules();
        return Msg.success().data("schedule",schedules);
    }
}

/**
 * @Description
 */
@RestController
@RequestMapping(value = "/room")
public class RoomController {
    @Autowired
    RoomService roomService;

    @RequestMapping(value = "/allRoom",method = RequestMethod.GET)
    public Msg getALLBlogs(){
        List<Room> rooms=roomService.getAllRooms();
        return Msg.success().data("room",rooms);
    }
}

                            }
                            int result = classUseService.addClassUse(rid, tid, beginTime ,  endTime, dayTime, classUse.setState(1),remark);
                        }
                        else { return Msg.fail().msg("您申请的日期有已过的日期");}
                    } catch (Exception e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }

                }
            }
        }

        return Msg.success();
    }

    @RequestMapping(value = "/displayAll",method = RequestMethod.GET)
    public Msg displayAll(){
        List<ClassUse> classUses=classUseService.displayAll();
        return Msg.success().data("classUse",classUses);
    }

    @RequestMapping(value = "/agreeById",method = RequestMethod.PUT)
    public Msg updateById(@RequestParam("id") int id,@RequestParam("name") String name){
        ClassUse classUse=classUseService.selectStateById(id);
        int state =classUse.getState();
        System.out.println(classUse.toString());
        if (state==0){return Msg.fail().msg("此机房未被申请");}
        else if (state==2){return  Msg.fail().msg("此机房已被申请");}
        else{
            int result = classUseService.updateById(id);
            return Msg.success();
        }
    }

    @RequestMapping(value = "/refuseById",method = RequestMethod.PUT)
    public Msg refuseById(@RequestParam("id") int id,@RequestParam("name") String name){
        int result = classUseService.refuseById(id);
        return Msg.success();
    }

    @RequestMapping(value = "/displayUse",method = RequestMethod.GET)
    public Msg displayUse(){
    ScheduleService scheduleService;

    @RequestMapping(value = "/schedule",method = RequestMethod.GET)
    public Msg getALLSchedules(){
        List<Schedule> schedules=scheduleService.getAllSchedules();
        return Msg.success().data("schedule",schedules);
    }
}

/**
 * @Description
 */
@RestController
@RequestMapping(value = "/room")
public class RoomController {
    @Autowired
    RoomService roomService;

    @RequestMapping(value = "/allRoom",method = RequestMethod.GET)
    public Msg getALLBlogs(){
        List<Room> rooms=roomService.getAllRooms();
        return Msg.success().data("room",rooms);
    }
}

        try {
            String jwtToken = request.getHeader("token");
            if (StringUtils.isEmpty(jwtToken)) return false;
            Jwts.parser().setSigningKey(APP_SECRET).parseClaimsJws(jwtToken);
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
        return true;
    }

    /**
     * 根据token获取id
     *
     * @param request
     * @return
     */
    public static String getMemberIdByJwtToken(HttpServletRequest request) {
        String jwtToken = request.getHeader("token");
        if (StringUtils.isEmpty(jwtToken)) return "";
        Jws<Claims> claimsJws = Jwts.parser().setSigningKey(APP_SECRET).parseClaimsJws(jwtToken);
        Claims claims = claimsJws.getBody();
        return (String) claims.get("id");
    }
}

/**
 * @Description
 */
@RestController
public class LoginController {
            if (days.isEmpty()) {
                // 2.2 为空,返回失败消息
                return Msg.fail().msg("您未输入日期");
            } else {
                for (Date dayTime : days
                ) {

                    try {
                        // 3. 将此时的教室编号、日期数据和时间数据传入数据库,
                        System.out.println(dayTime);
                        // 与当前时间相比较
                        String applyTime=dayTime+" "+beginTime;
                        String currentTime= LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
                        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//注意月份是MM
//                        simpleDateFormat.parse(applyTime);
                        int res=applyTime.compareTo(currentTime);
                        java.sql.Time time = new java.sql.Time(simpleDateFormat.parse(applyTime).getTime());
                        System.out.println(new java.sql.Time(simpleDateFormat.parse(applyTime).getTime()));
                        if(res>0) {
                            System.out.println("applyTime>currentTime");
                            List<Integer> currentState = classUseService.selectClassState(rid, beginTime, endTime, dayTime);
                            for (int states : currentState) {
                                // 3.1 看是否有值且state的值为1或2
                                if ((states == 1) || (states == 2))
                                    return Msg.fail().msg("抱歉!" + dayTime + " " + beginTime + "-" + endTime + " 该机房已被选择");
                            }
                            int result = classUseService.addClassUse(rid, tid, beginTime ,  endTime, dayTime, classUse.setState(1),remark);
                        }
                        else { return Msg.fail().msg("您申请的日期有已过的日期");}
                    } catch (Exception e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }

                }
            }
            }
        }

        return Msg.success();
    }

    @RequestMapping(value = "/displayAll",method = RequestMethod.GET)
    public Msg displayAll(){
        List<ClassUse> classUses=classUseService.displayAll();
        return Msg.success().data("classUse",classUses);
    }

    @RequestMapping(value = "/agreeById",method = RequestMethod.PUT)
    public Msg updateById(@RequestParam("id") int id,@RequestParam("name") String name){
        ClassUse classUse=classUseService.selectStateById(id);
        int state =classUse.getState();
        System.out.println(classUse.toString());
        if (state==0){return Msg.fail().msg("此机房未被申请");}
        else if (state==2){return  Msg.fail().msg("此机房已被申请");}
        else{
            int result = classUseService.updateById(id);
            return Msg.success();
        }
    }

    @RequestMapping(value = "/refuseById",method = RequestMethod.PUT)
    public Msg refuseById(@RequestParam("id") int id,@RequestParam("name") String name){
        int result = classUseService.refuseById(id);
        return Msg.success();
    }

    @RequestMapping(value = "/displayUse",method = RequestMethod.GET)
    public Msg displayUse(){
        List<ClassUse> classUses=classUseService.displayUse();
        return Msg.success().data("classUse",classUses);
    }
}

    public Msg refuseById(@RequestParam("id") int id,@RequestParam("name") String name){
        int result = classUseService.refuseById(id);
        return Msg.success();
    }

    @RequestMapping(value = "/displayUse",method = RequestMethod.GET)
    public Msg displayUse(){
        List<ClassUse> classUses=classUseService.displayUse();
        return Msg.success().data("classUse",classUses);
    }
}

/**
 * @Description jwt实现登录认证
 */
public class JwtUtils {
    // token过期时间
    public static final long EXPIRE = 1000 * 60 * 60 * 24;
    // 密钥 公司自己的不一样
    public static final String APP_SECRET = "ukc8BDbRigUDaY6pZFfWus2jZWLPHO";

    /**
     * 生成token字符串的方法
     *
     * @param id       用户id
     * @param nickname 用户
     * @return
     */
    public static String getJwtToken(String id, String nickname) {
        String JwtToken = Jwts.builder()
                // 设置token头信息
                .setHeaderParam("typ", "JWT")
                .setHeaderParam("alg", "HS256")
                // 设置过期时间
                .setSubject("admin-login")    // 需要更改   分类
                .setIssuedAt(new Date())
                .setExpiration(new Date(System.currentTimeMillis() + EXPIRE))
                .claim("id", id)    // token主体部分,存储用户信息
                .claim("nickname", nickname)
                .signWith(SignatureAlgorithm.HS256, APP_SECRET)
                .compact();
        return JwtToken;
    }

    /**
     * 判断token是否存在与有效
     *
     * @param jwtToken
     * @return
     */
    public static boolean checkToken(String jwtToken) {
        if (StringUtils.isEmpty(jwtToken)) return false;
        try {
            Jwts.parser().setSigningKey(APP_SECRET).parseClaimsJws(jwtToken);
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
        return true;
    }

    /**
     * 判断token是否存在与有效
     *
     * @param request
     * @return
     */
    public static boolean checkToken(HttpServletRequest request) {
        try {
            String jwtToken = request.getHeader("token");
            if (StringUtils.isEmpty(jwtToken)) return false;
            Jwts.parser().setSigningKey(APP_SECRET).parseClaimsJws(jwtToken);
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
        return true;
    }

    /**
     * 根据token获取id
     *

                    try {
                        // 3. 将此时的教室编号、日期数据和时间数据传入数据库,
                        System.out.println(dayTime);
                        // 与当前时间相比较
                        String applyTime=dayTime+" "+beginTime;
                        String currentTime= LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
                        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//注意月份是MM
//                        simpleDateFormat.parse(applyTime);
                        int res=applyTime.compareTo(currentTime);
                        java.sql.Time time = new java.sql.Time(simpleDateFormat.parse(applyTime).getTime());
                        System.out.println(new java.sql.Time(simpleDateFormat.parse(applyTime).getTime()));
                        if(res>0) {
                            System.out.println("applyTime>currentTime");
                            List<Integer> currentState = classUseService.selectClassState(rid, beginTime, endTime, dayTime);
                            for (int states : currentState) {
                                // 3.1 看是否有值且state的值为1或2
                                if ((states == 1) || (states == 2))
                                    return Msg.fail().msg("抱歉!" + dayTime + " " + beginTime + "-" + endTime + " 该机房已被选择");
                            }
                            int result = classUseService.addClassUse(rid, tid, beginTime ,  endTime, dayTime, classUse.setState(1),remark);
                        }
                        else { return Msg.fail().msg("您申请的日期有已过的日期");}
                    } catch (Exception e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }

                }
            }
        }

        return Msg.success();
    }

    @RequestMapping(value = "/displayAll",method = RequestMethod.GET)
    public Msg displayAll(){
        List<ClassUse> classUses=classUseService.displayAll();
        return Msg.success().data("classUse",classUses);
    }

    @RequestMapping(value = "/agreeById",method = RequestMethod.PUT)

/**
 * @Description
 */
@RestController
public class LoginController {
    @Autowired
    AdminService adminService;

    @Autowired
    TeacherService teacherService;

    @RequestMapping(value = "/doLogin",method = RequestMethod.POST)
    public Msg Login(
            @RequestParam("inputName")String inputName,
            @RequestParam("inputPassWord")String inputPassWord,
            @RequestParam("type")int type
    ){
        //将传来的表单数据用md5加密
        String userPswdForm = CrowdUtil.md5(inputPassWord);
        System.out.println("用户名:"+inputName+"\n 用户密码:"+userPswdForm+"\n button的id值"+type);
        if (type==2){
            List<Admin> admins = adminService.getAdminByLogin(inputName,userPswdForm);
            if (admins==null||admins.size()==0) {
                throw new LoginFailException(CrowdConstant.MESSAGE_LOGIN_FAILED);
            }
            else {
                Admin admin = admins.get(0);
                // 生成Token
                admin.setToken(JwtUtils.getJwtToken(admin.getName(), admin.getPassword()));
                return Msg.success().data("admin", admin);
            }
        }
        else if(type==1) {
            List<Teacher> teachers = teacherService.getTeacherByLogin(inputName,userPswdForm);
            if (teachers==null||teachers.size()==0) {
                throw new LoginFailException(CrowdConstant.MESSAGE_LOGIN_FAILED);
            }
            else {
                Teacher teacher = teachers.get(0);
                // 生成Token
                    } catch (Exception e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }

                }
            }
        }

        return Msg.success();
    }

    @RequestMapping(value = "/displayAll",method = RequestMethod.GET)
    public Msg displayAll(){
        List<ClassUse> classUses=classUseService.displayAll();
        return Msg.success().data("classUse",classUses);
    }

    @RequestMapping(value = "/agreeById",method = RequestMethod.PUT)
    public Msg updateById(@RequestParam("id") int id,@RequestParam("name") String name){
        ClassUse classUse=classUseService.selectStateById(id);
        int state =classUse.getState();
        System.out.println(classUse.toString());
        if (state==0){return Msg.fail().msg("此机房未被申请");}
        else if (state==2){return  Msg.fail().msg("此机房已被申请");}
        else{
            int result = classUseService.updateById(id);
            return Msg.success();
        }
    }

    @RequestMapping(value = "/refuseById",method = RequestMethod.PUT)
    public Msg refuseById(@RequestParam("id") int id,@RequestParam("name") String name){

    @Override
    public void destroy() {

    }

}

/**
 * @Description
 */
public class LoginInterceptor extends HandlerInterceptorAdapter {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
            throws Exception {
        // 1.通过request对象获取Session对象
        HttpSession session=request.getSession();
        // 2.尝试从Session域中User对象
        Admin admin = (Admin) session.getAttribute(CrowdConstant.ATTR_NAME_LOGIN_ADMIN);
        // 3.判断User对象是否为空
        if (admin==null){
            // 4.抛出异常
            throw new LoginFailException(CrowdConstant.MESSAGE_ACCESS_FORBIDEN);
        }
        return true;
    }
}

                    try {
                        // 3. 将此时的教室编号、日期数据和时间数据传入数据库,
                        System.out.println(dayTime);
                        // 与当前时间相比较
                        String applyTime=dayTime+" "+beginTime;
                        String currentTime= LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
                        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//注意月份是MM
//                        simpleDateFormat.parse(applyTime);
                        int res=applyTime.compareTo(currentTime);
                        java.sql.Time time = new java.sql.Time(simpleDateFormat.parse(applyTime).getTime());
                        System.out.println(new java.sql.Time(simpleDateFormat.parse(applyTime).getTime()));
                        if(res>0) {
                            System.out.println("applyTime>currentTime");
                            List<Integer> currentState = classUseService.selectClassState(rid, beginTime, endTime, dayTime);
                            for (int states : currentState) {
                                // 3.1 看是否有值且state的值为1或2
                                if ((states == 1) || (states == 2))
                                    return Msg.fail().msg("抱歉!" + dayTime + " " + beginTime + "-" + endTime + " 该机房已被选择");
                            }
                            int result = classUseService.addClassUse(rid, tid, beginTime ,  endTime, dayTime, classUse.setState(1),remark);
                        }
                        else { return Msg.fail().msg("您申请的日期有已过的日期");}
                    } catch (Exception e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }

                }
            }
        }

        return Msg.success();
    }

    @RequestMapping(value = "/displayAll",method = RequestMethod.GET)
    public Msg displayAll(){
        List<ClassUse> classUses=classUseService.displayAll();
}

/**
 * @Description
 */
@RestController
@RequestMapping(value = "/room")
public class RoomController {
    @Autowired
    RoomService roomService;

    @RequestMapping(value = "/allRoom",method = RequestMethod.GET)
    public Msg getALLBlogs(){
        List<Room> rooms=roomService.getAllRooms();
        return Msg.success().data("room",rooms);
    }
}

/**
        Jws<Claims> claimsJws = Jwts.parser().setSigningKey(APP_SECRET).parseClaimsJws(jwtToken);
        Claims claims = claimsJws.getBody();
        return (String) claims.get("id");
    }
}

/**
 * @Description
 */
@RestController
public class LoginController {
    @Autowired
    AdminService adminService;

    @Autowired
    TeacherService teacherService;

    @RequestMapping(value = "/doLogin",method = RequestMethod.POST)
    public Msg Login(
            @RequestParam("inputName")String inputName,
            @RequestParam("inputPassWord")String inputPassWord,
            @RequestParam("type")int type
    ){
        //将传来的表单数据用md5加密
        String userPswdForm = CrowdUtil.md5(inputPassWord);
        System.out.println("用户名:"+inputName+"\n 用户密码:"+userPswdForm+"\n button的id值"+type);
        if (type==2){
            List<Admin> admins = adminService.getAdminByLogin(inputName,userPswdForm);
            if (admins==null||admins.size()==0) {
                throw new LoginFailException(CrowdConstant.MESSAGE_LOGIN_FAILED);

/**
 * @Description
 */
@RestController
public class ScheduleController {
    @Autowired
    ScheduleService scheduleService;

    @RequestMapping(value = "/schedule",method = RequestMethod.GET)
    public Msg getALLSchedules(){
        List<Schedule> schedules=scheduleService.getAllSchedules();
        return Msg.success().data("schedule",schedules);
    }
}

/**
 * @Description
 */
@RestController
@RequestMapping(value = "/room")
public class RoomController {
    @Autowired
    RoomService roomService;
        }
        return true;
    }

    /**
     * 判断token是否存在与有效
     *
     * @param request
     * @return
     */
    public static boolean checkToken(HttpServletRequest request) {
        try {
            String jwtToken = request.getHeader("token");
            if (StringUtils.isEmpty(jwtToken)) return false;
            Jwts.parser().setSigningKey(APP_SECRET).parseClaimsJws(jwtToken);
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
        return true;
    }

    /**
     * 根据token获取id
     *
     * @param request
     * @return
     */
    public static String getMemberIdByJwtToken(HttpServletRequest request) {
        String jwtToken = request.getHeader("token");
        if (StringUtils.isEmpty(jwtToken)) return "";
        Jws<Claims> claimsJws = Jwts.parser().setSigningKey(APP_SECRET).parseClaimsJws(jwtToken);
        Claims claims = claimsJws.getBody();
        return (String) claims.get("id");
    }
}

请添加图片描述

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

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值