数据资产后台实现 试验1
parent
70cb531906
commit
d0e7ae8ba8
|
@ -0,0 +1,79 @@
|
|||
package com.muyu.etl.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.muyu.common.core.annotation.Excel;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
/**
|
||||
* 结构对象 Structure
|
||||
*
|
||||
* @author xiaohuang
|
||||
* on 2024/4/22
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@SuperBuilder
|
||||
public class Structure extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 主键 */
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/** 表id */
|
||||
@Excel(name = "表id")
|
||||
private Long tableId;
|
||||
|
||||
/** 字段名称 */
|
||||
@Excel(name = "字段名称")
|
||||
private String columnName;
|
||||
|
||||
/** 字段注释 */
|
||||
@Excel(name = "字段注释")
|
||||
private String columnRemark;
|
||||
|
||||
/** 是否主键 'Y'是主键 'N'不是主键 */
|
||||
@Excel(name = "是否主键 'Y'是主键 'N'不是主键")
|
||||
private String isPrimary;
|
||||
|
||||
/** 数据类型 */
|
||||
@Excel(name = "数据类型")
|
||||
private String columnType;
|
||||
|
||||
/** 映射类型 */
|
||||
@Excel(name = "映射类型")
|
||||
private String javaType;
|
||||
|
||||
/** 字段长度 */
|
||||
@Excel(name = "字段长度")
|
||||
private String columnLength;
|
||||
|
||||
/** 小数位数 */
|
||||
@Excel(name = "小数位数")
|
||||
private String columnDecimals;
|
||||
|
||||
/** 是否为空 'Y'是 'N'不是 */
|
||||
@Excel(name = "是否为空 'Y'是 'N'不是")
|
||||
private String isNull;
|
||||
|
||||
/** 默认值 */
|
||||
@Excel(name = "默认值")
|
||||
private String defaultValue;
|
||||
|
||||
/** 是否字典 'Y'是 'N'不是 */
|
||||
@Excel(name = "是否字典 'Y'是 'N'不是")
|
||||
private String isDictionary;
|
||||
|
||||
/** 映射字典 */
|
||||
@Excel(name = "映射字典")
|
||||
private String dictionaryTable;
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
package com.muyu.etl.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.muyu.common.core.annotation.Excel;
|
||||
import com.muyu.common.core.web.domain.TreeEntity;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* 库 TableInfo
|
||||
*
|
||||
* @author xiaohuang
|
||||
* on 2024/4/22
|
||||
*/
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@SuperBuilder
|
||||
public class TableInfo extends TreeEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(value = "id",type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
private Long basicId;
|
||||
|
||||
/**
|
||||
* 表名称/数据库
|
||||
*/
|
||||
@Excel(name = "表名称/数据库")
|
||||
private String tableName;
|
||||
|
||||
|
||||
/**
|
||||
* 表备注
|
||||
*/
|
||||
@Excel(name = "表备注")
|
||||
private String tableRemark;
|
||||
|
||||
|
||||
/**
|
||||
* 数据量
|
||||
*/
|
||||
@Excel(name = "数据量")
|
||||
private Long dataNum;
|
||||
|
||||
|
||||
/**
|
||||
* 是否核心 'Y'是 'N'不是
|
||||
*/
|
||||
@Excel(name = "是否核心 ")
|
||||
|
||||
}
|
|
@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.*;
|
|||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.sql.DataSource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -41,6 +42,8 @@ public class BasicConfigInfoController extends BaseController
|
|||
return getDataTable(list);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 导出基础信息列表
|
||||
*/
|
||||
|
@ -106,4 +109,11 @@ public class BasicConfigInfoController extends BaseController
|
|||
public Result connectionTest(@RequestBody BasicConfigInfo basicConfigInfo) throws ServletException {
|
||||
return toAjax(basicConfigInfoService.connectionTest(basicConfigInfo));
|
||||
}
|
||||
|
||||
@RequiresPermissions("etl:info:test")
|
||||
@Log(title = "获取成功链接中的")
|
||||
@GetMapping("/dataConstruct")
|
||||
public Result<TableDataInfo<List>> getData(){
|
||||
return getDataTable(basicConfigInfoService.getDataByEtl());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
package com.muyu.etl.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.etl.domain.Structure;
|
||||
|
||||
/**
|
||||
* 结构 StructureMapper
|
||||
*
|
||||
* @author xiaohuang
|
||||
* on 2024/4/22
|
||||
*/
|
||||
public interface StructureMapper extends BaseMapper<Structure> {
|
||||
|
||||
/**
|
||||
* 查询结构
|
||||
*/
|
||||
public Structure selectStructureById(Long id);
|
||||
|
||||
|
||||
/**
|
||||
* 新增结构
|
||||
*/
|
||||
public int insertStructure(Structure structure);
|
||||
|
||||
|
||||
/**
|
||||
* 修改结构
|
||||
* @param structure
|
||||
* @return
|
||||
*/
|
||||
public int updateStructure(Structure structure);
|
||||
|
||||
|
||||
/**
|
||||
* 删除结构
|
||||
*/
|
||||
public int deleteStructureById(Long id);
|
||||
|
||||
|
||||
/**
|
||||
* 批量删除结构
|
||||
*/
|
||||
public int deleteStructureByIds(Long[] ids);
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package com.muyu.etl.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.TableInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 库表基础信息 TableInfoMapper
|
||||
*
|
||||
* @author xiaohuang
|
||||
* on 2024/4/22
|
||||
*/
|
||||
public interface TableInfoMapper extends BaseMapper<TableInfo> {
|
||||
|
||||
|
||||
/**
|
||||
* 查询库表基础信息
|
||||
*/
|
||||
public TableInfo selectTableInfoById(Long id);
|
||||
|
||||
|
||||
public List<TableInfo> selectTableInfoList(TableInfo tableInfo);
|
||||
|
||||
|
||||
public int insertTableInfo(TableInfo tableInfo);
|
||||
|
||||
|
||||
public int updateTableInfo(TableInfo tableInfo);
|
||||
|
||||
|
||||
public int deleteTableInfoById(Long id);
|
||||
|
||||
|
||||
public int deleteTableInfoByIds(Long[] ids);
|
||||
}
|
|
@ -64,4 +64,8 @@ public interface BasicConfigInfoService extends IService<BasicConfigInfo> {
|
|||
public int deleteBasicConfigInfoById(Long id);
|
||||
|
||||
boolean connectionTest(BasicConfigInfo basicConfigInfo) throws ServletException;
|
||||
|
||||
List<List> getDataByEtl();
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
package com.muyu.etl.service;
|
||||
|
||||
/**
|
||||
* StructureService
|
||||
*
|
||||
* @author xiaohuang
|
||||
* on 2024/4/22
|
||||
*/
|
||||
public interface StructureService {
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package com.muyu.etl.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.TableInfo;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* 库表基础信息 TableInfoService
|
||||
*
|
||||
* @author xiaohuang
|
||||
* on 2024/4/22
|
||||
*/
|
||||
public interface TableInfoService extends IService<TableInfo> {
|
||||
}
|
|
@ -1,18 +1,21 @@
|
|||
package com.muyu.etl.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.TableInfo;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.etl.domain.BasicConfigInfo;
|
||||
import com.muyu.etl.mapper.BasicConfigInfoMapper;
|
||||
import com.muyu.etl.service.BasicConfigInfoService;
|
||||
import com.muyu.etl.service.StructureService;
|
||||
import com.muyu.etl.service.TableInfoService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.sql.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 业务层 BasicConfigInfoServiceImpl
|
||||
*
|
||||
|
@ -26,6 +29,12 @@ public class BasicConfigInfoServiceImpl extends ServiceImpl<BasicConfigInfoMappe
|
|||
@Autowired
|
||||
private BasicConfigInfoMapper basicConfigInfoMapper;
|
||||
|
||||
@Autowired
|
||||
private StructureService structureService;
|
||||
|
||||
@Autowired
|
||||
private TableInfoService tableInfoService;
|
||||
|
||||
@Override
|
||||
public BasicConfigInfo selectBasicConfigInfoById(Long id) {
|
||||
return basicConfigInfoMapper.selectBasicConfigInfoById(id);
|
||||
|
@ -74,11 +83,47 @@ public class BasicConfigInfoServiceImpl extends ServiceImpl<BasicConfigInfoMappe
|
|||
try {
|
||||
conn = DriverManager.getConnection(url, user, password);
|
||||
System.out.println("Connected to the MySQL server successfully.");
|
||||
|
||||
//同步数据库信息
|
||||
//树级结构 库,表
|
||||
|
||||
|
||||
} catch (SQLException e) {
|
||||
throw new ServletException("连接失败");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<List> getDataByEtl() {
|
||||
List<BasicConfigInfo> list = this.list();
|
||||
ArrayList<Map<String,List<String>>> mapList = new ArrayList<>();
|
||||
|
||||
for (BasicConfigInfo info : list) {
|
||||
String url = "jdbc:" + info.getDatabaseType()
|
||||
+ "://" + info.getHost()
|
||||
+ ":" +info.getPort()
|
||||
+ "/" +info.getDatabaseName() + "";
|
||||
|
||||
String user = info.getUsername();
|
||||
String password = info.getPassword();
|
||||
Connection conn = null;
|
||||
|
||||
try {
|
||||
conn = DriverManager.getConnection(url,user,password);
|
||||
DatabaseMetaData metaData = conn.getMetaData();
|
||||
ResultSet resultSet = metaData.getCatalogs();
|
||||
|
||||
while (resultSet.next()){
|
||||
//库名
|
||||
String catalogs = resultSet.getString("TABLE_CAT");
|
||||
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
package com.muyu.etl.service.impl;
|
||||
|
||||
/**
|
||||
* 结构 StructureServiceImpl
|
||||
*
|
||||
* @author xiaohuang
|
||||
* on 2024/4/22
|
||||
*/
|
||||
public class StructureServiceImpl {
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package com.muyu.etl.service.impl;
|
||||
|
||||
/**
|
||||
* 库表基础 TableInfoServiceImpl
|
||||
*
|
||||
* @author xiaohuang
|
||||
* on 2024/4/22
|
||||
*/
|
||||
public class TableInfoServiceImpl {
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.muyu.etl.mapper.StructureMapper">
|
||||
|
||||
|
||||
</mapper>
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.muyu.etl.mapper.StructureMapper">
|
||||
|
||||
|
||||
</mapper>
|
Loading…
Reference in New Issue