package com.ningdatech.kqapi.sso.controller;

import com.ningdatech.kqapi.sso.manage.SsoManage;
import com.ningdatech.kqapi.sso.model.dto.ReqSsoDTO;
import com.ningdatech.kqapi.sso.model.vo.SsoTokenVO;
import com.ningdatech.kqapi.sso.model.vo.SsoUserInfoVO;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @author CMM
 * @since 2024/04/07 11:15
 */
@Slf4j
@Validated
@RestController
@RequestMapping("/api/v1/sso/")
@RequiredArgsConstructor
public class SsoController {

    private final SsoManage ssoManage;

    @PostMapping ("/token")
    public SsoTokenVO getToken(@Valid @RequestBody ReqSsoDTO reqSsoDTO) {
        return ssoManage.getToken(reqSsoDTO);
    }

    @PostMapping ("/getUserInfo")
    public SsoUserInfoVO getUserInfo(@Valid @RequestBody ReqSsoDTO reqSsoDTO) {
        return ssoManage.getUserInfo(reqSsoDTO);
    }
}
