package com.sonic.frog.controller.openapi;

import com.sonic.bear.lib.client.UserSessionClient;
import com.sonic.common.auth.domains.Session;
import com.sonic.common.rpc.Result;
import com.sonic.frog.domain.input.TokenCheckInput;
import com.sonic.sdk.api.annotation.IgnoreAuth;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * Web-Dict管理
 *
 * @author code
 */
@RestController
@Slf4j
public class OpenApiWeb {

    @Autowired
    private UserSessionClient userSessionClient;

    @IgnoreAuth
    @ApiOperation(value = "用户token认证", tags = {"OpenApi接口"})
    @PostMapping("/web/auth/token-check")
    public Result<Session> authTokenCheck(@RequestBody TokenCheckInput input) {
        Session session = userSessionClient.touchSession(input.getToken());
        return Result.success(session);
    }

}
