mirror of
https://github.com/FreeeBird/hotel.git
synced 2025-11-02 05:24:46 +08:00
更新数据库结构,重写接口
This commit is contained in:
@@ -1,10 +1,7 @@
|
||||
package cn.mafangui.hotel.controller;
|
||||
|
||||
import cn.mafangui.hotel.entity.Room;
|
||||
import cn.mafangui.hotel.entity.RoomType;
|
||||
import cn.mafangui.hotel.entity.Worker;
|
||||
import cn.mafangui.hotel.service.RoomService;
|
||||
import cn.mafangui.hotel.service.RoomTypeService;
|
||||
import cn.mafangui.hotel.service.WorkerService;
|
||||
import cn.mafangui.hotel.utils.StaticString;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -20,8 +17,6 @@ public class AdminController {
|
||||
|
||||
@Autowired
|
||||
private WorkerService workerService;
|
||||
@Autowired
|
||||
private RoomService roomService;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,6 +4,7 @@ import cn.mafangui.hotel.entity.Order;
|
||||
import cn.mafangui.hotel.service.OrderService;
|
||||
import cn.mafangui.hotel.utils.StaticString;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@@ -17,9 +18,10 @@ public class OrderController {
|
||||
private OrderService orderService;
|
||||
|
||||
@RequestMapping(value = "/add")
|
||||
public int addOrder(String orderType,int userId, String phone, String roomType,
|
||||
Integer numOfRoom, Date orderDate, Integer orderDays, Integer orderStatus, Double orderCost){
|
||||
public int addOrder(String orderType, int userId,String name, String phone, String roomType,
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd") Date orderDate, Integer orderDays, Integer orderStatus, Double orderCost){
|
||||
Order order = new Order(orderType,userId,phone,roomType,orderDate,orderDays,orderStatus,orderCost);
|
||||
order.setName(name);
|
||||
return orderService.insert(order);
|
||||
}
|
||||
|
||||
@@ -44,6 +46,23 @@ public class OrderController {
|
||||
return orderService.update(order);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/cancel")
|
||||
public int cancelOrder(int orderId){
|
||||
Order order = new Order();
|
||||
order.setOrderId(orderId);
|
||||
order.setOrderStatus(StaticString.WAS_CANCELED);
|
||||
return orderService.update(order);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/overtime")
|
||||
public int orderOver(int orderId){
|
||||
Order order = new Order();
|
||||
order.setOrderId(orderId);
|
||||
order.setOrderStatus(StaticString.OVERTIME);
|
||||
return orderService.update(order);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/all")
|
||||
public List<Order> getAllOrder(){
|
||||
return orderService.selectAll();
|
||||
@@ -54,6 +73,11 @@ public class OrderController {
|
||||
return orderService.selectByUserId(userId);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/userOrder")
|
||||
public List<Order> getAllByUser(int userId){
|
||||
return orderService.userSelectAll(userId);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/withId")
|
||||
public Order getById(int orderId){
|
||||
return orderService.selectById(orderId);
|
||||
|
||||
@@ -127,6 +127,18 @@ public class UserController {
|
||||
return result;
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST,value = "/withUsername")
|
||||
public User getByUsername(String username){
|
||||
User user = userService.selectByUsername(username);
|
||||
user.setPassword(null);
|
||||
return user;
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST,value = "/withId")
|
||||
public User getById(int userId){
|
||||
return userService.selectById(userId);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/delete")
|
||||
public int deleteUser(int userId){
|
||||
return userService.deleteUser(userId);
|
||||
|
||||
@@ -9,11 +9,20 @@ public class Order {
|
||||
|
||||
private int userId;
|
||||
|
||||
private String name;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
private String phone;
|
||||
|
||||
private String roomType;
|
||||
|
||||
|
||||
private Date orderDate;
|
||||
|
||||
private Integer orderDays;
|
||||
@@ -136,6 +145,15 @@ public class Order {
|
||||
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
|
||||
public String toString() {
|
||||
@@ -153,4 +171,4 @@ public class Order {
|
||||
", updateTime=" + updateTime +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package cn.mafangui.hotel.entity;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Component
|
||||
public class Worker {
|
||||
private Integer workerId;
|
||||
|
||||
@@ -153,4 +156,4 @@ public class Worker {
|
||||
", updateTime=" + updateTime +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,5 +23,7 @@ public interface OrderMapper {
|
||||
|
||||
List<Order> selectAll();
|
||||
|
||||
List<Order> userSelectAll(int userId);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,4 +17,6 @@ public interface OrderService {
|
||||
List<Order> selectByUserId(int userId);
|
||||
|
||||
List<Order> selectAll();
|
||||
|
||||
List<Order> userSelectAll(int userId);
|
||||
}
|
||||
|
||||
@@ -43,4 +43,9 @@ public class OrderServiceImpl implements OrderService {
|
||||
public List<Order> selectAll() {
|
||||
return orderMapper.selectAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Order> userSelectAll(int userId) {
|
||||
return orderMapper.userSelectAll(userId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,19 +24,20 @@ public class StaticString {
|
||||
public static final int IN_USE = 3;
|
||||
/**
|
||||
* 订单状态
|
||||
* 被用户删除-2
|
||||
* 被用户删除-3
|
||||
* 超时 -2
|
||||
* 被取消-1
|
||||
* 未付款0
|
||||
* 已付款1
|
||||
* 已入住2
|
||||
* 超时3
|
||||
*
|
||||
*/
|
||||
public static final int WAS_DELETE = -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;
|
||||
public static final int OVERTIME = 3;
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user