ziyi.liu 4 éve
szülő
commit
731a24f166

+ 1 - 2
graphql-api/src/main/java/com/remy/graphql/resolvers/dataloader/UserDataLoaderResolver.java

@@ -1,6 +1,5 @@
 package com.remy.graphql.resolvers.dataloader;
 
-import com.remy.common.module.GoodsDTO;
 import com.remy.common.module.OrderDTO;
 import com.remy.common.module.UserDTO;
 import graphql.kickstart.execution.context.GraphQLContext;
@@ -16,7 +15,7 @@ import java.util.concurrent.CompletableFuture;
 @Component
 public class UserDataLoaderResolver implements GraphQLResolver<UserDTO> {
 
-    public CompletableFuture<List<OrderDTO>> orders(UserDTO userDTO, DataFetchingEnvironment env){
+    public CompletableFuture<List<OrderDTO>> orders(UserDTO userDTO, DataFetchingEnvironment env) {
         DataLoaderRegistry registry = ((GraphQLContext) env.getContext()).getDataLoaderRegistry();
         DataLoader<Long, List<OrderDTO>> orderUserDataLoader = registry.getDataLoader("orderUserDataLoader");
         if (orderUserDataLoader != null) {

+ 21 - 7
graphql-demo.sql

@@ -27,7 +27,7 @@ CREATE TABLE IF NOT EXISTS `t_goods` (
     PRIMARY KEY (`id`)
     ) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4;
 
--- 正在导出表  graphql-demo.t_goods 的数据:~7 rows (大约)
+-- 正在导出表  graphql-demo.t_goods 的数据:~6 rows (大约)
 /*!40000 ALTER TABLE `t_goods` DISABLE KEYS */;
 INSERT INTO `t_goods` (`id`, `create_time`, `update_time`, `description`, `detail`, `img`, `item_count`, `name`, `price`, `serial_no`) VALUES
 (1, '2021-06-21 16:49:12.094000', '2021-06-21 16:49:12.094000', 'GU女装起居套装(短袖)', 'GU女装起居套装(短袖)', 'https://graphql.cn/img/logo.svg', 99, 'GU女装', 74.00, 'pYmhjY58'),
@@ -51,10 +51,24 @@ CREATE TABLE IF NOT EXISTS `t_order` (
     `original_amount` decimal(19,2) DEFAULT NULL,
     `userid` bigint(20) DEFAULT NULL,
     PRIMARY KEY (`id`)
-    ) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8mb4;
+    ) ENGINE=InnoDB AUTO_INCREMENT=26 DEFAULT CHARSET=utf8mb4;
 
--- 正在导出表  graphql-demo.t_order 的数据:~0 rows (大约)
+-- 正在导出表  graphql-demo.t_order 的数据:~12 rows (大约)
 /*!40000 ALTER TABLE `t_order` DISABLE KEYS */;
+INSERT INTO `t_order` (`id`, `create_time`, `update_time`, `discount`, `discount_amount`, `goods_serial_no`, `order_no`, `original_amount`, `userid`) VALUES
+(13, '2021-06-22 10:23:06.601000', '2021-06-22 10:23:06.601000', 0.90, 66.60, 'pYmhjY58', '4bvd9i9pte', 74.00, 3),
+(14, '2021-06-22 10:23:38.583000', '2021-06-22 10:23:38.583000', 0.90, 143.10, '3qlihuWg', 'jnZ5nnHiK1', 159.00, 3),
+(15, '2021-06-22 10:23:45.893000', '2021-06-22 10:23:45.893000', 0.90, 259.20, 'vdjvwNjW', 'tFAyZo8DYE', 288.00, 3),
+(16, '2021-06-22 10:23:54.562000', '2021-06-22 10:23:54.562000', 0.90, 5669.10, 'INEnt8OV', 'OlkhJzLUej', 6299.00, 3),
+(17, '2021-06-22 10:24:01.914000', '2021-06-22 10:24:01.914000', 0.90, 1682.10, '1K7gdmNM', 'siSxjPn356', 1869.00, 3),
+(18, '2021-06-22 10:24:09.921000', '2021-06-22 10:24:09.921000', 0.85, 100.30, 'H5JJjJSj', 'rbLhAgyCUa', 118.00, 4),
+(19, '2021-06-22 10:24:15.119000', '2021-06-22 10:24:15.119000', 0.85, 135.15, '3qlihuWg', 'VbIwCbeI3O', 159.00, 4),
+(20, '2021-06-22 10:24:20.419000', '2021-06-22 10:24:20.419000', 0.85, 62.90, 'pYmhjY58', 'oL7ddUvrnP', 74.00, 4),
+(21, '2021-06-22 10:24:44.915000', '2021-06-22 10:24:44.915000', 0.80, 127.20, '3qlihuWg', 'H6snS9Nyv1', 159.00, 5),
+(22, '2021-06-22 10:24:51.826000', '2021-06-22 10:24:51.826000', 0.80, 127.20, '3qlihuWg', 'RpuQA5ospX', 159.00, 5),
+(23, '2021-06-22 10:24:57.448000', '2021-06-22 10:24:57.448000', 0.80, 59.20, 'pYmhjY58', 'wo9irE1ykw', 74.00, 5),
+(24, '2021-06-22 10:25:02.539000', '2021-06-22 10:25:02.539000', 0.80, 94.40, 'H5JJjJSj', 'RWLr4PxacG', 118.00, 5),
+(25, '2021-06-22 10:25:15.570000', '2021-06-22 10:25:15.570000', 0.80, 719.20, '5gqeGUEO', 'GivJBRVA7f', 899.00, 5);
 /*!40000 ALTER TABLE `t_order` ENABLE KEYS */;
 
 -- 导出  表 graphql-demo.t_user 结构
@@ -74,12 +88,12 @@ CREATE TABLE IF NOT EXISTS `t_user` (
     UNIQUE KEY `UK_jhib4legehrm4yscx9t3lirqi` (`username`)
     ) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4;
 
--- 正在导出表  graphql-demo.t_user 的数据:~3 rows (大约)
+-- 正在导出表  graphql-demo.t_user 的数据:~2 rows (大约)
 /*!40000 ALTER TABLE `t_user` DISABLE KEYS */;
 INSERT INTO `t_user` (`id`, `create_time`, `update_time`, `age`, `birthday`, `gender`, `img`, `level`, `nickname`, `password`, `username`) VALUES
 (3, '2021-06-18 10:26:10.914000', '2021-06-18 10:26:10.914000', 30, '1985-02-22', 'MALE', 'https://www.baidu.com', 1, '小明', '3A548574B23819E3AF577B795AB8A147', 'remylee'),
-(4, '2021-06-21 19:02:34.540000', '2021-06-21 19:02:34.540000', 22, '1999-12-21', 'MALE', 'https://graphql.cn/img/logo.svg', NULL, '杰克', '4D81FF7831351A0AEB58CC1719429002', 'jack'),
-(5, '2021-06-21 19:03:18.924000', '2021-06-21 19:03:18.924000', 21, '2000-02-12', 'FEMALE', 'https://graphql.cn/img/logo.svg', NULL, '柔丝', '08DF54DA47C5E343DA8ABD541FEF87F6', 'rose');
+(4, '2021-06-21 19:02:34.540000', '2021-06-21 19:02:34.540000', 22, '1999-12-21', 'MALE', 'https://graphql.cn/img/logo.svg', 2, '杰克', '4D81FF7831351A0AEB58CC1719429002', 'jack'),
+(5, '2021-06-21 19:03:18.924000', '2021-06-21 19:03:18.924000', 21, '2000-02-12', 'FEMALE', 'https://graphql.cn/img/logo.svg', 3, '柔丝', '08DF54DA47C5E343DA8ABD541FEF87F6', 'rose');
 /*!40000 ALTER TABLE `t_user` ENABLE KEYS */;
 
 -- 导出  表 graphql-demo.user_addresses 结构
@@ -90,7 +104,7 @@ CREATE TABLE IF NOT EXISTS `user_addresses` (
     CONSTRAINT `FKpws20r8ion9y4yrp5828uad38` FOREIGN KEY (`user_id`) REFERENCES `t_user` (`id`)
     ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
 
--- 正在导出表  graphql-demo.user_addresses 的数据:~3 rows (大约)
+-- 正在导出表  graphql-demo.user_addresses 的数据:~2 rows (大约)
 /*!40000 ALTER TABLE `user_addresses` DISABLE KEYS */;
 INSERT INTO `user_addresses` (`user_id`, `addresses`) VALUES
 (3, '上海'),

+ 2 - 5
order-service/src/main/java/com/remy/order/controller/OrderController.java

@@ -6,10 +6,8 @@ import org.apache.commons.lang3.RandomStringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
-import javax.persistence.EntityNotFoundException;
 import java.util.List;
 import java.util.Map;
-import java.util.Optional;
 
 @RestController
 @RequestMapping("orders")
@@ -20,8 +18,7 @@ public class OrderController {
 
     @RequestMapping()
     public List<Order> findAll() {
-        throw new EntityNotFoundException();
-//        return orderService.findAll();
+        return orderService.findAll();
     }
 
     @RequestMapping("{orderNo}")
@@ -30,7 +27,7 @@ public class OrderController {
     }
 
     @RequestMapping("query")
-    public List<Order> findAllByCondition(@RequestParam Map<String,String> params) {
+    public List<Order> findAllByCondition(@RequestParam Map<String, String> params) {
         return orderService.findByCondition(
                 Order.builder()
                         .goodsSerialNo(params.get("goodsSerialNo"))

BIN
初识GraphQL.pptx