保存表事务提交
This commit is contained in:
parent
83f027d1dd
commit
e929c61f3b
|
|
@ -71,15 +71,7 @@ public class StasSyncStrategyController extends JeecgController<StasSyncStrategy
|
|||
@Operation(summary="同步策略表-在目标库创建表结构")
|
||||
@PostMapping(value = "/createTargetTables")
|
||||
public Result<String> createTargetTables(@RequestBody List<StasSyncStrategy> stasSyncStrategys) {
|
||||
if(null != stasSyncStrategys && stasSyncStrategys.size() > 0) {
|
||||
String taskId = stasSyncStrategys.get(0).getTaskId();
|
||||
stasSyncStrategyService.remove(new LambdaQueryWrapper<StasSyncStrategy>().eq(StasSyncStrategy::getTaskId, taskId));
|
||||
for (StasSyncStrategy stasSyncStrategy : stasSyncStrategys) {
|
||||
if(stasSyncStrategyService.validateTables(stasSyncStrategy)){
|
||||
stasSyncStrategyService.createTargetTables(stasSyncStrategy);
|
||||
}
|
||||
}
|
||||
}
|
||||
stasSyncStrategyService.createTargetTables(stasSyncStrategys);
|
||||
return Result.OK("添加成功!");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import org.jeecg.modules.base.entity.StasSyncStrategy;
|
|||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 同步策略表
|
||||
|
|
@ -23,8 +24,8 @@ public interface IStasSyncStrategyService extends IService<StasSyncStrategy> {
|
|||
|
||||
/**
|
||||
* 在目标库创建表结构
|
||||
* @param stasSyncStrategy 同步策略信息
|
||||
* @param stasSyncStrategys 同步策略信息
|
||||
* @throws SQLException 数据库异常
|
||||
*/
|
||||
void createTargetTables(StasSyncStrategy stasSyncStrategy);
|
||||
void createTargetTables(List<StasSyncStrategy> stasSyncStrategys);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package org.jeecg.stasSyncStrategy.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.jeecg.common.constant.enums.SourceDataTypeEnum;
|
||||
import org.jeecg.common.exception.JeecgBootException;
|
||||
|
|
@ -32,6 +33,7 @@ public class StasSyncStrategyServiceImpl extends ServiceImpl<StasSyncStrategyMap
|
|||
|
||||
private final StasTaskConfigMapper stasTaskConfigMapper;
|
||||
private final StasDataSourceMapper stasDataSourceMapper;
|
||||
private final StasSyncStrategyMapper stasSyncStrategyService;
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -67,12 +69,16 @@ public class StasSyncStrategyServiceImpl extends ServiceImpl<StasSyncStrategyMap
|
|||
|
||||
/**
|
||||
* 在目标库创建表结构
|
||||
* @param stasSyncStrategy 同步策略信息
|
||||
* @param stasSyncStrategys 同步策略信息
|
||||
* @throws SQLException 数据库异常
|
||||
*/
|
||||
@Transactional
|
||||
@Override
|
||||
public void createTargetTables(StasSyncStrategy stasSyncStrategy) {
|
||||
public void createTargetTables(List<StasSyncStrategy> stasSyncStrategys) {
|
||||
if(null != stasSyncStrategys && stasSyncStrategys.size() > 0) {
|
||||
String taskId = stasSyncStrategys.get(0).getTaskId();
|
||||
stasSyncStrategyService.delete(new LambdaQueryWrapper<StasSyncStrategy>().eq(StasSyncStrategy::getTaskId, taskId));
|
||||
for (StasSyncStrategy stasSyncStrategy : stasSyncStrategys) {
|
||||
StasTaskConfig stasTaskConfig = stasTaskConfigMapper.selectById(stasSyncStrategy.getTaskId());
|
||||
StasDataSource sourceInfo = stasDataSourceMapper.selectById(stasTaskConfig.getSourceId());
|
||||
StasDataSource targetInfo = stasDataSourceMapper.selectById(stasTaskConfig.getTargetId());
|
||||
|
|
@ -116,6 +122,8 @@ public class StasSyncStrategyServiceImpl extends ServiceImpl<StasSyncStrategyMap
|
|||
throw new JeecgBootException(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取创建表的SQL语句
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user