Search in sources :

Example 1 with Order

use of com.rogge.order.model.Order in project spring-cloud by Rogge666.

the class OrderController method list.

@GetMapping("/list")
public ApiResponse list(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "0") Integer size) {
    PageHelper.startPage(page, size);
    List<Order> list = orderService.findAll();
    PageInfo pageInfo = new PageInfo(list);
    return ApiResponse.creatSuccess(pageInfo);
}
Also used : Order(com.rogge.order.model.Order) PageInfo(com.github.pagehelper.PageInfo) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 2 with Order

use of com.rogge.order.model.Order in project spring-cloud by Rogge666.

the class OrderController method getOrderByUserIdV2.

/**
 * 测试feign
 *
 * @param userId
 * @return
 */
@GetMapping("/getOrderByUserIdV2")
@HystrixCommand(fallbackMethod = "getOrderByUserNameError")
public ApiResponse getOrderByUserIdV2(@RequestParam("userId") Long userId) {
    User lUser = mUserFeign.detail(userId);
    String userName = lUser.getUsername();
    List<Order> lOrders = orderService.getOrderByUserName(userName);
    return ApiResponse.creatSuccess(lOrders);
}
Also used : Order(com.rogge.order.model.Order) User(com.rogge.common.model.User) HystrixCommand(com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 3 with Order

use of com.rogge.order.model.Order in project spring-cloud by Rogge666.

the class OrderController method getOrderByUserIdV3.

/**
 * 测试session透传  需要先调用user模块的登录
 *
 * @return
 */
@GetMapping("/getOrderByUserIdV3")
public ApiResponse getOrderByUserIdV3() {
    User lUser = mSessionUserInfo.getCurrentSessionUser(User.class);
    String userName = lUser.getUsername();
    List<Order> lOrders = orderService.getOrderByUserName(userName);
    return ApiResponse.creatSuccess(lOrders);
}
Also used : Order(com.rogge.order.model.Order) User(com.rogge.common.model.User) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 4 with Order

use of com.rogge.order.model.Order in project spring-cloud by Rogge666.

the class OrderController method getOrderByUserId.

/**
 * 测试mRestTemplate
 *
 * @param userId
 * @return
 */
@GetMapping("/getOrderByUserId")
@HystrixCommand(fallbackMethod = "getOrderByUserNameError")
public ApiResponse getOrderByUserId(@RequestParam("userId") Long userId) {
    // TODO: 2017/11/7 0007 by Rogge RestTemplate没有做session透传  所以会在拦截器失败,如需调用去掉登录拦截器即可
    System.out.println("==========" + name);
    Map<String, Object> map = new HashMap<>();
    map.put("userId", userId);
    User lUser = mRestTemplate.getForObject("http://user-module/detail?id={userId}", User.class, map);
    String userName = lUser.getUsername();
    List<Order> lOrders = orderService.getOrderByUserName(userName);
    return ApiResponse.creatSuccess(lOrders);
}
Also used : Order(com.rogge.order.model.Order) User(com.rogge.common.model.User) HashMap(java.util.HashMap) HystrixCommand(com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Aggregations

Order (com.rogge.order.model.Order)4 GetMapping (org.springframework.web.bind.annotation.GetMapping)4 User (com.rogge.common.model.User)3 HystrixCommand (com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand)2 PageInfo (com.github.pagehelper.PageInfo)1 HashMap (java.util.HashMap)1