共享token

沃森川job同步飞书
YXY 1 year ago
parent ff8343f227
commit 5a053a3546

@ -25,5 +25,6 @@ public class RedisConstants {
* ticketkey * ticketkey
*/ */
public static final String CJT_TICKET_CACHE_KEY = "TICKET_KEY"; public static final String CJT_TICKET_CACHE_KEY = "TICKET_KEY";
public static final String CJT_TOKEN_CACHE_KEY = "OPEN_TOKEN";
} }

@ -76,6 +76,7 @@ public class EdiController extends BaseController {
String appTicket = bizContent.getString("appTicket"); String appTicket = bizContent.getString("appTicket");
if (StringUtils.isNotBlank(appTicket)) { if (StringUtils.isNotBlank(appTicket)) {
redisCache.setCacheObject(RedisConstants.CJT_TICKET_CACHE_KEY,appTicket,10, TimeUnit.MINUTES); redisCache.setCacheObject(RedisConstants.CJT_TICKET_CACHE_KEY,appTicket,10, TimeUnit.MINUTES);
redisCache.deleteObject(CJT_TOKEN_CACHE_KEY);
} }
}catch (Exception e){ }catch (Exception e){
log.error("receiveWscTicket error request:{}",JSONObject.toJSONString(request),e); log.error("receiveWscTicket error request:{}",JSONObject.toJSONString(request),e);

@ -27,6 +27,7 @@ import org.springframework.util.StringUtils;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.*; import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.ruoyi.quartz.helper.OkHttpHelper.post; import static com.ruoyi.quartz.helper.OkHttpHelper.post;
@ -325,6 +326,8 @@ public abstract class SyncAccountsJobAbstract {
* token * token
*/ */
private void generateToken(CJTJobContext context) { private void generateToken(CJTJobContext context) {
String openToken = (String) redisCache.getCacheObject(RedisConstants.CJT_TOKEN_CACHE_KEY);
if (StringUtils.isEmpty(RedisConstants.CJT_TOKEN_CACHE_KEY)){
CJTRequest cjtRequest = new CJTRequest(REQUEST_GENERATE_TOKEN_PATH CJTRequest cjtRequest = new CJTRequest(REQUEST_GENERATE_TOKEN_PATH
, context.getAppKey() , context.getAppKey()
, context.getAppSecret() , context.getAppSecret()
@ -335,6 +338,8 @@ public abstract class SyncAccountsJobAbstract {
JSONObject value = body.getJSONObject("value"); JSONObject value = body.getJSONObject("value");
String token = value.getString("accessToken"); String token = value.getString("accessToken");
context.setOpenToken(token); context.setOpenToken(token);
redisCache.setCacheObject(RedisConstants.CJT_TOKEN_CACHE_KEY,token,10, TimeUnit.MINUTES);
}
} }
/** /**

Loading…
Cancel
Save