feat 规则版本测试引擎添加数据接入以及资产结构
parent
1b2ea812ee
commit
a6b87e1c6d
|
@ -6,7 +6,7 @@ import lombok.NoArgsConstructor;
|
|||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* 整体数据结构 overallDataStructure
|
||||
* 整体数据结构 overallStructure
|
||||
*
|
||||
* @author LeYang
|
||||
* on 2024/4/28
|
||||
|
|
|
@ -24,6 +24,18 @@ public class DataDisplay {
|
|||
* 库名
|
||||
*/
|
||||
private String warName;
|
||||
/**
|
||||
* kvtName
|
||||
*/
|
||||
private String kvtName;
|
||||
/**
|
||||
* 字段名
|
||||
*/
|
||||
private String fieldName;
|
||||
/**
|
||||
* 表名
|
||||
*/
|
||||
private String tableName;
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
|
|
|
@ -1,11 +1,7 @@
|
|||
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.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
|
@ -20,6 +16,7 @@ import lombok.experimental.SuperBuilder;
|
|||
@NoArgsConstructor
|
||||
@SuperBuilder
|
||||
public class ChildrenList {
|
||||
|
||||
private Integer id;
|
||||
private String name;
|
||||
private String as;
|
||||
|
|
|
@ -151,11 +151,10 @@ public class KvtController extends BaseController {
|
|||
* @param databaseName 数据库名称
|
||||
* @return
|
||||
*/
|
||||
|
||||
@PostMapping("/selectDataAuthorization")
|
||||
public Result selectDataAuthorization (@RequestParam String databaseName){
|
||||
kvtService.selectDataAuthorization(databaseName);
|
||||
return Result.success();
|
||||
public Result<List<DataAuthorization>> selectDataAuthorization (@RequestParam String databaseName){
|
||||
List<DataAuthorization> dataAuthorizations = kvtService.selectDataDisplayList(databaseName);
|
||||
return Result.success(dataAuthorizations);
|
||||
|
||||
}
|
||||
|
||||
|
@ -310,4 +309,21 @@ public class KvtController extends BaseController {
|
|||
kvtService.AddDepartment(permissionsUser);
|
||||
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<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<DataAuthorization> selectDataAuthorization(String databaseName);
|
||||
|
||||
Result synchronizationAdd(Kvt kvt) throws SQLException, ClassNotFoundException;
|
||||
|
||||
|
@ -82,4 +81,10 @@ public interface KvtService extends IService<Kvt> {
|
|||
List<Object> selectTableName(String tableName);
|
||||
|
||||
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
|
||||
private RemoteUserService remoteUserSer;
|
||||
|
@ -374,13 +368,14 @@ public class KvtServiceImpl extends ServiceImpl<KvtMapper, Kvt> implements KvtSe
|
|||
this.selectDatabaseName(connection, kvt);
|
||||
|
||||
|
||||
Result<SysUser> sysUserResult = remoteUserSer.selectUserId(SecurityUtils.getUserId());
|
||||
SysUser data = sysUserResult.getData();
|
||||
DeptUserKvt build = DeptUserKvt.builder()
|
||||
.userId(SecurityUtils.getUserId())
|
||||
.kvtId(kvt.getId())
|
||||
.deptId(data.getDeptId()).build();
|
||||
baseMapper.DeptUserKvtAdd(build);
|
||||
// Result<SysUser> sysUserResult = remoteUserSer.selectUserId(SecurityUtils.getUserId());
|
||||
// SysUser data = sysUserResult.getData();
|
||||
// DeptUserKvt build = DeptUserKvt.builder()
|
||||
// .userId(SecurityUtils.getUserId())
|
||||
// .kvtId(kvt.getId())
|
||||
// .deptId(data.getDeptId()).build();
|
||||
// baseMapper.DeptUserKvtAdd(build);
|
||||
|
||||
|
||||
resultSet.close();
|
||||
//结束时间
|
||||
|
@ -416,19 +411,19 @@ public class KvtServiceImpl extends ServiceImpl<KvtMapper, Kvt> implements KvtSe
|
|||
|
||||
int columnCount = metaDataTest.getColumnCount();
|
||||
|
||||
|
||||
List<DataDisplay> dataDisplays = new ArrayList<>();
|
||||
|
||||
while (resultSet2.next()) {
|
||||
for (int i = 1; i <= columnCount; i++) {
|
||||
DataDisplay dataDisplay = new DataDisplay();
|
||||
String columnName = metaDataTest.getColumnName(i);
|
||||
//资产展示类型
|
||||
String typeName = metaDataTest.getColumnTypeName(i);
|
||||
dataDisplay.setValue(resultSet2.getObject(i));
|
||||
dataDisplay.setType(typeName);
|
||||
dataDisplay.setWarName(kvt.getDatabaseName() + "-" + tableName + "-" + columnName);
|
||||
dataDisplays.add(dataDisplay);
|
||||
DataDisplay build = DataDisplay.builder()
|
||||
.warName(kvt.getDatabaseName() + "-" + tableName + "-" + metaDataTest.getColumnName(i))
|
||||
.type(metaDataTest.getColumnTypeName(i))
|
||||
.kvtName(kvt.getDatabaseName())
|
||||
.value(resultSet2.getObject(i))
|
||||
.tableName(tableName)
|
||||
.fieldName(metaDataTest.getColumnName(i))
|
||||
.build();
|
||||
dataDisplays.add(build);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -646,6 +641,16 @@ public class KvtServiceImpl extends ServiceImpl<KvtMapper, Kvt> implements KvtSe
|
|||
.isPrimaryKey(null)
|
||||
.build();
|
||||
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) {
|
||||
|
@ -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>
|
||||
<select id="selectDepartment" resultType="com.muyu.kvt.domain.ChildrenList">
|
||||
|
||||
|
||||
|
||||
SELECT
|
||||
TABLE_NAME as 'name',
|
||||
TABLE_COMMENT as 'as',
|
||||
TABLE_ROWS as 'dataTotal'
|
||||
FROM INFORMATION_SCHEMA.TABLES
|
||||
WHERE
|
||||
TABLE_SCHEMA = #{databaseName}
|
||||
SELECT
|
||||
TABLE_NAME as 'name',
|
||||
TABLE_COMMENT as 'as',
|
||||
TABLE_ROWS as 'dataTotal'
|
||||
FROM INFORMATION_SCHEMA.TABLES
|
||||
WHERE
|
||||
TABLE_SCHEMA = #{databaseName}
|
||||
|
||||
</select>
|
||||
<select id="selectType" resultType="com.muyu.kvt.domain.Kvt">
|
||||
|
@ -225,6 +222,17 @@ 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 INTO `data_basete`.`synchronization`
|
||||
( `name`, `system_name`, `type`, `host`, `port`, `database_name`,
|
||||
|
@ -302,10 +310,10 @@ SELECT
|
|||
</insert>
|
||||
<insert id="dataDisplayAdd">
|
||||
INSERT INTO `data_basete`.`data_display`
|
||||
(`war_name`, `type`, `value`)
|
||||
(`war_name`, `type`, `value`,`field_name`,`table_name`,`kvt_name`)
|
||||
VALUES
|
||||
<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>
|
||||
</insert>
|
||||
<insert id="permissionsUserAdd">
|
||||
|
|
Loading…
Reference in New Issue