8 changed files with 97 additions and 57 deletions
@ -1,32 +0,0 @@ |
|||
//package com.ccsens.tall_sdk.api;
|
|||
//
|
|||
//import com.ccsens.util.JsonResponse;
|
|||
//import io.swagger.annotations.Api;
|
|||
//import io.swagger.annotations.ApiImplicitParams;
|
|||
//import io.swagger.annotations.ApiOperation;
|
|||
//import lombok.extern.slf4j.Slf4j;
|
|||
//import org.springframework.web.bind.annotation.RequestMapping;
|
|||
//import org.springframework.web.bind.annotation.RequestMethod;
|
|||
//import org.springframework.web.bind.annotation.RestController;
|
|||
//
|
|||
//import javax.servlet.http.HttpServletRequest;
|
|||
//
|
|||
///**
|
|||
// * @author 逗
|
|||
// */
|
|||
//@Api(tags = "DEBUG" , description = "DebugController | ")
|
|||
//@RestController
|
|||
//@RequestMapping("/debug")
|
|||
//@Slf4j
|
|||
//public class DebugController {
|
|||
//
|
|||
// @ApiOperation(value = "/测试",notes = "")
|
|||
// @ApiImplicitParams({
|
|||
// })
|
|||
// @RequestMapping(value="",method = RequestMethod.GET,produces = {"application/json;charset=UTF-8"})
|
|||
// public JsonResponse debug(HttpServletRequest request) throws Exception {
|
|||
//
|
|||
// return JsonResponse.newInstance().ok("测试");
|
|||
// }
|
|||
//
|
|||
//}
|
@ -0,0 +1,56 @@ |
|||
package com.ccsens.tall_sdk.util; |
|||
|
|||
import com.ccsens.util.PropUtil; |
|||
import com.ccsens.util.RedisUtil; |
|||
import org.springframework.beans.factory.annotation.Value; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import javax.annotation.PostConstruct; |
|||
import javax.annotation.Resource; |
|||
|
|||
/** |
|||
* @author 逗 |
|||
*/ |
|||
@Component |
|||
public class TokenUtil { |
|||
|
|||
public static final String REDIS_IS_OPEN = "1"; |
|||
|
|||
public static String openRedis; |
|||
|
|||
@Value("${spring.application.sdk-cache-redis:}") |
|||
public void setApplication(String redis) { |
|||
openRedis = redis; |
|||
} |
|||
|
|||
@Resource |
|||
private RedisUtil redisUtil; |
|||
private static TokenUtil util; |
|||
|
|||
@PostConstruct |
|||
public void init(){ |
|||
util = this; |
|||
util.redisUtil = this.redisUtil; |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 获取accessToken |
|||
* @param appId appId |
|||
* @param secret secret |
|||
* @return 返回accessToken |
|||
*/ |
|||
public static String getAccessToken(String appId,String secret){ |
|||
//查看业务是否开启redis缓存
|
|||
if(REDIS_IS_OPEN.equals(openRedis)){ |
|||
util.redisUtil.get(appId); |
|||
} |
|||
//redis开启则通过appId去redis内查询
|
|||
//否则查找Map内是否存在
|
|||
//如果map内存在,则判断数据的时间是否到期
|
|||
//如果redis内未查到,或map内未查到,或map内时间到期,则调用tall的接口获取accessToken
|
|||
//在redis内缓存,或存在map内
|
|||
return null; |
|||
} |
|||
|
|||
} |
Loading…
Reference in new issue