更新数据库结构,重写订单接口,添加注释

This commit is contained in:
freeebird 2018-11-28 15:18:17 +08:00
parent 346dca6e65
commit 556e257d45
19 changed files with 554 additions and 245 deletions

View File

@ -1,6 +1,5 @@
package cn.mafangui.hotel; package cn.mafangui.hotel;
import cn.mafangui.hotel.utils.StaticString;
import org.mybatis.spring.annotation.MapperScan; import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;

View File

@ -1,16 +1,13 @@
package cn.mafangui.hotel.controller; package cn.mafangui.hotel.controller;
import cn.mafangui.hotel.entity.Worker; import cn.mafangui.hotel.entity.Worker;
import cn.mafangui.hotel.service.RoomService; import cn.mafangui.hotel.enums.Role;
import cn.mafangui.hotel.service.WorkerService; import cn.mafangui.hotel.service.WorkerService;
import cn.mafangui.hotel.utils.StaticString;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController @RestController
@RequestMapping(value = "/admin") @RequestMapping(value = "/admin")
public class AdminController { public class AdminController {
@ -27,11 +24,34 @@ public class AdminController {
*/ */
@RequestMapping(method = RequestMethod.POST,value = "/login") @RequestMapping(method = RequestMethod.POST,value = "/login")
public int login(String username,String password){ public int login(String username,String password){
if(workerService.login(username,password, StaticString.ADMIN) != null) if(workerService.login(username,password, Role.ADMIN.getValue()) != null)
return 1; return 1;
else return 0; else return 0;
} }
/**
* 管理员注册
* @param username
* @param password
* @param name
* @param gender
* @param phone
* @param email
* @param address
* @return
*/
@RequestMapping(method = RequestMethod.POST,value = "/register")
public int register(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());
return workerService.insert(worker);
}
/**
* 根据 username查找
* @param username
* @return
*/
@RequestMapping(method = RequestMethod.POST,value = "/withUsername") @RequestMapping(method = RequestMethod.POST,value = "/withUsername")
public Worker getByUsername(String username) { public Worker getByUsername(String username) {
Worker res = workerService.selectByUsername(username); Worker res = workerService.selectByUsername(username);

View File

@ -1,8 +1,8 @@
package cn.mafangui.hotel.controller; package cn.mafangui.hotel.controller;
import cn.mafangui.hotel.entity.Worker; import cn.mafangui.hotel.entity.Worker;
import cn.mafangui.hotel.enums.Role;
import cn.mafangui.hotel.service.WorkerService; import cn.mafangui.hotel.service.WorkerService;
import cn.mafangui.hotel.utils.StaticString;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
@ -18,7 +18,7 @@ public class OperatorController {
@RequestMapping(method = RequestMethod.POST,value = "/login") @RequestMapping(method = RequestMethod.POST,value = "/login")
public int login(String username,String password){ public int login(String username,String password){
if(workerService.login(username,password, StaticString.OPERATOR) != null) if(workerService.login(username,password, Role.OPERATOR.getValue()) != null)
return 1; return 1;
else return 0; else return 0;
} }
@ -30,7 +30,7 @@ public class OperatorController {
@RequestMapping(value = "/all") @RequestMapping(value = "/all")
public List<Worker> getAllOperator(){ public List<Worker> getAllOperator(){
return workerService.selectByRole(StaticString.OPERATOR); return workerService.selectByRole(Role.OPERATOR.getValue());
} }
@RequestMapping(method = RequestMethod.POST,value = "/withId") @RequestMapping(method = RequestMethod.POST,value = "/withId")
@ -41,7 +41,7 @@ public class OperatorController {
@RequestMapping(method = RequestMethod.POST,value = "/add") @RequestMapping(method = RequestMethod.POST,value = "/add")
public int addOperator(String username,String password,String name,String gender,String phone,String email,String address){ public int 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 worker = new Worker(username,password,name,gender,phone,email,address);
worker.setRole(StaticString.OPERATOR); worker.setRole(Role.OPERATOR.getValue());
return workerService.insert(worker); return workerService.insert(worker);
} }

View File

@ -1,8 +1,8 @@
package cn.mafangui.hotel.controller; package cn.mafangui.hotel.controller;
import cn.mafangui.hotel.entity.Order; import cn.mafangui.hotel.entity.Order;
import cn.mafangui.hotel.enums.OrderStatus;
import cn.mafangui.hotel.service.OrderService; import cn.mafangui.hotel.service.OrderService;
import cn.mafangui.hotel.utils.StaticString;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
@ -11,73 +11,139 @@ import org.springframework.web.bind.annotation.RestController;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
/**
* 订单接口
*/
@RestController @RestController
@RequestMapping(value = "/order") @RequestMapping(value = "/order")
public class OrderController { public class OrderController {
@Autowired @Autowired
private OrderService orderService; private OrderService orderService;
/**
* 添加预订
* 订单状态默认为未付款状态
* @param orderTypeId
* @param orderType
* @param userId
* @param name
* @param phone
* @param roomTypeId
* @param roomType
* @param orderDate
* @param orderDays
* @param orderCost
* @return
*/
@RequestMapping(value = "/add") @RequestMapping(value = "/add")
public int addOrder(String orderType, int userId,String name, String phone, String roomType, public int addOrder(int orderTypeId,String orderType, int userId,String name, String phone,int roomTypeId, String roomType,
@DateTimeFormat(pattern = "yyyy-MM-dd") Date orderDate, Integer orderDays, Integer orderStatus, Double orderCost){ @DateTimeFormat(pattern = "yyyy-MM-dd") Date orderDate, Integer orderDays, Double orderCost){
Order order = new Order(orderType,userId,phone,roomType,orderDate,orderDays,orderStatus,orderCost); Order order = new Order(orderTypeId,orderType,userId,name,phone,roomTypeId,
order.setName(name); roomType,orderDate,orderDays, OrderStatus.UNPAID.getCode(),orderCost);
return orderService.insert(order); return orderService.addOrder(order);
} }
/**
* 删除订单
* @param orderId
* @return
*/
@RequestMapping(value = "/delete") @RequestMapping(value = "/delete")
public int deleteOrder(int orderId){ public int deleteOrder(int orderId){
return orderService.delete(orderId); return orderService.delete(orderId);
} }
@RequestMapping(value = "/hide") /**
public int hideOrder(int orderId){ * 客户删除订单
Order order = new Order(); * @param orderId
order.setOrderId(orderId); * @return
order.setOrderStatus(StaticString.WAS_DELETE); */
@RequestMapping(value = "/deleteByUser")
public int deleteOrderByUser(int orderId){
Order order = new Order(orderId,OrderStatus.WAS_DELETED.getCode());
return orderService.update(order); return orderService.update(order);
} }
/**
* 修改订单
* @param orderId
* @param orderTypeId
* @param orderType
* @param userId
* @param name
* @param phone
* @param roomTypeId
* @param roomType
* @param orderDate
* @param orderDays
* @param orderCost
* @return
*/
@RequestMapping(value = "/update") @RequestMapping(value = "/update")
public int updateOrder(int orderId,String orderType,String roomType, public int updateOrder(int orderId,int orderTypeId,String orderType, int userId,String name, String phone,int roomTypeId, String roomType,
Date orderDate, Integer orderDays, Integer orderStatus, Double orderCost){ @DateTimeFormat(pattern = "yyyy-MM-dd") Date orderDate, Integer orderDays, Double orderCost){
Order order = new Order(orderType,roomType,orderDate,orderDays,orderStatus,orderCost); Order order = new Order(orderTypeId,orderType,userId,name,phone,roomTypeId,
order.setOrderId(orderId); roomType,orderDate,orderDays, OrderStatus.UNPAID.getCode(),orderCost);
return orderService.update(order); return orderService.update(order);
} }
/**
* 取消订单
* @param orderId
* @return
*/
@RequestMapping(value = "/cancel") @RequestMapping(value = "/cancel")
public int cancelOrder(int orderId){ public int cancelOrder(int orderId){
Order order = new Order(); Order order = new Order(orderId,OrderStatus.WAS_CANCELED.getCode());
order.setOrderId(orderId);
order.setOrderStatus(StaticString.WAS_CANCELED);
return orderService.update(order); return orderService.update(order);
} }
/**
* 订单超时
* @param orderId
* @return
*/
@RequestMapping(value = "/overtime") @RequestMapping(value = "/overtime")
public int orderOver(int orderId){ public int orderOver(int orderId){
Order order = new Order(); Order order = new Order(orderId,OrderStatus.OVERTIME.getCode());
order.setOrderId(orderId);
order.setOrderStatus(StaticString.OVERTIME);
return orderService.update(order); return orderService.update(order);
} }
/**
* 所有订单
* @return
*/
@RequestMapping(value = "/all") @RequestMapping(value = "/all")
public List<Order> getAllOrder(){ public List<Order> getAllOrder(){
return orderService.selectAll(); return orderService.AllOrders();
} }
/**
* 根据userID查询所有订单
* @param userId
* @return
*/
@RequestMapping(value = "/withUserId") @RequestMapping(value = "/withUserId")
public List<Order> getByUser(int userId){ public List<Order> getByUser(int userId){
return orderService.selectByUserId(userId); return orderService.selectByUserId(userId);
} }
/**
* 客户查询个人所有订单不包括被自己删除的
* @param userId
* @return
*/
@RequestMapping(value = "/userOrder") @RequestMapping(value = "/userOrder")
public List<Order> getAllByUser(int userId){ public List<Order> getAllByUser(int userId){
return orderService.userSelectAll(userId); return orderService.UsersAllOrders(userId);
} }
/**
* 根据订单号查询订单
* @param orderId
* @return
*/
@RequestMapping(value = "/withId") @RequestMapping(value = "/withId")
public Order getById(int orderId){ public Order getById(int orderId){
return orderService.selectById(orderId); return orderService.selectById(orderId);

View File

@ -1,7 +1,9 @@
package cn.mafangui.hotel.controller; package cn.mafangui.hotel.controller;
import cn.mafangui.hotel.entity.Room; import cn.mafangui.hotel.entity.Room;
import cn.mafangui.hotel.entity.RoomType;
import cn.mafangui.hotel.service.RoomService; import cn.mafangui.hotel.service.RoomService;
import cn.mafangui.hotel.service.RoomTypeService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
@ -15,11 +17,18 @@ public class RoomController {
@Autowired @Autowired
private RoomService roomService; private RoomService roomService;
@Autowired
private RoomTypeService roomTypeService;
@RequestMapping(value = "/add") @RequestMapping(value = "/add")
public int addRoom(String roomNumber,int typeId,String roomType,double roomPrice,double roomDiscount,int roomStatus,String remark){ public int addRoom(String roomNumber,int typeId,String roomType,double roomPrice,double roomDiscount,int roomStatus,String remark){
Room room = new Room(roomNumber,typeId,roomType,roomPrice,roomDiscount,roomStatus,remark); Room room = new Room(roomNumber,typeId,roomType,roomPrice,roomDiscount,roomStatus,remark);
return roomService.insert(room); RoomType rt = new RoomType();
if (roomService.insert(room) == 1){
rt.setTypeId(typeId);
rt.setRest(roomTypeService.selectById(typeId).getRest() + 1);
return roomTypeService.update(rt);
}else return 0;
} }
@RequestMapping(method = RequestMethod.POST,value = "/delete") @RequestMapping(method = RequestMethod.POST,value = "/delete")
@ -54,4 +63,10 @@ public class RoomController {
public List<Room> getAll(){ public List<Room> getAll(){
return roomService.selectAll(); return roomService.selectAll();
} }
}
@RequestMapping(value = "/typeRest")
public int countTypeRest(){
return 0;
}
}

View File

@ -32,6 +32,7 @@ public class RoomTypeController {
public int addRoomType(String roomType,Double price,Double discount,int area, public int addRoomType(String roomType,Double price,Double discount,int area,
int bedNum,String bedSize,int window,String remark){ int bedNum,String bedSize,int window,String remark){
RoomType rt = new RoomType(roomType,remark,price,discount,area,bedNum,bedSize,window); RoomType rt = new RoomType(roomType,remark,price,discount,area,bedNum,bedSize,window);
rt.setRest(0);
int result = 0; int result = 0;
result = roomTypeService.insert(rt); result = roomTypeService.insert(rt);
return result; return result;
@ -39,9 +40,10 @@ public class RoomTypeController {
@RequestMapping(method = RequestMethod.POST,value = "/update") @RequestMapping(method = RequestMethod.POST,value = "/update")
public int updateRoomType(int typeId,String roomType,Double price,Double discount,int area, public int updateRoomType(int typeId,String roomType,Double price,Double discount,int area,
int bedNum,String bedSize,int window,String remark){ int bedNum,String bedSize,int window,int rest,String remark){
RoomType rt = new RoomType(roomType,remark,price,discount,area,bedNum,bedSize,window); RoomType rt = new RoomType(roomType,remark,price,discount,area,bedNum,bedSize,window);
rt.setTypeId(typeId); rt.setTypeId(typeId);
rt.setRest(rest);
int result = 0; int result = 0;
result = roomTypeService.update(rt); result = roomTypeService.update(rt);
return result; return result;

View File

@ -5,22 +5,18 @@ import java.util.Date;
public class Order { public class Order {
private Integer orderId; private Integer orderId;
private Integer orderTypeId;
private String orderType; private String orderType;
private int userId; private Integer userId;
private String name; private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
private String phone; private String phone;
private Integer roomTypeId;
private String roomType; private String roomType;
private Date orderDate; private Date orderDate;
@ -35,14 +31,6 @@ public class Order {
private Date updateTime; private Date updateTime;
public int getUserId() {
return userId;
}
public void setUserId(int userId) {
this.userId = userId;
}
public Integer getOrderId() { public Integer getOrderId() {
return orderId; return orderId;
} }
@ -51,6 +39,14 @@ public class Order {
this.orderId = orderId; this.orderId = orderId;
} }
public Integer getOrderTypeId() {
return orderTypeId;
}
public void setOrderTypeId(Integer orderTypeId) {
this.orderTypeId = orderTypeId;
}
public String getOrderType() { public String getOrderType() {
return orderType; return orderType;
} }
@ -59,6 +55,22 @@ public class Order {
this.orderType = orderType == null ? null : orderType.trim(); this.orderType = orderType == null ? null : orderType.trim();
} }
public Integer getUserId() {
return userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name == null ? null : name.trim();
}
public String getPhone() { public String getPhone() {
return phone; return phone;
} }
@ -67,6 +79,14 @@ public class Order {
this.phone = phone == null ? null : phone.trim(); this.phone = phone == null ? null : phone.trim();
} }
public Integer getRoomTypeId() {
return roomTypeId;
}
public void setRoomTypeId(Integer roomTypeId) {
this.roomTypeId = roomTypeId;
}
public String getRoomType() { public String getRoomType() {
return roomType; return roomType;
} }
@ -126,10 +146,13 @@ public class Order {
public Order() { public Order() {
} }
public Order(String orderType, int userId, String phone, String roomType, Date orderDate, Integer orderDays, Integer orderStatus, Double orderCost) { public Order(Integer orderTypeId, String orderType, Integer userId, String name, String phone, Integer roomTypeId, String roomType, Date orderDate, Integer orderDays, Integer orderStatus, Double orderCost) {
this.orderTypeId = orderTypeId;
this.orderType = orderType; this.orderType = orderType;
this.userId = userId; this.userId = userId;
this.name = name;
this.phone = phone; this.phone = phone;
this.roomTypeId = roomTypeId;
this.roomType = roomType; this.roomType = roomType;
this.orderDate = orderDate; this.orderDate = orderDate;
this.orderDays = orderDays; this.orderDays = orderDays;
@ -137,31 +160,22 @@ public class Order {
this.orderCost = orderCost; this.orderCost = orderCost;
} }
public Order(String orderType, String roomType, Date orderDate, Integer orderDays, Integer orderStatus, Double orderCost) { public Order(Integer orderId, Integer orderStatus) {
this.orderType = orderType; this.orderId = orderId;
this.roomType = roomType;
this.orderDate = orderDate;
this.orderDays = orderDays;
this.orderStatus = orderStatus; this.orderStatus = orderStatus;
this.orderCost = orderCost;
}
public Order(String orderType, int userId, String phone,String roomType,Integer orderDays, Integer orderStatus, Double orderCost) {
this.userId = userId;
this.phone = phone;
this.orderType = orderType;
this.roomType = roomType;
this.orderDays = orderDays;
this.orderStatus = orderStatus;
this.orderCost = orderCost;
} }
@Override @Override
public String toString() { public String toString() {
return "Order{" + return "Order{" +
"orderId=" + orderId + "orderId=" + orderId +
", orderTypeId=" + orderTypeId +
", orderType='" + orderType + '\'' + ", orderType='" + orderType + '\'' +
", userId=" + userId + ", userId=" + userId +
", name='" + name + '\'' +
", phone='" + phone + '\'' + ", phone='" + phone + '\'' +
", roomTypeId=" + roomTypeId +
", roomType='" + roomType + '\'' + ", roomType='" + roomType + '\'' +
", orderDate=" + orderDate + ", orderDate=" + orderDate +
", orderDays=" + orderDays + ", orderDays=" + orderDays +

View File

@ -21,6 +21,16 @@ public class RoomType {
private Integer window; private Integer window;
private Integer rest;
public Integer getRest() {
return rest;
}
public void setRest(Integer rest) {
this.rest = rest;
}
private Date createTime; private Date createTime;
private Date updateTime; private Date updateTime;
@ -114,6 +124,7 @@ public class RoomType {
} }
public RoomType() { public RoomType() {
this.rest = 0;
} }
public RoomType(String roomType, String remark, Double price, Double discount, Integer area, Integer bedNum, String bedSize, Integer window) { public RoomType(String roomType, String remark, Double price, Double discount, Integer area, Integer bedNum, String bedSize, Integer window) {
@ -143,4 +154,4 @@ public class RoomType {
", updateTime=" + updateTime + ", updateTime=" + updateTime +
'}'; '}';
} }
} }

View File

@ -0,0 +1,33 @@
package cn.mafangui.hotel.enums;
public enum OrderStatus {
WAS_DELETED(-3,"已删除"),
OVERTIME(-2,"支付超时"),
WAS_CANCELED(-1,"已取消"),
UNPAID(0,"未付款"),
PAID(1,"待入住"),
CHECK_IN(2,"已入住")
;
private int code;
private String status;
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
OrderStatus(int code, String status) {
}
}

View File

@ -0,0 +1,30 @@
package cn.mafangui.hotel.enums;
public enum Role {
ADMIN("admin","管理员"),
OPERATOR("operator","操作员")
;
private String value;
private String role;
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public String getRole() {
return role;
}
public void setRole(String role) {
this.role = role;
}
Role(String value, String role) {
}
}

View File

@ -0,0 +1,31 @@
package cn.mafangui.hotel.enums;
public enum RoomStatus {
UNAVAILABLE(0,"不可用"),
AVAILABLE(1,"空闲"),
ORDERED(2,"被预订"),
IN_USE(3,"已入住")
;
private int code;
private String status;
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
RoomStatus(int code,String status) {
}
}

View File

@ -1,11 +1,7 @@
package cn.mafangui.hotel.mapper; package cn.mafangui.hotel.mapper;
import cn.mafangui.hotel.entity.Order; import cn.mafangui.hotel.entity.Order;
import org.springframework.stereotype.Component;
import java.util.List;
@Component
public interface OrderMapper { public interface OrderMapper {
int deleteByPrimaryKey(Integer orderId); int deleteByPrimaryKey(Integer orderId);
@ -18,12 +14,4 @@ public interface OrderMapper {
int updateByPrimaryKeySelective(Order record); int updateByPrimaryKeySelective(Order record);
int updateByPrimaryKey(Order record); int updateByPrimaryKey(Order record);
}
List<Order> selectByUserId(int userId);
List<Order> selectAll();
List<Order> userSelectAll(int userId);
}

View File

@ -8,6 +8,8 @@ public interface OrderService {
int insert(Order order); int insert(Order order);
int addOrder(Order order);
int delete(Integer orderId); int delete(Integer orderId);
Order selectById(Integer orderId); Order selectById(Integer orderId);
@ -16,7 +18,7 @@ public interface OrderService {
List<Order> selectByUserId(int userId); List<Order> selectByUserId(int userId);
List<Order> selectAll(); List<Order> AllOrders();
List<Order> userSelectAll(int userId); List<Order> UsersAllOrders(int userId);
} }

View File

@ -1,17 +0,0 @@
package cn.mafangui.hotel.utils;
public class RoomStaticUtil {
public static final int UNAVAILABLE = 0;
public static final int AVAILABLE = 1;
public static final int OCCUPIED = 2;
public static final int IN_USE = 3;
public static final String[] STATUS = {"UNAVAILABLE","AVAILABLE","OCCUPIED","IN_USE",};
public RoomStaticUtil(){
}
public static String getRoomStatic(){
return null;
}
}

View File

@ -1,43 +0,0 @@
package cn.mafangui.hotel.utils;
public class StaticString {
public static final String CODE = "code";
public static final String STATUS = "status";
public static final String DATA = "data";
/**
* 工作人员角色
*/
public static final String ADMIN = "admin";
public static final String OPERATOR = "operator";
/**
* 房间状态
* 不可用
* 空闲可用
* 已被预订
* 已被入住
*/
public static final int UNAVAILABLE = 0;
public static final int AVAILABLE = 1;
public static final int OCCUPIED = 2;
public static final int IN_USE = 3;
/**
* 订单状态
* 被用户删除-3
* 超时 -2
* 被取消-1
* 未付款0
* 已付款1
* 已入住2
*
*/
public static final int WAS_DELETE = -3;
public static final int OVERTIME = -2;
public static final int WAS_CANCELED = -1;
public static final int UNPAID = 0;
public static final int PAID = 1;
public static final int WAS_USED = 2;
}

View File

@ -59,50 +59,50 @@
<!-- schema即为数据库名 tableName为对应的数据库表 domainObjectName是要生成的实体类 enable*ByExample <!-- schema即为数据库名 tableName为对应的数据库表 domainObjectName是要生成的实体类 enable*ByExample
是否生成 example类 --> 是否生成 example类 -->
<table schema="hotel" tableName="user_info" <!--<table schema="hotel" tableName="user_info"-->
domainObjectName="User" enableCountByExample="false" <!--domainObjectName="User" enableCountByExample="false"-->
enableDeleteByExample="false" enableSelectByExample="false" <!--enableDeleteByExample="false" enableSelectByExample="false"-->
enableUpdateByExample="false"> <!--enableUpdateByExample="false">-->
</table> <!--</table>-->
<table schema="hotel" tableName="worker_info" <!--<table schema="hotel" tableName="worker_info"-->
domainObjectName="Worker" enableCountByExample="false" <!--domainObjectName="Worker" enableCountByExample="false"-->
enableDeleteByExample="false" enableSelectByExample="false" <!--enableDeleteByExample="false" enableSelectByExample="false"-->
enableUpdateByExample="false"> <!--enableUpdateByExample="false">-->
</table> <!--</table>-->
<table schema="hotel" tableName="room_type" <!--<table schema="hotel" tableName="room_type"-->
domainObjectName="RoomType" enableCountByExample="false" <!--domainObjectName="RoomType" enableCountByExample="false"-->
enableDeleteByExample="false" enableSelectByExample="false" <!--enableDeleteByExample="false" enableSelectByExample="false"-->
enableUpdateByExample="false"> <!--enableUpdateByExample="false">-->
</table> <!--</table>-->
<table schema="hotel" tableName="order_type" <!--<table schema="hotel" tableName="order_type"-->
domainObjectName="OrderType" enableCountByExample="false" <!--domainObjectName="OrderType" enableCountByExample="false"-->
enableDeleteByExample="false" enableSelectByExample="false" <!--enableDeleteByExample="false" enableSelectByExample="false"-->
enableUpdateByExample="false"> <!--enableUpdateByExample="false">-->
</table> <!--</table>-->
<table schema="hotel" tableName="room_info" <!--<table schema="hotel" tableName="room_info"-->
domainObjectName="Room" enableCountByExample="false" <!--domainObjectName="Room" enableCountByExample="false"-->
enableDeleteByExample="false" enableSelectByExample="false" <!--enableDeleteByExample="false" enableSelectByExample="false"-->
enableUpdateByExample="false"> <!--enableUpdateByExample="false">-->
</table> <!--</table>-->
<table schema="hotel" tableName="order_info" <table schema="hotel" tableName="order_info"
domainObjectName="Order" enableCountByExample="false" domainObjectName="Order" enableCountByExample="false"
enableDeleteByExample="false" enableSelectByExample="false" enableDeleteByExample="false" enableSelectByExample="false"
enableUpdateByExample="false"> enableUpdateByExample="false">
</table> </table>
<table schema="hotel" tableName="hotel_info" <!--<table schema="hotel" tableName="hotel_info"-->
domainObjectName="Hotel" enableCountByExample="false" <!--domainObjectName="Hotel" enableCountByExample="false"-->
enableDeleteByExample="false" enableSelectByExample="false" <!--enableDeleteByExample="false" enableSelectByExample="false"-->
enableUpdateByExample="false"> <!--enableUpdateByExample="false">-->
</table> <!--</table>-->
<table schema="hotel" tableName="department_info" <!--<table schema="hotel" tableName="department_info"-->
domainObjectName="Department" enableCountByExample="false" <!--domainObjectName="Department" enableCountByExample="false"-->
enableDeleteByExample="false" enableSelectByExample="false" <!--enableDeleteByExample="false" enableSelectByExample="false"-->
enableUpdateByExample="false"> <!--enableUpdateByExample="false">-->
</table> <!--</table>-->
<table schema="hotel" tableName="check_in" <!--<table schema="hotel" tableName="check_in"-->
domainObjectName="CheckIn" enableCountByExample="false" <!--domainObjectName="CheckIn" enableCountByExample="false"-->
enableDeleteByExample="false" enableSelectByExample="false" <!--enableDeleteByExample="false" enableSelectByExample="false"-->
enableUpdateByExample="false"> <!--enableUpdateByExample="false">-->
</table> <!--</table>-->
</context> </context>
</generatorConfiguration> </generatorConfiguration>

View File

@ -1,6 +1,201 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.mafangui.hotel.mapper.OrderMapper"> <mapper namespace="cn.mafangui.hotel.mapper.OrderMapper">
<resultMap id="BaseResultMap" type="cn.mafangui.hotel.entity.Order">
<id column="order_id" jdbcType="INTEGER" property="orderId" />
<result column="order_type_id" jdbcType="INTEGER" property="orderTypeId" />
<result column="order_type" jdbcType="VARCHAR" property="orderType" />
<result column="user_id" jdbcType="INTEGER" property="userId" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="phone" jdbcType="VARCHAR" property="phone" />
<result column="room_type_id" jdbcType="INTEGER" property="roomTypeId" />
<result column="room_type" jdbcType="VARCHAR" property="roomType" />
<result column="order_date" jdbcType="DATE" property="orderDate" />
<result column="order_days" jdbcType="INTEGER" property="orderDays" />
<result column="order_status" jdbcType="INTEGER" property="orderStatus" />
<result column="order_cost" jdbcType="DOUBLE" property="orderCost" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
</resultMap>
<sql id="Base_Column_List">
order_id, order_type_id, order_type, user_id, name, phone, room_type_id, room_type,
order_date, order_days, order_status, order_cost, create_time, update_time
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from order_info
where order_id = #{orderId,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from order_info
where order_id = #{orderId,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="cn.mafangui.hotel.entity.Order">
insert into order_info (order_id, order_type_id, order_type,
user_id, name, phone,
room_type_id, room_type, order_date,
order_days, order_status, order_cost,
create_time, update_time)
values (#{orderId,jdbcType=INTEGER}, #{orderTypeId,jdbcType=INTEGER}, #{orderType,jdbcType=VARCHAR},
#{userId,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{phone,jdbcType=VARCHAR},
#{roomTypeId,jdbcType=INTEGER}, #{roomType,jdbcType=VARCHAR}, #{orderDate,jdbcType=DATE},
#{orderDays,jdbcType=INTEGER}, #{orderStatus,jdbcType=INTEGER}, #{orderCost,jdbcType=DOUBLE},
#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP})
</insert>
<insert id="insertSelective" parameterType="cn.mafangui.hotel.entity.Order">
insert into order_info
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="orderId != null">
order_id,
</if>
<if test="orderTypeId != null">
order_type_id,
</if>
<if test="orderType != null">
order_type,
</if>
<if test="userId != null">
user_id,
</if>
<if test="name != null">
name,
</if>
<if test="phone != null">
phone,
</if>
<if test="roomTypeId != null">
room_type_id,
</if>
<if test="roomType != null">
room_type,
</if>
<if test="orderDate != null">
order_date,
</if>
<if test="orderDays != null">
order_days,
</if>
<if test="orderStatus != null">
order_status,
</if>
<if test="orderCost != null">
order_cost,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="orderId != null">
#{orderId,jdbcType=INTEGER},
</if>
<if test="orderTypeId != null">
#{orderTypeId,jdbcType=INTEGER},
</if>
<if test="orderType != null">
#{orderType,jdbcType=VARCHAR},
</if>
<if test="userId != null">
#{userId,jdbcType=INTEGER},
</if>
<if test="name != null">
#{name,jdbcType=VARCHAR},
</if>
<if test="phone != null">
#{phone,jdbcType=VARCHAR},
</if>
<if test="roomTypeId != null">
#{roomTypeId,jdbcType=INTEGER},
</if>
<if test="roomType != null">
#{roomType,jdbcType=VARCHAR},
</if>
<if test="orderDate != null">
#{orderDate,jdbcType=DATE},
</if>
<if test="orderDays != null">
#{orderDays,jdbcType=INTEGER},
</if>
<if test="orderStatus != null">
#{orderStatus,jdbcType=INTEGER},
</if>
<if test="orderCost != null">
#{orderCost,jdbcType=DOUBLE},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="cn.mafangui.hotel.entity.Order">
update order_info
<set>
<if test="orderTypeId != null">
order_type_id = #{orderTypeId,jdbcType=INTEGER},
</if>
<if test="orderType != null">
order_type = #{orderType,jdbcType=VARCHAR},
</if>
<if test="userId != null">
user_id = #{userId,jdbcType=INTEGER},
</if>
<if test="name != null">
name = #{name,jdbcType=VARCHAR},
</if>
<if test="phone != null">
phone = #{phone,jdbcType=VARCHAR},
</if>
<if test="roomTypeId != null">
room_type_id = #{roomTypeId,jdbcType=INTEGER},
</if>
<if test="roomType != null">
room_type = #{roomType,jdbcType=VARCHAR},
</if>
<if test="orderDate != null">
order_date = #{orderDate,jdbcType=DATE},
</if>
<if test="orderDays != null">
order_days = #{orderDays,jdbcType=INTEGER},
</if>
<if test="orderStatus != null">
order_status = #{orderStatus,jdbcType=INTEGER},
</if>
<if test="orderCost != null">
order_cost = #{orderCost,jdbcType=DOUBLE},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
</set>
where order_id = #{orderId,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="cn.mafangui.hotel.entity.Order">
update order_info
set order_type_id = #{orderTypeId,jdbcType=INTEGER},
order_type = #{orderType,jdbcType=VARCHAR},
user_id = #{userId,jdbcType=INTEGER},
name = #{name,jdbcType=VARCHAR},
phone = #{phone,jdbcType=VARCHAR},
room_type_id = #{roomTypeId,jdbcType=INTEGER},
room_type = #{roomType,jdbcType=VARCHAR},
order_date = #{orderDate,jdbcType=DATE},
order_days = #{orderDays,jdbcType=INTEGER},
order_status = #{orderStatus,jdbcType=INTEGER},
order_cost = #{orderCost,jdbcType=DOUBLE},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP}
where order_id = #{orderId,jdbcType=INTEGER}
</update>
<resultMap id="BaseResultMap" type="cn.mafangui.hotel.entity.Order"> <resultMap id="BaseResultMap" type="cn.mafangui.hotel.entity.Order">
<id column="order_id" jdbcType="INTEGER" property="orderId" /> <id column="order_id" jdbcType="INTEGER" property="orderId" />
<result column="order_type" jdbcType="VARCHAR" property="orderType" /> <result column="order_type" jdbcType="VARCHAR" property="orderType" />
@ -40,7 +235,7 @@
select select
* *
from order_info from order_info
where order_status >= -2 and user_id = #{userId,jdbcType=VARCHAR} where order_status &gt;= -2 and user_id = #{userId,jdbcType=VARCHAR}
</select> </select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer"> <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from order_info delete from order_info
@ -172,4 +367,4 @@
update_time = now() update_time = now()
where order_id = #{orderId,jdbcType=INTEGER} where order_id = #{orderId,jdbcType=INTEGER}
</update> </update>
</mapper> </mapper>

View File

@ -11,15 +11,16 @@
<result column="bed_num" jdbcType="INTEGER" property="bedNum" /> <result column="bed_num" jdbcType="INTEGER" property="bedNum" />
<result column="bed_size" jdbcType="VARCHAR" property="bedSize" /> <result column="bed_size" jdbcType="VARCHAR" property="bedSize" />
<result column="window" jdbcType="INTEGER" property="window" /> <result column="window" jdbcType="INTEGER" property="window" />
<result column="rest" jdbcType="INTEGER" property="rest" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" /> <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" /> <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
</resultMap> </resultMap>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
type_id, room_type, remark, price, discount, area, bed_num, bed_size, window, create_time, type_id, room_type, remark, price, discount, area, bed_num, bed_size, window, rest,create_time,
update_time update_time
</sql> </sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap"> <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select select
<include refid="Base_Column_List" /> <include refid="Base_Column_List" />
from room_type from room_type
where type_id = #{typeId,jdbcType=INTEGER} where type_id = #{typeId,jdbcType=INTEGER}
@ -35,13 +36,14 @@
where type_id = #{typeId,jdbcType=INTEGER} where type_id = #{typeId,jdbcType=INTEGER}
</delete> </delete>
<insert id="insert" parameterType="cn.mafangui.hotel.entity.RoomType"> <insert id="insert" parameterType="cn.mafangui.hotel.entity.RoomType">
insert into room_type (type_id, room_type, remark, insert into room_type (type_id, room_type, remark,
price, discount, area, price, discount, area,
bed_num, bed_size, window, bed_num, bed_size, window, rest
create_time, update_time) create_time, update_time)
values (#{typeId,jdbcType=INTEGER}, #{roomType,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR}, values (#{typeId,jdbcType=INTEGER}, #{roomType,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR},
#{price,jdbcType=DOUBLE}, #{discount,jdbcType=DOUBLE}, #{area,jdbcType=INTEGER}, #{price,jdbcType=DOUBLE}, #{discount,jdbcType=DOUBLE}, #{area,jdbcType=INTEGER},
#{bedNum,jdbcType=INTEGER}, #{bedSize,jdbcType=VARCHAR}, #{window,jdbcType=INTEGER}, #{bedNum,jdbcType=INTEGER}, #{bedSize,jdbcType=VARCHAR}, #{window,jdbcType=INTEGER},
#{rest,jdbcType=INTEGER},
now(), now()) now(), now())
</insert> </insert>
<insert id="insertSelective" parameterType="cn.mafangui.hotel.entity.RoomType"> <insert id="insertSelective" parameterType="cn.mafangui.hotel.entity.RoomType">
@ -73,6 +75,9 @@
</if> </if>
<if test="window != null"> <if test="window != null">
window, window,
</if>
<if test="rest != null">
rest,
</if> </if>
create_time, create_time,
update_time, update_time,
@ -105,6 +110,9 @@
<if test="window != null"> <if test="window != null">
#{window,jdbcType=INTEGER}, #{window,jdbcType=INTEGER},
</if> </if>
<if test="rest != null">
#{rest,jdbcType=INTEGER},
</if>
now(), now(),
now(), now(),
</trim> </trim>
@ -135,6 +143,9 @@
</if> </if>
<if test="window != null"> <if test="window != null">
window = #{window,jdbcType=INTEGER}, window = #{window,jdbcType=INTEGER},
</if>
<if test="rest != null">
rest = #{rest,jdbcType=INTEGER},
</if> </if>
update_time = now(), update_time = now(),
</set> </set>
@ -150,7 +161,8 @@
bed_num = #{bedNum,jdbcType=INTEGER}, bed_num = #{bedNum,jdbcType=INTEGER},
bed_size = #{bedSize,jdbcType=VARCHAR}, bed_size = #{bedSize,jdbcType=VARCHAR},
window = #{window,jdbcType=INTEGER}, window = #{window,jdbcType=INTEGER},
rest = #{rest,jdbcType=INTEGER},
update_time = now() update_time = now()
where type_id = #{typeId,jdbcType=INTEGER} where type_id = #{typeId,jdbcType=INTEGER}
</update> </update>
</mapper> </mapper>

View File

@ -1,49 +0,0 @@
package cn.mafangui.hotel.controller;
import cn.mafangui.hotel.entity.RoomType;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.util.List;
import static org.junit.Assert.*;
@SpringBootTest
@RunWith(SpringJUnit4ClassRunner.class)
public class RoomTypeControllerTest {
@Autowired
RoomTypeController rtc;
@Test
public void getAllRoomType() {
List<RoomType> result = rtc.getAllRoomType();
System.out.println(result);
Assert.assertEquals(2,result.size());
}
@Test
public void addRoomType() {
int res = 0;
res = rtc.addRoomType("单人房",129.0,12.0,10,1,"1.2",0,"1 Person");
Assert.assertEquals(1,res);
}
@Test
public void updateRoomType() {
int res = 0;
res = rtc.updateRoomType(2,"单人房",109.0,22.0,10,1,"1.2",0,"1 Person");
Assert.assertEquals(1,res);
}
@Test
public void deleteRoomType() {
int res = 0;
res = rtc.deleteRoomType(1);
Assert.assertEquals(1,res);
}
}