Search in sources :

Example 1 with User

use of com.rogge.common.model.User 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 2 with User

use of com.rogge.common.model.User in project spring-cloud by Rogge666.

the class UserController method login.

@GetMapping("/login")
public ApiResponse login(HttpSession session, @RequestParam Integer id) {
    User lUser = userService.findById(id);
    mSessionUserInfo.setSessionUser(session, lUser);
    return ApiResponse.creatSuccess((Object) "登录成功");
}
Also used : User(com.rogge.common.model.User) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 3 with User

use of com.rogge.common.model.User 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 User

use of com.rogge.common.model.User 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)

Example 5 with User

use of com.rogge.common.model.User in project spring-cloud by Rogge666.

the class UserController method list.

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

Aggregations

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