Search in sources :

Example 6 with User

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

the class LoginInterceptor method preHandle.

public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
    // 未登录
    User user = sessionUserInfo.getCurrentSessionUser(User.class);
    if (user == null) {
        ApiResponse apiResponse = ApiResponse.creatFail(ResponseCode.LoginRegister.NOLOGIN);
        response.setContentType("application/json;charset=UTF-8");
        response.getWriter().print(JSON.toJSONString(apiResponse, SerializerFeature.DisableCircularReferenceDetect, SerializerFeature.WriteEnumUsingToString));
        return false;
    } else {
        sessionUserInfo.setSessionUser(user);
    }
    return true;
}
Also used : User(com.rogge.common.model.User) ApiResponse(com.rogge.common.core.ApiResponse)

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