@@ -300,29 +300,33 @@ public void initRefreshThread() {
300300 */
301301 @ Override
302302 public void init () {
303- DateTime now = DateUtil .date ();
304303 List <SysToken > sysTokens = tokenMapper .selectList (new LambdaQueryWrapper <>());
305304 for (SysToken sysToken : sysTokens ) {
306- Integer userId = sysToken .getUserId ();
307- dataMap .put (stpLogic .splicingKeyTokenValue (sysToken .getTokenValue ()), userId .toString ());
308- dataMap .put (stpLogic .splicingKeyLastActiveTime (sysToken .getTokenValue ()), StrUtil .toString (now .getTime ()));
309- UserDTO userInfo = new UserDTO ();
310- User user = new User ();
311- user .setId (userId );
312- userInfo .setUser (user );
313- userInfo .setTenantList (Collections .singletonList (tenantMapper .selectById (sysToken .getTenantId ())));
314- UserInfoContextHolder .set (userId , userInfo );
315- if (sysToken .getExpireType () == 1 ) {
316- expireMap .put (stpLogic .splicingKeyTokenValue (sysToken .getTokenValue ()), NEVER_EXPIRE );
317- } else {
318- expireMap .put (
319- stpLogic .splicingKeyTokenValue (sysToken .getTokenValue ()),
320- sysToken .getExpireEndTime ().getTime ());
321- }
305+ injectToken (sysToken );
322306 }
323307 initRefreshThread ();
324308 }
325309
310+ public void injectToken (SysToken sysToken ) {
311+ DateTime now = DateUtil .date ();
312+ Integer userId = sysToken .getUserId ();
313+ dataMap .put (stpLogic .splicingKeyTokenValue (sysToken .getTokenValue ()), userId .toString ());
314+ dataMap .put (stpLogic .splicingKeyLastActiveTime (sysToken .getTokenValue ()), StrUtil .toString (now .getTime ()));
315+ UserDTO userInfo = new UserDTO ();
316+ User user = new User ();
317+ user .setId (userId );
318+ userInfo .setUser (user );
319+ userInfo .setTenantList (Collections .singletonList (tenantMapper .selectById (sysToken .getTenantId ())));
320+ UserInfoContextHolder .set (userId , userInfo );
321+ if (sysToken .getExpireType () == 1 ) {
322+ expireMap .put (stpLogic .splicingKeyTokenValue (sysToken .getTokenValue ()), NEVER_EXPIRE );
323+ } else {
324+ expireMap .put (
325+ stpLogic .splicingKeyTokenValue (sysToken .getTokenValue ()),
326+ sysToken .getExpireEndTime ().getTime ());
327+ }
328+ }
329+
326330 /**
327331 * 组件被卸载时,结束定时任务,不再定时清理过期数据
328332 */
0 commit comments