feat 现场变量
parent
a6b87e1c6d
commit
c03414dc1e
|
@ -40,7 +40,7 @@ public interface KvtMapper extends BaseMapper<Kvt> {
|
||||||
|
|
||||||
List<DataStructure> selectDataStructure(@Param("databaseName") String databaseName, @Param("name") String name);
|
List<DataStructure> selectDataStructure(@Param("databaseName") String databaseName, @Param("name") String name);
|
||||||
|
|
||||||
void add(DataStructure dataStructure);
|
void add(@Param("dataStructure") List<DataStructure> dataStructure);
|
||||||
|
|
||||||
|
|
||||||
List<DataStructure> selectDataStur(@Param("tableName") String tableName);
|
List<DataStructure> selectDataStur(@Param("tableName") String tableName);
|
||||||
|
|
|
@ -37,7 +37,7 @@ public interface KvtService extends IService<Kvt> {
|
||||||
|
|
||||||
List<DataStructure> selectDataStructure(@Param("databaseName") String databaseName, @Param("name") String name);
|
List<DataStructure> selectDataStructure(@Param("databaseName") String databaseName, @Param("name") String name);
|
||||||
|
|
||||||
void add(DataStructure dataStructure);
|
|
||||||
|
|
||||||
List<DataStructure> selectDataStur(String tableName);
|
List<DataStructure> selectDataStur(String tableName);
|
||||||
|
|
||||||
|
|
|
@ -208,10 +208,6 @@ public class KvtServiceImpl extends ServiceImpl<KvtMapper, Kvt> implements KvtSe
|
||||||
return baseMapper.selectDataStructure(databaseName, name);
|
return baseMapper.selectDataStructure(databaseName, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void add(DataStructure dataStructure) {
|
|
||||||
baseMapper.add(dataStructure);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<DataStructure> selectDataStur(String tableName) {
|
public List<DataStructure> selectDataStur(String tableName) {
|
||||||
|
@ -467,8 +463,7 @@ public class KvtServiceImpl extends ServiceImpl<KvtMapper, Kvt> implements KvtSe
|
||||||
preparedStatement = connection.prepareStatement(this.sql4()
|
preparedStatement = connection.prepareStatement(this.sql4()
|
||||||
+ " information_schema.columns.table_name = '" + tableName + " ' ");
|
+ " information_schema.columns.table_name = '" + tableName + " ' ");
|
||||||
}
|
}
|
||||||
|
List<DataStructure> structures = new ArrayList<>();
|
||||||
|
|
||||||
ResultSet executeQuery = preparedStatement.executeQuery();
|
ResultSet executeQuery = preparedStatement.executeQuery();
|
||||||
while (executeQuery.next()) {
|
while (executeQuery.next()) {
|
||||||
if (kvt.getType() == 1) {
|
if (kvt.getType() == 1) {
|
||||||
|
@ -515,68 +510,73 @@ public class KvtServiceImpl extends ServiceImpl<KvtMapper, Kvt> implements KvtSe
|
||||||
.type(type)
|
.type(type)
|
||||||
.mappingType(mappingType)
|
.mappingType(mappingType)
|
||||||
.length(length)
|
.length(length)
|
||||||
.decimalPlaces(null)
|
.decimalPlaces(decimalPlaces)
|
||||||
.isNull(isNull)
|
.isNull(isNull)
|
||||||
.defaultValue(defaultValue)
|
.defaultValue(defaultValue)
|
||||||
.isDict(null)
|
.isDict(isNull)
|
||||||
.dictKey(null)
|
.dictKey(null)
|
||||||
.build();
|
.build();
|
||||||
|
structures.add(build);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (kvt.getType() == 2) {
|
// if (kvt.getType() == 2) {
|
||||||
//名称
|
// //名称
|
||||||
String name = executeQuery.getString(1);
|
// String name = executeQuery.getString(1);
|
||||||
/**
|
// /**
|
||||||
* 注释
|
// * 注释
|
||||||
*/
|
// */
|
||||||
String comment = executeQuery.getString(2);
|
// String comment = executeQuery.getString(2);
|
||||||
/**
|
// /**
|
||||||
* 类型
|
// * 类型
|
||||||
*/
|
// */
|
||||||
String type = executeQuery.getString(3);
|
// String type = executeQuery.getString(3);
|
||||||
/**
|
// /**
|
||||||
* 长度
|
// * 长度
|
||||||
*/
|
// */
|
||||||
String length = executeQuery.getString(4);
|
// String length = executeQuery.getString(4);
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * 映射类型
|
||||||
|
// */
|
||||||
|
// String mappingType = executeQuery.getString(5);
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * 默认值
|
||||||
|
// */
|
||||||
|
// String defaultValue = executeQuery.getString(6);
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * 是否为空
|
||||||
|
// */
|
||||||
|
// String isNull = executeQuery.getString(7);
|
||||||
|
// /**
|
||||||
|
// * 是否主键
|
||||||
|
// */
|
||||||
|
// String isPrimaryKey = executeQuery.getString(8);
|
||||||
|
// build = DataStructure.builder()
|
||||||
|
// .tableName(tableName)
|
||||||
|
// .warName(kvt.getDatabaseName())
|
||||||
|
// .name(name)
|
||||||
|
// .comment(comment)
|
||||||
|
// .isPrimaryKey(isPrimaryKey)
|
||||||
|
// .type(type)
|
||||||
|
// .mappingType(mappingType)
|
||||||
|
// .length(length)
|
||||||
|
// .decimalPlaces(null)
|
||||||
|
// .isNull(isNull)
|
||||||
|
// .defaultValue(defaultValue)
|
||||||
|
// .isDict(null)
|
||||||
|
// .dictKey(null)
|
||||||
|
// .build();
|
||||||
|
// structures.add(build);
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
|
||||||
/**
|
|
||||||
* 映射类型
|
|
||||||
*/
|
|
||||||
String mappingType = executeQuery.getString(5);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 默认值
|
|
||||||
*/
|
|
||||||
String defaultValue = executeQuery.getString(6);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否为空
|
|
||||||
*/
|
|
||||||
String isNull = executeQuery.getString(7);
|
|
||||||
/**
|
|
||||||
* 是否主键
|
|
||||||
*/
|
|
||||||
String isPrimaryKey = executeQuery.getString(8);
|
|
||||||
build = DataStructure.builder()
|
|
||||||
.tableName(tableName)
|
|
||||||
.warName(kvt.getDatabaseName())
|
|
||||||
.name(name)
|
|
||||||
.comment(comment)
|
|
||||||
.isPrimaryKey(isPrimaryKey)
|
|
||||||
.type(type)
|
|
||||||
.mappingType(mappingType)
|
|
||||||
.length(length)
|
|
||||||
.decimalPlaces(null)
|
|
||||||
.isNull(isNull)
|
|
||||||
.defaultValue(defaultValue)
|
|
||||||
.isDict(null)
|
|
||||||
.dictKey(null)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
if (structures!=null){
|
||||||
|
|
||||||
|
baseMapper.add(structures);
|
||||||
baseMapper.add(build);
|
|
||||||
}
|
}
|
||||||
executeQuery.close();
|
executeQuery.close();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
|
|
|
@ -246,17 +246,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
|
||||||
|
|
||||||
</insert>
|
</insert>
|
||||||
<insert id="add">
|
|
||||||
INSERT INTO `data_basete`.`data_structure`
|
|
||||||
( `name`, `comment`,`war_name`,`table_name`, `isPrimaryKey`, `type`, `mappingType`,
|
|
||||||
`length`, `decimalPlaces`, `isNull`, `defaultValue`, `isDict`,
|
|
||||||
`dictKey`)
|
|
||||||
VALUES ( #{name}, #{comment}, #{warName} ,#{tableName},#{isPrimaryKey}, #{type}, #{mappingType},
|
|
||||||
#{length}, #{decimalPlaces}, #{isNull}, #{defaultValue}, #{isDict},
|
|
||||||
#{dictKey});
|
|
||||||
|
|
||||||
|
|
||||||
</insert>
|
|
||||||
<insert id="ChildAdd">
|
<insert id="ChildAdd">
|
||||||
INSERT INTO `data_basete`.`child` ( `name`, `as`, `data_total`, `is_primary_key`)
|
INSERT INTO `data_basete`.`child` ( `name`, `as`, `data_total`, `is_primary_key`)
|
||||||
VALUES
|
VALUES
|
||||||
|
@ -320,5 +310,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
INSERT INTO `data_basete`.`permissions_user` ( `user_id`, `kvt_id`, `tbale_name`, `dept_id`)
|
INSERT INTO `data_basete`.`permissions_user` ( `user_id`, `kvt_id`, `tbale_name`, `dept_id`)
|
||||||
values (#{userId},#{kvtId},#{tbaleName},#{deptId})
|
values (#{userId},#{kvtId},#{tbaleName},#{deptId})
|
||||||
</insert>
|
</insert>
|
||||||
|
<insert id="add">
|
||||||
|
INSERT INTO `data_basete`.`data_structure`
|
||||||
|
( `name`, `comment`,`war_name`,`table_name`, `isPrimaryKey`, `type`, `mappingType`,
|
||||||
|
`length`, `decimalPlaces`, `isNull`, `defaultValue`, `isDict`,
|
||||||
|
`dictKey`)
|
||||||
|
VALUES
|
||||||
|
<foreach collection="dataStructure" item="dataStructure" separator=",">
|
||||||
|
(#{dataStructure.name}, #{dataStructure.comment},#{dataStructure.warName},#{dataStructure.tableName}, #{dataStructure.isPrimaryKey}, #{dataStructure.type}, #{dataStructure.mappingType},
|
||||||
|
#{dataStructure.length}, #{dataStructure.decimalPlaces}, #{dataStructure.isNull}, #{dataStructure.defaultValue}, #{dataStructure.isDict},
|
||||||
|
#{dataStructure.dictKey})
|
||||||
|
</foreach>
|
||||||
|
|
||||||
|
</insert>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
@ -9,4 +9,5 @@ import com.muyu.engine.Engine;
|
||||||
* on 2024/5/8
|
* on 2024/5/8
|
||||||
*/
|
*/
|
||||||
public interface DataSetEngine extends Engine {
|
public interface DataSetEngine extends Engine {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
package com.muyu.engine.test;
|
||||||
|
|
||||||
|
import com.muyu.engine.Engine;
|
||||||
|
import com.muyu.engine.test.data.TestDataModel;
|
||||||
|
import com.muyu.model.DataModel;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test
|
||||||
|
*
|
||||||
|
* @author Yangle
|
||||||
|
* Date 2024/5/13 15:19
|
||||||
|
*/
|
||||||
|
@SpringBootApplication
|
||||||
|
public class Test {
|
||||||
|
|
||||||
|
public static final Map<String, Engine> map = new ConcurrentHashMap<>();
|
||||||
|
static {
|
||||||
|
map.put("test",new TestDataModel());
|
||||||
|
}
|
||||||
|
public static void main(String[] args) {
|
||||||
|
DataModel dataModel = new DataModel();
|
||||||
|
dataModel.setKey("test");
|
||||||
|
dataModel.setValue("s");
|
||||||
|
dataModel.setProcessType("String");
|
||||||
|
dataModel.setProcessClass(String.class);
|
||||||
|
dataModel.setSourceType("varchar");
|
||||||
|
|
||||||
|
Engine test = map.get("test");
|
||||||
|
test.execution();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
package com.muyu.engine.test.data;
|
||||||
|
|
||||||
|
import com.muyu.model.DataModel;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DataModelConstant
|
||||||
|
*
|
||||||
|
* @author Yangle
|
||||||
|
* Date 2024/5/13 15:14
|
||||||
|
*/
|
||||||
|
@Log4j2
|
||||||
|
public class DataModelConstant {
|
||||||
|
public static final ThreadLocal<DataModel> dataModelThreadLocal = new ThreadLocal<>();
|
||||||
|
|
||||||
|
|
||||||
|
public static DataModel getDataModel() {
|
||||||
|
log.info("小头");
|
||||||
|
return dataModelThreadLocal.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void setDataModel(DataModel dataModel) {
|
||||||
|
log.info("大头");
|
||||||
|
dataModelThreadLocal.set(dataModel);
|
||||||
|
}
|
||||||
|
private static void removeDataModel() {
|
||||||
|
log.info("remove");
|
||||||
|
dataModelThreadLocal.remove();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
package com.muyu.engine.test.data;
|
||||||
|
|
||||||
|
import com.muyu.engine.Engine;
|
||||||
|
import com.muyu.model.DataModel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据模型
|
||||||
|
* TestDataModel
|
||||||
|
*
|
||||||
|
* @author Yangle
|
||||||
|
* Date 2024/5/13 15:11
|
||||||
|
*/
|
||||||
|
public class TestDataModel implements Engine<DataModel> {
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execution() {
|
||||||
|
DataModelConstant.getDataModel();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DataModel get() {
|
||||||
|
return DataModelConstant.getDataModel();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue