diff --git a/src/main/java/cn/mafangui/hotel/controller/RoomController.java b/src/main/java/cn/mafangui/hotel/controller/RoomController.java index 9d096bc..30dbeef 100644 --- a/src/main/java/cn/mafangui/hotel/controller/RoomController.java +++ b/src/main/java/cn/mafangui/hotel/controller/RoomController.java @@ -3,7 +3,7 @@ package cn.mafangui.hotel.controller; import cn.mafangui.hotel.entity.Room; import cn.mafangui.hotel.service.RoomService; -import cn.mafangui.hotel.utils.finalString; +import cn.mafangui.hotel.utils.StaticString; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -20,25 +20,26 @@ public class RoomController { * 增加房间 * @param roomNumber * @param roomFloor - * @param roomType * @param typeName * @param roomPrice * @param roomDiscount * @param roomStatus + * @param remark * @return */ @RequestMapping(value = "/add") - public HashMap addRoom(String roomNumber, int roomFloor, int roomType, String typeName, double roomPrice,double roomDiscount,String roomStatus){ + public HashMap addRoom(String roomNumber, int roomFloor, String typeName, + double roomPrice,double roomDiscount,String roomStatus,String remark){ HashMap result = new HashMap(); int data = 0; - Room room = new Room(roomNumber,roomFloor,roomType,typeName,roomPrice,roomDiscount,roomStatus); + Room room = new Room(roomNumber,roomFloor,typeName,roomPrice,roomDiscount,roomStatus,remark); try { data = roomService.addRoom(room); }catch (Exception e){ data = -1; } - result.put(finalString.CODE,20000); - result.put(finalString.DATA,data); + result.put(StaticString.CODE,20000); + result.put(StaticString.DATA,data); return result; } @@ -61,8 +62,8 @@ public class RoomController { }catch (Exception e){ data = -1; } - result.put(finalString.CODE,20000); - result.put(finalString.DATA,data); + result.put(StaticString.CODE,20000); + result.put(StaticString.DATA,data); return result; } @@ -71,26 +72,27 @@ public class RoomController { * @param roomId * @param roomNumber * @param roomFloor - * @param roomType * @param typeName * @param roomPrice * @param roomDiscount * @param roomStatus + * @param remark * @return */ @RequestMapping(value = "/update") - public HashMap updateRoom(int roomId,String roomNumber, int roomFloor, int roomType, String typeName, double roomPrice,double roomDiscount,String roomStatus){ + public HashMap updateRoom(int roomId,String roomNumber, int roomFloor, String typeName, + double roomPrice,double roomDiscount,String roomStatus,String remark){ HashMap result = new HashMap(); int data = 0; - Room room = new Room(roomNumber,roomFloor,roomType,typeName,roomPrice,roomDiscount,roomStatus); + Room room = new Room(roomNumber,roomFloor,typeName,roomPrice,roomDiscount,roomStatus,remark); room.setRoomId(roomId); try { data = roomService.updateRoom(room); }catch (Exception e){ data = -1; } - result.put(finalString.CODE,20000); - result.put(finalString.DATA,data); + result.put(StaticString.CODE,20000); + result.put(StaticString.DATA,data); return result; } @@ -101,8 +103,8 @@ public class RoomController { @RequestMapping(value = "/all") public HashMap allRoom(){ HashMap result = new HashMap(); - result.put(finalString.DATA,roomService.findAll()); - result.put(finalString.CODE,20000); + result.put(StaticString.DATA,roomService.findAll()); + result.put(StaticString.CODE,20000); return result; } @@ -115,11 +117,11 @@ public class RoomController { @RequestMapping(value = "/withId") public HashMap findRoomById(int roomId){ HashMap result = new HashMap(); - result.put(finalString.CODE,20000); + result.put(StaticString.CODE,20000); try{ - result.put(finalString.DATA,roomService.findById(roomId)); + result.put(StaticString.DATA,roomService.findById(roomId)); }catch (Exception e){ - result.put(finalString.DATA,-1); + result.put(StaticString.DATA,-1); } return result; } @@ -132,11 +134,11 @@ public class RoomController { @RequestMapping(value = "/withRoomNumber") public HashMap findRoomByNumber(String roomNumber){ HashMap result = new HashMap(); - result.put(finalString.CODE,20000); + result.put(StaticString.CODE,20000); try{ - result.put(finalString.DATA,roomService.findByNumber(roomNumber)); + result.put(StaticString.DATA,roomService.findByNumber(roomNumber)); }catch (Exception e){ - result.put(finalString.DATA,-1); + result.put(StaticString.DATA,-1); } return result; } @@ -149,11 +151,11 @@ public class RoomController { @RequestMapping(value = "/withStatus") public HashMap findRoomByStatus(String roomStatus){ HashMap result = new HashMap(); - result.put(finalString.CODE,20000); + result.put(StaticString.CODE,20000); try{ - result.put(finalString.DATA,roomService.findByStatus(roomStatus)); + result.put(StaticString.DATA,roomService.findByStatus(roomStatus)); }catch (Exception e){ - result.put(finalString.DATA,-1); + result.put(StaticString.DATA,-1); } return result; } @@ -166,11 +168,11 @@ public class RoomController { @RequestMapping(value = "/withType") public HashMap findRoomByType(String typeName){ HashMap result = new HashMap(); - result.put(finalString.CODE,20000); + result.put(StaticString.CODE,20000); try{ - result.put(finalString.DATA,roomService.findByType(typeName)); + result.put(StaticString.DATA,roomService.findByType(typeName)); }catch (Exception e){ - result.put(finalString.DATA,-1); + result.put(StaticString.DATA,-1); } return result; } diff --git a/src/main/java/cn/mafangui/hotel/entity/Room.java b/src/main/java/cn/mafangui/hotel/entity/Room.java index d931a56..6125029 100644 --- a/src/main/java/cn/mafangui/hotel/entity/Room.java +++ b/src/main/java/cn/mafangui/hotel/entity/Room.java @@ -1,6 +1,6 @@ package cn.mafangui.hotel.entity; -import java.math.BigDecimal; +import java.math.BigInteger; import java.util.Date; public class Room { @@ -10,9 +10,7 @@ public class Room { private Integer roomFloor; - private Integer roomType; - - private String typeName; + private String roomType; private Double roomPrice; @@ -20,6 +18,8 @@ public class Room { private String roomStatus; + private String remark; + private Date createTime; private Date updateTime; @@ -48,22 +48,14 @@ public class Room { this.roomFloor = roomFloor; } - public Integer getRoomType() { + public String getRoomType() { return roomType; } - public void setRoomType(Integer roomType) { + public void setRoomType(String roomType) { this.roomType = roomType; } - public String getTypeName() { - return typeName; - } - - public void setTypeName(String typeName) { - this.typeName = typeName; - } - public Double getRoomPrice() { return roomPrice; } @@ -88,6 +80,14 @@ public class Room { this.roomStatus = roomStatus == null ? null : roomStatus.trim(); } + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + public Date getCreateTime() { return createTime; } @@ -107,14 +107,14 @@ public class Room { public Room() { } - public Room(String roomNumber, Integer roomFloor, Integer roomType, String typeName, Double roomPrice, Double roomDiscount, String roomStatus) { + public Room(String roomNumber, Integer roomFloor, String roomType, Double roomPrice, Double roomDiscount, String roomStatus,String remark) { this.roomNumber = roomNumber; this.roomFloor = roomFloor; this.roomType = roomType; - this.typeName = typeName; this.roomPrice = roomPrice; this.roomDiscount = roomDiscount; this.roomStatus = roomStatus; + this.remark = remark; } @Override @@ -123,8 +123,7 @@ public class Room { "roomId=" + roomId + ", roomNumber='" + roomNumber + '\'' + ", roomFloor=" + roomFloor + - ", roomType=" + roomType + - ", typeName='" + typeName + '\'' + + ", roomType='" + roomType + '\'' + ", roomPrice=" + roomPrice + ", roomDiscount=" + roomDiscount + ", roomStatus='" + roomStatus + '\'' + diff --git a/src/main/java/cn/mafangui/hotel/utils/finalString.java b/src/main/java/cn/mafangui/hotel/utils/StaticString.java similarity index 62% rename from src/main/java/cn/mafangui/hotel/utils/finalString.java rename to src/main/java/cn/mafangui/hotel/utils/StaticString.java index 5bbf11b..eb50b55 100644 --- a/src/main/java/cn/mafangui/hotel/utils/finalString.java +++ b/src/main/java/cn/mafangui/hotel/utils/StaticString.java @@ -1,7 +1,8 @@ package cn.mafangui.hotel.utils; -public class finalString { +public class StaticString { public static final String CODE = "code"; + public static final String STATUS = "status"; public static final String DATA = "data"; } diff --git a/src/main/resources/generatorConfig.xml b/src/main/resources/generatorConfig.xml index 71acfa4..2fa2892 100644 --- a/src/main/resources/generatorConfig.xml +++ b/src/main/resources/generatorConfig.xml @@ -59,23 +59,26 @@ - +
- -
-
+ +
+ +
- -
\ No newline at end of file diff --git a/src/main/resources/mybatis/config.xml b/src/main/resources/mybatis/config.xml index fe519c1..c73c563 100644 --- a/src/main/resources/mybatis/config.xml +++ b/src/main/resources/mybatis/config.xml @@ -43,6 +43,7 @@ + diff --git a/src/main/resources/schema.sql b/src/main/resources/schema.sql new file mode 100644 index 0000000..7fa5867 --- /dev/null +++ b/src/main/resources/schema.sql @@ -0,0 +1,157 @@ +-- 创建数据库 +DROP DATABASE +IF EXISTS hotel; + +CREATE DATABASE hotel DEFAULT CHARACTER SET utf8; +use hotel + +-- 1客房类型表 +CREATE TABLE +IF NOT EXISTS `room_type` ( + `type_id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '类型ID', + `room_type` VARCHAR(16) not NULL COMMENT '类型名', + `remark` VARCHAR(128) null COMMENT '房型备注', + `price` DOUBLE NOT NULL DEFAULT 0 COMMENT '预定价格', + `discount` DOUBLE NOT NULL COMMENT '预定折扣', + `area` int not null DEFAULT 12 COMMENT '房间大小:m2', + `bed_num` int not null DEFAULT 1 COMMENT '床位', + `bed_size` varchar(16) not null DEFAULT '1.5m*1.8m' COMMENT '床位大小', + `window` int not null DEFAULT 0 COMMENT '是否有窗:0-无,1-有', + `create_time` TIMESTAMP not null DEFAULT '0000-00-00 00:00:00' COMMENT '创建时间', + `update_time` TIMESTAMP null ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + PRIMARY KEY (`type_id`), + UNIQUE KEY `uqe_room_type` (`room_type`) + +) COMMENT '房间类型表'; + +-- 2客房信息表 +CREATE TABLE +IF NOT EXISTS `room_info` ( + `room_id` INT NOT NULL AUTO_INCREMENT COMMENT '房间id', + `room_number` VARCHAR (8) NOT NULL COMMENT '房间号码', + `type_id` int NOT NULL COMMENT '房间类型ID', + `room_type` VARCHAR(16) NOT NULL COMMENT '房间类型', + `room_price` DOUBLE NOT NULL DEFAULT 0 COMMENT '房间价格', + `room_discount` DOUBLE NOT NULL DEFAULT 0 COMMENT '房间折扣', + `room_status` int NOT NULL DEFAULT 1 COMMENT '房间状态:1-可预订,0-已被预订,-1:已入住,-2:不可用', + `remark` VARCHAR(255) null COMMENT '备注', + `create_time` TIMESTAMP not null DEFAULT '0000-00-00 00:00:00' COMMENT '创建时间', + `update_time` TIMESTAMP null ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + PRIMARY KEY (`room_id`), + UNIQUE KEY `uqe_room_number` (`room_number`) +) COMMENT '房间信息表'; + +-- 3入住退房登记信息表 +CREATE TABLE +IF NOT EXISTS `check_in` ( + `check_in_id` INT AUTO_INCREMENT COMMENT '入住id', + `order_id` int NOT NULL COMMENT '订单号', + `room_number` VARCHAR (8) NOT NULL comment '房间号', + `room_type` VARCHAR(16) NOT NULL COMMENT '房间类型', + `peo_count` INT NOT NULL DEFAULT 1 COMMENT '入住人数', + `persons` VARCHAR (255) NOT NULL COMMENT '入住人', + `ids` VARCHAR (255) NOT NULL COMMENT '身份证号', + `check_in_time` TIMESTAMP null DEFAULT '0000-00-00 00:00:00' COMMENT '入住时间', + `create_time` TIMESTAMP not null DEFAULT '0000-00-00 00:00:00' COMMENT '创建时间', + `update_time` TIMESTAMP null ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + PRIMARY KEY (`check_in_id`), + UNIQUE KEY `uqe_order_id`(`order_id`) +) comment '入住退房登记表'; + +-- 4订单信息表 +CREATE TABLE +IF NOT EXISTS `order_info` ( + `order_id` INT AUTO_INCREMENT COMMENT '订单号', + `order_type` VARCHAR(8) not null COMMENT '预订方式', + `phone` VARCHAR (16) NOT NULL COMMENT '手机号', + `room_type` VARCHAR (16) not null COMMENT '房间类型', + `num_of_room` int not null DEFAULT 1 COMMENT '房间数', + `order_date` DATE not null COMMENT '预订日期', + `order_days` INT NOT NULL DEFAULT 1 COMMENT '预定天数', + `order_status` int not null DEFAULT 0 COMMENT '订单状态:0-已下单,1-已付款,2-已消费,-1-已取消,-2-被删除', + `order_cost` DOUBLE NOT NULL COMMENT '订单费用', + `create_time` TIMESTAMP null DEFAULT '0000-00-00 00:00:00' COMMENT '创建时间', + `update_time` TIMESTAMP null ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + PRIMARY KEY (`order_id`) +) COMMENT '订单信息表'; + + +-- 5注册用户信息表 +CREATE TABLE +IF NOT EXISTS `user_info` ( + `user_id` INT NULL AUTO_INCREMENT COMMENT '用户id', + `username` VARCHAR (16) NOT NULL COMMENT '用户名', + `password` VARCHAR (16) NOT NULL COMMENT '密码', + `name` VARCHAR(16) not NULL COMMENT '姓名', + `gender` CHAR(2) not null DEFAULT '男' COMMENT '性别', + `phone` VARCHAR (16) NOT NULL COMMENT '手机号码', + `email` VARCHAR (16) NULL COMMENT '邮箱地址', + `address` VARCHAR (32) NULL COMMENT '地址', + `idcard` VARCHAR (32) NOT NULL COMMENT '身份证号码', + `create_time` TIMESTAMP not null DEFAULT '0000-00-00 00:00:00' COMMENT '创建时间', + `update_time` TIMESTAMP null ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + PRIMARY KEY (`user_id`), + UNIQUE KEY `uqe_username` (`username`) +) COMMENT '注册用户信息表'; + +-- 6工作人员信息表 +CREATE TABLE +IF NOT EXISTS `worker_info` ( + `worker_id` INT NULL AUTO_INCREMENT COMMENT '操作员id', + `role` VARCHAR(8) NOT NULL DEFAULT 'worker' COMMENT '角色:worker/admin', + `username` VARCHAR (16) NOT NULL COMMENT '用户名', + `password` VARCHAR (16) NOT NULL COMMENT '密码', + `name` VARCHAR (8) NOT NULL comment '姓名', + `gender` CHAR(2) not null DEFAULT '男' COMMENT '性别', + `phone` VARCHAR (16) NOT NULL COMMENT '手机号码', + `department` int null COMMENT '部门', + `email` VARCHAR (16) NULL COMMENT '邮箱地址', + `address` VARCHAR (32) NULL COMMENT '地址', + `create_time` TIMESTAMP not null DEFAULT '0000-00-00 00:00:00' COMMENT '创建时间', + `update_time` TIMESTAMP null ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + PRIMARY KEY (`worker_id`), + UNIQUE KEY `uqe_username` (`username`) + +) COMMENT '工作人员信息表' + +-- 7酒店信息表 +CREATE TABLE +IF NOT EXISTS `hotel_info` ( + `hotel_id` int not null auto_increment COMMENT '酒店id', + `hotel_name` VARCHAR (16) NOT NULL COMMENT '酒店名', + `phone` VARCHAR (16) NULL COMMENT '手机号', + `telephone` VARCHAR (16) NOT NULL COMMENT '电话号码', + `email` VARCHAR (16) NOT NULL COMMENT '电子邮箱', + `address` VARCHAR (32) NOT NULL COMMENT '地址', + `website` VARCHAR (16) NOT NULL COMMENT '网站', + `create_time` TIMESTAMP not null DEFAULT '0000-00-00 00:00:00' COMMENT '创建时间', + `update_time` TIMESTAMP null ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + PRIMARY KEY (`hotel_id`) + +) comment '酒店信息表'; + +-- 8部门信息表 +CREATE TABLE +IF NOT EXISTS `department_info` ( + `department_id` int not null auto_increment COMMENT '部门id', + `departmen` VARCHAR(16) not null DEFAULT '可用' COMMENT '部门', + `remark` VARCHAR(32) null COMMENT '备注', + `create_time` TIMESTAMP not null DEFAULT '0000-00-00 00:00:00' COMMENT '创建时间', + `update_time` TIMESTAMP null ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + PRIMARY KEY (`department_id`), + UNIQUE KEY `uqe_status` (`departmen`) + +) COMMENT '部门信息表'; + +-- 9预订方式表 +CREATE TABLE +IF NOT EXISTS `order_type` ( + `type_id` int not null auto_increment COMMENT 'typeId', + `type` VARCHAR(16) not null COMMENT '方式', + `remark` VARCHAR(32) null COMMENT '备注', + `create_time` TIMESTAMP not null DEFAULT '0000-00-00 00:00:00' COMMENT '创建时间', + `update_time` TIMESTAMP null ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + PRIMARY KEY(`type_id`) +) COMMENT '预订方式表'; + +