Java项目:SSM酒店客房管理系统

作者主页:夜未央5788

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

文末获取源码

 

项目介绍

本项目分为前后台,前台为用户角色登录,后台为管理员角色登录。

管理员角色包含以下功能:

管理员登录,用户管理,客房类型管理,客房信息管理,预订管理,入住信息管理等功能。

用户角色包含以下功能:
用户首页,查看客房,客房预订,查看客房评价,酒店客房评价等功能。

环境需要

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.数据库:MySql 5.7/8.0版本均可;
6.是否Maven项目:是;

技术栈

1. 后端:Spring+SpringMVC+Mybatis

2. 前端:JSP+CSS+JavaScript+jquery+bootstrap

使用说明

1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;
3. 将项目中jdbc.properties配置文件中的数据库配置改为自己的配置;
4. 运行项目,输入http://localhost:8080/user_main.html 登录前台
用户账号/密码: user/123456

后台管理地址:http://localhost:8080/
管理员账号/密码:admin/123456

运行截图

前台界面-用户角色

 

 

 

 

 

后台界面-管理员角色

 

 

 

 

 

相关代码

CommentController

package cn.edu.glut.jiudian.controller;

import cn.edu.glut.jiudian.entity.Comment;
import cn.edu.glut.jiudian.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import java.util.HashMap;
import java.util.List;

/**
 * @author stone(huangshizhang) at 2019-06-11 15:59
 */
@Controller
public class CommentController {

    @Autowired
    private CommentService commentService;

    private  List<Comment> commentList = null;


    private  List<Comment> geRoomComment = null;

    @RequestMapping("roomCommentList")
    @ResponseBody
    public Object roomCommentList(@RequestParam("roomId") String roomId){
        commentList = commentService.getRoomComment(roomId);

        //HashMap<String, List<Comment>> res = new HashMap<>();
        //res.put("commentList", commentList);
        return "1";
    }

    @RequestMapping("geRoomComment")
    @ResponseBody
    public Object geRoomComment(@RequestParam("roomId") String roomId){
        geRoomComment = commentService.getRoomComment(roomId);

        //HashMap<String, List<Comment>> res = new HashMap<>();
        //res.put("commentList", commentList);
        return "1";
    }

    @RequestMapping("comment_management.html")
    public ModelAndView commentManagement(){
        ModelAndView mav = new ModelAndView("comment_management");
        mav.addObject("commentList", geRoomComment);
        return mav;
    }

    @RequestMapping("room_comment.html")
    public ModelAndView modalRoomComment(){
        ModelAndView mav = new ModelAndView("room_comment");
        mav.addObject("commentList", commentList);
        return mav;
    }

    @RequestMapping("addRoomComment")
    @ResponseBody
    public Object addRoomComment(Comment comment){

        comment.setReleaseTime(new java.sql.Date(new java.util.Date().getTime()));

        HashMap<String, String> res = new HashMap<>();
        if (commentService.addComment(comment)) {
            res.put("stateCode", "1");
        } else {
            res.put("stateCode", "0");
        }
        return res;
    }

    @RequestMapping("write_comment.html")
    public ModelAndView writeComment(){
        return new ModelAndView("write_comment");
    }

    @RequestMapping("deleteComment")
    @ResponseBody
    public Object deleteComment(@RequestParam("serNum") Integer serNum, @RequestParam("roomId") String roomId){

        Comment comment = new Comment();

        comment.setSerNum(serNum);
        comment.setContent("");

        HashMap<String, List<Comment>> res = new HashMap<>();
        if (commentService.updateByPrimaryKey(comment)) {
            List<Comment> commentList1 = commentService.getRoomComment(roomId);
            res.put("commentList", commentList1);
            return res;
        } else {
            return false;
        }
    }
}

登录控制器

package cn.edu.glut.jiudian.controller;

import cn.edu.glut.jiudian.entity.Admin;
import cn.edu.glut.jiudian.entity.User;
import cn.edu.glut.jiudian.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;

/**
 * @author stone(huangshizhang) at 2019-06-04 09:37
 */

@Controller
public class LoginController {

    @Autowired
    private LoginService loginService;

    @RequestMapping(value = {"/","adminLogin.html"})
    public ModelAndView toAdminLogin(HttpServletRequest request) {
        request.getSession().invalidate();
        return new ModelAndView("index");
    }

    @RequestMapping("adminLogout.html")
    public String adminLogout(HttpServletRequest request) {
        request.getSession().invalidate();
        return "redirect:adminLogin.html";
    }

    @RequestMapping(value = {"userLogin.html"})
    public ModelAndView toUserLogin(HttpServletRequest request) {
        request.getSession().invalidate();
        return new ModelAndView("user_main");
    }


    @RequestMapping("userLogout.html")
    public String userLogout(HttpServletRequest request) {
        request.getSession().invalidate();
        return "redirect:userLogin.html";
    }

    @RequestMapping(value = "/adminLoginCheck", method = RequestMethod.POST)
    @ResponseBody
    public Object adminLoginCheck(HttpServletRequest request, Admin admin){
        Admin admin1 = loginService.selectAdmin(admin.getAdminName(), admin.getAdminPwd());
        HashMap<String, String> res = new HashMap<>();
        if (admin1 != null){
            request.getSession().setAttribute("admin", admin1);
            res.put("stateCode", "1");
            return res;
        }else {
            res.put("stateCode", "0");
        }
        return res;
    }


    @RequestMapping(value = "/userLoginCheck", method = RequestMethod.POST)
    @ResponseBody
    public Object userLoginCheck(HttpServletRequest request, User user){

        User user1 = loginService.selectUser(user.getUserName(), user.getUserPwd());

        HashMap<String, String> res = new HashMap<>();

        if (user1 != null){

            request.getSession().setAttribute("user", user1);

            res.put("stateCode", "1");
            return res;

        }else {
            res.put("stateCode", "0");
        }

        return res;
    }


    @RequestMapping("admin_main.html")
    public ModelAndView adminMain(){
        return new ModelAndView("admin_main");
    }

    @RequestMapping("userRegister")
    @ResponseBody
    public Object userRegister(User user){
        HashMap<String, String> res = new HashMap<>();
        if (loginService.selectUserByName(user.getUserName()) > 0){
            res.put("registerState", "2");
        } else {
            if (loginService.addUser(user)) {
                res.put("registerState", "1");
            } else {
                res.put("registerState", "0");
            }
        }
        return res;
    }

}

订单控制器

package cn.edu.glut.jiudian.controller;

import cn.edu.glut.jiudian.entity.Order;
import cn.edu.glut.jiudian.entity.Room;
import cn.edu.glut.jiudian.service.OrderService;
import cn.edu.glut.jiudian.service.RoomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import java.util.HashMap;
import java.util.List;

/**
 * @author stone(huangshizhang) at 2019-06-13 19:55
 */
@Controller
public class OrderController {

    @Autowired
    private OrderService orderService;

    @Autowired
    private RoomService roomService;

    private Order checkout;

    @RequestMapping("ruzhu_management.html")
    public ModelAndView ruzhuManagement(){
        List<Order> orderList = orderService.selectAll();
        ModelAndView mav = new ModelAndView("ruzhu_management");
        mav.addObject("orderList", orderList);
        return mav;
    }

    @RequestMapping("addPayment")
    @ResponseBody
    public Object addPayment(Order order){
        order.setEndTime(new java.sql.Date(new java.util.Date().getTime()));
        HashMap<String, String> res = new HashMap<>();
        if (orderService.updateByRoomId(order)) {
            res.put("stateCode", "1");
        } else {
            res.put("stateCode", "0");
        }
        return res;
    }

    @RequestMapping("checkout")
    @ResponseBody
    public Object checkout(@RequestParam("roomId") String roomId){
        checkout = orderService.selectByRoomId(roomId);
        return true;
    }

    @RequestMapping("ruzhu_checkout.html")
    public ModelAndView ruzhuCheckout(){
        ModelAndView mav = new ModelAndView("ruzhu_checkout");
        mav.addObject("checkout", checkout);
        return mav;
    }

    @RequestMapping("ruzhu_add.html")
    public ModelAndView ruzhuAdd(){
        List<Room> roomList = roomService.selectNotInRuZhu();
        ModelAndView mav = new ModelAndView("ruzhu_add");
        mav.addObject("roomList", roomList);
        return mav;
    }

    @RequestMapping("addRuZhu")
    @ResponseBody
    public Object addRuZhu(Order order){
        order.setStartTime(new java.sql.Date(new java.util.Date().getTime()));

        HashMap<String, String> res = new HashMap<>();
        if (orderService.addOrder(order)) {
            res.put("stateCode", "1");
        } else {
            res.put("stateCode", "0");
        }
        return res;
    }

    @RequestMapping("deleteRuZhu")
    @ResponseBody
    public Object deleteRuZhu(@RequestParam("roomId") String roomId){

        HashMap<String, String> res = new HashMap<>();
        if (orderService.deleteByRoomId(roomId)) {
            res.put("stateCode", "1");
        } else {
            res.put("stateCode", "0");
        }
        return res;
    }
}

用户控制器

package cn.edu.glut.jiudian.controller;

import cn.edu.glut.jiudian.entity.Notice;
import cn.edu.glut.jiudian.entity.Room;
import cn.edu.glut.jiudian.entity.RoomType;
import cn.edu.glut.jiudian.entity.User;
import cn.edu.glut.jiudian.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import java.util.HashMap;
import java.util.List;

/**
 * @author stone(huangshizhang) at 2019-06-07 20:02
 */
@Controller
public class UserController {

    @Autowired
    private RoomTypeService roomTypeService;

    @Autowired
    private ReserveService reserveService;

    @Autowired
    private RoomService roomService;

    @Autowired
    private NoticeService noticeService;

    @Autowired
    private UserService userService;

    @RequestMapping("user_main.html")
    public ModelAndView userMain(){
        List<RoomType> roomTypeList = roomTypeService.selectAll();
        ModelAndView mav = new ModelAndView("user_main");
        mav.addObject("roomTypeList", roomTypeList);
        List<Room> roomList = roomService.selectAll();
        mav.addObject("roomList", roomList);
        List<Notice> noticeList = noticeService.selectAll();
        mav.addObject("noticeList", noticeList);
        return mav;
    }

    @RequestMapping(value = "room_type.html", method = RequestMethod.GET)
    public ModelAndView roomType(@RequestParam(value = "typeId") int typeId, @RequestParam(value = "type") String type){
        List<Room> roomList = reserveService.selectByRoomType(type);
        ModelAndView mav = new ModelAndView("user_main");
        mav.addObject("roomList", roomList);
        return mav;
    }

    @RequestMapping("deleteUser")
    @ResponseBody
    public Object deleteUser(@RequestParam("userName") String userName){
        HashMap<String, String> res = new HashMap<>();
        if (userService.deleteUser(userName)){
            res.put("stateCode", "1");
        } else {
            res.put("stateCode", "0");
        }
        return res;
    }

    @RequestMapping("user_management.html")
    public ModelAndView toUserInfoManagement(){
        List<User> userList = userService.selectAll();
        ModelAndView mav = new ModelAndView("user_management");
        mav.addObject("userList", userList);
        return mav;
    }
}

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

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

夜未央5788

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值