2021-11-23 11:24:23 +08:00
|
|
|
package net.geedge.handler;
|
2021-05-08 19:33:06 +08:00
|
|
|
|
2022-09-28 18:16:06 +08:00
|
|
|
import cn.hutool.log.Log;
|
|
|
|
|
import net.geedge.dao.SqlDao;
|
2021-05-08 19:33:06 +08:00
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.boot.CommandLineRunner;
|
|
|
|
|
import org.springframework.core.annotation.Order;
|
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
2022-09-28 18:16:06 +08:00
|
|
|
import java.util.List;
|
2021-05-08 19:33:06 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 此类用于数据同步完成后 清除无用表
|
|
|
|
|
* @author admin
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
@Component
|
|
|
|
|
@Order(3)
|
|
|
|
|
public class AfterHandler implements CommandLineRunner {
|
|
|
|
|
|
|
|
|
|
private Log log = Log.get();
|
|
|
|
|
|
|
|
|
|
@Autowired
|
2022-09-28 18:16:06 +08:00
|
|
|
private SqlDao sqlDao;
|
|
|
|
|
|
2021-05-08 19:33:06 +08:00
|
|
|
@Override
|
|
|
|
|
public void run(String... args) throws Exception {
|
2021-05-12 15:56:47 +08:00
|
|
|
|
2022-09-28 18:16:06 +08:00
|
|
|
String dropColumnSql = "ALTER TABLE `monitor_module` DROP COLUMN `type`;"
|
|
|
|
|
+ "ALTER TABLE `monitor_endpoint` DROP COLUMN `configs`;"
|
|
|
|
|
+ "ALTER TABLE `monitor_endpoint` DROP COLUMN `hash`;"
|
|
|
|
|
+ "ALTER TABLE `monitor_endpoint` DROP COLUMN `enabled`;";
|
|
|
|
|
sqlDao.execute(dropColumnSql);
|
2021-11-23 11:10:28 +08:00
|
|
|
log.info("remove column successful");
|
2022-09-28 18:16:06 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
List<String> sqls = sqlDao.allRemoveCopyTables();
|
|
|
|
|
for (String sql : sqls) {
|
|
|
|
|
sb.append(sql);
|
|
|
|
|
}
|
|
|
|
|
sqlDao.execute(sb.toString());
|
2021-11-23 11:10:28 +08:00
|
|
|
log.info("remove table successful");
|
2021-05-08 19:33:06 +08:00
|
|
|
log.info("-----------------transfer data success-----------------------");
|
2022-09-28 18:16:06 +08:00
|
|
|
|
2021-05-08 19:33:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|