基于javaweb+mysql的ssm+maven酒店管理系统(java+ssm+jsp+mysql+maven)
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的SSM+Maven酒店管理系统(java+ssm+jsp+mysql+maven)
主要技术:java springmvc mybatis mysql tomcat js jauery jsp log4j等一些常见基本技术适用于Java毕设和学习使用
主要实现: 前台:登录、注册、酒店信息浏览、搜索酒店信息、查看房间、预定房间、等
后台:部门管理、房间管理、楼层管理、订单管理、入住管理、营业额报表、承担控制权限、员工管理、角色管理、预定报表等
主要功能截图如下: 前端登陆注册和一些基本信息查看等
//map中存放的信息已json形式返回
return JSON.toJSONString(map);
}
//删除角色信息
@RequestMapping("/deleteById")
public String deleteById(Integer id){
Map<String,Object> map = new HashMap<String, Object>();
int deleteById = roleService.deleteById(id);
if (deleteById>0){
map.put(SystemConstant.SUCCESS,true);//删除成功
map.put(SystemConstant.MESSAGE,"删除成功");
}else{
map.put(SystemConstant.SUCCESS,false);//删除失败
map.put(SystemConstant.MESSAGE,"删除失败");
}
return JSON.toJSONString(map);
}
//查看该角色编号下是否有员工
@RequestMapping("/checkRoleHasEmployee")
public String checkDeptHasEmployee(Integer id){
Map<String,Object> map = new HashMap<String, Object>();
int countById = employeeService.getEmployeeCountByRoleId(id);
if (countById>0){
//该角色是否有员工在用
map.put(SystemConstant.EXISI,true);//存在
map.put(SystemConstant.MESSAGE,"该角色有员工使用,不能删除");
}else{
map.put(SystemConstant.EXISI,false);//存在
}
return JSON.toJSONString(map);
}
/**
* 初始化菜单
* @return
*/
@RequestMapping("/initMenuTree")
public DataGridViewResult initMenuTree(Integer roleId){
//调用查询菜单列表的方法
List<Menu> menuList = menuService.findMenuList();
//根据角色ID查询该角色已经拥有的菜单ID的方法
List<Integer> currentRoleMenuIds = menuService.findMenuIdListByRoleId(roleId);
//定义集合,保存菜单信息
List<Menu> currentMenus = new ArrayList<Menu>();
@RequestMapping("/addCheckout")
public String addCheckin(Checkout checkout, HttpSession session){
Map<String,Object> map = new HashMap<String,Object>();
//获取当前登录用户
Employee employee = (Employee) session.getAttribute(SystemConstant.LOGINUSER);
//创建人
checkout.setCreatedBy(employee.getId());
//调用添加入住信息的方法
if(checkoutService.addCheckout(checkout)>0){
map.put(SystemConstant.SUCCESS,true);
map.put(SystemConstant.MESSAGE,"退房成功");
}else{
map.put(SystemConstant.SUCCESS,false);
map.put(SystemConstant.MESSAGE,"退房失败");
}
return JSON.toJSONString(map);
}
}
@Controller
@RequestMapping("/orders")
public class OrdersController {
@Resource
private OrdersService ordersService;
/**
* 添加订单
* @param orders
* @return
*/
@RequestMapping("/addOrders")
@ResponseBody
public String addOrders(Orders orders){
Map<String,Object> map = new HashMap<String,Object>();
//调用添加订单的方法
if(ordersService.addOrders(orders)>0){
map.put(SystemConstant.SUCCESS,true);
map.put(SystemConstant.MESSAGE,"酒店预订成功");
}else{
map.put(SystemConstant.SUCCESS,false);
public String deleteById(Integer id){
Map<String,Object> map = new HashMap<String, Object>();
int deleteById = roleService.deleteById(id);
if (deleteById>0){
map.put(SystemConstant.SUCCESS,true);//删除成功
map.put(SystemConstant.MESSAGE,"删除成功");
}else{
map.put(SystemConstant.SUCCESS,false);//删除失败
map.put(SystemConstant.MESSAGE,"删除失败");
}
return JSON.toJSONString(map);
}
//查看该角色编号下是否有员工
@RequestMapping("/checkRoleHasEmployee")
public String checkDeptHasEmployee(Integer id){
Map<String,Object> map = new HashMap<String, Object>();
int countById = employeeService.getEmployeeCountByRoleId(id);
if (countById>0){
//该角色是否有员工在用
map.put(SystemConstant.EXISI,true);//存在
map.put(SystemConstant.MESSAGE,"该角色有员工使用,不能删除");
}else{
map.put(SystemConstant.EXISI,false);//存在
}
return JSON.toJSONString(map);
}
/**
* 初始化菜单
* @return
*/
@RequestMapping("/initMenuTree")
public DataGridViewResult initMenuTree(Integer roleId){
//调用查询菜单列表的方法
List<Menu> menuList = menuService.findMenuList();
//根据角色ID查询该角色已经拥有的菜单ID的方法
List<Integer> currentRoleMenuIds = menuService.findMenuIdListByRoleId(roleId);
//定义集合,保存菜单信息
List<Menu> currentMenus = new ArrayList<Menu>();
//判断集合是否存在数据
if(currentRoleMenuIds!=null && currentRoleMenuIds.size()>0){
//根据菜单ID查询该菜单的信息
currentMenus = menuService.findMenuByMenuId(currentRoleMenuIds);
}
* 去到房间管理页面
* @return
*/
@RequestMapping("/toRoomManager")
public String toRoomManager(){
return "admin/room/roomManager";
}
/**
* 去到预订管理页面
* @return
*/
@RequestMapping("/toOrdersManager")
public String toOrdersManager(){
return "admin/orders/ordersManager";
}
/**
* 去到入住管理页面
* @return
*/
@RequestMapping("/toCheckinManager")
public String toCheckinManager(){
return "admin/checkin/checkinManager";
}
/**
* 去到年度营业额报表统计分析页面
* @return
*/
@RequestMapping("/toYearTotalPriceManager")
public String toYearTotalPriceManager(){
return "admin/charts/yearTotalPriceCharts";
}
/**
* 去到月营业额报表统计分析页面
* @return
*/
@RequestMapping("/toYearOfMonthCharts")
public String toYearOfMonthCharts(){
return "admin/charts/yearOfMonthCharts";
}
/**
* 去到季度营业额报表统计分析页面
* @return
*/
@RequestMapping("/toQuarterTotalPriceCharts")
public String toQuarterTotalPriceCharts(){
return "admin/charts/quarterTotalPriceCharts";
}
//保存登录用户信息到session中
Session.setAttribute(SystemConstant.FRONT_LOGIN_USER,loginUser);
}else{
map.put(SystemConstant.SUCCESS,false);
map.put(SystemConstant.MESSAGE,"用户名或密码错误,请重新登录!");
}
return JSON.toJSONString(map);
}
/**
* 根据用户名查询用户信息
* @param loginName
* @return
*/
@RequestMapping("/checkName")
@ResponseBody
public String checkName(String loginName){
Map<String,Object> map = new HashMap<String,Object>();
//调用注册的方法
if(userService.findUserByName(loginName)!=null){
map.put(SystemConstant.EXISI,true);
map.put(SystemConstant.MESSAGE,"用户名存在,请重新输入");
}else{
map.put(SystemConstant.EXISI,false);
}
return JSON.toJSONString(map);
}
}
/**
* HP - the login name of the current user.
//map中存放的信息已json形式返回
return JSON.toJSONString(map);
}
//修改角色信息
@RequestMapping("/updateRole")
public String updateRole(Role role){
Map<String,Object> map = new HashMap<String, Object>();
int updateRole = roleService.updateRole(role);
if(updateRole>0){
map.put(SystemConstant.SUCCESS,true);
map.put(SystemConstant.MESSAGE,"修改成功");
}else{
map.put(SystemConstant.SUCCESS,false);
map.put(SystemConstant.MESSAGE,"修改失败");
}
//map中存放的信息已json形式返回
return JSON.toJSONString(map);
}
//删除角色信息
@RequestMapping("/deleteById")
public String deleteById(Integer id){
Map<String,Object> map = new HashMap<String, Object>();
int deleteById = roleService.deleteById(id);
if (deleteById>0){
map.put(SystemConstant.SUCCESS,true);//删除成功
map.put(SystemConstant.MESSAGE,"删除成功");
}else{
map.put(SystemConstant.SUCCESS,false);//删除失败
map.put(SystemConstant.MESSAGE,"删除失败");
}
return JSON.toJSONString(map);
}
//查看该角色编号下是否有员工
@RequestMapping("/checkRoleHasEmployee")
public String checkDeptHasEmployee(Integer id){
Map<String,Object> map = new HashMap<String, Object>();
attach.transferTo(dest);
map.put("code",0);//状态码
map.put("msg","上传成功");//执行消息
Map<String,Object> dataMap = new HashMap<String,Object>();
dataMap.put("src","/hotel/show/"+finalName);
map.put("data",dataMap);//文件数据
map.put("imagePath",finalName);//隐藏域的值,只保留日期文件夹+重命名后的文件名
} catch (IOException e) {
e.printStackTrace();
}
}
return JSON.toJSONString(map);
}
}
/**
* HP - the login name of the current user.
* 16:27 - the current system time.
*/
@Controller
@RequestMapping("/room")
public class RoomController {
@Resource
private RoomService roomService;
@Resource
private RoomTypeService roomTypeService;
/**
* 查询房间详情
@Autowired
private UserService userService;
/**
* 注册
* @param user
* @return
*/
@RequestMapping("/register")
@ResponseBody
public String register(User user){
Map<String,Object> map = new HashMap<String,Object>();
//调用注册的方法
if(userService.addUser(user)>0){
map.put(SystemConstant.SUCCESS,true);
map.put(SystemConstant.MESSAGE,"恭喜你,注册成功!");
}else{
map.put(SystemConstant.SUCCESS,false);
map.put(SystemConstant.MESSAGE,"很遗憾,注册失败,请重新尝试!");
}
return JSON.toJSONString(map);
}
/**
* 登录
* @param
* @return
*/
@RequestMapping("/login")
@ResponseBody
public String login(String loginName, String password, HttpSession Session){
Map<String,Object> map = new HashMap<String,Object>();
//调用注册的方法
User loginUser = userService.login(loginName, password);
//登录判断
if(loginUser!=null){
@RestController
@RequestMapping("/admin/checkout")
public class CheckoutAdminController {
@Resource
private CheckoutService checkoutService;
/**
* 办理退房
* @param checkout
* @return
*/
@RequestMapping("/addCheckout")
public String addCheckin(Checkout checkout, HttpSession session){
Map<String,Object> map = new HashMap<String,Object>();
//获取当前登录用户
Employee employee = (Employee) session.getAttribute(SystemConstant.LOGINUSER);
//创建人
checkout.setCreatedBy(employee.getId());
//调用添加入住信息的方法
if(checkoutService.addCheckout(checkout)>0){
map.put(SystemConstant.SUCCESS,true);
map.put(SystemConstant.MESSAGE,"退房成功");
}else{
map.put(SystemConstant.SUCCESS,false);
map.put(SystemConstant.MESSAGE,"退房失败");
}
return JSON.toJSONString(map);
}
}
//map中存放的信息已json形式返回
return JSON.toJSONString(map);
}
//修改部门信息
@RequestMapping("/updateDept")
public String updateDept(Dept dept){
Map<String,Object> map = new HashMap<String, Object>();
int updateDept = deptService.updateDept(dept);
if(updateDept>0){
map.put(SystemConstant.SUCCESS,true);
map.put(SystemConstant.MESSAGE,"修改成功");
}else{
map.put(SystemConstant.SUCCESS,false);
map.put(SystemConstant.MESSAGE,"修改失败");
}
//map中存放的信息已json形式返回
return JSON.toJSONString(map);
}
//查询该部门下是否有员工
@RequestMapping("/checkDeptHasEmployee")
public String checkDeptHasEmployee(Integer id){
Map<String,Object> map = new HashMap<String, Object>();
int countById = employeeService.getEmployeeCountById(id);
if (countById>0){
//该部门下存在员工
map.put(SystemConstant.EXISI,true);//存在
map.put(SystemConstant.MESSAGE,"该部门下存在员工,不能删除");
}else{
map.put(SystemConstant.EXISI,false);//不存在
}
return JSON.toJSONString(map);
}
//删除部门信息
@RequestMapping("/deleteById")
public String deleteById(Integer id){
Map<String,Object> map = new HashMap<String, Object>();
int deleteById = deptService.deleteById(id);
if (deleteById>0){
map.put(SystemConstant.SUCCESS,true);//删除成功
map.put(SystemConstant.MESSAGE,"删除成功");
}else{
map.put(SystemConstant.SUCCESS,false);//删除失败
map.put(SystemConstant.MESSAGE,"删除失败");
}
return JSON.toJSONString(map);
}
//查询所有部门
}
return JSON.toJSONString(map);
}
/**
* 初始化菜单
* @return
*/
@RequestMapping("/initMenuTree")
public DataGridViewResult initMenuTree(Integer roleId){
//调用查询菜单列表的方法
List<Menu> menuList = menuService.findMenuList();
//根据角色ID查询该角色已经拥有的菜单ID的方法
List<Integer> currentRoleMenuIds = menuService.findMenuIdListByRoleId(roleId);
//定义集合,保存菜单信息
List<Menu> currentMenus = new ArrayList<Menu>();
//判断集合是否存在数据
if(currentRoleMenuIds!=null && currentRoleMenuIds.size()>0){
//根据菜单ID查询该菜单的信息
currentMenus = menuService.findMenuByMenuId(currentRoleMenuIds);
}
//创建集合保存树节点信息
List<TreeNode> treeNodes = new ArrayList<TreeNode>();
//循环遍历集合
for (Menu menu : menuList) {
//定义变量,标识是否选中
String checkArr = "0";//0表示复选框不选中,1表示选中复选框
//内层循环遍历当前角色拥有的权限菜单
//循环比较的原因:比较两个集合中的数据是否有相同的,有相同的表示当前角色拥有这个权限
for (Menu currentMenu : currentMenus) {
//如果ID相等,表示当前角色有这个菜单,有这个菜单则需要将复选框选中
if(menu.getId() == currentMenu.getId()){
checkArr ="1";//选中
break;
}
}
//定义变量,表示菜单是否展开
Boolean spread = (menu.getSpread()==null || menu.getSpread()==1) ? true : false;
treeNodes.add(new TreeNode(menu.getId(),menu.getPid(),menu.getTitle(),spread,checkArr));
}
//将数据返回到页面
return new DataGridViewResult(treeNodes);
}
/**
* 分配菜单
* @param ids
* @param roleId
/**
* HP - the login name of the current user.
* 16:27 - the current system time.
*/
@Controller
@RequestMapping("/room")
public class RoomController {
@Resource
private RoomService roomService;
@Resource
private RoomTypeService roomTypeService;
/**
* 查询房间详情
* @param id
* @param model
* @return
*/
@RequestMapping("/{id}.html")
public String detail(@PathVariable Integer id, Model model){
//调用查询房间详情的方法
Room room = roomService.findById(id);
//将数据放到模型中
model.addAttribute("room",room);
return "detail";
}
/**
* 查询全部房间列表
* @param model
* @return
*/
@RequestMapping("/list.html")
public String list(Model model){
//调用查询所有房型列表的方法
List<RoomType> roomTypeList = roomTypeService.findRoomTypeList(null);
//创建查询条件类
RoomVo roomVo = new RoomVo();
roomVo.setStatus(3);//可预订
//查询房间列表
* @return
*/
@RequestMapping("/list")
public DataGridViewResult list(FloorVo floorVo){
//设置分页信息
PageHelper.startPage(floorVo.getPage(),floorVo.getLimit());
//查询楼层列表
List<Floor> floorList = floorService.findFloorList(floorVo);
//创建分页对象
PageInfo<Floor> pageInfo = new PageInfo<Floor>(floorList);
//返回分页信息
return new DataGridViewResult(pageInfo.getTotal(),pageInfo.getList());
}
/**
* 添加楼层
* @param floor
* @return
*/
@RequestMapping("/addFloor")
public String addFloor(Floor floor){
Map<String,Object> map = new HashMap<String, Object>();
if (floorService.addFloor(floor)>0){
map.put(SystemConstant.SUCCESS,true);
map.put(SystemConstant.MESSAGE,"添加成功");
}else{
map.put(SystemConstant.SUCCESS,false);
map.put(SystemConstant.MESSAGE,"添加失败");
}
return JSON.toJSONString(map);
}
/**
* 修改楼层
* @param floor
* @return
*/
@RequestMapping("/updateFloor")
public String updateFloor(Floor floor){
Map<String,Object> map = new HashMap<String, Object>();
if (floorService.updateFloor(floor)>0){
map.put(SystemConstant.SUCCESS,true);
map.put(SystemConstant.MESSAGE,"修改成功");
}else{
map.put(SystemConstant.SUCCESS,false);
map.put(SystemConstant.MESSAGE,"修改失败");
/**
* 查询员工列表
* @param employeeVo
* @return
*/
@RequestMapping("/list")
public DataGridViewResult list(EmployeeVo employeeVo){
//设置分页信息
PageHelper.startPage(employeeVo.getPage(),employeeVo.getLimit());
//调用查询方法
List<Employee> employeeList = employeeService.findEmployeeList(employeeVo);
//创建分页对象
PageInfo<Employee> pageInfo = new PageInfo<Employee>(employeeList);
//返回数据
return new DataGridViewResult(pageInfo.getTotal(),pageInfo.getList());
}
/**
* 添加员工
* @param employee
* @param session
* @return
*/
@RequestMapping("/addEmployee")
public String addEmployee(Employee employee,HttpSession session){
Map<String,Object> map = new HashMap<String,Object>();
//获取当前登录用户
Employee loginUser = (Employee) session.getAttribute(SystemConstant.LOGINUSER);
//设置创建人
employee.setCreatedBy(loginUser.getId());
//调用新增员工的方法
if(employeeService.addEmployee(employee)>0) {
map.put(SystemConstant.SUCCESS, true);
map.put(SystemConstant.MESSAGE, "添加成功");
}else{
map.put(SystemConstant.SUCCESS, false);
map.put(SystemConstant.MESSAGE, "添加失败");
}
return JSON.toJSONString(map);
* @param id
* @return
*/
@RequestMapping("/deleteById")
public String deleteById(int id){
Map<String,Object> map = new HashMap<String,Object>();
//调用删除员工的方法
if(employeeService.deleteById(id)>0){
map.put(SystemConstant.SUCCESS, true);
map.put(SystemConstant.MESSAGE, "删除成功");
}else{
map.put(SystemConstant.SUCCESS, false);
map.put(SystemConstant.MESSAGE, "删除失败");
}
return JSON.toJSONString(map);
}
/**
* 重置密码
* @param id
* @return
*/
@RequestMapping("/resetPwd")
public String resetPwd(int id){
Map<String,Object> map = new HashMap<String,Object>();
//调用删除员工的方法
if(employeeService.resetPwd(id)>0){
map.put(SystemConstant.SUCCESS, true);
map.put(SystemConstant.MESSAGE, "重置密码成功");
}else{
map.put(SystemConstant.SUCCESS, false);
map.put(SystemConstant.MESSAGE, "重置密码失败");
}
return JSON.toJSONString(map);
}
/**
* 分配角色
* @param roleIds
* @param empId
* @return
*/
@RequestMapping("/saveEmployeeRole")
public String saveEmployeeRole(String roleIds,Integer empId){
Map<String,Object> map = new HashMap<String, Object>();
public String deleteById(Integer id){
Map<String,Object> map = new HashMap<String,Object>();
if(roomService.deleteById(id)>0){
map.put(SystemConstant.SUCCESS,true);//成功
map.put(SystemConstant.MESSAGE,"删除成功");
}else{
map.put(SystemConstant.SUCCESS,false);//失败
map.put(SystemConstant.MESSAGE,"删除失败");
}
return JSON.toJSONString(map);
}
}
@RestController
@RequestMapping("/admin/orders")
public class OrdersAdminController {
@Resource
private OrdersService ordersService;
/**
* 查询订单列表
* @param ordersVo
* @return
*/
@RequestMapping("/list")
public DataGridViewResult list(OrdersVo ordersVo){
//设置分页信息
PageHelper.startPage(ordersVo.getPage(),ordersVo.getLimit());
//调用分页查询订单列表的方法
List<Orders> ordersList = ordersService.findOrdersList(ordersVo);
//创建分页对象
/**
* HP - the login name of the current user.
* 21:55 - the current system time.
* 角色管理
*/
@RequestMapping("/admin/role")
@RestController
public class RoleController {
@Autowired
private RoleService roleService;
@Autowired
private EmployeeService employeeService;
@Autowired
private MenuService menuService;
/**