package org.lingniu.example.demo.controller;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.lingniu.sdk.model.base.CommonResult;
import org.lingniu.sdk.model.user.UserInfo;
import org.springframework.boot.autoconfigure.security.oauth2.client.OAuth2ClientProperties;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/test")
@RestController
public class DemoController {

    private final OAuth2ClientProperties oAuth2ClientProperties;
    private final ObjectMapper objectMapper;

    public DemoController(OAuth2ClientProperties oAuth2ClientProperties, ObjectMapper objectMapper) {
        this.oAuth2ClientProperties = oAuth2ClientProperties;
        this.objectMapper = objectMapper;
    }
    @GetMapping("/getUserInfo")
    public CommonResult<UserInfo> getUserInfo(@AuthenticationPrincipal UserInfo userInfo) throws Exception {
        return CommonResult.success(userInfo);
    }


}
