Java项目:225基于springboot酒店管理系统

114 篇文章 2 订阅
2 篇文章 0 订阅

 作者主页:源码空间站2022

 简介:Java领域优质创作者、Java项目、学习资料、技术互助

文末获取源码

项目介绍

基于springboot酒店管理系统

本项目分为前后台,前台为顾客登录,后台为管理员登录;

前台功能: 
登录、注册、首页、房间预定、个人信息、我的预约、用户留言、退出登录

后台功能:
登录、工作人员管理、角色管理、应用管理、日志管理、客户管理、留言管理、房型管理、房间管理、预约订单管理、入住管理、统计分析管理、退出登录

使用人群:
正在做毕设的学生,或者需要项目实战练习的Java学习者

由于本程序规模不大,可供课程设计,毕业设计学习演示之用

环境需要

1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 
4.数据库:MySql 5.7/8.0版本均可;

5.是否Maven项目:是;

技术栈

后端:SpringBoot+Mybaits

前端:AdminLTE+jQuery+vue.js+elementui+jsp

使用说明

项目运行:
1. 使用Navicat或者其它工具,在mysql中创建对应sql文件名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,导入成功后请执行maven clean;maven install命令;
3. 将项目中application.properties配置文件中的数据库配置改为自己的配置;
4. 运行项目,在浏览器中输入地址:http://localhost:8088/
顾客:zhangsan 密码:123456

管理员:admin 密码:123456

运行截图

前台界面

后台界面

相关代码

CheckInController

package com.example.hotel.modular.hotel.controller;

import com.example.hotel.core.common.page.DataGridDataSource;
import com.example.hotel.core.common.page.JsonData;
import com.example.hotel.core.common.page.PageBean;
import com.example.hotel.modular.hotel.model.CheckIn;
import com.example.hotel.modular.hotel.model.OrderInfo;
import com.example.hotel.modular.hotel.model.RoomInfo;
import com.example.hotel.modular.hotel.service.CheckInService;
import com.example.hotel.modular.hotel.service.OrderInfoService;
import com.example.hotel.modular.hotel.service.RoomInfoService;
import org.springframework.core.annotation.Order;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Auther: IT教程资源
 * @Date: 2023/4/15 21:32
 * @Description:
 */
@RestController
@RequestMapping("/checkin")
@CrossOrigin
public class CheckInController {

    @Resource
    private CheckInService checkInService;

    @Resource
    private RoomInfoService roomInfoService;

    @Resource
    private OrderInfoService orderInfoService;

    @PostMapping("/in")
    public JsonData in(CheckIn checkIn) {
        int count = checkInService.saveCheckIn(checkIn);
        //更新房间状态为已入住
        RoomInfo roomInfo = new RoomInfo();
        roomInfo.setRoomId(checkIn.getRoomId());
        roomInfo.setRoomStatus(1);
        roomInfoService.updateRoomInfo(roomInfo);
        //更新订单状态为已入住
        OrderInfo orderInfo = new OrderInfo();
        orderInfo.setOrderId(checkIn.getOrderId());
        orderInfo.setOrderStatus(1);
        orderInfoService.updateOrderInfo(orderInfo);

        if (count > 0) {
            return JsonData.success(count, "入住成功");
        } else {
            return JsonData.fail("入住失败");
        }
    }

    @PostMapping("/list")
//    @LoginRequired
    public DataGridDataSource<CheckIn> getOrderInfoList(@RequestParam(value = "page", required = false, defaultValue = "1") Integer page,
                                                        @RequestParam(value = "rows", required = false, defaultValue = "5") Integer rows) {

        PageBean pageBean = new PageBean(page, rows);
        Map<String, Object> map = new HashMap<>();
        map.put("start", pageBean.getStart());
        map.put("size", pageBean.getPageSize());
        List<CheckIn> checkIns = checkInService.selectCheckInList(map);

        int totalcheckIns = checkInService.getTotalCheckIn(map);
        DataGridDataSource<CheckIn> dataGridDataSource = new DataGridDataSource<>();
        dataGridDataSource.setTotal(totalcheckIns);
        dataGridDataSource.setRows(checkIns);
        return dataGridDataSource;
    }

    @PostMapping("/out")
    public JsonData out(@RequestParam(value = "orderId") Integer orderId,
                        @RequestParam(value = "roomId") Integer roomId) {

        OrderInfo orderInfo1 = orderInfoService.selectOrderInfoById(orderId);
        if (orderInfo1.getOrderStatus() == 3) {
            checkInService.deleteCheckIn(orderId);
            return JsonData.fail("已成功退房,无需重复退房");
        } else {
            //更新房间状态为正常可入住
            RoomInfo roomInfo = new RoomInfo();
            roomInfo.setRoomId(roomId);
            roomInfo.setRoomStatus(0);
            roomInfoService.updateRoomInfo(roomInfo);
            //更新订单状态为已退房
            OrderInfo orderInfo = new OrderInfo();
            orderInfo.setOrderId(orderId);
            orderInfo.setOrderStatus(3);
            checkInService.deleteCheckIn(orderId);
            int count = orderInfoService.updateOrderInfo(orderInfo);

            if (count > 0) {
                return JsonData.success(count, "退房成功");
            } else {
                return JsonData.fail("退房失败");
            }
        }
    }
}

CustomerController

package com.example.hotel.modular.hotel.controller;


import com.example.hotel.core.common.annotation.LoginRequired;
import com.example.hotel.core.common.page.DataGridDataSource;
import com.example.hotel.core.common.page.JsonData;
import com.example.hotel.core.common.page.PageBean;
import com.example.hotel.core.util.Md5Util;
import com.example.hotel.modular.hotel.model.Customer;
import com.example.hotel.modular.hotel.model.CustomerLogin;
import com.example.hotel.modular.hotel.service.CustomerService;

import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.*;


@RestController
@RequestMapping("/customer")
@CrossOrigin
public class CustomerController {

    @Resource
    private CustomerService customerService;


    @PostMapping("/list")
    @LoginRequired
    public DataGridDataSource<Customer> getUserList(@RequestParam(value = "customerLoginName", required = false, defaultValue = "") String customerLoginName,
                                                    @RequestParam(value = "customerName", required = false, defaultValue = "") String customerName,
                                                    @RequestParam(value = "customerPhone", required = false, defaultValue = "") String customerPhone,
                                                    @RequestParam(value = "page", required = false, defaultValue = "1") Integer page,
                                                    @RequestParam(value = "rows", required = false, defaultValue = "5") Integer rows) {

        PageBean pageBean = new PageBean(page, rows);
        Map<String, Object> map = new HashMap<>();
        map.put("customerLoginName", "%" + customerLoginName + "%");
        map.put("customerName", "%" + customerName + "%");
        map.put("customerPhone", "%" + customerPhone + "%");
        map.put("start", pageBean.getStart());
        map.put("size", pageBean.getPageSize());
        List<Customer> customerList = customerService.selectCustomerList(map);

        int totalCustomer = customerService.getTotalCustomer(map);
        DataGridDataSource<Customer> dataGridDataSource = new DataGridDataSource<>();
        dataGridDataSource.setTotal(totalCustomer);
        dataGridDataSource.setRows(customerList);
        return dataGridDataSource;
    }


    @PostMapping("/save")
//    @LoginRequired
    public JsonData saveCustomer(Customer customer) {
        int count = customerService.saveCustomer(customer);
        if (count > 0) {
            return JsonData.success(count, "注册成功");
        } else {
            return JsonData.fail("注册失败");
        }

    }

    @PutMapping("/update")
//    @LoginRequired
    public JsonData updateCustomer(Customer customer) {
        int count = customerService.updateCustomer(customer);
        if (count > 0) {
            Customer customerInfo = customerService.findCustomerByCustomerLoginName(customer.getCustomerLoginName());
            return JsonData.success(customerInfo, "修改成功");
        } else {
            return JsonData.fail("修改失败");
        }

    }


    @DeleteMapping("/delete")
    @LoginRequired
    public JsonData deleteCustomer(@RequestParam(value = "customerId") Integer customerId) {

        int count = customerService.deleteCustomer(customerId);
        if (count > 0) {
            return JsonData.success(count, "删除成功");
        } else {
            return JsonData.fail("删除失败");

        }
    }

    @PostMapping("/login")
    public JsonData customerLogin(CustomerLogin customerLogin){
        if (StringUtils.isEmpty(customerLogin.getCustomerLoginName())) {
            return JsonData.fail("用户名不能为空!");
        }
        if (StringUtils.isEmpty(customerLogin.getCustomerLoginPassword())) {
            return JsonData.fail("密码不能为空!");
        }
        Customer customer= customerService.findCustomerByCustomerLoginName(customerLogin.getCustomerLoginName());
        if(customer==null){
            return JsonData.fail("用户不存在!");
        }
        if (Md5Util.md5(customerLogin.getCustomerLoginPassword(), Md5Util.SALT).equals(customer.getCustomerLoginPassword())) {
            customer.setCustomerLoginPassword("");
            Map<String,Object> customerMap = new HashMap<>();
            customerMap.put("user",customer);
            return JsonData.success(customerMap);
        }else{
            return JsonData.fail("用户名或密码错误!");
        }

    }





}

RoomInfoController

package com.example.hotel.modular.hotel.controller;

import com.example.hotel.core.common.page.DataGridDataSource;
import com.example.hotel.core.common.page.JsonData;
import com.example.hotel.core.common.page.PageBean;
import com.example.hotel.modular.hotel.model.RoomInfo;
import com.example.hotel.modular.hotel.model.RoomType;
import com.example.hotel.modular.hotel.service.RoomInfoService;
import com.example.hotel.modular.hotel.service.RoomTypeService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Auther: IT教程资源
 * @Date: 2023/4/13 18:45
 * @Description:
 */
@RestController
@RequestMapping("/roominfo")
@CrossOrigin
public class RoomInfoController {

    @Resource
    private RoomInfoService roomInfoService;

    @Resource
    private RoomTypeService roomTypeService;


    @PostMapping("/save")
//    @LoginRequired
    public JsonData saveRoomInfo(RoomInfo roomInfo) {
        RoomType roomType = roomTypeService.findByTypeId(roomInfo.getTypeId());
        RoomInfo save = new RoomInfo();
        save.setRoomNumber(roomInfo.getRoomNumber());
        save.setTypeId(roomInfo.getTypeId());
        save.setRoomType(roomType.getTypeName());
        save.setRoomPrice(roomType.getPrice());
        int count = roomInfoService.saveRoomInfo(save);
        if (count > 0) {
            return JsonData.success(count, "添加成功");
        } else {
            return JsonData.fail("添加失败");
        }

    }

    @PutMapping("/update")
//    @LoginRequired
    public JsonData updateRoomInfo(RoomInfo roomInfo) {
        RoomType roomType = roomTypeService.findByTypeId(roomInfo.getTypeId());
        RoomInfo update = new RoomInfo();
        update.setRoomId(roomInfo.getRoomId());
        update.setRoomNumber(roomInfo.getRoomNumber());
        update.setTypeId(roomInfo.getTypeId());
        update.setRoomType(roomType.getTypeName());
        update.setRoomPrice(roomType.getPrice());
        int count = roomInfoService.updateRoomInfo(update);
        if (count > 0) {
            return JsonData.success(count, "修改成功");
        } else {
            return JsonData.fail("修改失败");
        }

    }

    @DeleteMapping("/delete")
//    @LoginRequired
    public JsonData deleteRoomType(@RequestParam(value = "roomId") Integer roomId) {
        int count = roomInfoService.deleteRoomInfo(roomId);
        if (count > 0) {
            return JsonData.success(count, "删除成功");
        } else {
            return JsonData.fail("删除失败");
        }

    }


    @PostMapping("/list")
//    @LoginRequired
    public DataGridDataSource<RoomInfo> getRoomTypeList(@RequestParam(value = "page", required = false, defaultValue = "1") Integer page,
                                                        @RequestParam(value = "rows", required = false, defaultValue = "5") Integer rows) {

        PageBean pageBean = new PageBean(page, rows);
        Map<String, Object> map = new HashMap<>();
        map.put("start", pageBean.getStart());
        map.put("size", pageBean.getPageSize());
        List<RoomInfo> roomInfoList = roomInfoService.selectRoomInfoList(map);

        int totalroomInfo = roomInfoService.getTotalRoomInfo(map);
        DataGridDataSource<RoomInfo> dataGridDataSource = new DataGridDataSource<>();
        dataGridDataSource.setTotal(totalroomInfo);
        dataGridDataSource.setRows(roomInfoList);
        return dataGridDataSource;
    }


    @PostMapping("/listByRoomTypeId")
//    @LoginRequired
    public DataGridDataSource<RoomInfo> getRoomTypeListByRoomTypeId(@RequestParam(value = "page", required = false, defaultValue = "1") Integer page,
                                                                    @RequestParam(value = "rows", required = false, defaultValue = "5") Integer rows,
                                                                    @RequestParam(value = "typeId") Integer typeId) {

        PageBean pageBean = new PageBean(page, rows);
        Map<String, Object> map = new HashMap<>();
        map.put("start", pageBean.getStart());
        map.put("size", pageBean.getPageSize());
        map.put("typeId", typeId);
        map.put("roomStatus", 0);
        List<RoomInfo> roomInfoList = roomInfoService.selectRoomInfoList(map);

        int totalroomInfo = roomInfoService.getTotalRoomInfo(map);
        DataGridDataSource<RoomInfo> dataGridDataSource = new DataGridDataSource<>();
        dataGridDataSource.setTotal(totalroomInfo);
        dataGridDataSource.setRows(roomInfoList);
        return dataGridDataSource;
    }


}

如果也想学习本系统,下面领取。关注并回复:225sb

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值