Open houyouliang opened 7 years ago
package com.hat.init;
import java.util.List;
import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.ApplicationListener; import org.springframework.context.event.ContextRefreshedEvent;
import com.hat.bean.ChannelRelInter; import com.hat.db.service.AuthService; import com.hat.db.service.RedisService;
public class ApplicationStartup implements ApplicationListener{
private Logger logger = LoggerFactory.getLogger(ApplicationStartup.class); @Override public void onApplicationEvent(ContextRefreshedEvent event) { RedisService redisService = event.getApplicationContext().getBean(RedisService.class); AuthService authService = event.getApplicationContext().getBean(AuthService.class); List<ChannelRelInter> channelRelInter = authService.findAll(); if (!channelRelInter.isEmpty()) { channelRelInter.forEach(c -> { redisService.setSet(c.getAuthToken(), c.getInerUri().getInterUrl()); }); } logger.info("共写入权限:" + channelRelInter.size()); }
}
package com.hat.init;
import java.util.List;
import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.ApplicationListener; import org.springframework.context.event.ContextRefreshedEvent;
import com.hat.bean.ChannelRelInter; import com.hat.db.service.AuthService; import com.hat.db.service.RedisService;
public class ApplicationStartup implements ApplicationListener{
}