package com.hst.oauth2.controller;
import com.hst.ces.controller.BaseFatherController;
import com.hst.oauth2.service.IVerifyService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.concurrent.Callable;
/**
* 统一认证服务,根据token校验用户信息
*
* @author walter
*/
@Controller
@RequestMapping(value = "/v1")
@Slf4j
public class VerifyTokenController extends BaseFatherController {
@Autowired
private IVerifyService verifyService;
/**
* 校验token,返回用户信息
*
* @param authorization 服务器认证信息
* @param accessToken token
* @return 返回
*/
@RequestMapping(value = "/tokeninfo")
@ResponseBody
public Callable<Object> verifyToken(@RequestHeader("Authorization") String authorization,
@RequestParam("access_token") String accessToken) {
return () -> verifyService.verifyToken(authorization, accessToken);
}
}
使用上面的lambda表达式,前提是返回参数必须interface类型(如callable<泛型>接口)。