新增数据迁移模块

pull/22/head
rays 2021-07-07 17:54:08 +08:00
parent 374ae979a5
commit 9b34342509
21 changed files with 951 additions and 0 deletions

View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>cn.stylefeng.roses</groupId>
<artifactId>kernel-s-message</artifactId>
<version>7.0.4</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>migration-api</artifactId>
<packaging>jar</packaging>
<dependencies>
<!--auth模块的api-->
<!--记录日志时候有可能需要记录当前登录用户id-->
<!--如果不要记录当前登录用户id时就不用本模块所以optional=true-->
<dependency>
<groupId>cn.stylefeng.roses</groupId>
<artifactId>auth-api</artifactId>
<version>${roses.version}</version>
<optional>true</optional>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,54 @@
package cn.stylefeng.roses.kernel.migration.api;
import cn.stylefeng.roses.kernel.migration.api.enums.MigrationAggregationTypeEnum;
import cn.stylefeng.roses.kernel.migration.api.pojo.MigrationInfo;
/**
* Api
* <p>
* 1.
*
* @author majianguo
* @date 2021/7/6 15:17
*/
public interface AccessMigrationApi {
/**
*
*
* @return {@link java.lang.String}
* @author majianguo
* @date 2021/7/6 17:15
**/
String getAppName();
/**
*
*
* @return {@link java.lang.String}
* @author majianguo
* @date 2021/7/6 17:15
**/
String getModuleName();
/**
*
*
* @return {@link MigrationInfo}
* @author majianguo
* @date 2021/7/6 15:20
**/
MigrationInfo exportData();
/**
*
*
* @param type -{@link MigrationAggregationTypeEnum}
* @param data
* @return {@link boolean}
* @author majianguo
* @date 2021/7/6 15:23
**/
boolean importData(String type, MigrationInfo data);
}

View File

@ -0,0 +1,50 @@
/*
* Copyright [2020-2030] [https://www.stylefeng.cn]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* GunsAPACHE LICENSE 2.0使
*
* 1.LICENSE
* 2.Guns
* 3.
* 4. https://gitee.com/stylefeng/guns
* 5. https://gitee.com/stylefeng/guns
* 6.
*/
package cn.stylefeng.roses.kernel.migration.api.constants;
/**
* migration
*
* @author majianguo
* @date 2021/7/6 15:04
*/
public interface MigrationConstants {
/**
* migration
*/
String MIGRATION_MODULE_NAME = "kernel-d-migration";
/**
*
*/
String MIGRATION_EXCEPTION_STEP_CODE = "32";
/**
*
*/
String NAME_SEPARATOR = "#";
}

View File

@ -0,0 +1,32 @@
package cn.stylefeng.roses.kernel.migration.api.enums;
import lombok.Getter;
/**
*
*
* @author majianguo
* @date 2021/7/6 16:25
*/
@Getter
public enum MigrationAggregationTypeEnum {
/**
*
*/
MIGRATION_FULL("FULL", "全量迁移"),
/**
*
*/
MIGRATION_INCREMENTAL("INCREMENTAL", "增量迁移");
private final String code;
private final String name;
MigrationAggregationTypeEnum(String code, String name) {
this.code = code;
this.name = name;
}
}

View File

@ -0,0 +1,47 @@
/*
* Copyright [2020-2030] [https://www.stylefeng.cn]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* GunsAPACHE LICENSE 2.0使
*
* 1.LICENSE
* 2.Guns
* 3.
* 4. https://gitee.com/stylefeng/guns
* 5. https://gitee.com/stylefeng/guns
* 6.
*/
package cn.stylefeng.roses.kernel.migration.api.exception;
import cn.stylefeng.roses.kernel.migration.api.constants.MigrationConstants;
import cn.stylefeng.roses.kernel.rule.exception.AbstractExceptionEnum;
import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException;
/**
* migration
*
* @author majianguo
* @date 2021/7/6 15:07
*/
public class MigrationException extends ServiceException {
public MigrationException(AbstractExceptionEnum exception) {
super(MigrationConstants.MIGRATION_MODULE_NAME, exception);
}
public MigrationException(String errorCode, String userTip) {
super(MigrationConstants.MIGRATION_MODULE_NAME, errorCode, userTip);
}
}

View File

@ -0,0 +1,61 @@
/*
* Copyright [2020-2030] [https://www.stylefeng.cn]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* GunsAPACHE LICENSE 2.0使
*
* 1.LICENSE
* 2.Guns
* 3.
* 4. https://gitee.com/stylefeng/guns
* 5. https://gitee.com/stylefeng/guns
* 6.
*/
package cn.stylefeng.roses.kernel.migration.api.exception.enums;
import cn.stylefeng.roses.kernel.migration.api.constants.MigrationConstants;
import cn.stylefeng.roses.kernel.rule.constants.RuleConstants;
import cn.stylefeng.roses.kernel.rule.exception.AbstractExceptionEnum;
import lombok.Getter;
/**
* Migration
*
* @author majianguo
* @date 2021/7/6 15:09
*/
@Getter
public enum MigrationExceptionEnum implements AbstractExceptionEnum {
/**
* Migration
*/
MIGRATION_ERROR(RuleConstants.THIRD_ERROR_TYPE_CODE + MigrationConstants.MIGRATION_EXCEPTION_STEP_CODE + "01", "操作异常,具体信息为:{}");
/**
*
*/
private final String errorCode;
/**
*
*/
private final String userTip;
MigrationExceptionEnum(String errorCode, String userTip) {
this.errorCode = errorCode;
this.userTip = userTip;
}
}

View File

@ -0,0 +1,35 @@
/*
* Copyright [2020-2030] [https://www.stylefeng.cn]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* GunsAPACHE LICENSE 2.0使
*
* 1.LICENSE
* 2.Guns
* 3.
* 4. https://gitee.com/stylefeng/guns
* 5. https://gitee.com/stylefeng/guns
* 6.
*/
package cn.stylefeng.roses.kernel.migration.api.expander;
/**
* Migration
*
* @author majianguo
* @date 2021/7/6 15:11
*/
public class MigrationConfigExpander {
}

View File

@ -0,0 +1,45 @@
package cn.stylefeng.roses.kernel.migration.api.pojo;
import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.List;
import java.util.Map;
/**
*
*
* @author majianguo
* @date 2021/7/6 16:10
*/
@Data
public class MigrationAggregationPOJO extends BaseRequest {
/**
*
*/
@NotNull(message = "模块名称不能为空", groups = {export.class, restore.class})
private List<String> appAndModuleNameList;
/**
*
*/
@NotNull(message = "数据集不能为空", groups = {restore.class})
private Map<String, MigrationInfo> data;
/**
*
*/
public @interface export {
}
/**
*
*/
public @interface restore {
}
}

View File

@ -0,0 +1,24 @@
package cn.stylefeng.roses.kernel.migration.api.pojo;
import lombok.Data;
/**
*
*
* @author majianguo
* @date 2021/7/6 16:30
*/
@Data
public class MigrationInfo {
/**
*
*/
private String version;
/**
*
*/
private Object data;
}

View File

@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>cn.stylefeng.roses</groupId>
<artifactId>kernel-s-message</artifactId>
<version>7.0.4</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>migration-business-web</artifactId>
<packaging>jar</packaging>
<dependencies>
<!--资源api模块-->
<!--用在资源控制器,资源扫描上-->
<dependency>
<groupId>cn.stylefeng.roses</groupId>
<artifactId>scanner-api</artifactId>
<version>${roses.version}</version>
</dependency>
<!--参数校验模块-->
<!--用在控制器,参数校验-->
<dependency>
<groupId>cn.stylefeng.roses</groupId>
<artifactId>validator-api</artifactId>
<version>${roses.version}</version>
</dependency>
<!--数据库sdk-->
<!--数据库初始化-->
<dependency>
<groupId>cn.stylefeng.roses</groupId>
<artifactId>db-sdk-init</artifactId>
<version>${roses.version}</version>
</dependency>
<!--数据库sdk-->
<!--数据库dao框架-->
<dependency>
<groupId>cn.stylefeng.roses</groupId>
<artifactId>db-sdk-mp</artifactId>
<version>${roses.version}</version>
</dependency>
<!--数据迁移sdk-->
<dependency>
<groupId>cn.stylefeng.roses</groupId>
<artifactId>migration-sdk-data-aggregation</artifactId>
<version>${roses.version}</version>
</dependency>
<!--web模块-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,84 @@
package cn.stylefeng.roses.kernel.migration.web.controller;
import cn.stylefeng.roses.kernel.migration.aggregation.scheduling.SchedulingCenter;
import cn.stylefeng.roses.kernel.migration.api.pojo.MigrationAggregationPOJO;
import cn.stylefeng.roses.kernel.migration.web.pojo.MigrationRequest;
import cn.stylefeng.roses.kernel.migration.web.service.MigrationService;
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.List;
/**
*
*
* @author majianguo
* @date 2021/7/6 17:35
*/
@RestController
@ApiResource(name = "数据迁移控制器")
public class MigrationController {
@Autowired
private MigrationService migrationService;
/**
*
*
* @return {@link ResponseData}
* @author majianguo
* @date 2021/7/6 17:37
**/
@GetResource(name = "获取所有可备份数据列表", path = "/dataMigration/getAllMigrationList")
public ResponseData getAllMigrationList() {
List<MigrationRequest> migrationRequestList = migrationService.getAllMigrationList();
return new SuccessResponseData(migrationRequestList);
}
/**
*
*
* @return {@link cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData}
* @author majianguo
* @date 2021/7/7 11:11
**/
@GetResource(name = "备份指定数据列表", path = "/dataMigration/migrationSelectData")
public ResponseData migrationSelectData(@Validated(MigrationAggregationPOJO.export.class) MigrationAggregationPOJO migrationAggregationPOJO) {
List<String> res = new ArrayList<>();
for (String s : migrationAggregationPOJO.getAppAndModuleNameList()) {
try {
String decode = URLDecoder.decode(s, "UTF-8");
res.add(decode);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
migrationAggregationPOJO.setAppAndModuleNameList(res);
String migrationSelectDataStr = migrationService.migrationSelectData(migrationAggregationPOJO);
return new SuccessResponseData(migrationSelectDataStr);
}
/**
*
*
* @return {@link ResponseData}
* @author majianguo
* @date 2021/7/7 11:11
**/
@PostResource(name = "恢复备份数据", path = "/dataMigration/restoreData")
public ResponseData restoreData(@RequestPart("file") MultipartFile file,String type) {
migrationService.restoreData(file,type);
return new SuccessResponseData();
}
}

View File

@ -0,0 +1,26 @@
package cn.stylefeng.roses.kernel.migration.web.pojo;
import lombok.Data;
import java.util.List;
/**
*
*
* @author majianguo
* @date 2021/7/7 9:15
*/
@Data
public class MigrationRequest {
/**
*
*/
private String appName;
/**
*
*/
private List<String> moduleNames;
}

View File

@ -0,0 +1,41 @@
package cn.stylefeng.roses.kernel.migration.web.service;
import cn.stylefeng.roses.kernel.migration.api.pojo.MigrationAggregationPOJO;
import cn.stylefeng.roses.kernel.migration.web.pojo.MigrationRequest;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
/**
*
*
* @author majianguo
* @date 2021/7/7 9:34
*/
public interface MigrationService {
/**
*
*
* @return {@link List< MigrationRequest>}
* @author majianguo
* @date 2021/7/7 9:36
**/
List<MigrationRequest> getAllMigrationList();
/**
*
*
* @author majianguo
* @date 2021/7/7 9:37
**/
String migrationSelectData(MigrationAggregationPOJO migrationAggregationPOJO);
/**
*
*
* @author majianguo
* @date 2021/7/7 11:14
**/
void restoreData(MultipartFile file,String type);
}

View File

@ -0,0 +1,99 @@
package cn.stylefeng.roses.kernel.migration.web.service.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.URLUtil;
import cn.stylefeng.roses.kernel.migration.aggregation.scheduling.SchedulingCenter;
import cn.stylefeng.roses.kernel.migration.api.constants.MigrationConstants;
import cn.stylefeng.roses.kernel.migration.api.pojo.MigrationAggregationPOJO;
import cn.stylefeng.roses.kernel.migration.web.pojo.MigrationRequest;
import cn.stylefeng.roses.kernel.migration.web.service.MigrationService;
import cn.stylefeng.roses.kernel.rule.util.HttpServletUtil;
import com.alibaba.fastjson.JSON;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
*
*
* @author majianguo
* @date 2021/7/7 9:34
*/
@Service
public class MigrationServiceImpl implements MigrationService {
@Override
public List<MigrationRequest> getAllMigrationList() {
// 结构:应用-模块列表
Map<String, MigrationRequest> migrationRequestList = new HashMap<>();
// 获取所有应用和模块的名称列表
List<String> allMigrationInfo = SchedulingCenter.getAllMigrationInfo();
// 应用,模块映射关系
for (String migration : allMigrationInfo) {
// 分割应用名称和模块名称
String[] appAndModuleName = migration.split(MigrationConstants.NAME_SEPARATOR);
// 获取应用名称
String appName = appAndModuleName[0];
// 获取模块名称
String moduleName = appAndModuleName[1];
// 查找该应用
MigrationRequest migrationRequest = migrationRequestList.get(appName);
if (ObjectUtil.isEmpty(migrationRequest)) {
migrationRequest = new MigrationRequest();
migrationRequest.setAppName(appName);
migrationRequestList.put(appName, migrationRequest);
}
// 该应用是否有模块
List<String> moduleNames = migrationRequest.getModuleNames();
if (ObjectUtil.isEmpty(moduleNames)) {
moduleNames = new ArrayList<>();
migrationRequest.setModuleNames(moduleNames);
}
moduleNames.add(moduleName);
}
return new ArrayList<>(migrationRequestList.values());
}
@Override
public String migrationSelectData(MigrationAggregationPOJO migrationAggregationPOJO) {
// 执行导出逻辑
SchedulingCenter.exportData(migrationAggregationPOJO);
// 转换为Json字符串
return JSON.toJSONString(migrationAggregationPOJO);
}
@Override
public void restoreData(MultipartFile file,String type) {
String jsonStr = null;
try {
// 转换文件为String类型
jsonStr = new String(file.getBytes(), StandardCharsets.UTF_8);
// 把字符串转为java对象
MigrationAggregationPOJO migrationAggregationPOJO = JSON.parseObject(jsonStr, MigrationAggregationPOJO.class);
// 交给调度中心去调度
SchedulingCenter.importData(migrationAggregationPOJO,type);
} catch (IOException e) {
e.printStackTrace();
}
}
}

View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>cn.stylefeng.roses</groupId>
<artifactId>kernel-s-message</artifactId>
<version>7.0.4</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>migration-sdk-data-aggregation</artifactId>
<packaging>jar</packaging>
<dependencies>
<!--migration模块的api-->
<dependency>
<groupId>cn.stylefeng.roses</groupId>
<artifactId>migration-api</artifactId>
<version>${roses.version}</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,122 @@
package cn.stylefeng.roses.kernel.migration.aggregation.scheduling;
import cn.hutool.core.util.ObjectUtil;
import cn.stylefeng.roses.kernel.migration.api.AccessMigrationApi;
import cn.stylefeng.roses.kernel.migration.api.constants.MigrationConstants;
import cn.stylefeng.roses.kernel.migration.api.pojo.MigrationAggregationPOJO;
import cn.stylefeng.roses.kernel.migration.api.pojo.MigrationInfo;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
*
*
* @author majianguo
* @date 2021/7/6 16:01
*/
public class SchedulingCenter {
/**
*
*/
private static final ConcurrentHashMap<String, AccessMigrationApi> migrationCollection = new ConcurrentHashMap<>();
/**
*
*
* @param accessMigrationApi
* @author majianguo
* @date 2021/7/6 17:21
**/
public static void addMigration(AccessMigrationApi accessMigrationApi) {
// 拼接key值
String appAndModuleNameItem = accessMigrationApi.getAppName() + MigrationConstants.NAME_SEPARATOR + accessMigrationApi.getModuleName();
// 存储迁移类
migrationCollection.put(appAndModuleNameItem, accessMigrationApi);
}
/**
*
*
* @param migrationAggregationPOJO
* @author majianguo
* @date 2021/7/6 16:10
**/
public static void importData(MigrationAggregationPOJO migrationAggregationPOJO, String type) {
// 所有导入数据集合
Map<String, MigrationInfo> migrationInfoMap = migrationAggregationPOJO.getData();
// 找到每个应用的处理程序,调用相关方法
for (String appAndModuleName : migrationAggregationPOJO.getAppAndModuleNameList()) {
AccessMigrationApi accessMigrationApi = migrationCollection.get(appAndModuleName);
if (ObjectUtil.isNotEmpty(accessMigrationApi)) {
// 找到数据
MigrationInfo migrationInfo = migrationInfoMap.get(appAndModuleName);
// 发送给实现类处理
try {
accessMigrationApi.importData(type, migrationInfo);
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
/**
*
*
* @param migrationAggregationPOJO
* @return {@link MigrationAggregationPOJO}
* @author majianguo
* @date 2021/7/6 16:11
**/
public static MigrationAggregationPOJO exportData(MigrationAggregationPOJO migrationAggregationPOJO) {
Map<String, MigrationInfo> data = migrationAggregationPOJO.getData();
if (ObjectUtil.isEmpty(data)) {
data = new HashMap<>();
migrationAggregationPOJO.setData(data);
}
// 导出所有指定项
for (String appAndModuleName : migrationAggregationPOJO.getAppAndModuleNameList()) {
// 查找对应的实现类
AccessMigrationApi accessMigrationApi = migrationCollection.get(appAndModuleName);
if (ObjectUtil.isNotEmpty(accessMigrationApi)) {
// 执行导出
try {
// 获取数据
MigrationInfo migrationInfo = accessMigrationApi.exportData();
// 放入返回结果中
data.put(appAndModuleName, migrationInfo);
} catch (Exception e) {
e.printStackTrace();
}
} else {
data.put(appAndModuleName, new MigrationInfo());
}
}
return migrationAggregationPOJO;
}
/**
*
*
* @return {@link java.util.List<MigrationInfo>}
* @author majianguo
* @date 2021/7/6 16:13
**/
public static List<String> getAllMigrationInfo() {
return new ArrayList<>(migrationCollection.keySet());
}
}

View File

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>cn.stylefeng.roses</groupId>
<artifactId>kernel-s-message</artifactId>
<version>7.0.4</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>migration-spring-boot-starter</artifactId>
<packaging>jar</packaging>
<dependencies>
<!--migration模块的SDK-->
<dependency>
<groupId>cn.stylefeng.roses</groupId>
<artifactId>migration-sdk-data-aggregation</artifactId>
<version>${roses.version}</version>
</dependency>
<!--migration模块的业务-->
<dependency>
<groupId>cn.stylefeng.roses</groupId>
<artifactId>migration-business-web</artifactId>
<version>${roses.version}</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,33 @@
package cn.stylefeng.roses.kernel.migration.starter.spring;
import cn.hutool.extra.spring.SpringUtil;
import cn.stylefeng.roses.kernel.migration.aggregation.scheduling.SchedulingCenter;
import cn.stylefeng.roses.kernel.migration.api.AccessMigrationApi;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;
import java.util.Map;
/**
* Spring boot
* <p>
*
*
* @author majianguo
* @date 2021/7/7 9:49
*/
@Component
public class MigrationApplicationRunnerImpl implements ApplicationRunner {
@Override
public void run(ApplicationArguments args) throws Exception {
// 获取所有的实现类
Map<String, AccessMigrationApi> accessMigrationApiMap = SpringUtil.getBeansOfType(AccessMigrationApi.class);
for (AccessMigrationApi accessMigrationApi : accessMigrationApiMap.values()) {
// 加入调度中心
SchedulingCenter.addMigration(accessMigrationApi);
}
}
}

View File

@ -0,0 +1 @@
org.springframework.boot.autoconfigure.EnableAutoConfiguration=

View File

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>cn.stylefeng.roses</groupId>
<artifactId>roses-kernel</artifactId>
<version>7.0.4</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>kernel-s-migration</artifactId>
<packaging>pom</packaging>
<modules>
<module>migration-api</module>
<module>migration-sdk-data-aggregation</module>
<module>migration-business-web</module>
<module>migration-spring-boot-starter</module>
</modules>
<dependencies>
<!-- 开发规则 -->
<dependency>
<groupId>cn.stylefeng.roses</groupId>
<artifactId>kernel-a-rule</artifactId>
<version>${roses.version}</version>
</dependency>
</dependencies>
</project>

View File

@ -109,6 +109,9 @@
<!-- Socket模块 -->
<module>kernel-d-socket</module>
<!-- 数据迁移模块 -->
<module>kernel-s-migration</module>
</modules>
<properties>