项目概述
随着旅游业的快速发展和人们生活水平的提高,酒店行业的管理需求日益复杂化,传统的手工管理方式已无法满足现代酒店高效运营的需求。酒店客房管理系统作为信息化管理的重要工具,能够有效提升客房资源的利用率、优化客户体验并降低运营成本。该系统通过数字化手段实现客房预订、入住、退房等全流程管理,为酒店管理者提供实时数据支持,同时为顾客提供便捷的在线服务。
本系统基于 SpringBoot 和 Vue 的前后端分离架构开发,后端采用 SpringBoot 框架实现业务逻辑处理和数据交互,前端使用 Vue.js 构建用户友好的界面。系统整合了 MyBatis 作为持久层框架,MySQL 作为数据库存储数据,确保了系统的高效性和稳定性。功能模块包括客房管理、订单管理、用户管理和系统管理,支持多角色权限控制,如管理员、前台人员和顾客。系统实现了在线预订、实时房态查看、订单统计等功能,满足了酒店日常运营的多样化需求。
数据表设计
客房信息数据表
客房信息数据表中记录了酒店所有客房的基本信息和状态,创建时间由系统自动生成,房间编号是该表的主键,存储客房类型、价格、状态等属性内容。
| 字段名 | 数据类型 | 是否为空 | 描述 |
|---|
| room_id | INT | 否 | 客房唯一编号(主键) |
| room_type | VARCHAR(20) | 否 | 客房类型(如标准间) |
| room_price | DECIMAL(10,2) | 否 | 客房每日价格 |
| room_status | VARCHAR(10) | 否 | 客房状态(空闲/占用) |
| room_desc | TEXT | 是 | 客房描述信息 |
| create_time | DATETIME | 否 | 记录创建时间 |
订单信息数据表
订单信息数据表存储客户预订和入住的相关信息,订单编号为主键,包含客户信息、入住时间、订单状态等字段。
| 字段名 | 数据类型 | 是否为空 | 描述 |
|---|
| order_id | INT | 否 | 订单唯一编号(主键) |
| user_id | INT | 否 | 客户关联编号 |
| room_id | INT | 否 | 客房关联编号 |
| check_in_time | DATETIME | 否 | 入住时间 |
| check_out_time | DATETIME | 否 | 退房时间 |
| order_status | VARCHAR(10) | 否 | 订单状态(已支付/未支付) |
| total_amount | DECIMAL(10,2) | 否 | 订单总金额 |
| create_time | DATETIME | 否 | 订单创建时间 |
用户信息数据表
用户信息数据表用于存储系统用户的基本信息和权限角色,用户编号为主键,包含登录账号、密码、角色类型等字段。
| 字段名 | 数据类型 | 是否为空 | 描述 |
|---|
| user_id | INT | 否 | 用户唯一编号(主键) |
| username | VARCHAR(50) | 否 | 用户登录账号 |
| password | VARCHAR(100) | 否 | 用户登录密码(加密) |
| user_role | VARCHAR(20) | 否 | 用户角色(管理员/前台/顾客) |
| phone | VARCHAR(20) | 是 | 用户联系电话 |
| email | VARCHAR(50) | 是 | 用户电子邮箱 |
| create_time | DATETIME | 否 | 用户注册时间 |
技术架构栈
后端技术:Spring Boot
Spring Boot 作为现代 Java 企业级开发的核心框架,以其'约定优于配置'的设计哲学重新定义了应用开发模式。核心特性解析:零配置启动,集成自动配置机制,大幅减少 XML 配置文件编写;嵌入式服务器,内置 Tomcat/Jetty/Undertow,支持独立 JAR 包部署;生产就绪,集成 Actuator 监控组件,提供健康检查、指标收集等企业级特性;微服务友好,天然支持分布式架构,与 Spring Cloud 生态无缝集成。
开发优势:通过 Starter 依赖体系和智能自动装配,开发者可将精力完全聚焦于业务逻辑实现,而非底层基础设施搭建。单一可执行 JAR 的部署模式极大简化了运维流程。
前端技术:Vue.js
Vue.js 以其渐进式框架设计和卓越的开发体验,成为现代前端开发的首选解决方案。技术亮点:响应式数据流,基于依赖追踪的响应式系统,实现高效的视图更新;组件化架构,单文件组件(SFC)设计,实现样式、逻辑、模板的完美封装;灵活的渐进式设计,可从简单的视图层库扩展至完整的 SPA 解决方案;丰富的生态系统,Vue Router、Vuex/Pinia、Vue CLI 等官方工具链完备。
开发效率:直观的模板语法结合强大的指令系统,让复杂的用户交互变得简洁明了。优秀的 TypeScript 支持和开发者工具,为大型项目提供可靠的开发保障。
核心代码
package com.controller;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Map;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import com.utils.ValidatorUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.annotation.IgnoreAuth;
import com.entity.ShangpinxinxiEntity;
import com.entity.view.ShangpinxinxiView;
import com.service.ShangpinxinxiService;
import com.service.TokenService;
import com.utils.PageUtils;
import com.utils.R;
import com.utils.MD5Util;
import com.utils.MPUtil;
import com.utils.CommonUtil;
import java.io.IOException;
import com.service.StoreupService;
com.entity.StoreupEntity;
{
ShangpinxinxiService shangpinxinxiService;
StoreupService storeupService;
R {
request.getSession().getAttribute().toString();
(tableName.equals()) {
shangpinxinxi.setShangpubianhao((String) request.getSession().getAttribute());
}
EntityWrapper<ShangpinxinxiEntity> ew = <ShangpinxinxiEntity>();
(pricestart != ) ew.ge(, pricestart);
(priceend != ) ew.le(, priceend);
shangpinxinxiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, shangpinxinxi), params), params));
R.ok().put(, page);
}
R {
EntityWrapper<ShangpinxinxiEntity> ew = <ShangpinxinxiEntity>();
(pricestart != ) ew.ge(, pricestart);
(priceend != ) ew.le(, priceend);
shangpinxinxiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, shangpinxinxi), params), params));
R.ok().put(, page);
}
R {
EntityWrapper<ShangpinxinxiEntity> ew = <ShangpinxinxiEntity>();
ew.allEq(MPUtil.allEQMapPre(shangpinxinxi, ));
R.ok().put(, shangpinxinxiService.selectListView(ew));
}
R {
EntityWrapper<ShangpinxinxiEntity> ew = <ShangpinxinxiEntity>();
ew.allEq(MPUtil.allEQMapPre(shangpinxinxi, ));
shangpinxinxiService.selectView(ew);
R.ok().put(, shangpinxinxiView);
}
R {
shangpinxinxiService.selectById(id);
shangpinxinxi.setClicknum(shangpinxinxi.getClicknum() + );
shangpinxinxi.setClicktime( ());
shangpinxinxiService.updateById(shangpinxinxi);
R.ok().put(, shangpinxinxi);
}
R {
shangpinxinxiService.selectById(id);
shangpinxinxi.setClicknum(shangpinxinxi.getClicknum() + );
shangpinxinxi.setClicktime( ());
shangpinxinxiService.updateById(shangpinxinxi);
R.ok().put(, shangpinxinxi);
}
R {
shangpinxinxiService.selectById(id);
(type.equals()) {
shangpinxinxi.setThumbsupnum(shangpinxinxi.getThumbsupnum() + );
} {
shangpinxinxi.setCrazilynum(shangpinxinxi.getCrazilynum() + );
}
shangpinxinxiService.updateById(shangpinxinxi);
R.ok();
}
R {
shangpinxinxi.setId( ().getTime() + (Math.floor(Math.random() * )).longValue());
shangpinxinxiService.insert(shangpinxinxi);
R.ok();
}
R {
shangpinxinxi.setId( ().getTime() + (Math.floor(Math.random() * )).longValue());
shangpinxinxiService.insert(shangpinxinxi);
R.ok();
}
R {
shangpinxinxiService.updateById(shangpinxinxi);
R.ok();
}
R {
shangpinxinxiService.deleteBatchIds(Arrays.asList(ids));
R.ok();
}
R {
EntityWrapper<ShangpinxinxiEntity> ew = <ShangpinxinxiEntity>();
Map<String, Object> newMap = <String, Object>();
Map<String, Object> param = <String, Object>();
Iterator<Map.Entry<String, Object>> it = param.entrySet().iterator();
(it.hasNext()) {
Map.Entry<String, Object> entry = it.next();
entry.getKey();
entry.getKey();
(pre.endsWith()) {
newMap.put(pre + newKey, entry.getValue());
} (StringUtils.isEmpty(pre)) {
newMap.put(newKey, entry.getValue());
} {
newMap.put(pre + + newKey, entry.getValue());
}
}
params.put(, );
params.put(, );
shangpinxinxiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, shangpinxinxi), params), params));
R.ok().put(, page);
}
}