源码获取:博客首页 "资源" 里下载!基础环境
搭建环境
- Tomcat 8.5
- Java 1.8+
- Mysql 5.7
Spring、Mybatis、MySql、easyui、h-ui、Jsp、echars
项目介绍
酒店管理系统的目标是为用户提供高效的服务,减少手工处理的繁琐与误差,及时准确地反映酒店工作情况、经营信息,从而提高酒店工作质量,获得更好的经济效益,实现客房管理的规范化、自动化。具体目标包括:
- 高效的客房预订及订单处理。
- 准确无误地记录客人每笔消费信息。
- 实时、快速、准确提供客房动态。
- 酒店收益的最终统计。
- 系统运行稳定可靠、各项维护功能齐全、易于维护。
- 简单、友好的操作界面
模块 | 主要功能 |
---|---|
酒店信息展示 | 客房信息展示、房间状态查询、房间预定、客房信息检索、 |
会员用户预订 | 会员注册登录、用户中心、订单查询、用户信息修改、用户密码修改 |
模块 | 主要功能 |
---|---|
系统设置 | 菜单管理、角色管理、修改密码 |
用户管理 | 用户列表管理 |
系统日志 | 日志列表 |
酒店管理 | 楼层管理、房型管理、房间管理、客户管理、预订管理、入住管理 |
营业统计 | 统计图标 |
文章图片
文章图片
文章图片
文章图片
【Java毕业设计项目实战篇|Java项目:YY酒店管理系统(java+JSP+Easyui+Echars+ssm+mysql)】
文章图片
文章图片
客户管理后台控制器:
/**
* 客户管理后台控制器
* @author yy
*
*/
@RequestMapping("/admin/account")
@Controller
public class AccountController {
@Autowired
private AccountService accountService;
/**
* 客户管理列表页面
* @param model
* @return
*/
@RequestMapping(value="https://www.it610.com/list",method=RequestMethod.GET)
public ModelAndView list(ModelAndView model){
model.setViewName("account/list");
return model;
}
/**
* 客户信息添加操作
* @param account
* @return
*/
@RequestMapping(value="https://www.it610.com/add",method=RequestMethod.POST)
@ResponseBody
public Map add(Account account){
Map ret = new HashMap();
if(account == null){
ret.put("type", "error");
ret.put("msg", "请填写正确的客户信息!");
return ret;
}
if(StringUtils.isEmpty(account.getName())){
ret.put("type", "error");
ret.put("msg", "客户名称不能为空!");
return ret;
}
if(StringUtils.isEmpty(account.getPassword())){
ret.put("type", "error");
ret.put("msg", "客户密码不能为空!");
return ret;
}
if(isExist(account.getName(), 0l)){
ret.put("type", "error");
ret.put("msg", "该用户名已经存在!");
return ret;
}
if(accountService.add(account) <= 0){
ret.put("type", "error");
ret.put("msg", "添加失败,请联系管理员!");
return ret;
}
ret.put("type", "success");
ret.put("msg", "添加成功!");
return ret;
}
/**
* 客户信息编辑操作
* @param account
* @return
*/
@RequestMapping(value="https://www.it610.com/edit",method=RequestMethod.POST)
@ResponseBody
public Map edit(Account account){
Map ret = new HashMap();
if(account == null){
ret.put("type", "error");
ret.put("msg", "请填写正确的客户信息!");
return ret;
}
if(StringUtils.isEmpty(account.getName())){
ret.put("type", "error");
ret.put("msg", "客户名称不能为空!");
return ret;
}
if(StringUtils.isEmpty(account.getPassword())){
ret.put("type", "error");
ret.put("msg", "客户密码不能为空!");
return ret;
}
if(isExist(account.getName(), account.getId())){
ret.put("type", "error");
ret.put("msg", "该用户名已经存在!");
return ret;
}
if(accountService.edit(account) <= 0){
ret.put("type", "error");
ret.put("msg", "添加失败,请联系管理员!");
return ret;
}
ret.put("type", "success");
ret.put("msg", "修改成功!");
return ret;
}
/**
* 分页查询客户信息
* @param name
* @param page
* @return
*/
@RequestMapping(value="https://www.it610.com/list",method=RequestMethod.POST)
@ResponseBody
public Map list(
@RequestParam(name="name",defaultValue="") String name,
@RequestParam(name="realName",defaultValue="") String realName,
@RequestParam(name="idCard",defaultValue="") String idCard,
@RequestParam(name="mobile",defaultValue="") String mobile,
@RequestParam(name="status",required=false) Integer status,
Page page
){
Map ret = new HashMap();
Map queryMap = new HashMap();
queryMap.put("name", name);
queryMap.put("status", status);
queryMap.put("realName", realName);
queryMap.put("idCard", idCard);
queryMap.put("mobile", mobile);
queryMap.put("offset", page.getOffset());
queryMap.put("pageSize", page.getRows());
ret.put("rows", accountService.findList(queryMap));
ret.put("total", accountService.getTotal(queryMap));
return ret;
}
/**
* 客户信息删除操作
* @param id
* @return
*/
@RequestMapping(value="https://www.it610.com/delete",method=RequestMethod.POST)
@ResponseBody
public Map delete(Long id){
Map ret = new HashMap();
if(id == null){
ret.put("type", "error");
ret.put("msg", "请选择要删除的信息!");
return ret;
}
try {
if(accountService.delete(id) <= 0){
ret.put("type", "error");
ret.put("msg", "删除失败,请联系管理员!");
return ret;
}
} catch (Exception e) {
// TODO: handle exception
ret.put("type", "error");
ret.put("msg", "该客户下存在订单信息,请先删除该客户下的所有订单信息!");
return ret;
}
ret.put("type", "success");
ret.put("msg", "删除成功!");
return ret;
}
/**
* 判断用户名是否存在
* @param name
* @param id
* @return
*/
private boolean isExist(String name,Long id){
Account findByName = accountService.findByName(name);
if(findByName == null)return false;
if(findByName.getId().longValue() == id.longValue())return false;
return true;
}
}
角色role控制器:
/**
* 角色role控制器
* @author yy
*
*/
@RequestMapping("/admin/role")
@Controller
public class RoleController {
@Autowired
private RoleService roleService;
@Autowired
private AuthorityService authorityService;
@Autowired
private MenuService menuService;
/**
* 角色列表页面
* @param model
* @return
*/
@RequestMapping(value="https://www.it610.com/list",method=RequestMethod.GET)
public ModelAndView list(ModelAndView model){
model.setViewName("/role/list");
return model;
}
/**
* 获取角色列表
* @param page
* @param name
* @return
*/
@RequestMapping(value="https://www.it610.com/list",method=RequestMethod.POST)
@ResponseBody
public Map getList(Page page,
@RequestParam(name="name",required=false,defaultValue="") String name
){
Map ret = new HashMap();
Map queryMap = new HashMap();
queryMap.put("name", name);
queryMap.put("offset", page.getOffset());
queryMap.put("pageSize", page.getRows());
ret.put("rows", roleService.findList(queryMap));
ret.put("total", roleService.getTotal(queryMap));
return ret;
}
/**
* 角色添加
* @param role
* @return
*/
@RequestMapping(value="https://www.it610.com/add",method=RequestMethod.POST)
@ResponseBody
public Map add(Role role){
Map ret = new HashMap();
if(role == null){
ret.put("type", "error");
ret.put("msg", "请填写正确的角色信息!");
return ret;
}
if(StringUtils.isEmpty(role.getName())){
ret.put("type", "error");
ret.put("msg", "请填写角色名称!");
return ret;
}
if(roleService.add(role) <= 0){
ret.put("type", "error");
ret.put("msg", "角色添加失败,请联系管理员!");
return ret;
}
ret.put("type", "success");
ret.put("msg", "角色添加成功!");
return ret;
}
/**
* 角色修改
* @param role
* @return
*/
@RequestMapping(value="https://www.it610.com/edit",method=RequestMethod.POST)
@ResponseBody
public Map edit(Role role){
Map ret = new HashMap();
if(role == null){
ret.put("type", "error");
ret.put("msg", "请填写正确的角色信息!");
return ret;
}
if(StringUtils.isEmpty(role.getName())){
ret.put("type", "error");
ret.put("msg", "请填写角色名称!");
return ret;
}
if(roleService.edit(role) <= 0){
ret.put("type", "error");
ret.put("msg", "角色修改失败,请联系管理员!");
return ret;
}
ret.put("type", "success");
ret.put("msg", "角色修改成功!");
return ret;
}
/**
* 删除角色信息
* @param id
* @return
*/
@RequestMapping(value="https://www.it610.com/delete",method=RequestMethod.POST)
@ResponseBody
public Map delete(Long id){
Map ret = new HashMap();
if(id == null){
ret.put("type", "error");
ret.put("msg", "请选择要删除的角色!");
return ret;
}
try {
if(roleService.delete(id) <= 0){
ret.put("type", "error");
ret.put("msg", "删除失败,请联系管理员!");
return ret;
}
} catch (Exception e) {
// TODO: handle exception
ret.put("type", "error");
ret.put("msg", "该角色下存在权限或者用户信息,不能删除!");
return ret;
}
ret.put("type", "success");
ret.put("msg", "角色删除成功!");
return ret;
}
/**
* 获取所有的菜单信息
* @return
*/
@RequestMapping(value="https://www.it610.com/get_all_menu",method=RequestMethod.POST)
@ResponseBody
public List
前台首页控制器:
/**
* 前台首页控制器
* @author yy
*
*/
@RequestMapping("/home")
@Controller
public class HomeController {
@Autowired
private RoomTypeService roomTypeService;
@Autowired
private AccountService accountService;
/**
* 前台首页
* @param model
* @param name
* @return
*/
@RequestMapping(value="https://www.it610.com/index",method=RequestMethod.GET)
public ModelAndView list(ModelAndView model,
@RequestParam(name="name",defaultValue="") String name
){
Map queryMap = new HashMap();
queryMap.put("name", name);
queryMap.put("offset", 0);
queryMap.put("pageSize", 999);
model.addObject("roomTypeList", roomTypeService.findList(queryMap));
model.setViewName("home/index/index");
model.addObject("kw", name);
return model;
}
/**
* 登录页面
* @param model
* @return
*/
@RequestMapping(value="https://www.it610.com/login",method=RequestMethod.GET)
public ModelAndView login(ModelAndView model
){
model.setViewName("home/index/login");
return model;
}
/**
* 注册页面
* @param model
* @return
*/
@RequestMapping(value="https://www.it610.com/reg",method=RequestMethod.GET)
public ModelAndView reg(ModelAndView model
){
model.setViewName("home/index/reg");
return model;
}
/**
* 登录信息提交
* @param account
* @return
*/
@RequestMapping(value="https://www.it610.com/login",method=RequestMethod.POST)
@ResponseBody
public Map loginAct(Account account,String vcode,HttpServletRequest request){
Map retMap = new HashMap();
if(account == null){
retMap.put("type", "error");
retMap.put("msg", "请填写正确的用户信息!");
return retMap;
}
if(StringUtils.isEmpty(account.getName())){
retMap.put("type", "error");
retMap.put("msg", "用户名不能为空!");
return retMap;
}
if(StringUtils.isEmpty(account.getPassword())){
retMap.put("type", "error");
retMap.put("msg", "密码不能为空!");
return retMap;
}
if(StringUtils.isEmpty(vcode)){
retMap.put("type", "error");
retMap.put("msg", "验证码不能为空!");
return retMap;
}
Object attribute = request.getSession().getAttribute("accountLoginCpacha");
if(attribute == null){
retMap.put("type", "error");
retMap.put("msg", "验证码过期,请刷新!");
return retMap;
}
if(!vcode.equalsIgnoreCase(attribute.toString())){
retMap.put("type", "error");
retMap.put("msg", "验证码错误!");
return retMap;
}
Account findByName = accountService.findByName(account.getName());
if(findByName == null){
retMap.put("type", "error");
retMap.put("msg", "用户名不存在!");
return retMap;
}
if(!account.getPassword().equals(findByName.getPassword())){
retMap.put("type", "error");
retMap.put("msg", "密码错误!");
return retMap;
}
if(findByName.getStatus() == -1){
retMap.put("type", "error");
retMap.put("msg", "该用户已被禁用,请联系管理员!");
return retMap;
}
request.getSession().setAttribute("account", findByName);
request.getSession().setAttribute("accountLoginCpacha", null);
retMap.put("type", "success");
retMap.put("msg", "登录成功!");
return retMap;
}
/**
* 注册信息提交
* @param account
* @return
*/
@RequestMapping(value="https://www.it610.com/reg",method=RequestMethod.POST)
@ResponseBody
public Map regAct(Account account){
Map retMap = new HashMap();
if(account == null){
retMap.put("type", "error");
retMap.put("msg", "请填写正确的用户信息!");
return retMap;
}
if(StringUtils.isEmpty(account.getName())){
retMap.put("type", "error");
retMap.put("msg", "用户名不能为空!");
return retMap;
}
if(StringUtils.isEmpty(account.getPassword())){
retMap.put("type", "error");
retMap.put("msg", "密码不能为空!");
return retMap;
}
if(StringUtils.isEmpty(account.getMobile())){
retMap.put("type", "error");
retMap.put("msg", "手机号不能为空!");
return retMap;
}
if(isExist(account.getName())){
retMap.put("type", "error");
retMap.put("msg", "该用户名已经存在!");
return retMap;
}
if(accountService.add(account) <= 0){
retMap.put("type", "error");
retMap.put("msg", "注册失败,请联系管理员!");
return retMap;
}
retMap.put("type", "success");
retMap.put("msg", "注册成功!");
return retMap;
}
/**
* 退出登录
* @param request
* @return
*/
@RequestMapping(value="https://www.it610.com/logout",method=RequestMethod.GET)
public String logout(HttpServletRequest request){
request.getSession().setAttribute("account", null);
return "redirect:login";
}
private boolean isExist(String name){
Account account = accountService.findByName(name);
if(account == null)return false;
return true;
}
}
前台用户控制器:
/**
* 前台用户控制器
* @author yy
*
*/
@RequestMapping("/home/account")
@Controller
public class HomeAccountController {
@Autowired
private RoomTypeService roomTypeService;
@Autowired
private AccountService accountService;
@Autowired
private BookOrderService bookOrderService;
/**
* 前台用户中心首页
* @param model
* @param name
* @return
*/
@RequestMapping(value="https://www.it610.com/index",method=RequestMethod.GET)
public ModelAndView list(ModelAndView model,HttpServletRequest request
){
Account account = (Account)request.getSession().getAttribute("account");
Map queryMap = new HashMap();
queryMap.put("accountId", account.getId());
queryMap.put("offset", 0);
queryMap.put("pageSize", 999);
model.addObject("bookOrderList", bookOrderService.findList(queryMap));
model.addObject("roomTypeList", roomTypeService.findAll());
model.setViewName("home/account/index");
return model;
}
/**
* 预定房间页面
* @param model
* @return
*/
@RequestMapping(value="https://www.it610.com/book_order",method=RequestMethod.GET)
public ModelAndView bookOrder(ModelAndView model,Long roomTypeId
){
model.addObject("roomType", roomTypeService.find(roomTypeId));
model.setViewName("home/account/book_order");
return model;
}
/**
* 预定信息提交
* @param account
* @return
*/
@RequestMapping(value="https://www.it610.com/book_order",method=RequestMethod.POST)
@ResponseBody
public Map bookOrderAct(BookOrder bookOrder,HttpServletRequest request){
Map ret = new HashMap();
if(bookOrder == null){
ret.put("type", "error");
ret.put("msg", "请填写正确的预定订单信息!");
return ret;
}
Account account = (Account)request.getSession().getAttribute("account");
if(account == null){
ret.put("type", "error");
ret.put("msg", "客户不能为空!");
return ret;
}
bookOrder.setAccountId(account.getId());
if(bookOrder.getRoomTypeId() == null){
ret.put("type", "error");
ret.put("msg", "房型不能为空!");
return ret;
}
if(StringUtils.isEmpty(bookOrder.getName())){
ret.put("type", "error");
ret.put("msg", "预定订单联系人名称不能为空!");
return ret;
}
if(StringUtils.isEmpty(bookOrder.getMobile())){
ret.put("type", "error");
ret.put("msg", "预定订单联系人手机号不能为空!");
return ret;
}
if(StringUtils.isEmpty(bookOrder.getIdCard())){
ret.put("type", "error");
ret.put("msg", "联系人身份证号不能为空!");
return ret;
}
if(StringUtils.isEmpty(bookOrder.getArriveDate())){
ret.put("type", "error");
ret.put("msg", "到达时间不能为空!");
return ret;
}
if(StringUtils.isEmpty(bookOrder.getLeaveDate())){
ret.put("type", "error");
ret.put("msg", "离店时间不能为空!");
return ret;
}
bookOrder.setCreateTime(new Date());
bookOrder.setStatus(0);
if(bookOrderService.add(bookOrder) <= 0){
ret.put("type", "error");
ret.put("msg", "添加失败,请联系管理员!");
return ret;
}
RoomType roomType = roomTypeService.find(bookOrder.getRoomTypeId());
//预定成功后去修改该房型的预定数
if(roomType != null){
roomType.setBookNum(roomType.getBookNum() + 1);
roomType.setAvilableNum(roomType.getAvilableNum() - 1);
roomTypeService.updateNum(roomType);
//如果可用的房间数为0,则设置该房型状态已满
if(roomType.getAvilableNum() == 0){
roomType.setStatus(0);
roomTypeService.edit(roomType);
}
}
ret.put("type", "success");
ret.put("msg", "预定成功!");
return ret;
}
/**
* 修改个人信息提交
* @param account
* @return
*/
@RequestMapping(value="https://www.it610.com/update_info",method=RequestMethod.POST)
@ResponseBody
public Map updateInfoAct(Account account,HttpServletRequest request){
Map retMap = new HashMap();
if(account == null){
retMap.put("type", "error");
retMap.put("msg", "请填写正确的用户信息!");
return retMap;
}
if(StringUtils.isEmpty(account.getName())){
retMap.put("type", "error");
retMap.put("msg", "用户名不能为空!");
return retMap;
}
Account loginedAccount = (Account)request.getSession().getAttribute("account");
if(isExist(account.getName(),loginedAccount.getId())){
retMap.put("type", "error");
retMap.put("msg", "该用户名已经存在!");
return retMap;
}
loginedAccount.setAddress(account.getAddress());
loginedAccount.setIdCard(account.getIdCard());
loginedAccount.setMobile(account.getMobile());
loginedAccount.setName(account.getName());
loginedAccount.setRealName(account.getRealName());
if(accountService.edit(loginedAccount) <= 0){
retMap.put("type", "error");
retMap.put("msg", "修改失败,请联系管理员!");
return retMap;
}
request.getSession().setAttribute("account", loginedAccount);
retMap.put("type", "success");
retMap.put("msg", "修改成功!");
return retMap;
}
/**
* 修改密码提交
* @param account
* @return
*/
@RequestMapping(value="https://www.it610.com/update_pwd",method=RequestMethod.POST)
@ResponseBody
public Map updatePwdAct(String oldPassword,String newPassword,HttpServletRequest request){
Map retMap = new HashMap();
if(StringUtils.isEmpty(oldPassword)){
retMap.put("type", "error");
retMap.put("msg", "请填写原来的密码!");
return retMap;
}
if(StringUtils.isEmpty(newPassword)){
retMap.put("type", "error");
retMap.put("msg", "请填写新密码!");
return retMap;
}
Account loginedAccount = (Account)request.getSession().getAttribute("account");
if(!oldPassword.equals(loginedAccount.getPassword())){
retMap.put("type", "error");
retMap.put("msg", "原密码错误!");
return retMap;
}
loginedAccount.setPassword(newPassword);
if(accountService.edit(loginedAccount) <= 0){
retMap.put("type", "error");
retMap.put("msg", "修改失败,请联系管理员!");
return retMap;
}
retMap.put("type", "success");
retMap.put("msg", "修改密码成功!");
return retMap;
}
/**
* 判断用户是否存在
* @param name
* @param id
* @return
*/
private boolean isExist(String name,Long id){
Account account = accountService.findByName(name);
if(account == null)return false;
if(account != null && account.getId().longValue() == id)return false;
return true;
}
}
源码获取:博客首页 "资源" 里下载!
推荐阅读
- 蓝桥杯|2021年 第12届 蓝桥杯 Java B组 省赛真题详解及小结【第1场省赛 2021.04.18】
- 蓝桥杯|2021年 第12届 蓝桥杯 Java B组 省赛真题详解及小结【第2场省赛 2021.05.09】
- Java IO 流
- Java_tips|静态代码块
- docker|如何部署一个Kubernetes集群
- MYSQL|MYSQL基础
- 记录|Java输出文件流
- 49-springboot 打jar,独立出三方的依赖包
- 算法|近似算法的近似率_选择最佳近似最近算法的数据科学家指南