feat 规则版本测试引擎添加数据接入以及资产结构
parent
1b2ea812ee
commit
a6b87e1c6d
|
@ -6,7 +6,7 @@ import lombok.NoArgsConstructor;
|
||||||
import lombok.experimental.SuperBuilder;
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 整体数据结构 overallDataStructure
|
* 整体数据结构 overallStructure
|
||||||
*
|
*
|
||||||
* @author LeYang
|
* @author LeYang
|
||||||
* on 2024/4/28
|
* on 2024/4/28
|
||||||
|
|
|
@ -24,6 +24,18 @@ public class DataDisplay {
|
||||||
* 库名
|
* 库名
|
||||||
*/
|
*/
|
||||||
private String warName;
|
private String warName;
|
||||||
|
/**
|
||||||
|
* kvtName
|
||||||
|
*/
|
||||||
|
private String kvtName;
|
||||||
|
/**
|
||||||
|
* 字段名
|
||||||
|
*/
|
||||||
|
private String fieldName;
|
||||||
|
/**
|
||||||
|
* 表名
|
||||||
|
*/
|
||||||
|
private String tableName;
|
||||||
/**
|
/**
|
||||||
* 类型
|
* 类型
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,11 +1,7 @@
|
||||||
package com.muyu.kvt.domain;
|
package com.muyu.kvt.domain;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import com.muyu.common.core.web.domain.BaseEntity;
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.experimental.SuperBuilder;
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
@ -20,6 +16,7 @@ import lombok.experimental.SuperBuilder;
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@SuperBuilder
|
@SuperBuilder
|
||||||
public class ChildrenList {
|
public class ChildrenList {
|
||||||
|
|
||||||
private Integer id;
|
private Integer id;
|
||||||
private String name;
|
private String name;
|
||||||
private String as;
|
private String as;
|
||||||
|
|
|
@ -151,11 +151,10 @@ public class KvtController extends BaseController {
|
||||||
* @param databaseName 数据库名称
|
* @param databaseName 数据库名称
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@PostMapping("/selectDataAuthorization")
|
@PostMapping("/selectDataAuthorization")
|
||||||
public Result selectDataAuthorization (@RequestParam String databaseName){
|
public Result<List<DataAuthorization>> selectDataAuthorization (@RequestParam String databaseName){
|
||||||
kvtService.selectDataAuthorization(databaseName);
|
List<DataAuthorization> dataAuthorizations = kvtService.selectDataDisplayList(databaseName);
|
||||||
return Result.success();
|
return Result.success(dataAuthorizations);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -310,4 +309,21 @@ public class KvtController extends BaseController {
|
||||||
kvtService.AddDepartment(permissionsUser);
|
kvtService.AddDepartment(permissionsUser);
|
||||||
return Result.success("添加成功");
|
return Result.success("添加成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据表名查询规则引擎版本中字段的值
|
||||||
|
* @param tableName
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/selectDataStructureTableName")
|
||||||
|
public Result<List<DataStructure>> selectDataStructureTableName (@RequestParam String tableName){
|
||||||
|
List<DataStructure> list= kvtService.selectDataStructureTableName(tableName);
|
||||||
|
return Result.success(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/selectDataDisplayVal")
|
||||||
|
public Result<List<DataDisplay>> selectDataDisplayVal(@RequestParam String tableName){
|
||||||
|
List<DataDisplay> list= kvtService.selectDataDisplayVal(tableName);
|
||||||
|
return Result.success(list);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,4 +109,10 @@ public interface KvtMapper extends BaseMapper<Kvt> {
|
||||||
List<DataStructure> selectDataStructureAll();
|
List<DataStructure> selectDataStructureAll();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
List<DataAuthorization> selectDataDisplayList(String databaseName);
|
||||||
|
|
||||||
|
List<DataStructure> selectDataStructureTableName(String tableName);
|
||||||
|
|
||||||
|
List<DataDisplay> selectDataDisplayVal(String tableName);
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,6 @@ public interface KvtService extends IService<Kvt> {
|
||||||
|
|
||||||
List<Diction> selectDictionaryy(Integer id);
|
List<Diction> selectDictionaryy(Integer id);
|
||||||
|
|
||||||
List<DataAuthorization> selectDataAuthorization(String databaseName);
|
|
||||||
|
|
||||||
Result synchronizationAdd(Kvt kvt) throws SQLException, ClassNotFoundException;
|
Result synchronizationAdd(Kvt kvt) throws SQLException, ClassNotFoundException;
|
||||||
|
|
||||||
|
@ -82,4 +81,10 @@ public interface KvtService extends IService<Kvt> {
|
||||||
List<Object> selectTableName(String tableName);
|
List<Object> selectTableName(String tableName);
|
||||||
|
|
||||||
void AddDepartment(PermissionsUser permissionsUser);
|
void AddDepartment(PermissionsUser permissionsUser);
|
||||||
|
|
||||||
|
List<DataAuthorization> selectDataDisplayList(String databaseName);
|
||||||
|
|
||||||
|
List<DataStructure> selectDataStructureTableName(String tableName);
|
||||||
|
|
||||||
|
List<DataDisplay> selectDataDisplayVal(String tableName);
|
||||||
}
|
}
|
||||||
|
|
|
@ -319,12 +319,6 @@ public class KvtServiceImpl extends ServiceImpl<KvtMapper, Kvt> implements KvtSe
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<DataAuthorization> selectDataAuthorization(String databaseName) {
|
|
||||||
|
|
||||||
List<ChildrenList> list = baseMapper.selectDepartment(databaseName);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RemoteUserService remoteUserSer;
|
private RemoteUserService remoteUserSer;
|
||||||
|
@ -374,13 +368,14 @@ public class KvtServiceImpl extends ServiceImpl<KvtMapper, Kvt> implements KvtSe
|
||||||
this.selectDatabaseName(connection, kvt);
|
this.selectDatabaseName(connection, kvt);
|
||||||
|
|
||||||
|
|
||||||
Result<SysUser> sysUserResult = remoteUserSer.selectUserId(SecurityUtils.getUserId());
|
// Result<SysUser> sysUserResult = remoteUserSer.selectUserId(SecurityUtils.getUserId());
|
||||||
SysUser data = sysUserResult.getData();
|
// SysUser data = sysUserResult.getData();
|
||||||
DeptUserKvt build = DeptUserKvt.builder()
|
// DeptUserKvt build = DeptUserKvt.builder()
|
||||||
.userId(SecurityUtils.getUserId())
|
// .userId(SecurityUtils.getUserId())
|
||||||
.kvtId(kvt.getId())
|
// .kvtId(kvt.getId())
|
||||||
.deptId(data.getDeptId()).build();
|
// .deptId(data.getDeptId()).build();
|
||||||
baseMapper.DeptUserKvtAdd(build);
|
// baseMapper.DeptUserKvtAdd(build);
|
||||||
|
|
||||||
|
|
||||||
resultSet.close();
|
resultSet.close();
|
||||||
//结束时间
|
//结束时间
|
||||||
|
@ -416,19 +411,19 @@ public class KvtServiceImpl extends ServiceImpl<KvtMapper, Kvt> implements KvtSe
|
||||||
|
|
||||||
int columnCount = metaDataTest.getColumnCount();
|
int columnCount = metaDataTest.getColumnCount();
|
||||||
|
|
||||||
|
|
||||||
List<DataDisplay> dataDisplays = new ArrayList<>();
|
List<DataDisplay> dataDisplays = new ArrayList<>();
|
||||||
|
|
||||||
while (resultSet2.next()) {
|
while (resultSet2.next()) {
|
||||||
for (int i = 1; i <= columnCount; i++) {
|
for (int i = 1; i <= columnCount; i++) {
|
||||||
DataDisplay dataDisplay = new DataDisplay();
|
DataDisplay build = DataDisplay.builder()
|
||||||
String columnName = metaDataTest.getColumnName(i);
|
.warName(kvt.getDatabaseName() + "-" + tableName + "-" + metaDataTest.getColumnName(i))
|
||||||
//资产展示类型
|
.type(metaDataTest.getColumnTypeName(i))
|
||||||
String typeName = metaDataTest.getColumnTypeName(i);
|
.kvtName(kvt.getDatabaseName())
|
||||||
dataDisplay.setValue(resultSet2.getObject(i));
|
.value(resultSet2.getObject(i))
|
||||||
dataDisplay.setType(typeName);
|
.tableName(tableName)
|
||||||
dataDisplay.setWarName(kvt.getDatabaseName() + "-" + tableName + "-" + columnName);
|
.fieldName(metaDataTest.getColumnName(i))
|
||||||
dataDisplays.add(dataDisplay);
|
.build();
|
||||||
|
dataDisplays.add(build);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -646,6 +641,16 @@ public class KvtServiceImpl extends ServiceImpl<KvtMapper, Kvt> implements KvtSe
|
||||||
.isPrimaryKey(null)
|
.isPrimaryKey(null)
|
||||||
.build();
|
.build();
|
||||||
baseMapper.childAdd(build1);
|
baseMapper.childAdd(build1);
|
||||||
|
DataAuthorization build = DataAuthorization.builder()
|
||||||
|
.name(name)
|
||||||
|
.systemName(kvt.getSystemName())
|
||||||
|
.databaseName(kvt.getDatabaseName())
|
||||||
|
.tableName(name)
|
||||||
|
.as(as)
|
||||||
|
.dataTotal(Integer.valueOf(dataTotal))
|
||||||
|
.build();
|
||||||
|
baseMapper.DataAuthorizationAdd(build);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
|
@ -829,6 +834,22 @@ public class KvtServiceImpl extends ServiceImpl<KvtMapper, Kvt> implements KvtSe
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<DataAuthorization> selectDataDisplayList(String databaseName) {
|
||||||
|
|
||||||
|
return baseMapper.selectDataDisplayList(databaseName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<DataStructure> selectDataStructureTableName(String tableName) {
|
||||||
|
return baseMapper.selectDataStructureTableName(tableName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<DataDisplay> selectDataDisplayVal(String tableName) {
|
||||||
|
return baseMapper.selectDataDisplayVal(tableName);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询 根据库名跟表名查询字段信息
|
* 查询 根据库名跟表名查询字段信息
|
||||||
*
|
*
|
||||||
|
|
|
@ -83,16 +83,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
select * from synchronization
|
select * from synchronization
|
||||||
</select>
|
</select>
|
||||||
<select id="selectDepartment" resultType="com.muyu.kvt.domain.ChildrenList">
|
<select id="selectDepartment" resultType="com.muyu.kvt.domain.ChildrenList">
|
||||||
|
SELECT
|
||||||
|
TABLE_NAME as 'name',
|
||||||
|
TABLE_COMMENT as 'as',
|
||||||
SELECT
|
TABLE_ROWS as 'dataTotal'
|
||||||
TABLE_NAME as 'name',
|
FROM INFORMATION_SCHEMA.TABLES
|
||||||
TABLE_COMMENT as 'as',
|
WHERE
|
||||||
TABLE_ROWS as 'dataTotal'
|
TABLE_SCHEMA = #{databaseName}
|
||||||
FROM INFORMATION_SCHEMA.TABLES
|
|
||||||
WHERE
|
|
||||||
TABLE_SCHEMA = #{databaseName}
|
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
<select id="selectType" resultType="com.muyu.kvt.domain.Kvt">
|
<select id="selectType" resultType="com.muyu.kvt.domain.Kvt">
|
||||||
|
@ -225,6 +222,17 @@ SELECT
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
<select id="selectDataStructureTableName" resultType="com.muyu.kvt.domain.DataStructure">
|
||||||
|
select * from data_structure where table_name=#{tableName}
|
||||||
|
</select>
|
||||||
|
<select id="selectDataDisplayList" resultType="com.muyu.kvt.domain.DataAuthorization">
|
||||||
|
select * from data_authorization where database_name=#{databaseName}
|
||||||
|
</select>
|
||||||
|
<select id="selectDataDisplayVal" resultType="com.muyu.kvt.datadisplay.DataDisplay">
|
||||||
|
select * from data_display where table_name=#{tableName}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
<insert id="synchronizationAdd">
|
<insert id="synchronizationAdd">
|
||||||
INSERT INTO `data_basete`.`synchronization`
|
INSERT INTO `data_basete`.`synchronization`
|
||||||
( `name`, `system_name`, `type`, `host`, `port`, `database_name`,
|
( `name`, `system_name`, `type`, `host`, `port`, `database_name`,
|
||||||
|
@ -302,10 +310,10 @@ SELECT
|
||||||
</insert>
|
</insert>
|
||||||
<insert id="dataDisplayAdd">
|
<insert id="dataDisplayAdd">
|
||||||
INSERT INTO `data_basete`.`data_display`
|
INSERT INTO `data_basete`.`data_display`
|
||||||
(`war_name`, `type`, `value`)
|
(`war_name`, `type`, `value`,`field_name`,`table_name`,`kvt_name`)
|
||||||
VALUES
|
VALUES
|
||||||
<foreach collection="dataDisplays" item="dataDisplays" separator=",">
|
<foreach collection="dataDisplays" item="dataDisplays" separator=",">
|
||||||
(#{dataDisplays.warName}, #{dataDisplays.type}, #{dataDisplays.value})
|
(#{dataDisplays.warName}, #{dataDisplays.type}, #{dataDisplays.value},#{dataDisplays.fieldName},#{dataDisplays.tableName},#{dataDisplays.kvtName})
|
||||||
</foreach>
|
</foreach>
|
||||||
</insert>
|
</insert>
|
||||||
<insert id="permissionsUserAdd">
|
<insert id="permissionsUserAdd">
|
||||||
|
|
Loading…
Reference in New Issue