基于javaweb+mysql的springboot酒店宾馆管理系统(java+springboot+html+layui+jquery+maven+mysql)
运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的SpringBoot酒店宾馆管理系统(java+springboot+html+layui+jquery+maven+mysql)
功能介绍
springboot酒店宾馆管理系统。该系统为后管系统,无前台。主要分三种角色:管理者/工作人员/前台人员。
主要功能有: 客房:客房标准、房间信息; 订单:入住订单; 员工:员工信息; 事务:事务信息; 停车:车位信息; 财务:财务信息; 历史:订单历史、车库历史; 会员:会员信息;
环境需要
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.是否Maven项目: 是;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven项目
6.数据库:MySql 8.0版本;
技术栈
-
后端:SpringBoot
-
前端:html+layui+jQuery
使用说明
-
使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;若为maven项目,导入成功后请执行maven clean;maven install命令,下载所需jar包;
-
使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 3. 将项目中db.properties配置文件中的数据库配置改为自己的配置 4. 配置tomcat,然后运行项目,输入localhost:8888 登录 5. 数据库中的employ中有密码,密码是加密过的,三种权限,管理者/工作人员/前台人员 管理账号:admin 密码:worker1 工作人员账号:worker1 密码:worker1
前台人员:sever1 密码:worker1
newGarage.setType(0);
garageList.add(garageService.save(newGarage));
garageService.save(newGarage);
}while (--number>0);
return ResultReturn.success(garageList);
}
}
package com.hotel.controller;
@RestController
public class OrderHistoryController
{
private final OrderHistoryService orderHistoryService;
private final FinanceService financeService;
@Autowired
public OrderHistoryController(OrderHistoryService orderHistoryService,FinanceService financeService)
{
this.orderHistoryService=orderHistoryService;
this.financeService=financeService;
}
/**
* @return 返回订单历史集合
*/
@RequestMapping("/orderhistory/getall")
* @param orderNo 订单号
* @return 返回对应的订单历史
*/
@RequestMapping("/orderhistory/getallbyorderno")
public Result<List<OrderHistory>> getAllByOrderNo(@RequestParam("orderno") String orderNo)
{
return ResultReturn.success(orderHistoryService.findByOrderNo(orderNo));
}
/**
* 根据订单号查找对应订单信息
*
* @param orderNo 订单号
* @return 返回对应的订单历史
*/
@RequestMapping("/orderhistory/searchOne/{orderno}")
public Result<Order> orderSearchOne(@PathVariable("orderno") String orderNo)
{
return ResultReturn.success(orderHistoryService.findByOrderNo(orderNo));
}
/**
* @param order 结算完成的订单
* @return 返回对应的订单记录(作为历史记录)
*/
private OrderHistory saveOrderHistory(Order order)
{
OrderHistory orderHistory=new OrderHistory();
orderHistory.setEndtime(order.getEndtime());
orderHistory.setId(order.getId());
orderHistory.setMember(order.getIsmenber());
orderHistory.setName(order.getName());
orderHistory.setPhone(order.getPhone());
orderHistory.setPrice(order.getPrice());
orderHistory.setRoomcount(order.getRoomcount());
orderHistory.setStarttime(order.getStarttime());
return orderHistory;
}
/**
* 注意!!此方法只于OrderController中调用!!
*
* @param order 结算完成的订单
* @return 返回插入新的订单记录的结果
*/
Result<OrderHistory> orderHistoryInsert(Order order)
{
OrderHistory orderHistory=saveOrderHistory(order);
orderHistory.setOrderno(new TimeStampUtil().getString(new Timestamp(System.currentTimeMillis())));
@RestController
public class GarageHistoryController
{
private final GarageHistoryService garageHistoryService;
private final FinanceService financeService;
@Autowired
public GarageHistoryController(GarageHistoryService garageHistoryService,FinanceService financeService)
{
this.garageHistoryService=garageHistoryService;
this.financeService=financeService;
}
/**
* @return 返回车库历史纪录列表
*/
@RequestMapping("/garagehistory/getall")
public Result<List<GarageHistory>> garageHistoryList()
{
return ResultReturn.success(garageHistoryService.findAll());
}
/**
* @param garageId 车库(位)编号
* @return 返回根据车库(位)编号查询到的车库历史纪录列表
*/
@RequestMapping("/garagehistory/getallbyid/{garageno}")
public Result<List<GarageHistory>> garageHistoryListById(@PathVariable("garageno") int garageId)
{
return ResultReturn.success(garageHistoryService.findAllById(garageId));
}
/**
* @param brand 车牌
* @return 返回根据车牌查询到的车库历史纪录列表
*/
@RequestMapping("/garagehistory/getallbybrand/{brand}")
@RestController
public class EmployController
{
private final EmployService employservice;
@Autowired
public EmployController(EmployService employservice)
{
this.employservice=employservice;
}
@Autowired
EventService eventService;
@RequestMapping("/employ/list")
public Result<Employ> employList() {
return ResultReturn.success(employservice.findAll());
}
@RequestMapping("/employ/searchOne/{employno}")
public Result employSearchOne(@PathVariable("employno") int employno) {
Employ r = employservice.findByEmployno(employno);
if(r == null) {
return ResultReturn.error(1,"it's not exist, you can't delete!");
}
else {
return ResultReturn.success(r);
}
}
@RequestMapping("/employ/add")
public Result employAdd(@RequestParam("employno")int employno,@RequestParam("employname") String employname,
@RequestParam("employsex")int employsex,@RequestParam("employage") int employage,
@RequestParam("employposition")int employposition,
@RequestParam("employauthority") int employauthority,
@RequestParam("employpaymentpermonth")int employpaymentpermonth,
@RequestParam("employworktime") int employworktime,
@RequestParam("username") String username,
@RequestParam("password") String password) {
Employ e = employservice.findByEmployno(employno);
if(e!=null)
return ResultReturn.error(2,"that employno arleady exist");
else{
e = saveEmploy(employno,employname,employsex,employage,employposition,employauthority,
employpaymentpermonth,employworktime,username,password);
return ResultReturn.success(employservice.save(e));
@RestController
public class GarageHistoryController
{
private final GarageHistoryService garageHistoryService;
private final FinanceService financeService;
@Autowired
public GarageHistoryController(GarageHistoryService garageHistoryService,FinanceService financeService)
{
this.garageHistoryService=garageHistoryService;
this.financeService=financeService;
}
/**
* @return 返回车库历史纪录列表
*/
@RequestMapping("/garagehistory/getall")
public Result<List<GarageHistory>> garageHistoryList()
{
return ResultReturn.success(garageHistoryService.findAll());
}
/**
* @param garageId 车库(位)编号
* @return 返回根据车库(位)编号查询到的车库历史纪录列表
*/
@RequestMapping("/garagehistory/getallbyid/{garageno}")
public Result<List<GarageHistory>> garageHistoryListById(@PathVariable("garageno") int garageId)
{
else if (roles.contains("ROLE_WORKER")){
response.sendRedirect(basePath+"workerHotel");
return;
}
else if (roles.contains("ROLE_SERVER")){
response.sendRedirect(basePath+"serverHotel");
return;
}
else {
response.sendRedirect(basePath+"/403");
}
}
}
package com.hotel.handle;
@ControllerAdvice
public class ExceptionHandle
{
@ExceptionHandler(value=Exception.class)
@ResponseBody
public Result handel(Exception e)
{
if(e instanceof HotelException)
{
HotelException hotelException=(HotelException)e;
return ResultReturn.error(
hotelException.getCode(),
hotelException.getMessage()
);
}
else
{
e.printStackTrace();
return ResultReturn.error(
ExceptionType.UNKNOWN_ERROR.getCode(),
ExceptionType.UNKNOWN_ERROR.getMsg()
);
}
}
}
employpaymentpermonth,employworktime,username,password);
return ResultReturn.success(employservice.save(e));
}
}
@RequestMapping("/employ/update/{employno}")
public Result employUpdate(@PathVariable("employno")int employno,@RequestParam("employname") String employname,
@RequestParam("employsex")int employsex,@RequestParam("employage") int employage,
@RequestParam("employposition")int employposition,
@RequestParam("employauthority") int employauthority,
@RequestParam("employpaymentpermonth")int employpaymentpermonth,
@RequestParam("employworktime") int employworktime,
@RequestParam("username") String username,
@RequestParam("password") String password) {
Employ e = employservice.findByEmployno(employno);
if(e==null) {
return ResultReturn.error(1,"that employno did not exist");
}
else{
e = saveEmploy(employno,employname,employsex,employage,employposition,employauthority,
employpaymentpermonth, employworktime,username,password);
return ResultReturn.success(employservice.save(e));
}
}
@RequestMapping("/employ/delete/{employno}")
public Result employDelete(@PathVariable("employno")int employno) {
Employ e = employservice.findByEmployno(employno);
if (e==null)
return ResultReturn.error(1,"can't find this employno");
employservice.delete(e);
return ResultReturn.success(e);
}
@RequestMapping("/employ/personalMeasage")
public Result getPersonalMeasage() {
UserDetails userDetails = (UserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
String username = userDetails.getUsername();
String password = userDetails.getPassword();
Employ e = employservice.findByUsernameAndPassword(username,password);
System.out.println("employ measage:"+e);
return ResultReturn.success(e);
}
@RequestMapping("/employ/personalEvent")
public Result getPersonalEvent() {
return ResultReturn.error(1,"can't find this eventno");
//更新时房间号确认
E.setType(type);
Room r=roomservice.findByRoom(roomno);
if(r==null)
return ResultReturn.error(1,"roomno is not exist");
E.setRoomno(roomno);
E.setComment(comment);
Employ em=employservice.eventMatch(type,E.getStarttime());
if(em.getEmployno()==0)
{
return ResultReturn.error(1,"can't match worker in that time");
}
else
{
E.setEmployno(em.getEmployno());
return ResultReturn.success(eventservice.save(E));
}
}
//根据eventno删除事务
@RequestMapping("/event/delete/{eventno}")
public Result eventDelete(@PathVariable("eventno") int eventno)
{
Event E=eventservice.findAllByEventno(eventno);
if(E==null)
return ResultReturn.error(1,"can't find this eventno");
eventservice.delete(E);
return ResultReturn.success(E);
}
@RequestMapping("/event/searchOne/{eventno}")
public Result evenSerchOne(@PathVariable("eventno") int eventno)
{
Event e=eventservice.findById(eventno);
if(e==null)
{
return ResultReturn.error(1,"it's not exist, you can't delete!");
}
else
{
return ResultReturn.success(e);
}
}
}
package com.hotel.controller;
return ResultReturn.success(r);
}
}
public Room saveRoom(int roomno,int type,int price,int ifwindow,String comment) {
Room r = new Room();
r.setRoomno(roomno);
r.setType(type);
r.setPrice(price);
r.setIfwindow(ifwindow);
r.setComment(comment);
return r;
}
public Standard saveStandard(String stdname,int roomarea,int bedno,String equip1,String equip2){
Standard s = new Standard();
s.setStdname(stdname);
s.setRoomerea(roomarea);
s.setBedno(bedno);
s.setEquip1(equip1);
s.setEquip2(equip2);
return s;
}
}
package com.hotel.controller;
@RestController
public class OrderController
{
private final OrderService orderservice;
private final OrderRoomService orderroomservice;
private final RoomidService roomidservice;
private final RoomService roomservice;
private final OrderHistoryService orderHistoryService;
private final FinanceService financeService;
@Autowired
public OrderController(OrderService orderservice,OrderRoomService orderroomservice,RoomidService roomidservice,
RoomService roomservice,OrderHistoryService orderHistoryService,
FinanceService financeService)
{
this.orderservice=orderservice;
this.orderroomservice=orderroomservice;
this.roomidservice=roomidservice;
this.roomservice=roomservice;
this.orderHistoryService=orderHistoryService;
this.financeService=financeService;
}
/**
* 查找所有订单
*
* @return 返回现有的全部订单
*/
@RequestMapping("/order/orderlist")
public Result<List<Order>> orderList()
{
return ResultReturn.success(orderservice.findAll());
}
/**
* 根据订单号查找对应订单信息
*
* @param orderno 订单号
* @return 返回订单号对应的订单
*/
@RequestMapping("/order/searchOne/{orderno}")
public Result<Order> orderSearchOne(@PathVariable("orderno") int orderno)
{
return ResultReturn.success(orderservice.findByOrderNo(orderno));
}
/**
this.orderservice=orderservice;
this.orderroomservice=orderroomservice;
this.roomidservice=roomidservice;
this.roomservice=roomservice;
this.orderHistoryService=orderHistoryService;
this.financeService=financeService;
}
/**
* 查找所有订单
*
* @return 返回现有的全部订单
*/
@RequestMapping("/order/orderlist")
public Result<List<Order>> orderList()
{
return ResultReturn.success(orderservice.findAll());
}
/**
* 根据订单号查找对应订单信息
*
* @param orderno 订单号
* @return 返回订单号对应的订单
*/
@RequestMapping("/order/searchOne/{orderno}")
public Result<Order> orderSearchOne(@PathVariable("orderno") int orderno)
{
return ResultReturn.success(orderservice.findByOrderNo(orderno));
}
/**
* 更新订单信息
*
* @param orderno 订单号
* @param name 姓名
* @param id 身份证
* @param phone 电话号码
* @param isenter 是否入住
* @return 返回更新后的订单
*/
@RequestMapping("/order/update/{orderno}")
public Result<Order> orderUpdate(@PathVariable("orderno") int orderno,@RequestParam("name") String name,
@RequestParam("id") String id,@RequestParam("phone") String phone,
@RequestParam("isenter") int isenter)
finance.setMoney(((GarageHistory)object).getPrice());
finance.setTime(((GarageHistory)object).getEndtime());
finance.setType("车库");
financeService.save(finance);
}
else
{
throw new HotelException(ExceptionType.FINANCE_INSERT_TYPE_ERROR.getCode(),
ExceptionType.FINANCE_INSERT_TYPE_ERROR.getMsg());
}
}
}
package com.hotel.controller;
@RestController
public class MemberController
{
private final MemberService memberService;
@Autowired
public MemberController(MemberService memberService)
{
this.memberService=memberService;
}
/**
*
* @return 返回会员列表
*/
@RequestMapping("/member/getall")
public Result<List<Member>> getAll()
{
@RestController
public class RoomInformationController {
private final StandardService standservice;
private final RoomService roomservice;
@Autowired
public RoomInformationController(StandardService standservice,RoomService roomservice)
{
this.standservice=standservice;
this.roomservice=roomservice;
}
//查询房间标准列表
@RequestMapping("/standard")
public Result<List<Standard>> standardList() {
return ResultReturn.success(standservice.getAll());
}
//添加客房标准
@RequestMapping("/standard/add")
public Result standardAdd(@RequestParam("stdname") String stdname,
@RequestParam("roomarea") int roomarea,@RequestParam("bedno") int bedno,
@RequestParam("equip1") String equip1,@RequestParam("equip2") String equip2) {
Standard standard = saveStandard(stdname,roomarea,bedno,equip1,equip2);
return ResultReturn.success(standservice.save(standard));
}
//删除客房标准
@RequestMapping("/standard/deletebystdno")
public Result deleteByStdNo(@RequestParam("stdno") int stdno){
standservice.delete(standservice.findByStandard(stdno));
return ResultReturn.success();
}
//查询客房信息列表
@RequestMapping("/room/roomlist")
public Result<List<Room>> roomList() {
public Result<OrderRoom> orderroomSearchOne(@PathVariable("orno") int orno)
{
return ResultReturn.success(orderroomservice.findOne(orno));
}
/**
* OrderRoom表更新
*
* @param orno 编号
* @param brand 车牌号
* @param roomnoAfter 之前的房间号
* @param roomnoBefore 现在重新设定的房间号(计算价格需要)
* @param orderno 订单号(保存当前订单的价格需要)
* @return 返回保存的orderroom对象
*/
@RequestMapping("/order/orderroom/update/{orno}")
public Result orderroomUpdate(@PathVariable("orno") int orno,@RequestParam("brand") String brand,
@RequestParam("roomnoAfter") int roomnoAfter,
@RequestParam("roomnoBefore") int roomnoBefore,@RequestParam("orderno") int orderno)
{
OrderRoom or=orderroomservice.findOne(orno);
or.setBrand(brand);
or.setRoomno(roomnoAfter);
List<Roomid> ri=roomidservice.findAll(roomnoBefore);
for (Roomid aRi : ri)
{
aRi.setRoomno(roomnoAfter);
}
roomidservice.saveAll(ri);
Order order=orderservice.findByOrderNo(orderno);
Room roomAfter=roomservice.findByRoom(roomnoAfter);
Room roomBefore=roomservice.findByRoom(roomnoBefore);
order.setPrice(order.getPrice()+roomAfter.getPrice()-roomBefore.getPrice());
orderservice.save(order);
return ResultReturn.success(orderroomservice.save(or));
}
{
return ResultReturn.success(memberService.findByID(id));
}
/**
*
* @param phone 电话号码
* @param name 姓名
* @param id 身份证
* @return 返回对应会员
*/
@RequestMapping("/member/insert")
public Result<Member> insert(@RequestParam("phone") String phone,
@RequestParam("name") String name,
@RequestParam("id") String id)
{
Member member=new Member();
member.setPhone(phone);
member.setName(name);
member.setId(id);
member.setEntertime(new Timestamp(System.currentTimeMillis()));
return ResultReturn.success(memberService.save(member));
}
/**
*
* @param phone 电话号码
* @return 返回成功
*/
@RequestMapping("/member/deletebyphone")
public Result deleteByPhone(@RequestParam("phone") String phone)
{
memberService.delete(memberService.findByPhone(phone));
return ResultReturn.success();
}
/**
*
* @param id 身份证
* @return 返回成功
*/
@RequestMapping("/member/deletebyid")
public Result deleteByID(@RequestParam("id") String id)
{
memberService.delete(memberService.findByID(id));
return ResultReturn.success();
}
}
package com.hotel.login;
Employ e = employservice.findByUsernameAndPassword(username,password);
System.out.println("employ measage:"+e);
return ResultReturn.success(e);
}
@RequestMapping("/employ/personalEvent")
public Result getPersonalEvent() {
UserDetails userDetails = (UserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
String username = userDetails.getUsername();
String password = userDetails.getPassword();
Employ e = employservice.findByUsernameAndPassword(username,password);
List<Event> event = eventService.findAllByEmployno(e.getEmployno());
System.out.println("event: "+event);
return ResultReturn.success(event);
}
public Employ saveEmploy(int employno,String employname,int employsex,int employage,
int employposition,int employauthority,
int employpaymentpermonth,int employworktime,
String username,String password) {
Employ e = new Employ();
e.setEmployno(employno);
e.setEmployposition(employposition);
e.setEmployworktime(employworktime);
e.setEmployage(employage);
e.setEmploysex(employsex);
e.setEmployname(employname);
e.setEmploypaymentpermonth(employpaymentpermonth);
e.setEmployauthority(employauthority);
e.setUsername(username);
e.setPassword(BCrypt.hashpw(password, BCrypt.gensalt()));
return e;
}
}
package com.hotel.controller;
return ResultReturn.success(garageHistoryService.findAllById(garageId));
}
/**
* @param brand 车牌
* @return 返回根据车牌查询到的车库历史纪录列表
*/
@RequestMapping("/garagehistory/getallbybrand/{brand}")
public Result<List<GarageHistory>> garageHistoryListByBrand(@PathVariable("brand") String brand)
{
return ResultReturn.success(garageHistoryService.findAllByBrand(brand));
}
/**
* @param year 年份
* @param month 月份
* @param day 天数
* @return 返回日车库历史
*/
@RequestMapping("/garagehistory/getallbyday")
public Result<List<GarageHistory>> getAllByDay(@RequestParam("year") int year,@RequestParam("month") int month,
@RequestParam("day") int day)
{
return ResultReturn.success(garageHistoryService.findAllByDay(year,month,day));
}
/**
* @param year 年份
* @param month 月份
* @return 返回日车库历史
*/
@RequestMapping("/garagehistory/getallbymonth")
public Result<List<GarageHistory>> getAllByMonth(@RequestParam("year") int year,@RequestParam("month") int month)
{
return ResultReturn.success(garageHistoryService.findAllByMonth(year,month));
}
/**
* @param year 年份
* @return 返回日车库历史
*/
return ResultReturn.success(memberService.findByPhone(phone));
}
/**
*
* @param id 身份证
* @return 返回对应会员
*/
@RequestMapping("/member/getbyid")
public Result<Member> getByID(@RequestParam("id") String id)
{
return ResultReturn.success(memberService.findByID(id));
}
/**
*
* @param phone 电话号码
* @param name 姓名
* @param id 身份证
* @return 返回对应会员
*/
@RequestMapping("/member/insert")
public Result<Member> insert(@RequestParam("phone") String phone,
@RequestParam("name") String name,
@RequestParam("id") String id)
{
Member member=new Member();
member.setPhone(phone);
member.setName(name);
member.setId(id);
member.setEntertime(new Timestamp(System.currentTimeMillis()));
return ResultReturn.success(memberService.save(member));
}
/**
*
* @param phone 电话号码
* @return 返回成功
*/
@RequestMapping("/member/deletebyphone")
public Result deleteByPhone(@RequestParam("phone") String phone)
{