@author Hellohao @version 1.0 @date 2019/11/29 14:32
| 19 | * @date 2019/11/29 14:32 |
| 20 | */ |
| 21 | @Configuration |
| 22 | public class FirstRun implements InitializingBean { |
| 23 | private static Logger logger = LoggerFactory.getLogger(FirstRun.class); |
| 24 | @Value("${spring.datasource.username}") |
| 25 | private String jdbcusername; |
| 26 | |
| 27 | @Value("${spring.datasource.password}") |
| 28 | private String jdbcpass; |
| 29 | |
| 30 | @Value("${spring.datasource.url}") |
| 31 | private String jdbcurl; |
| 32 | |
| 33 | @Value("${DockerWebHost}") |
| 34 | private String DockerWebHost; |
| 35 | |
| 36 | |
| 37 | @Override |
| 38 | public void afterPropertiesSet() { |
| 39 | if(!DockerWebHost.contains("null")){ |
| 40 | contentToTxt("/hellohaotbed/webapps/hellohao/config.json", "{\"serverHost\": \""+DockerWebHost+"\"}"); |
| 41 | } |
| 42 | isWindows(); |
| 43 | RunSqlScript.USERNAME = jdbcusername; |
| 44 | RunSqlScript.PASSWORD = jdbcpass; |
| 45 | RunSqlScript.DBURL = jdbcurl; |
| 46 | logger.info("正在校验数据库参数..."); |
| 47 | RunSqlScript.RunInsert(dynamic); |
| 48 | RunSqlScript.RunInsert(compressed); |
| 49 | |
| 50 | String uid = UUID.randomUUID().toString().replace("-", "").toLowerCase(); |
| 51 | RunSqlScript.RunInsert("update user set uid='"+uid+"' where id = 1"); |
| 52 | |
| 53 | Integer ret0 = |
| 54 | RunSqlScript.RunSelectCount(judgeTable + "'keys' and column_name = 'Region'"); |
| 55 | if (ret0 == 0) { |
| 56 | RunSqlScript.RunInsert(sql0); |
| 57 | Print.Normal("Add keys.Region||RootPath"); |
| 58 | } |
| 59 | |
| 60 | Integer ret1 = RunSqlScript.RunSelectCount(sql1); |
| 61 | if(ret1==0){ |
| 62 | Print.Normal("In execution..."); |
| 63 | RunSqlScript.RunInsert(sql2); |
| 64 | }else{ |
| 65 | if(ret1>0){ |
| 66 | Print.Normal("Stage 1"); |
| 67 | }else{ |
| 68 | Print.Normal("Mysql 报了一个错"); |
| 69 | } |
| 70 | } |
| 71 | Integer imgandalbum = RunSqlScript.RunSelectCount(judgeTable+"'imgandalbum'"); |
| 72 | if(imgandalbum==0){ |
| 73 | RunSqlScript.RunInsert(sql3); |
| 74 | Print.Normal("Stage 2"); |
| 75 | } |
| 76 | Integer album = RunSqlScript.RunSelectCount(judgeTable+"'album'"); |
| 77 | if(album==0){ |
| 78 | RunSqlScript.RunInsert(sql4); |
nothing calls this directly
no outgoing calls
no test coverage detected