package com.xy.third;

import cn.dev33.satoken.stp.StpUtil;
import com.xy.dto.ThirdLoginDto;
import com.xy.redis.RedisCache;
import com.xy.service.ThirdLoginService;
import com.xy.utils.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

@Service
@AllArgsConstructor
@Api(tags = "第三方登录")
public class ThirdLoginServiceImpl implements ThirdLoginService {

    @Override
    @ApiOperation("登录")
    public R<String> login(ThirdLoginDto thirdLoginDto) {
        StpUtil.login(thirdLoginDto.getLoginId());
        RedisCache.workCache(thirdLoginDto.getLoginId());
        return R.ok(StpUtil.getTokenValue());
    }
}
