1500字范文,内容丰富有趣,写作好帮手!
1500字范文 > 基于javaweb的酒店客房管理系统(java+jsp+html+bootstrap+jquery+servlet+mysql)

基于javaweb的酒店客房管理系统(java+jsp+html+bootstrap+jquery+servlet+mysql)

时间:2022-04-28 04:13:35

相关推荐

基于javaweb的酒店客房管理系统(java+jsp+html+bootstrap+jquery+servlet+mysql)

基于javaweb的酒店客房管理系统(java+jsp+html+bootstrap+jquery+servlet+mysql)

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

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

适用

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

功能说明

基于javaweb+mysql的酒店客房管理系统(java+JSP+html+bootstrap+jQuery+Servlet+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项目: 否;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven项目

技术栈

后端:Servlet 2. 前端:JSP+bootstrap+jQuery

使用说明

使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中jdbc.properties配置文件中的数据库配置改为自己的配置; 4. 运行项目,输入localhost:8080/SLH 登录 注:tomcat中配置项目路径必须为/SLH,否则会报错; 客房经理用户名密码:admin/admin 前台管理员用户名密码:test/123456 客户用户名密码:jack/123456

客户管理后台控制器:

/**

客户管理后台控制器

@author yy

*/

@RequestMapping(“/admin/account”)

@Controller

public class AccountController {

@Autowired

private AccountService accountService;

/**

客户管理列表页面

@param model

@return

*/

@RequestMapping(value=“/list”,method=RequestMethod.GET)

public ModelAndView list(ModelAndView model){

model.setViewName(“account/list”);

return model;

/**

客户信息添加操作

@param account

@return

*/

@RequestMapping(value=“/add”,method=RequestMethod.POST)

@ResponseBody

public Map<String, String> add(Account account){

Map<String, String> ret = new HashMap<String, String>();

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=“/edit”,method=RequestMethod.POST)

@ResponseBody

public Map<String, String> edit(Account account){

Map<String, String> ret = new HashMap<String, String>();

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=“/list”,method=RequestMethod.POST)

@ResponseBody

public Map<String,Object> 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<String,Object> ret = new HashMap<String, Object>();

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

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=“/delete”,method=RequestMethod.POST)

@ResponseBody

public Map<String, String> delete(Long id){

Map<String, String> ret = new HashMap<String, String>();

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=“/list”,method=RequestMethod.GET)

public ModelAndView list(ModelAndView model){

model.setViewName(“/role/list”);

return model;

/**

获取角色列表

@param page

@param name

@return

*/

@RequestMapping(value=“/list”,method=RequestMethod.POST)

@ResponseBody

public Map<String, Object> getList(Page page,

@RequestParam(name=“name”,required=false,defaultValue=“”) String name

){

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

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

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=“/add”,method=RequestMethod.POST)

@ResponseBody

public Map<String, String> add(Role role){

Map<String, String> ret = new HashMap<String, String>();

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=“/edit”,method=RequestMethod.POST)

@ResponseBody

public Map<String, String> edit(Role role){

Map<String, String> ret = new HashMap<String, String>();

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=“/delete”,method=RequestMethod.POST)

@ResponseBody

public Map<String, String> delete(Long id){

Map<String, String> ret = new HashMap<String, String>();

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=“/get_all_menu”,method=RequestMethod.POST)

@ResponseBody

public List

getAllMenu(){

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

queryMap.put(“offset”, 0);

queryMap.put(“pageSize”, 99999);

return menuService.findList(queryMap);

/**

添加权限

@param ids

@return

*/

@RequestMapping(value=“/add_authority”,method=RequestMethod.POST)

@ResponseBody

public Map<String, String> addAuthority(

@RequestParam(name=“ids”,required=true) String ids,

@RequestParam(name=“roleId”,required=true) Long roleId

){

Map<String,String> ret = new HashMap<String, String>();

if(StringUtils.isEmpty(ids)){

ret.put(“type”, “error”);

ret.put(“msg”, “请选择相应的权限!”);

return ret;

if(roleId == null){

ret.put(“type”, “error”);

ret.put(“msg”, “请选择相应的角色!”);

return ret;

if(ids.contains(“,”)){

ids = ids.substring(0,ids.length()-1);

String[] idArr = ids.split(“,”);

if(idArr.length > 0){

authorityService.deleteByRoleId(roleId);

for(String id:idArr){

Authority authority = new Authority();

authority.setMenuId(Long.valueOf(id));

authority.setRoleId(roleId);

authorityService.add(authority);

ret.put(“type”, “success”);

ret.put(“msg”, “权限编辑成功!”);

return ret;

/**

获取某个角色的所有权限

@param roleId

@return

*/

@RequestMapping(value=“/get_role_authority”,method=RequestMethod.POST)

@ResponseBody

public List getRoleAuthority(

@RequestParam(name=“roleId”,required=true) Long roleId

){

return authorityService.findListByRoleId(roleId);

前台首页控制器:

/**

前台首页控制器

@author yy

*/

@RequestMapping(“/home”)

@Controller

public class HomeController {

@Autowired

private RoomTypeService roomTypeService;

@Autowired

private AccountService accountService;

/**

前台首页

@param model

@param name

@return

*/

@RequestMapping(value=“/index”,method=RequestMethod.GET)

public ModelAndView list(ModelAndView model,

@RequestParam(name=“name”,defaultValue=“”) String name

){

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

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=“/login”,method=RequestMethod.GET)

public ModelAndView login(ModelAndView model

){

model.setViewName(“home/index/login”);

return model;

/**

注册页面

@param model

@return

*/

@RequestMapping(value=“/reg”,method=RequestMethod.GET)

public ModelAndView reg(ModelAndView model

){

model.setViewName(“home/index/reg”);

return model;

/**

登录信息提交

@param account

@return

*/

@RequestMapping(value=“/login”,method=RequestMethod.POST)

@ResponseBody

public Map<String,String> loginAct(Account account,String vcode,HttpServletRequest request){

Map<String,String> retMap = new HashMap<String, String>();

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=“/reg”,method=RequestMethod.POST)

@ResponseBody

public Map<String,String> regAct(Account account){

Map<String,String> retMap = new HashMap<String, String>();

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=“/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;

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。