package com.kidgrow.oauth2.service.impl;
import cn.hutool.core.util.PageUtil;
import cn.hutool.core.util.StrUtil;
import com.kidgrow.common.constant.SecurityConstants;
import com.kidgrow.common.model.PageResult;
import com.kidgrow.common.model.ResultBody;
import com.kidgrow.common.utils.StringUtils;
import com.kidgrow.redis.template.RedisRepository;
import com.kidgrow.oauth2.model.TokenVo;
import com.kidgrow.oauth2.service.ITokensService;
import com.kidgrow.redis.util.RedisUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.MapUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.oauth2.common.DefaultOAuth2AccessToken;
import org.springframework.security.oauth2.provider.OAuth2Authentication;
import org.springframework.security.oauth2.provider.OAuth2Request;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* 石家庄喜高科技有限责任公司 版权所有 © Copyright 2020
*
* @Description: token管理服务(redis token)
* @Project:
* @CreateDate: Created in 2020/2/20 09:19
* @Author: liuke
*/
@Slf4j
@Service
public class RedisTokensServiceImpl implements ITokensService {
@Autowired
private RedisRepository redisRepository;
@Autowired
private RedisUtils redisUtils;
@Override
public PageResult listTokens(Map params, String clientId) {
Integer page = MapUtils.getInteger(params, "page");
Integer limit = MapUtils.getInteger(params, "limit");
int[] startEnds = PageUtil.transToStartEnd(page, limit);
//根据请求参数生成redis的key
String redisKey = getRedisKey(params, clientId);
long size = redisRepository.length(redisKey);
List result = new ArrayList<>(limit);
//查询token集合
List