源码获取:俺的博客首页 "资源" 里下载!

项目介绍

管理员角色包含以下功能:
管理员登陆,会议室管理,预约审核管理,用户注册等功能。

用户角色包含以下功能:
用户登录,会议室查询,预约记录查询,会议室预约申请,取消预约等功能。


环境需要

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版本;


技术栈

1. 后端:Spring+SpringMVC+Mybatis
2. 前端:HTML+CSS+JavaScript+jsp


使用说明

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

 

 

 

 

 

用户管理控制层:

@Controller
public class UserController {

    @Autowired
    UserServiceImpl userService;

    /*
    * queryUserlike  通过用户姓名进行模糊查询
    * */
    @GetMapping("/queryUserlike/{username}")
    @ResponseBody
    public Msg queryUserlikeId(@RequestParam(value = "pn",defaultValue = "1") Integer pn,
                               @PathVariable("username") String username){
        PageHelper.startPage(pn,20);
        List<User> users = userService.queryByUserName(username);
        PageInfo<User> page=new PageInfo<User>(users,5);
        return Msg.success().add("pageInfo",page);
    }

    /*
    * 前端发送请求后端分页数据,
    * */
    @GetMapping("/userTables")
    @ResponseBody
    public Msg userTables(@RequestParam(value = "pn",defaultValue = "1") Integer pn){
        PageHelper.startPage(pn,7);
        List<User> users = userService.getAll();
        PageInfo<User> page=new PageInfo<User>(users,5);
        return Msg.success().add("pageInfo",page);
    }

    //到tables页面
    @RequestMapping("/usertables")
    public String toUserTables(Map<String,Object> map){
        List<User> users = userService.getAll();
        map.put("users",users);
        return "Tables";
    }

    //点击编辑按键传入userid查询用户,返回用户信息
    @GetMapping("/queryUserByID/{userid}")
    @ResponseBody
    public Msg queryUserID(@PathVariable("userid") Integer userid,Map<String,Object> map){
        User users = userService.getUserByID(userid);
        return Msg.success().add("users",users);
    }
    /*
    * 查询全部用户
    */
    /*@GetMapping("/user22")
    public String getAllUser(Map<String,Object> map){
        List<User> users = userService.getAll();
        map.put("users",users);
        return "Dashboard";
    }*/



    /*
     * 用户删除请求
     */
    @DeleteMapping(value = "/user/{ids}")
    @ResponseBody
    public Msg delEmp(@PathVariable("ids") String ids) {
        if(ids.contains("-")) {
            List<Integer> delids = new ArrayList<Integer>();
            String[] split = ids.split("-");
            for (String string : split) {
                delids.add(Integer.parseInt(string));
            }
            userService.batchUser(delids);
        }else {
            int id = Integer.parseInt(ids);
            userService.deleteUser(id);
        }
        return Msg.success();
    }

    /*
     * 用户更新
     */
    @PutMapping(value = "/user/{userID}")
    @ResponseBody
    public Msg saveEmp(User user) {
        System.out.println(user);
        userService.updateUser(user);
        return Msg.success();
    }

    /*
     * 根据用户ID查询结果
     */
    @GetMapping(value = "user/{id}")
    @ResponseBody
    public Msg getEmp(@PathVariable(value = "id")Integer userID) {
        User user = userService.getUserByID(userID);
        return Msg.success().add("user", user);
    }
    /*
     * 检查用户名是否可用
     */
    @RequestMapping(value = "/checkAddUser")
    @ResponseBody
    public Msg checkAddUser(@RequestParam("username")String userName) {
        //先判断用户名是否合法的表达式
        String regex = "(^[a-zA-Z0-9_-]{6,16}$)|(^[\\u2E80-\\u9FFF]+$)";
        boolean c = userName.matches(regex);
        if(!c) {
            return Msg.fail().add("va_msg", "用户名可以是2-5位中文,或者6-16位英文和数字的组合");
        }
        //数据库用户名重复校验
        boolean b = userService.checkUserName(userName);
        if(b) {
            return Msg.success().add("va_msg", "用户名可用");
        }else {
            return Msg.fail().add("va_msg",	"用户名已存在");
        }
    }
    /*校验手机号码格式*/
    @RequestMapping("/checkAddTel")
    @ResponseBody
    public Msg checkAddTel(@RequestParam(value = "usertel")String userTel1) {
        String userTel = userTel1.trim();
        String regex = "(^1\\d{10}$)";
        boolean matches = userTel.matches(regex);
        if(matches == true){
            return Msg.success().add("va_msg","");
        }else{
            return Msg.fail().add("va_msg","手机号必须以1开头,11位的数字!");
        }
    }
    /*校验年龄码格式*/
    @RequestMapping("/checkAddAge")
    @ResponseBody
    public Msg checkAddAge(@RequestParam(value = "userage")Integer userAge1) {
        String s = userAge1.toString();
        String userTel = s.trim();
        String regex = "(^\\d{1,3}$)";
        boolean matches = userTel.matches(regex);
        if(matches == true){
            return Msg.success().add("va_msg","");
        }else{
            return Msg.fail().add("va_msg","请输入数字");
        }
    }
    /*校验密码格式*/
    @RequestMapping("/checkAddPwd")
    @ResponseBody
    public Msg checkAddPwd(@RequestParam(value = "userpwd")String userPwd1) {
        String userPwd = userPwd1.trim();
        String regex = "(^[a-zA-Z0-9_-]{6,16}$)";
        boolean matches = userPwd.matches(regex);
        if(matches == true){
            return Msg.success().add("va_msg","");
        }else{
            return Msg.fail().add("va_msg","密码格式不正确:必须超过6位,小于16位的英文和数字!");
        }
    }
    /****************************************************插入*********
     * 点击保存按钮,新增用户
     * */
    @PostMapping("/insertUser")
    @ResponseBody
    public Msg insertUser(User user){
        user.setUserid(null);
        userService.insertUser(user);
        return Msg.success().add("va_msg","插入成功!");
    }

    //点击更新按钮,更新修改的数据
    @PutMapping("/updateUser")
    @ResponseBody
    public Msg updateUser(User user){
        userService.updateUser(user);
        return Msg.success().add("va_msg","插入成功!");
    }

    //用户删除
    @DeleteMapping("/deleteUser/{userid}")
    @ResponseBody
    public Msg deleteEmployee(@PathVariable("userid") Integer userid){
        boolean b = userService.deleteUser(userid);
        if (b){
            return Msg.success().add("va_msg","用户删除成功!");
        }else {
            return Msg.fail().add("va_msg","用户删除失败!");
        }
    }

    /*
    * 前端ajax请求,查询userid是否在表中存在
    * */
    @GetMapping("/checkUserID")
    @ResponseBody
    public Msg checkUserID(@RequestParam("userid") Integer userid){
        boolean b = userService.checkUserID(userid);
        if(b){
            return Msg.success().add("va_msg","用户名存在!");
        }else {
            return Msg.fail().add("va_msg","用户名不存在,重新输入!");
        }
    }
}

后台管理控制层:

@Controller
public class ManagerController {

    @Autowired
    ManagerServiceImpl managerService;

    //进入忘记密码页面
    @RequestMapping("/forgotPwd")
    public String toForgotPage(){
        return "ForgotPassword";
    }
    @RequestMapping("/forgotPwd2")
    public String toForgotPage2(){
        return "ForgotPassword2";
    }

    @RequestMapping("/logout")
    public String toLoginPage(HttpSession session){
        Enumeration<String> attributeNames = session.getAttributeNames();
        while (attributeNames.hasMoreElements()) {
            session.removeAttribute(attributeNames.nextElement());
        }
        return "Login";
    }

    //进入重置密码页面
    @RequestMapping("/register")
    public String toRegisterPage(){
        return "Register";
    }

    //登陆和忘记密码==》检查用户名是否存在
    @GetMapping("/checkLoginManagerName")
    @ResponseBody
    public Msg checkLoginManagerName(@RequestParam("managername") String managername1){
        String managername = managername1.trim();
        String regex = "(^[a-zA-Z0-9_-]{6,16}$)|(^[\\u2E80-\\u9FFF]+$)";

        boolean c = managername.matches(regex);
        if(!c) {
            return Msg.fail().add("va_msg", "用户名是2-5位中文,或者6-16位英文和数字的组合");
        }
        boolean b = managerService.checkManagerName(managername);
        if (b==true){
            return Msg.fail().add("va_msg","用户名不存在!");
        }else {
            return Msg.success().add("va_msg","");
        }
    }
    //注册检查用户名是否存在
    @GetMapping("/checkManagerName")
    @ResponseBody
    public Msg checkManagerName(@RequestParam("managername") String managername1){
        String managername = managername1.trim();
        String regex = "(^[a-zA-Z0-9_-]{6,16}$)|(^[\\u2E80-\\u9FFF]+$)";
        boolean c = managername.matches(regex);
        if(!c) {
            return Msg.fail().add("va_msg", "用户名可以是2-5位中文,或者6-16位英文和数字的组合");
        }
        boolean b = managerService.checkManagerName(managername);
        if (b==true){
            return Msg.success().add("va_msg","用户名可用!");
        }else {
            return Msg.fail().add("va_msg","用户名已存在!");
        }
    }
    //检查手机号是否是十一位
    @GetMapping("/checkManagerTel")
    @ResponseBody
    public Msg checkManagerTel(@RequestParam("managertel") String managertel1){
        String managertel = managertel1.trim();
        String regex = "(^1\\d{10}$)";
        boolean matches = managertel.matches(regex);
        if(matches == true){
            return Msg.success().add("va_msg"," ");
        }else{
            return Msg.fail().add("va_msg","手机号必须以1开头,11位的数字!");
        }
    }
    //登陆检查密码
    @GetMapping("/checkLoginManagerPwd")
    @ResponseBody
    public Msg checkLoginManagerPwd(@RequestParam("managerpwd") String managerpwd1){
        String managerpwd = managerpwd1.trim();
        String regex = "(^[a-zA-Z0-9_-]{6,16}$)";
        boolean matches = managerpwd.matches(regex);
        if(matches == true){
            return Msg.success().add("va_msg"," ");
        }else{
            return Msg.fail().add("va_msg","密码格式不正确:必须超过6位,小于16位!");
        }
    }
    //注册检查密码
    @GetMapping("/checkManagerPwd")
    @ResponseBody
    public Msg checkManagerPwd(@RequestParam("managerpwd") String managerpwd1){
        String managerpwd = managerpwd1.trim();
        String regex = "(^[a-zA-Z0-9_-]{6,16}$)";
        boolean matches = managerpwd.matches(regex);
        if(matches == true){
            return Msg.success().add("va_msg"," ");
        }else{
            return Msg.fail().add("va_msg","密码格式不正确:必须超过6位,小于16位!");
        }
    }

    /*新增管理员
    **/
    @PostMapping("/registerManager")
    public String registerManger(Manager manager,Map<String,Object> map){
        manager.setManagerid(null);
        boolean flag = managerService.createManager(manager);
        if(flag == true){
            map.put("msg","插入成功!");
            return "redirect:share.html";
        }else{
            map.put("msg","插入失败!");
            return "Register";
        }
    }

    //点击进入按钮校验用户名和密码是否正确
    @PostMapping("/loginD")
    public String loginDashboard(@RequestParam("managername") String managername1,
                                 @RequestParam("managerpwd") String managerpwd1,
                                 Map<String,Object> map, HttpSession session){
        /*
         * ==true没有该用户
         * ==false 用户存在
         * */
        String managername = managername1.trim();
        String managerpwd = managerpwd1.trim();
        if(managername != "" && managerpwd!=""){
            boolean name = managerService.checkManagerName(managername);
            boolean pwd = managerService.checkManagerPwd(managerpwd);
            if(name == false && pwd ==false ){
//                System.out.println("用户名或密码正确!");
                session.setAttribute("username",managername);
                return "redirect:/user22";
            }else{
//                System.out.println("密码错误!");
                map.put("msg","账号密码错误,请重新输入账号和密码!");
                return "Login";
            }
        }else {
            map.put("msg","请输入账号or密码!");
            return "Login";
        }
    }

    /*resetpwd
     * 点击确认修改密码并且返回登陆页面*/
    @PutMapping("/resetpwd")
    public String backLogin(@RequestParam("managername") String managername1,
                            @RequestParam("managerpwd") String managerpwd1,
                            Map<String,Object> map){
        String managername = managername1.trim();
        String managerpwd = managerpwd1.trim();
        if (managername != "" && managerpwd != ""){
            boolean tel = managerService.checkManagerName(managername);
            if(tel == true){
                map.put("msg","账号不存在,请重新输入!");
                return "ForgotPassword";
            }else {
                int i = managerService.updateUserPwd(managername,managerpwd);
                map.put("msg","reset success!");
                if(i>0){
                    return "redirect:/share.html";
                }else {
                    return "ForgotPassword";
                }
            }
        }else {
            map.put("msg","账号或新密码为空,请输入!");
            return "ForgotPassword";
        }
    }
    @PutMapping("/resetpwd2")
    public String backLogin2(@RequestParam("managername") String managername1,
                            @RequestParam("managerpwd") String managerpwd1,
                            Map<String,Object> map){
        String managername = managername1.trim();
        String managerpwd = managerpwd1.trim();
        if (managername != "" && managerpwd != ""){
            boolean tel = managerService.checkManagerName(managername);
            if(tel == true){
                map.put("msg","账号不存在,请重新输入!");
                return "ForgotPassword2";
            }else {
                int i = managerService.updateUserPwd(managername,managerpwd);
                map.put("msg","reset success!");
                if(i>0){
                    return "redirect:/forgotPwd2";
                }else {
                    return "ForgotPassword2";
                }
            }
        }else {
            map.put("msg","账号或新密码为空,请输入!");
            return "ForgotPassword2";
        }
    }

}

预定管理控制层:

@Controller
public class SeatuseController {
    @Autowired
    SeatuseServiceImpl seatuseService;

    /*
     *  通过用户ID进行查询
     * */
    @GetMapping("/queryByUserID/{userid}")
    @ResponseBody
    public Msg queryUserID(@RequestParam(value = "pn",defaultValue = "1") Integer pn,
                           @PathVariable("userid") Integer userid){
        PageHelper.startPage(pn,20);
        List<Seatuse> users = seatuseService.queryByUserID(userid);
        PageInfo<Seatuse> page=new PageInfo<Seatuse>(users,5);
        return Msg.success().add("pageInfo",page);
    }
    /*
    * 到座位使用统计页面
    * */
    @RequestMapping("/seatUseCount")
    public String toSeatUserPage(Map<String,Object> map){
        List<Seatuse> seatusers = seatuseService.getAll();
        map.put("sus",seatusers);
        return "SeatUse";
    }

    @GetMapping("/seatUsePage")
    @ResponseBody
    public Msg SeatUserInfo(@RequestParam(value = "pn",defaultValue = "1") Integer pn){
        PageHelper.startPage(pn,6);
        List<Seatuse> seatusers = seatuseService.getAll();
        //使用pageInfo包装查询后的结果,只需要将pageInfo交给页面就好了
        //封装了详细的分页信息,包括有我们查询出来的数据,传入连续显示的页数
        PageInfo<Seatuse> page=new PageInfo<Seatuse>(seatusers,5);
        return Msg.success().add("pageInfo",page);
    }


    /*
    * 插入数据到记录表中
    * */
    @PostMapping("/insertSUInfo")
    @ResponseBody
    public Msg insertSUInfo(Seatuse seatuse, @RequestParam("status") String status){
        boolean b = seatuseService.insertSeatUseInfo(seatuse, status);
        if (b){
            return Msg.success().add("va_msg","插入到座位使用记录表成功!");
        }else {
            return Msg.fail().add("va_msg","插入到座位使用记录表失败!");
        }
    }

    @DeleteMapping("/deleteSeatUseByID/{seatuserid}")
    @ResponseBody
    public Msg deleteSeatUserInfo(@PathVariable("seatuserid") Integer seatuserid){
        boolean b = seatuseService.deleteSeatUserInfo(seatuserid);
        if(b){
            return Msg.success().add("va_msg","删除成功座位使用记录");
        }else {
            return Msg.fail().add("va_msg","删除失败座位使用记录");
        }
    }

    /*
    * 获取状态为1的数据条数
    * */
    @GetMapping("/state1Count/{state}")
    @ResponseBody
    public Msg state1Count(@PathVariable("state") String state){
        long l = seatuseService.queryStateCount(state);
        return Msg.success().add("state1Count",l);
    }
}

源码获取:俺的博客首页 "资源" 里下载! 

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐