proud1251 6 years ago
parent
commit
a135d463ef

+ 5 - 1
src/main/java/g/g11/controller/order/OrderBasicController.java

@@ -48,8 +48,12 @@ public class OrderBasicController {
         Map<String, Object> map = new HashMap<>();
         List<Order> orderByPage = orderService.getOrderByPage(page, size, keywords);
         Long count = orderService.getCountByKeywords(keywords);
-        map.put("orders", orderByPage);
+        map.put("emps", orderByPage);
         map.put("count", count);
         return map;
     }
+//    @RequestMapping(value = "/order/datatable", method = RequestMethod.GET)
+//    public Map<String, Object> getOrderByDatatable(){
+//
+//    }
 }

+ 2 - 0
src/main/java/g/g11/mapper/OrderMapper.java

@@ -13,6 +13,8 @@ public interface OrderMapper {
     Long getCountByKeywords(@Param("keywords") String keywords);
     int updateOrder(@Param("order") Order order);
     int deleteOrderById(@Param("ids") String[] ids);
+    //unused
     int addOrders(@Param("orders") List<Order> orders);
+    //unused
     List<Order> getOrderByPageShort(@Param("start") int start, @Param("size") Integer size);
 }

+ 3 - 3
src/main/java/g/g11/service/OrderService.java

@@ -35,15 +35,15 @@ public class OrderService {
         String[] split = ids.split(",");
         return orderMapper.deleteOrderById(split) == split.length;
     }
-
+    //unused
     public List<Order> getAllOrders() {
         return orderMapper.getOrderByPage(null, null, "");
     }
-
+    //unused
     public int addOrders(List<Order> orders) {
         return orderMapper.addOrders(orders);
     }
-
+    //unused
     public List<Order> getOrderByPageShort(Integer page, Integer size) {
         int start = (page - 1) * size;
         return orderMapper.getOrderByPageShort(start,size);

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

@@ -1,4 +1,4 @@
-#localhost:8082/order/basic/order
+# GET localhost:8082/order/basic/order
 #MySQL配置
 spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
 spring.datasource.url=jdbc:mysql://127.0.0.1:3306/oms_final?useUnicode=true&characterEncoding=UTF-8

+ 13 - 0
src/main/resources/templates/data.json

@@ -0,0 +1,13 @@
+{
+  "data": [
+    {
+      "id": 1,
+      "name": "蔡徐坤",
+      "product_id": "p1",
+      "charge": 100,
+      "address": "中国",
+      "status": "未发货"
+    }
+  ],
+  "recordsTotal": 1
+}

+ 1 - 4
src/main/resources/templates/index.html

@@ -1,11 +1,8 @@
 <!DOCTYPE html>
-<html>
+<html lang="en">
 <head>
     <meta charset="UTF-8">
     <title>Title</title>
-    <script src="https://code.jquery.com/jquery-3.3.1.js"></script>
-    <script src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
-    <link href="https://cdn.datatables.net/1.10.19/css/jquery.dataTables.min.css">
 </head>
 <body>
 hi

+ 42 - 0
src/main/resources/templates/index_.html

@@ -0,0 +1,42 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <meta charset="UTF-8">
+    <title>Title</title>
+    <script src="https://code.jquery.com/jquery-3.3.1.js"></script>
+    <script src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
+    <link href="https://cdn.datatables.net/1.10.19/css/jquery.dataTables.min.css">
+</head>
+<body>
+<table id="example" class="display" style="width:100%">
+    <thead>
+    <tr>
+        <th>订单号</th>
+        <th>客户姓名</th>
+        <th>商品编号</th>
+        <th>价格</th>
+        <th>收货地址</th>
+        <th>发货状态</th>
+    </tr>
+    </thead>
+</table>
+<script>
+    $(document).ready(function() {
+        $('#example').DataTable( {
+            "processing": true,
+            "serverSide": true,
+            "ajax": {
+                url: "http://localhost:8082/order/basic/order/datatable",
+                type: "GET"
+            },
+            "columnDefs": [
+                {
+                    "targets": [0, 1, 2, 3, 4, 5],
+                    "orderable": false,
+                },
+            ]
+        } );
+    } );
+</script>
+</body>
+</html>