酒店管理系统

article/2025/8/19 16:07:16

酒店后台管理系统

这是一个基于ssm+jsp的maven后台管理系统项目,使用idea,Mysql来搭建项目,在完成项目后,我想通过一篇博客来记录我的学习过程已经对项目进行讲解,具体的代码会放在Github上
功能介绍:
1,能够实现对系统管理员进行授权,不同级别的管理员可以授予不同的管理员权限。
2,能够实现入住信息的查询,添加,删除。
3,能够实现对客房信息的查询,已经管理不同类型的客房
4,管理VIP客户
功能展示
首页添加系统用户
在这里插入图片描述
注册会员
在这里插入图片描述入住信息
在这里插入图片描述

在介绍项目之前,我想先记录一个分页功能和按条件查询功能(手机号,姓名,房间号),分页在展示数据的时候是必不可少的,按条件查询也同样重要

1在pom中加分页插件

<!-- 分页插件 --><dependency><groupId>com.github.pagehelper</groupId><artifactId>pagehelper</artifactId><version>4.1.6</version></dependency>

2, 配置mybatis的分页插件PageHelper

<!-- 配置mybatis的分页插件PageHelper --><plugins><!-- com.github.pagehelper为PageHelper类所在包名 --><plugin interceptor="com.github.pagehelper.PageHelper"><!-- 设置数据库类型Oracle,Mysql,MariaDB,SQLite,Hsqldb,PostgreSQL六种数据库 --><property name="dialect" value="mysql"/></plugin></plugins>

在service层调用

3,service层
@AutowiredUserDao userDao;@Overridepublic List<Map<String, Object>> findUsersInfo(Map<String, Object> paramMap, Integer pageNum, Integer pageSize) {PageHelper.startPage(pageNum, pageSize);return userDao.selectUser(paramMap);}

在controller层调用

4,controller层@RequestMapping("/getUserInfo.do")public String getInRoomInfo(Model model,@RequestParam(value = "pageNum", required = false, defaultValue = "1") Integer pageNum,@RequestParam(value = "pageSize", required = false, defaultValue = "2") Integer pageSize,@RequestParam(value = "name", required = false) String name,@RequestParam(value = "email", required = false) String email,@RequestParam(value = "tel", required = false) String tel){Map<String, Object> paramMap = new HashMap<String, Object>();if(name!=null){name=name.trim();}if(email!=null){email=email.trim();}if(tel!=null){tel=tel.trim();}paramMap.put("name", name);paramMap.put("email", email);paramMap.put("tel",tel);List<Map<String, Object>> usersInfo = userService.findUsersInfo(paramMap, pageNum, pageSize);PageInfo<Map<String, Object>> pageInfo = new PageInfo<>(usersInfo);model.addAttribute("pageInfo",pageInfo);return "testuserinfo.jsp";}

在jsp页面

<script src="${pageContext.request.contextPath }/static/js/bootstrap/jquery.min.js"></script><!-- 引入bootstrap分页 --><link rel="stylesheet" href="${pageContext.request.contextPath }/static/js/bootstrap/bootstrap.css" /><%-- <script src="<%=basePath%>/static/js/bootstrap/jquery.min.js"></script> --%><script src="${pageContext.request.contextPath }/static/js/bootstrap.min.js"></script><script src="${pageContext.request.contextPath }/static/js/bootstrap-paginator.js"></script><div class="row"><div class="col-md-6">第${pageInfo.pageNum}页,共${pageInfo.pages}页,共${pageInfo.total}条记录</div><div class="col-md-6 offset-md-4"><nav aria-label="Page navigation example"><ul class="pagination pagination-sm"><li class="page-item"><a class="page-link" href="${pageContext.request.contextPath}/getUserInfo.do?pageNum=1">首页</a></li><c:if test="${pageInfo.hasPreviousPage}"><li class="page-item"><a class="page-link"href="${pageContext.request.contextPath}/getUserInfo.do?pageNum=${pageInfo.pageNum-1}">上一页</a></li></c:if><c:forEach items="${pageInfo.navigatepageNums}" var="page"><c:if test="${page==pageInfo.pageNum}"><li class="page-item active"><a class="page-link" href="#">${page}</a></li></c:if><c:if test="${page!=pageInfo.pageNum}"><li class="page-item"><a class="page-link"href="${pageContext.request.contextPath}/getUserInfo.do?pageNum=${page}">${page}</a></li></c:if></c:forEach><c:if test="${pageInfo.hasNextPage}"><li class="page-item"><a class="page-link"href="${pageContext.request.contextPath}/getUserInfo.do?pageNum=${pageInfo.pageNum+1}">下一页</a></li></c:if><li class="page-item"><a class="page-link" href="${pageContext.request.contextPath}/getUserInfo.do?pageNum=${pageInfo.pages}">末页</a></li></ul></nav></div></div>

按条件查询
在这里插入图片描述
实现步骤:
1,在jsp页面的form标签中以post的方式发请求到获取全部用户信息的请求方法getInRoomInfo.do。

<table><form action="<%=basePath %>/getInRoomInfo.do" method="post" name="serch"><tr><td class="zi"><span>选择分类:</span></td><td><select id="conditionType"><option value="roomNum">房间号</option><option value="customerName">客人姓名</option><option value="phone">手机号码</option></select></td><td class="zi"><span>关键字:</span></td><td><input id="keyword" name="roomNum" type="text" value="" placeholder="与分类关联"/></td><td><input type="submit" value="查询" class="button"/></td></tr></form></table><script type="text/javascript">jQuery(function(){jQuery("#conditionType").change(function(){var v = jQuery(this).find("option:selected").val();console.log(v);jQuery("#keyword").attr("name",v);});});</script>

在controller中,将customerName,roomNum,phone放入map集合中再去调用service方法,由于只能按照一个条件去查询,所以这三个参数只有一个是有值的,另外两个是null的。

 @RequestMapping("/getInRoomInfo.do")public String getInRoomInfo(Model model,@RequestParam(value = "pageNum", required = false, defaultValue = "1") Integer pageNum,@RequestParam(value = "pageSize", required = false, defaultValue = "3") Integer pageSize,@RequestParam(value = "customerName", required = false) String customerName,@RequestParam(value = "roomNum", required = false) String roomNum,@RequestParam(value = "phone", required = false) String phone) {Map<String, Object> paramMap = new HashMap<String, Object>();paramMap.put("customerName", customerName);paramMap.put("roomNum", roomNum);paramMap.put("phone", phone);List<Map<String, Object>> inRoomList = inRoomService.findInRoomInfo(paramMap, pageNum, pageSize);PageInfo<Map<String, Object>> pageInfo = new PageInfo<>(inRoomList);model.addAttribute("pageInfo", pageInfo);return "bill/inroominfo.jsp";}

service层中调用dao方法接口
在Mapper中SQL是这样写的,使用if标签,使得传进来的非空的值能够成为条件拼接到SQL语句中。

<!-- 查询入住信息 --><select id="selectInRoomInfo" resultType="Map" parameterType="Map">SELECT iri.out_room_status,rm.room_num,rt.room_type_name,iri.customer_name,iri.gender,iri.phone,iri.money,iri.idcard,iri.create_date,iri.is_vip,vp.vip_rateFROM hotel.in_room_info iri INNER JOIN hotel.rooms rm ON iri.room_id=rm.idINNER JOIN hotel.room_type rt ON rt.id=rm.room_type_id LEFT JOIN hotel.vip vp ONiri.idcard=vp.idcard WHERE iri.status='1'<if test="customerName!=null and customerName!=''">AND iri.customer_name=#{customerName}</if><if test="roomNum!=null and roomNum!=''">and rm.room_num=#{roomNum}</if><if test="phone!=null and phone!=''">AND iri.phone=#{phone}</if></select>

项目搭建:只需要配置Spring,Springmvc,Mybatis的配置文件,CSDN上很多这种文件,只需要修改一下数据库文件即可使用,需要注意的是不同版本的数据库文件数据库驱动不同,这里代码就不贴上来了。
自此,项目的底层就搭建好了!
.接下来我分三层,来讲解我的项目:dao层(持久层),service(服务层),controller(层)
持久层主要用于操作数据库,实现对数据库的增删改查
分别对VIP模块,系统管理员模块,登录模块,入住模块,客房模块
service
controller

  1. 代码不在一一赘述,我想记录一些SQl语句,便于后来学习。
    首先是验证登录的SQL,用户名,密码正确,使用状态为1
<select id="login" resultType="Integer">SELECT COUNT(*) FROM system_user where username=#{username} AND pwd=#{password} AND use_status=1</select>

2,授权信息列表 ,因为不同权限的管理登录,他拥有的权限也是不同的,所以在完成登录之后需要去获取权限

<select id="getSQAuthority" resultMap="BaseOneMenu">SELECT * FROM(SELECT id AS oneId,authority_name AS oneName FROM system_authority WHERE parent=0) t1INNER JOIN(SELECT id AS twoId,authority_name AS twoName,authority_url AS url,parentFROM system_authority WHERE parent!=0) t2ON t2.parent=t1.oneId WHERE t1.oneId!=5</select>
<!-- 根据用户id获取具体的权限 --><select id="getAuthorityByUsername" resultMap="BaseOneMenu">select * from(select sa.id as oneId,sa.authority_name as oneName from hotel.system_authority sainner join hotel.user_authority ua on sa.id=ua.authority_idinner join hotel.system_user su on su.id=ua.user_id where su.username=#{0} and sa.parent=0) t1inner join(select sa.id as twoId,sa.authority_name as twoName,sa.authority_url as url,sa.parent from hotel.system_authority sainner join hotel.user_authority ua on sa.id=ua.authority_idinner join hotel.system_user su on su.id=ua.user_id where su.username=#{0} and sa.parent!=0) t2on t1.oneId=t2.parent;</select>

在service层中完成调用Mapper的方法,实现基本的业务逻辑
注入Mapper对象

@Autowiredprivate LoginMapper loginMapper;

验证登录

@Transactional(readOnly = false)public boolean login(String username, String pwd, HttpSession session) throws Exception {// 对明文密码进行加密后在调用mapper层pwd = MD5Tool.md5(pwd);int flag = loginMapper.login(username, pwd);if (flag >= 1) {List<OneMenu> oneMenuList = loginMapper.getAuthorityByUsername(username);session.setAttribute("oneMenuList", oneMenuList);session.setAttribute("username", username);return true;}return false;

controller层:调用service层的业务逻辑,并且返回给前端
注入service对象用于调用,登录成功即可跳到首页,登录失败则跳到登录页重新登录

@Controller
public class LoginController {@Resourceprivate LoginService loginService;@RequestMapping("/login.do")public String login(String username, String pwd, HttpSession session) throws Exception {boolean flag = loginService.login(username, pwd, session);return flag ? "index.jsp" : "login.jsp";}}

以上便是登录功能,接下来介绍增加系统管理员功能
向系统添加管理员涉及到两条SQL

<!-- 添加系统用户parameterType参数类型  keyProperty:key的值 keyColumn:取到的对应数据库的列--><insert id="insertSystemUser" parameterType="Map" useGeneratedKeys="true" keyProperty="userId" keyColumn="id">INSERT INTO SYSTEM_USER VALUES(NULL,#{username},#{pwd},NOW(),'1','0')</insert><!-- 添加二级权限信息 --><insert id="insertAuthority"  parameterType="Long" >INSERT INTO user_authority VALUES(#{userId},#{authority})</insert>

因为这个功能的实现,需要涉及到多张表,因此在这里着重记录一下数据库的相关知识
只读事务(@Transactional(readOnly = true))的一些概念
注意是一次执行多次查询来统计某些信息,这时为了保证数据整体的一致性,要用只读事务,在将事务设置成只读后,相当于将数据库设置成只读数据库,此时若要进行写的操作,会出现错误
service层中,使用map,将用户名和密码放入map集合中,然后调用登录的接口,验证登录。再将userId与权限id都添加到user_authority表中

 @Transactional(readOnly = false)@Overridepublic boolean saveSystemUser(String username, String pwd, String oneIds, String twoIds) throws Exception {// 1、往system_user表中添加数据,获取生成的主键值Map<String, Object> paramMap = new HashMap<>();paramMap.put("username", username);paramMap.put("pwd", MD5Tool.md5(pwd));int flag1 = systemUserMapper.insertSystemUser(paramMap);// 2、将userId与权限id都添加到user_authority表中中if (flag1 <= 0)return false;Long userId = Long.parseLong(paramMap.get("userId") + "");String idStr = oneIds + twoIds;// "1,1,1,4,4,10,12,14"String[] idAttr = idStr.replaceAll("(.,)\\1+", "$1").split("\\,");for (String authorityId : idAttr) {int flag2 = systemUserMapper.insertAuthority(userId, Long.parseLong(authorityId));if (flag2 <= 0){return false;}}return true;}

controller中去调用即可

 /* 添加系统用户(同时授权)*/@RequestMapping("/addSystemUser.do")public @ResponseBodyboolean addSystemUser(String username, String pwd, String oneIds, String twoIds)throws Exception {return systemUserService.saveSystemUser(username, pwd, oneIds, twoIds);}@RequestMapping("/getSystemUserByLimit.do")public String getSystemUserByLimit(Model model,@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {List<Map<String, Object>> systemUserList = systemUserService.findSystemUserByLimit(pageNum, pageSize);model.addAttribute("systemUserList", systemUserList);return "user/showSystemUser.jsp";}

以上记录的是两个比较常见的功能,其他功能类似,就不在一一介绍了。


http://chatgpt.dhexx.cn/article/UmgOs0d1.shtml

相关文章

Hotel Manager 酒店管理系统

Hotel Manager 酒店管理系统 问题分析 菜单界面 操作员能够方便的选择所需要进行的操作 在main函数中对每次操作跳转到不同的函数中 执行完操作后返回到管理页面 不同房间的标准价格制定&#xff0c;收费方式的制定&#xff1a;/天 或 /小时 每个房间的收费方式要写2个 ro…

酒店管理系统的设计与实现/酒店客房管理系统/酒店预定系统

摘 要 随着科学技术的飞速发展&#xff0c;社会的方方面面、各行各业都在努力与现代的先进技术接轨&#xff0c;通过科技手段来提高自身的优势&#xff0c;酒店管理系统当然也不能排除在外。酒店管理系统是以实际运用为开发背景&#xff0c;运用软件工程开发方法&#xff0c;采…

酒店管理系统/酒店客房管理系统的设计与实现

摘 要 酒店管理系统采用B/S模式&#xff0c;促进了酒店管理的安全、高效、快捷的发展。传统的管理模式还处于手工处理阶段&#xff0c;管理效率极低&#xff0c;随着用户的不断增多&#xff0c;传统基于手工管理模式已经无法满足当前用户需求&#xff0c;随着信息化时代的到来…

酒店客房管理信息系统

目 录 摘 要 Abstracts 目 录 第1章 绪论 1.1课题背景 1.2研究意义 1.3研究内容 第2章 技术介绍 2.1相关技术 2.2java技术 2.3MySQL数据库 2.4 Tomcat介绍 2.5SSM框架 第3章 需求分析 3.1需求分析概述 3.2可行性分析 3.2.1经济可行性 3.2.2技术可行性 3.3…

酒店客房管理系统

技术&#xff1a;Java、JSP等 摘要&#xff1a;随着我国经济的不断发展&#xff0c;外出旅游或工作越来越多成为居民必不可少的一部分。所以酒店也在这样的条件下不断快速的发展。同时&#xff0c;随着酒店企业的蓬勃发展&#xff0c;酒店对酒店客房信息的管理的难度不断增大&a…

asp.net1053-酒店宾馆客房预订管理系统#毕业设计

项目编号:asp.net1053-酒店宾馆客房预订管理系统#毕业设计 运行环境&#xff1a;VSSQL 开发工具:VS2010及以上版本 数据库:SQL2008及以上版本 使用技术&#xff1a;HTMLJSHTML 开发语言&#xff1a;C#&#xff0c;框架&#xff1a;asp.net 传统的酒店管理模式基本上都是用传统的…

模型量化各类论文综述(摘要、方法总结)

模型量化各类论文综述&#xff08;摘要、方法总结&#xff09; 方法&#xff08;总结&#xff09;&#xff1a; Fixed-point Scalar Quantization Reference 1、韩松2、https://arxiv.org/pdf/2004.07320.pdf

毕业论文 | 文献综述应该怎么写

毕业论文 | 文献综述应该怎么写 01关于论文写作的顺序02 研究背景该写点啥03 文献综述包括啥子04 文献综述大纲05 文献综述引用小技巧06 Endnote文献管理工具 这篇文章想输出一下这份我在写文献综述时的总结。 依旧是提前说明&#xff0c;这篇文章只是我在毕业论文写作中总结到…

【论文笔记】中文词向量论文综述(一)

导读 最近在做中文词向量相关工作&#xff0c;其中看了一些中文词向量的相关论文&#xff0c;在这篇文章&#xff0c;将把近几年的中文词向量进展及其模型结构加以简述&#xff0c;大概要写3-4篇综述&#xff0c;每篇包含2-3篇论文。 一、Component-Enhanced Chinese Characte…

超分论文综述( DualCNN,Deep SR-ITM ,DSGAN)

论文来源&#xff1a; [1] Pan, J., Liu, S., Sun, D., Zhang, J., Liu, Y., Ren, J., ... & Yang, M. H. (2018). Learning dual convolutional neural networks for low-level vision. In Proceedings of the IEEE conference on computer vision and pattern recognit…

【论文笔记】知识图谱综述2021

KRL - Knowledge Representation Learning 在知识表示学习里&#xff0c;我们希望把实体和关系映射到低维空间上&#xff0c;这样便于我们提取实体与关系的特征表示。这时我们的思路可以是&#xff1a; which representation space to choose 本文描述了4种表示空间&#xff1…

目标检测论文综述(四)Anchor-Free

——CNN based Anchor-Free Detectors 所有论文综述均保持如下格式&#xff1a; 1、一页PPT内容总结一篇论文 2、标题格式一致&#xff1a;出处 年份 《标题》 3、内容格式一致&#xff1a;针对XX问题&#xff1b;提出了XX方法&#xff1b;本文证明了XXX 4、把握核心创新点&am…

本科毕业论文内容必须有国内外文献综述吗?

不知不觉间整个暑假变过去了&#xff0c;现在大部分的大学生都已经开学了。2023届毕业的学生现在也开始借鉴毕业论文的选题工作。但是无论是现在正在选题的大四的同学们还是还在上大一大&#xff0c;二大三的同学们都对毕业论文这4个字有着天生的恐惧感。因为对于大多数人来说&…

OCR论文综述(含文字识别、文本检测、端到端和数据集合)

OCR综述概览 主要分为四个部分 文字识别、文本检测、端到端文字识别和数据集的介绍 1. 文字识别 指标为f1-score Conf.NetTitleSVTIIIT5KICDAR13TPAMI2015CRNNAn end-to-end trainable neural network for image-based sequencerecognition and its application to scene t…

医学诊断报告生成论文综述

摘要 由Image/Video Captioning、VQA等图像理解任务的不断往前发展&#xff0c;以及目前智能医疗的兴起&#xff0c;有些学者自然而然地想到图像理解是否可以应用到医学领域&#xff0c;因此根据CT、核磁等图像自动生成诊断报告(病例)&#xff0c;这个任务被提了出来。 2018年…

目标检测论文综述(三)One-Stage(YOLO系列)

一、CNN based One-Stage Detectors 所有论文综述均保持如下格式&#xff1a; 1、一页PPT内容总结一篇论文 2、标题格式一致&#xff1a;出处 年份 《标题》 3、内容格式一致&#xff1a;针对XX问题&#xff1b;提出了XX方法&#xff1b;本文证明了XXX 4、把握核心创新点&…

【半监督论文综述】A survey on semi-supervised learning

下载 半监督学习 1. 半监督学习1.1 三个假设1.1.1 平滑假设1.1.2 低密度假设1.1.3 流形假设1.1.4 聚类假设 1.2. 评估半监督学习算法 2. 半监督学习算法分类2.1 Inductive methods2.1.1. Wrapper methods2.1.1.1 Self-training2.1.1.2 Co-Training2.1.1.2.1 Multi-view co-tra…

综述类论文怎么写?

综述类论文的关键点在于必须要有一个明确有效的叙述结构。严格来说&#xff0c;这类文章并没有固定的结构安排要求&#xff0c;但一个科学有效的叙述结构不仅会让作者的表达逻辑更为清晰和条理&#xff0c;还能帮助读者减少阅读困难&#xff0c;提高阅读效率&#xff0c;对论述…

视频理解论文综述

A Comprehensive Study of Deep Video Action Recognition TSN网络是一个很经典的网络&#xff0c;如果不知道的自己查... 基于TSN的改进论文分了三大类&#xff1a; 其他资料&#xff1a; Temporal Segment Network TSN提出的背景是当时业界做动作识别都是用 Two-stream …

毕业论文第一步--如何快速写出让人眼前一亮的文献综述论文(citspace)

一、文献综述是什么&#xff1f; 文献综述简称综述&#xff0c;是对某一领域&#xff0c;某一专业或某一方面的课题、问题或研究专题搜集大量相关资料&#xff0c;然后通过阅读、分析、提炼、整理当前课题、问题或研究专题的最新进展、学术见解或建议&#xff0c;对其做出综合性…