作者主页:夜未央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
- 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
commentList = null; -
-
- private List
geRoomComment = null; -
- @RequestMapping("roomCommentList")
- @ResponseBody
- public Object roomCommentList(@RequestParam("roomId") String roomId){
- commentList = commentService.getRoomComment(roomId);
-
- //HashMap
> res = new HashMap<>(); - //res.put("commentList", commentList);
- return "1";
- }
-
- @RequestMapping("geRoomComment")
- @ResponseBody
- public Object geRoomComment(@RequestParam("roomId") String roomId){
- geRoomComment = commentService.getRoomComment(roomId);
-
- //HashMap
> 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
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
> res = new HashMap<>(); - if (commentService.updateByPrimaryKey(comment)) {
- List
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
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
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
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
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
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
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
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
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
roomTypeList = roomTypeService.selectAll(); - ModelAndView mav = new ModelAndView("user_main");
- mav.addObject("roomTypeList", roomTypeList);
- List
roomList = roomService.selectAll(); - mav.addObject("roomList", roomList);
- List
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
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
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
userList = userService.selectAll(); - ModelAndView mav = new ModelAndView("user_management");
- mav.addObject("userList", userList);
- return mav;
- }
- }
如果也想学习本系统,下面领取。关注并回复:130ssm