Browse Source

浏览订单列表

CHENYIZONG 6 years ago
parent
commit
1298af8297

+ 4 - 0
src/main/java/com/example/hotel/bl/user/ClientService.java

@@ -2,6 +2,8 @@ package com.example.hotel.bl.user;
 
 import com.example.hotel.vo.OrderVO;
 
+import java.util.List;
+
 /**
  * @Author: chenyizong
  * @Date: 2020-02-29
@@ -12,4 +14,6 @@ public interface ClientService {
      * @param orderVO
      */
     void addOrder(OrderVO orderVO);
+
+    List<OrderVO> retrieveOrders();
 }

+ 7 - 0
src/main/java/com/example/hotel/blImpl/user/ClientServiceImpl.java

@@ -7,6 +7,8 @@ import com.example.hotel.vo.OrderVO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 /**
  * @Author: chenyizong
  * @Date: 2020-02-29
@@ -32,4 +34,9 @@ public class ClientServiceImpl implements ClientService {
 
 
     }
+
+    @Override
+    public List<OrderVO> retrieveOrders() {
+        return orderMapper.selectAllOrder();
+    }
 }

+ 9 - 4
src/main/java/com/example/hotel/controller/user/ClientController.java

@@ -5,10 +5,8 @@ import com.example.hotel.util.Result;
 import com.example.hotel.vo.OrderVO;
 import com.example.hotel.vo.ResponseVO;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
 
 /**
  * @Author: chenyizong
@@ -27,4 +25,11 @@ public class ClientController {
         clientService.addOrder(orderVO);
         return ResponseVO.buildSuccess(orderVO);
     }
+
+    @GetMapping("/order/all")
+    public ResponseEntity<?> retrieveAllOrders(){
+        return Result.ok(clientService.retrieveOrders());
+    }
+
+
 }

+ 5 - 0
src/main/java/com/example/hotel/data/user/OrderMapper.java

@@ -1,9 +1,12 @@
 package com.example.hotel.data.user;
 
 import com.example.hotel.po.Order;
+import com.example.hotel.vo.OrderVO;
 import org.apache.ibatis.annotations.Mapper;
 import org.springframework.stereotype.Repository;
 
+import java.util.List;
+
 /**
  * @Author: chenyizong
  * @Date: 2020-02-29
@@ -12,4 +15,6 @@ import org.springframework.stereotype.Repository;
 @Repository
 public interface OrderMapper {
     int insertOrder(Order order);
+
+    List<OrderVO> selectAllOrder();
 }

+ 1 - 1
src/main/resources/application.yml

@@ -2,7 +2,7 @@ spring:
   datasource:
      url: jdbc:mysql://localhost:3306/Hotel?serverTimezone=CTT&characterEncoding=UTF-8
      username: root
-     password: root
+     password: 1598753
      driver-class-name: com.mysql.cj.jdbc.Driver
      max-active: 200
      max-idle: 20