添加初始化计时器

This commit is contained in:
2024-04-27 10:38:34 +08:00
parent 89aeabdb67
commit 05475484c7

View File

@@ -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());
}
}
}