酒店管理系统
一、项目介绍
1、项目用到的技术栈
开发工具:idea
语言:java、js、html+ajax
数据库:MySQL
服务器:Tomcat
框架:mybatis、jQuery、springboot、vue
2、项目实现功能
管理员和用户登录和退出功能以及用户注册功能(根据不同的账号密码进入不同的页面,注册页面以及登录都有校验)
用户可以预定房间,可以查看预定完房间的基本信息
管理员和用户可以查看个人信息,并且可以修改个人信息(修改时支持信息回显)
管理员和用户可以通过模糊查询和多条件查询
管理员可以对房间进行增删改查(增删房型,增删改查房间)
3.系统展示
3.1 登录
用户进入酒店登陆界面。输入自己的注册所用的账号、密码,点击登录按钮。前端向后台接口地址/login发起ajax请求,后台验证账号是否存在,账号对应密码是否正确。账号、密码验证正确后,登陆成功,反之失败。
界面实现效果如图3-1所示。
<!DOCTYPE html>
<html lang="en"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="./favicon.ico"><title>酒店管理系统</title><link href="./css/app.129a2d00.css" rel="preload" as="style"><link href="./css/chunk-vendors.a72b0961.css" rel="preload" as="style"><link href="./js/app.31a09f91.js" rel="preload" as="script"><link href="./js/chunk-vendors.2aafffa1.js" rel="preload" as="script"><link href="./css/chunk-vendors.a72b0961.css" rel="stylesheet"><link href="./css/app.129a2d00.css" rel="stylesheet">
</head><body><noscript><strong>We're sorry but mas-creator-admin doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div><script src="./js/chunk-vendors.2aafffa1.js"></script><script src="./js/app.31a09f91.js"></script>
</body></html>
登录成功后,前端根据后端返回的角色类型,进入不同的操作页面进行展示,
后端根据不同的账号返回角色对应的数据进行展示
管理员后台操作页面
Controller层
/*** 登录*/@IgnoreAuth@PostMapping(value = "/login")public R login(String username, String password, String captcha, HttpServletRequest request) {UserEntity user = userService.selectOne(new EntityWrapper<UserEntity>().eq("username", username));if(user==null || !user.getPassword().equals(password)) {return R.error("账号或密码不正确");}String token = tokenService.generateToken(user.getId(),username, "users", user.getRole());return R.ok().put("token", token);}
Service层
@Overridepublic String generateToken(Long userid,String username, String tableName, String role) {TokenEntity tokenEntity = this.selectOne(new EntityWrapper<TokenEntity>().eq("userid", userid).eq("role", role));String token = CommonUtil.getRandomString(32);Calendar cal = Calendar.getInstance(); cal.setTime(new Date()); cal.add(Calendar.HOUR_OF_DAY, 1);if(tokenEntity!=null) {tokenEntity.setToken(token);tokenEntity.setExpiratedtime(cal.getTime());this.updateById(tokenEntity);} else {this.insert(new TokenEntity(userid,username, tableName, role, token, cal.getTime()));}return token;}
用户后台操作页面
Controller层
/*** 登录*/@IgnoreAuth@RequestMapping(value = "/login")public R login(String username, String password, String captcha, HttpServletRequest request) {YonghuEntity user = yonghuService.selectOne(new EntityWrapper<YonghuEntity>().eq("yonghuming", username));if(user==null || !user.getMima().equals(password)) {return R.error("账号或密码不正确");}String token = tokenService.generateToken(user.getId(), username,"yonghu", "用户" );return R.ok().put("token", token);}
Service层
@Overridepublic String generateToken(Long userid,String username, String tableName, String role) {TokenEntity tokenEntity = this.selectOne(new EntityWrapper<TokenEntity>().eq("userid", userid).eq("role", role));String token = CommonUtil.getRandomString(32);Calendar cal = Calendar.getInstance(); cal.setTime(new Date()); cal.add(Calendar.HOUR_OF_DAY, 1);if(tokenEntity!=null) {tokenEntity.setToken(token);tokenEntity.setExpiratedtime(cal.getTime());this.updateById(tokenEntity);} else {this.insert(new TokenEntity(userid,username, tableName, role, token, cal.getTime()));}return token;}
员工后台操作页面
Controller层
/*** 登录*/@IgnoreAuth@RequestMapping(value = "/login")public R login(String username, String password, String captcha, HttpServletRequest request) {YuangongEntity user = yuangongService.selectOne(new EntityWrapper<YuangongEntity>().eq("yuangonggonghao", username));if(user==null || !user.getMima().equals(password)) {return R.error("账号或密码不正确");}String token = tokenService.generateToken(user.getId(), username,"yuangong", "员工" );return R.ok().put("token", token);}
Service层
@Overridepublic String generateToken(Long userid,String username, String tableName, String role) {TokenEntity tokenEntity = this.selectOne(new EntityWrapper<TokenEntity>().eq("userid", userid).eq("role", role));String token = CommonUtil.getRandomString(32);Calendar cal = Calendar.getInstance(); cal.setTime(new Date()); cal.add(Calendar.HOUR_OF_DAY, 1);if(tokenEntity!=null) {tokenEntity.setToken(token);tokenEntity.setExpiratedtime(cal.getTime());this.updateById(tokenEntity);} else {this.insert(new TokenEntity(userid,username, tableName, role, token, cal.getTime()));}return token;}