yangys
2024-04-04 ed4a5236bab800094be4a8378f5098eebe3de6ac
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package com.qianwen.smartman.modules.system.runner;
 
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.qianwen.core.launch.utils.PropsUtil;
import com.qianwen.smartman.modules.cps.mapper.InitMapper;
import com.qianwen.smartman.modules.cps.service.IInitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
 
@Component
/* loaded from: blade-api.jar:BOOT-INF/classes/org/springblade/modules/system/runner/SystemApplicationInitRunner.class */
public class SystemApplicationInitRunner implements ApplicationRunner {
    private static final Logger log = LoggerFactory.getLogger(SystemApplicationInitRunner.class);
    @Autowired
    private IInitService initService;
    @Autowired
    private InitMapper initMapper;
    @Autowired
    private Environment environment;
 
    public void run(ApplicationArguments args) throws Exception {
        PropsUtil.setProperty(System.getProperties(), "blade.system.need_init", this.initService.checkIsNeedInit().toString());
        try {
            String apiUrl = "http://127.0.0.1:" + this.environment.getProperty("local.server.port");
            if (!checkRunInIDEA()) {
                this.initMapper.initBladeReport(apiUrl);
                log.info("替换报表api地址成功,替换为:{}", apiUrl);
            }
        } catch (Exception e) {
            log.error("---替换api地址异常,若未初始化则初始化后会重新自动替换---");
        }
    }
 
    private static boolean checkRunInIDEA() {
        try {
            Class.forName("com.intellij.rt.execution.application.AppMainV2");
            return Boolean.TRUE.booleanValue();
        } catch (ClassNotFoundException e) {
            return Boolean.FALSE.booleanValue();
        }
    }
}