mirror of
https://codeup.aliyun.com/64f7d6b8ce01efaafef1e678/coal/coal.git
synced 2026-01-25 07:46:40 +08:00
添加初始化计时器
This commit is contained in:
@@ -25,6 +25,7 @@ import org.springframework.security.core.context.SecurityContext;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.StopWatch;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
@@ -59,12 +60,21 @@ public class InitDataRunner implements CommandLineRunner {
|
||||
@Async
|
||||
public void run(String... args) throws Exception {
|
||||
|
||||
flyway.migrate();
|
||||
StopWatch stopWatch = new StopWatch("InitDataRunner");
|
||||
|
||||
stopWatch.start("flyway.migrate");
|
||||
flyway.migrate();
|
||||
stopWatch.stop();
|
||||
|
||||
stopWatch.start("organizationService.initOrGetAdminOrg");
|
||||
OrganizationEntity e = organizationService.initOrGetAdminOrg();
|
||||
|
||||
stopWatch.stop();
|
||||
|
||||
stopWatch.start("userService.initOrGetAdminUser");
|
||||
UserEntity u = userService.initOrGetAdminUser(e);
|
||||
|
||||
stopWatch.stop();
|
||||
SecurityContext context = SecurityContextHolder.createEmptyContext();
|
||||
|
||||
context.setAuthentication(
|
||||
@@ -74,20 +84,35 @@ public class InitDataRunner implements CommandLineRunner {
|
||||
|
||||
try {
|
||||
|
||||
stopWatch.start("sysConfigService.initDefault");
|
||||
sysConfigService.initDefault();
|
||||
|
||||
stopWatch.stop();
|
||||
|
||||
|
||||
|
||||
stopWatch.start("dictionaryService.initDefault");
|
||||
dictionaryService.initDefault();
|
||||
|
||||
stopWatch.stop();
|
||||
|
||||
|
||||
stopWatch.start("scriptService.initFromResource");
|
||||
scriptService.initFromResource();
|
||||
|
||||
passwordDictService.initDict();
|
||||
stopWatch.stop();
|
||||
|
||||
stopWatch.start("passwordDictService.initDict");
|
||||
passwordDictService.initDict();
|
||||
stopWatch.stop();
|
||||
|
||||
stopWatch.start("errorMsgService.initDefault");
|
||||
errorMsgService.initDefault();
|
||||
stopWatch.stop();
|
||||
|
||||
} finally {
|
||||
SecurityContextHolder.clearContext();
|
||||
log.info(stopWatch.prettyPrint());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user