content: package com.taota.sso.query.controller;
  
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.http.HttpStatus;
  import org.springframework.http.ResponseEntity;
  import org.springframework.stereotype.Controller;
  import org.springframework.web.bind.annotation.PathVariable;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RequestMethod;
  
  import com.taotao.sso.query.api.UserQueryService;
  import com.taotao.sso.query.bean.User;
  
  @RequestMapping("user")
  @Controller
  public class UserController {
  
      @Autowired
      private UserQueryService userQueryService;
  
      /**
       * 根据token查询用户信息
       * 
       * @param token
       * @return
       */
      @RequestMapping(value = "{token}", method = RequestMethod.GET)
      public ResponseEntity<User> queryUserByToken(@PathVariable("token") String token) {
          try {
              User user = this.userQueryService.queryUserByToken(token);
              if (null == user) {
                  return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null);
              }
              return ResponseEntity.ok(user);
          } catch (Exception e) {
              e.printStackTrace();
          }
          return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
      }
  
  }
  