基于javaweb+mysql的springboot酒店预订管理系统(java+springboot+vue+maven+mysql)

基于javaweb+mysql的springboot酒店预订管理系统(java+springboot+vue+maven+mysql)

运行环境

Java≥8、MySQL≥5.7、Node.js≥10

开发工具

后端:eclipse/idea/myeclipse/sts等均可配置运行

前端:WebStorm/VSCode/HBuilderX等均可

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

基于javaweb+mysql的SpringBoot酒店预订管理系统(java+springboot+vue+maven+mysql)

一、项目运行 环境配置:

Jdk1.8 + Tomcat8.5 + Mysql + HBuilderX(Webstorm也行)+ Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)。

项目技术:

Spring + SpringBoot+ mybatis + Maven + Vue 等等组成,B/S模式 + Maven管理等等。


    @RequestMapping(method = RequestMethod.POST,value = "/delete/{workerId}")
    public AjaxResult deleteOperator(@PathVariable Integer workerId){
        int re = workerService.delete(workerId);
        if(re!=1) ResponseTool.failed();
        return ResponseTool.success("删除成功");
    }

    @RequestMapping(value = "")
    public AjaxResult getAllOperator(){
        return ResponseTool.success(workerService.selectByRole(Role.OPERATOR.getValue()));
    }

    @RequestMapping(method = RequestMethod.POST,value = "/{workerId}")
    public AjaxResult getOperator(@PathVariable Integer workerId){
        return ResponseTool.success(workerService.selectById(workerId));
    }

    @RequestMapping(method = RequestMethod.POST,value = "/add")
    public AjaxResult addOperator(String username,String password,String name,String gender,String phone,String email,String address){
        Worker worker = new Worker(username,password,name,gender,phone,email,address);
        worker.setRole(Role.OPERATOR.getValue());
        int re = workerService.insert(worker);
        if(re!=1) return ResponseTool.failed();
        return ResponseTool.success("添加成功");
    }

    @RequestMapping(method = RequestMethod.POST,value = "/update")
    public AjaxResult updateOperator(int workerId,String name,String gender,String phone,String email,String address){
        Worker worker = new Worker();
        worker.setWorkerId(workerId);
        worker.setName(name);
        worker.setGender(gender);
        worker.setPhone(phone);
        worker.setEmail(email);
        worker.setAddress(address);
        int re =  workerService.updateById(worker);
        if(re!=1) return ResponseTool.failed();
        return ResponseTool.success("更新成功");
    /**
     * 根据userID查询所有公告
     *
     * @param userId
     * @return
     */
    @RequestMapping(value = "/user/{userId}")
    public AjaxResult getByUser(@PathVariable int userId) {
        return ResponseTool.success(noticeService.selectByUserId(userId));
    }

    /**
     * 根据id号查询公告
     *
     * @param id
     * @return
     */
    @RequestMapping(value = "/{id}")
    public AjaxResult getById(@PathVariable Integer id) {
        return ResponseTool.success(noticeService.selectById(id));
    }

}

@RestController
@RequestMapping(value = "/op/room")
public class OpRoomController {

    @Autowired
    private RoomService roomService;
    @Autowired
    private RoomTypeService roomTypeService;

    @RequestMapping(value = "/add")
    public AjaxResult addRoom(String roomNumber, Integer typeId, String roomType, double roomPrice, double roomDiscount, int roomStatus, String remark){
        if(roomService.selectByNumber(roomNumber)!=null) return ResponseTool.failed("房间号码重复");

@RestController
@RequestMapping(value = "/register")
public class RegisterController {

    @Autowired
    UserService userService;
    @Autowired
    WorkerService workerService;

    @RequestMapping(method = RequestMethod.POST,value = "/user")
    public AjaxResult userRegister(String username,String password,String name,String gender,String phone,String email,String address,String idcard){
        User user = new User(username,password,name,gender,phone,email,address,idcard);
        int result = userService.insertUser(user);
        if(result==1){
            return ResponseTool.success(result);
        }
        else return ResponseTool.failed("注册失败,请稍后再试");
    }

    @RequestMapping(method = RequestMethod.POST,value = "/admin")
    public AjaxResult adminRegister(String username, String password, String name, String gender, String phone, String email, String address){
        Worker worker = new Worker(username,password,name,gender,phone,email,address);
        worker.setRole(Role.ADMIN.getValue());
        int result = workerService.insert(worker);
        if(result==1){
            return ResponseTool.success(result);
        }
        else return ResponseTool.failed("注册失败,请稍后再试");
    }

    @RequestMapping(method = RequestMethod.POST,value = "/operator")
    public AjaxResult operatorRegister(String username,String password,String name,String gender,String phone,String email,String address){
        Worker worker = new Worker(username,password,name,gender,phone,email,address);
        worker.setRole(Role.OPERATOR.getValue());
        int result = workerService.insert(worker);
        if(result==1){
            return ResponseTool.success(result);
        }
        else return ResponseTool.failed("注册失败,请稍后再试");
    }

}


    @RequestMapping(value = "/username/{username}")
    public AjaxResult getByUsername(@PathVariable String username){
        User user = userService.selectByUsername(username);
        user.setPassword(null);
        return ResponseTool.success(user);
    }

}

@RestController
@RequestMapping(value = "/user")
public class UserController {
    @Autowired
    private UserService userService;

    /**
     * 更新用户信息
     * @param userId
     * @param name
     * @param gender
     * @param phone
     * @param email
     * @param address
     * @param idcard
        user.setName(name);
        user.setGender(gender);
        user.setPhone(phone);
        user.setEmail(email);
        user.setAddress(address);
        user.setIdcard(idcard);
        if(userService.updateUser(user)==1)
            return ResponseTool.success("修改成功");
        return ResponseTool.success("修改失败,请检查或稍后再试");
    }

    @RequestMapping(method = RequestMethod.POST,value = "/updatePassword")
    public AjaxResult updatePassword(String username,String oldPassword,String newPassword){
        User user = userService.selectByUsernameAndPassword(username,oldPassword);
        if (user == null){
            return ResponseTool.failed("密码不对");
        }
        user.setPassword(newPassword);
        if(userService.updateUser(user)==1)
            return ResponseTool.success("修改成功");
        return ResponseTool.failed("修改失败");
    }

    @RequestMapping(value = "/{userId}")
    public AjaxResult getProfile(@PathVariable Integer userId){
        User user = userService.selectById(userId);
        user.setPassword(null);
        return ResponseTool.success(user);
    }

    @RequestMapping(value = "/username/{username}")
    public AjaxResult getByUsername(@PathVariable String username){
        User user = userService.selectByUsername(username);
        user.setPassword(null);
        return ResponseTool.success(user);
    }

}

 * @description:公告管理控制层
 * @modified By* @version: v1.0.0$
 */
@RestController
@RequestMapping(value = "/op/dishesmanager")
public class OpDishesManagerController {
    @Autowired
    private DishesManagerService dishesManagerService;

    /**
     * 添加公告
     * 订单状态默认为未付款状态
     */
    @RequestMapping(value = "/add")
    public AjaxResult addNotice(String dishName, String dishPrice) {
        DishesManager dishesManager = new DishesManager(0, dishName, dishPrice);
        int re = dishesManagerService.insert(dishesManager);
        if (re != 1) return ResponseTool.failed(MsgType.FAILED);
        return ResponseTool.success("添加成功.");
    }

    @RequestMapping(value = "/delete")
    public AjaxResult deleteNotice(String orderId) {
        int re = dishesManagerService.delete(Integer.parseInt(orderId));
        if (re != 1) return ResponseTool.failed(MsgType.FAILED);
        return ResponseTool.success("删除成功.");
    }

    @RequestMapping(value = "")
    public AjaxResult getAllDishesManager() {
        return ResponseTool.success(dishesManagerService.AllDishesManager());
    }

    @RequestMapping(value = "/count")
    public AjaxResult getDishesCount() {
        return ResponseTool.success(dishesManagerService.getDishesCount());
    }

    /**
     * 根据id号查询
     *
     * @param id
     * @return
     */
    @RequestMapping(value = "/{id}")
        HttpSession session = request.getSession();
        session.setAttribute("worker",worker);
        session.setAttribute("userId",worker.getWorkerId());
        session.setAttribute("role",worker.getRole());
        HashMap<String, String> map = new HashMap<>();
        map.put("sessionId",session.getId());
        map.put("role",worker.getRole());
        map.put("id",worker.getWorkerId().toString());
        return ResponseTool.success(map);
    }

}

/**
 * @ProjectName: hotel
 * @Package: cn.mafangui.hotel.controller.worker
 * @ClassName: OpMsgController
 * @description:留言管理
 * @modified By:
 * @version: v1.0.0$
 */
@RestController
@RequestMapping(value = "/op/msg")
public class OpMsgController {
    @Autowired
    private MsgService msgService;

    /**
     * 添加公告
     * 订单状态默认为未付款状态
     */
    @RequestMapping(value = "/add")
    public AjaxResult addNotice(String title, String content, @DateTimeFormat(pattern = "yyyy-MM-dd") Date time, String userId, String userName, String phone,String role) {
        Msg msg = new Msg(0,title, content, time, Integer.parseInt(userId), userName, phone,role);
        int re = msgService.insert(msg);
        if (re != 1) return ResponseTool.failed(MsgType.FAILED);
        return ResponseTool.success("添加成功.");
        User user = userService.selectByUsernameAndPassword(username,oldPassword);
        if (user == null){
            return ResponseTool.failed("密码不对");
        }
        user.setPassword(newPassword);
        if(userService.updateUser(user)==1)
            return ResponseTool.success("修改成功");
        return ResponseTool.failed("修改失败");
    }

    /**
     *  获取个人资料
     * @param request
     * @return
     */
    @RequestMapping(value = "/profile")
    public AjaxResult getProfile(HttpServletRequest request){
        String username = (String) request.getSession().getAttribute("username");
        User user = userService.selectByUsername(username);
        if(user==null) return ResponseTool.failed("未知错误");
        user.setPassword(null);
        StringBuilder sb = new StringBuilder(user.getIdcard());
        sb.replace(5,12,"********");
        user.setIdcard(sb.toString());
        return ResponseTool.success(user);
    }

    /**
     * 注销
     * @param request
     * @return
     */
    @RequestMapping(value = "/logout",method = RequestMethod.POST)
    public AjaxResult logout(HttpServletRequest request){
        HttpSession session = request.getSession();
        session.removeAttribute("userId");
        session.removeAttribute("username");
        return ResponseTool.success("注销成功");
    }

}


    /**
     * 所有房型
     * @return
     */
    @RequestMapping(value = "")
    public AjaxResult getAllRoomType(){
        List<RoomType> rooms = roomTypeService.findAllType();
        return ResponseTool.success(rooms);
    }

    /**
     * 查找有余量的房型
     * @return
     */
    @RequestMapping(value = "/rest")
    public AjaxResult findAllRestRoomType(){
        return ResponseTool.success(roomTypeService.findAllRestType());
    }

    /**
     * 根据id查找房型
     * @param typeId
     * @return
     */
    @RequestMapping(value = "/{typeId}")
    public AjaxResult getById(@PathVariable int typeId){
        return ResponseTool.success(roomTypeService.selectById(typeId));
    }

    /**
     * 添加房型
     * @param roomType
     * @param price
     * @param discount
     * @param area
     * @param bedNum
     * @param bedSize
}

/**
 * 订单接口
 */
@RestController
@RequestMapping(value = "/user/order")
public class UserOrderController {
    @Autowired
    private OrderService orderService;
    @Autowired
    private UserService userService;

    /**
     * 添加预订
     * 订单状态默认为未付款状态
     * @param orderTypeId
     * @param orderType
     * @param userId
     * @param name
     * @param phone
     * @param roomTypeId
     * @param roomType
     * @param orderDate
     * @param orderDays
     * @param orderCost
     * @return
     */
    @RequestMapping(value = "/add")
    public AjaxResult addOrder(int orderTypeId,String orderType, int userId,String name, String phone,int roomTypeId, String roomType,
                        @DateTimeFormat(pattern = "yyyy-MM-dd") Date orderDate, Integer orderDays, Double orderCost){
        Order order = new Order(orderTypeId,orderType,userId,name,phone,roomTypeId,
                roomType,orderDate,orderDays, OrderStatus.UNPAID.getCode(),orderCost);
    public AjaxResult getProfile(@PathVariable Integer userId){
        User user = userService.selectById(userId);
        user.setPassword(null);
        return ResponseTool.success(user);
    }

    @RequestMapping(value = "/username/{username}")
    public AjaxResult getByUsername(@PathVariable String username){
        User user = userService.selectByUsername(username);
        user.setPassword(null);
        return ResponseTool.success(user);
    }

}

@RestController
@RequestMapping(value = "/user")
public class UserController {
    @Autowired
    private UserService userService;

    /**
     * 更新用户信息
     * @param userId
     * @param name
     * @param gender
     * @param phone
     * @param email
     * @param address
     * @param idcard
     * @return
     */
    @RequestMapping(method = RequestMethod.POST,value = "/update")
    public AjaxResult userUpdate(Integer userId, String name, String gender, String phone,
}

@RestController
@RequestMapping(value = "/op/room-type")
public class OpRoomTypeController {

    @Autowired
    private RoomTypeService roomTypeService;

    /**
     * 所有房型
     * @return
     */
    @RequestMapping(value = "")
    public AjaxResult getAllRoomType(){
        List<RoomType> rooms = roomTypeService.findAllType();
        return ResponseTool.success(rooms);
    }

    /**
     * 查找有余量的房型
     * @return
     */
    @RequestMapping(value = "/rest")
    public AjaxResult findAllRestRoomType(){
        return ResponseTool.success(roomTypeService.findAllRestType());
    }

    /**
     * 根据id查找房型
     * @param typeId
     * @return
     */
    @RequestMapping(value = "/{typeId}")
    public AjaxResult getById(@PathVariable int typeId){
        return ResponseTool.success(roomTypeService.selectById(typeId));

/**
 * @ProjectName: hotel
 * @Package: cn.mafangui.hotel.controller.worker
 * @ClassName: OpNoticeController
 * @description:公告管理控制层
 * @modified By:
 * @version: v1.0.0$
 */
@RestController
@RequestMapping(value = "/op/notice")
public class OpNoticeController {
    @Autowired
    private NoticeService noticeService;

    /**
     * 添加公告
     * 订单状态默认为未付款状态
     */
    @RequestMapping(value = "/add")
    public AjaxResult addNotice(String title, String content, @DateTimeFormat(pattern = "yyyy-MM-dd") Date time, String userId, String userName, String phone,String role) {
        Notice notice = new Notice(0,title, content, time, Integer.parseInt(userId), userName, phone,role);
        int re = noticeService.insert(notice);
        if (re != 1) return ResponseTool.failed(MsgType.FAILED);
        return ResponseTool.success("添加成功.");
    }

    @RequestMapping(value = "/delete")
 * @description:公告管理控制层
 * @modified By* @version: v1.0.0$
 */
@RestController
@RequestMapping(value = "/op/notice")
public class OpNoticeController {
    @Autowired
    private NoticeService noticeService;

    /**
     * 添加公告
     * 订单状态默认为未付款状态
     */
    @RequestMapping(value = "/add")
    public AjaxResult addNotice(String title, String content, @DateTimeFormat(pattern = "yyyy-MM-dd") Date time, String userId, String userName, String phone,String role) {
        Notice notice = new Notice(0,title, content, time, Integer.parseInt(userId), userName, phone,role);
        int re = noticeService.insert(notice);
        if (re != 1) return ResponseTool.failed(MsgType.FAILED);
        return ResponseTool.success("添加成功.");
    }

    @RequestMapping(value = "/delete")
    public AjaxResult deleteNotice(int id) {
        int re = noticeService.delete(id);
        if (re != 1) return ResponseTool.failed(MsgType.FAILED);
        return ResponseTool.success("删除成功.");
    }

    @RequestMapping(value = "/update")
    public AjaxResult updateNotice(int id, String title, String content) {
        Notice notice = new Notice(id,title,content);
        int re = noticeService.update(notice);
        if (re != 1) return ResponseTool.failed(MsgType.FAILED);
        return ResponseTool.success("修改成功.");
    }

    @RequestMapping(value = "")
    public AjaxResult getAllNotice() {
        return ResponseTool.success(noticeService.AllNotices());
    }

    @RequestMapping(value = "/count")
        return ResponseTool.success("修改失败,请检查或稍后再试");
    }

    @RequestMapping(method = RequestMethod.POST,value = "/updatePassword")
    public AjaxResult updatePassword(String username,String oldPassword,String newPassword){
        User user = userService.selectByUsernameAndPassword(username,oldPassword);
        if (user == null){
            return ResponseTool.failed("密码不对");
        }
        user.setPassword(newPassword);
        if(userService.updateUser(user)==1)
            return ResponseTool.success("修改成功");
        return ResponseTool.failed("修改失败");
    }

    @RequestMapping(value = "/{userId}")
    public AjaxResult getProfile(@PathVariable Integer userId){
        User user = userService.selectById(userId);
        user.setPassword(null);
        return ResponseTool.success(user);
    }

    @RequestMapping(value = "/username/{username}")
    public AjaxResult getByUsername(@PathVariable String username){
        User user = userService.selectByUsername(username);
        user.setPassword(null);
        return ResponseTool.success(user);
    }

}

     * 根据姓名、预留手机号查找订单
     * 主要用于客户入住
     * @param name
     * @param phone
     * @return
     */
    @RequestMapping(value = "/withNameAndPhone")
    public AjaxResult getByNameAndPhone(String name,String phone){
        return ResponseTool.success(orderService.selectByNameAndPhone(name,phone));
    }

}

/**
 * @ProjectName: hotel
 * @Package: cn.mafangui.hotel.controller.worker
 * @ClassName: OpNoticeController
 * @description:公告管理控制层
 * @modified By:
 * @version: v1.0.0$
 */

    /**
     * 根据userID查询所有公告
     *
     * @param userId
     * @return
     */
    @RequestMapping(value = "/user/{userId}")
    public AjaxResult getByUser(@PathVariable int userId) {
        return ResponseTool.success(dishesService.selectByUserId(userId));
    }

    /**
     * 根据id号查询公告
     *
     * @param id
     * @return
     */
    @RequestMapping(value = "/{id}")
    public AjaxResult getById(@PathVariable Integer id) {
        return ResponseTool.success(dishesService.selectById(id));
    }

}

请添加图片描述

请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值