
package com.tmerclub.cloud.auth.feign;

import com.tmerclub.cloud.api.auth.bo.LoginInfoBO;
import com.tmerclub.cloud.api.auth.bo.UidInfoBO;

import com.tmerclub.cloud.api.auth.dto.ThirdApiAbutmentUserDto;
import com.tmerclub.cloud.api.auth.feign.TokenFeignClient;
import com.tmerclub.cloud.auth.manager.TokenStore;
import com.tmerclub.cloud.common.security.AuthUserContext;
import jakarta.servlet.http.HttpServletRequest;
import org.apache.dubbo.config.annotation.DubboService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @author tmerclub
 * @date 2020/7/15
 */
@DubboService
public class TokenFeignController implements TokenFeignClient {

    private static final Logger logger = LoggerFactory.getLogger(TokenFeignController.class);

    @Autowired
    private TokenStore tokenStore;

    @Override
    public UidInfoBO checkToken(String accessToken) {
        UidInfoBO uidInfoBO = tokenStore.getUidInfoByAccessToken(accessToken);
        return uidInfoBO;
    }

    @Override
    public void clearToken() {
        tokenStore.deleteUserToken();
    }

    @Override
    public UidInfoBO getUidInfoInToken() {
        return tokenStore.getUidInfoInToken();
    }

    @Override
    public LoginInfoBO getLoginInfo() {
        return tokenStore.getLoginInfoByCache();
    }

    @Override
    public void userTokenSync(ThirdApiAbutmentUserDto thirdApiAbutmentUserDto) {
        tokenStore.userTokenSync(thirdApiAbutmentUserDto);
    }
}
