Commit a81458f4 authored by mcb's avatar mcb

源数据表 查询

parent 8c0cdf1e
......@@ -221,6 +221,27 @@
<artifactId>hibernate-validator</artifactId>
<version>6.1.6.Final</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.7</version><!--$NO-MVN-MAN-VER$ -->
</dependency>
<!-- agent begin -->
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-client</artifactId>
<version>2.6.0-cdh5.16.2</version>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-common</artifactId>
<version>2.6.0-cdh5.16.2</version>
</dependency>
<dependency>
<groupId>org.apache.kudu</groupId>
<artifactId>kudu-client</artifactId>
<version>1.1.0</version>
</dependency>
</dependencies>
<build>
......
......@@ -53,6 +53,9 @@ public class JsonResult<T> {
this.setData(data);
}
public JsonResult(com.jz.dmp.agent.ResultCode code, String message) {
}
public String getCode() {
return code;
}
......
......@@ -4,6 +4,7 @@ import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import javax.crypto.Cipher;
......@@ -18,8 +19,8 @@ public class BaseService {
protected Logger logger = LoggerFactory.getLogger(getClass());
@Value("${spring.public-key}")
private String publicKey;
/*@Value("${spring.public-key}")
private String publicKey;*/
public BigDecimal format(Object obj) {
BigDecimal bak = new BigDecimal(0);
......@@ -41,7 +42,7 @@ public class BaseService {
return bak;
}
public String encode(String pass) {
public String encode(String pass,String publicKey) {
String str = "";
try {
Key key = new SecretKeySpec(Base64.getMimeDecoder().decode(publicKey), "DESede");
......@@ -54,7 +55,7 @@ public class BaseService {
return str;
}
public String decode(String pass) {
public String decode(String pass,String publicKey) {
String str = "";
try {
Key key = new SecretKeySpec(Base64.getMimeDecoder().decode(publicKey), "DESede");
......
......@@ -73,7 +73,7 @@ public class OfflineSynchController {
@GetMapping(value = "/sourceTableList")
@ApiImplicitParam(name = "sourceDbId", value = "源数据库id")
public JsonResult getSourceTableList(@RequestParam Integer sourceDbId,@RequestParam(value = "targetName", required = false) String targetName) throws Exception {
List<Map> list = offlineSynchService.querygSourceTableList(sourceDbId,targetName);
JsonResult list = offlineSynchService.querygSourceTableList(sourceDbId,targetName);
return new JsonResult(ResultCode.SUCCESS, list);
}
}
......@@ -3,6 +3,7 @@ package com.jz.dmp.modules.dao;
import com.jz.dmp.modules.controller.DataIntegration.bean.SourceDbNameListDto;
import com.jz.dmp.modules.controller.DataIntegration.bean.TaskListPageDto;
import com.jz.dmp.modules.controller.DataIntegration.bean.TaskListPageReq;
import com.jz.dmp.modules.model.DmpAgentDatasourceInfo;
import com.jz.dmp.modules.model.DmpSyncingDatasource;
import org.apache.ibatis.annotations.Param;
......@@ -20,4 +21,6 @@ public interface OfflineSynchDao {
List<SourceDbNameListDto> querygSourceDbList(Map map) throws Exception;
DmpSyncingDatasource queryDmpSyncingDatasource(@Param("sourceDbId") Integer sourceDbId) throws Exception;
DmpAgentDatasourceInfo querySourceDbInfoBySourceId(@Param("sourceDbId") Integer sourceDbId) throws Exception;
}
\ No newline at end of file
......@@ -21,5 +21,5 @@ public interface OfflineSynchService {
JsonResult querygSourceDbList(Integer projectId) throws Exception;
List<Map> querygSourceTableList(Integer sourceDbId,String targetName) throws Exception;
JsonResult querygSourceTableList(Integer sourceDbId,String targetName) throws Exception;
}
package com.jz.dmp.modules.service.impl;
import com.fasterxml.jackson.databind.json.JsonMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.jz.agent.service.DmpDsAgentService;
import com.jz.common.constant.JsonResult;
import com.jz.common.constant.ResultCode;
import com.jz.common.page.PageInfoResponse;
import com.jz.common.persistence.BaseService;
import com.jz.common.utils.JsonMapper;
import com.jz.dmp.agent.DmpAgentResult;
import com.jz.dmp.modules.controller.DataIntegration.bean.SourceDbNameListDto;
import com.jz.dmp.modules.controller.DataIntegration.bean.TaskListPageDto;
......@@ -14,12 +15,10 @@ import com.jz.dmp.modules.controller.DataIntegration.bean.TaskListPageReq;
import com.jz.dmp.modules.dao.DmpProjectDao;
import com.jz.dmp.modules.dao.OfflineSynchDao;
import com.jz.dmp.modules.model.DmpAgentDatasourceInfo;
import com.jz.dmp.modules.model.DmpProjectSystemInfo;
import com.jz.dmp.modules.model.DmpSyncingDatasource;
import com.jz.dmp.modules.model.DmpSyncingDatasourceType;
import com.jz.dmp.modules.service.OfflineSynchService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -38,12 +37,18 @@ import java.util.Map;
@Transactional
public class OfflineSynchServiceImpl implements OfflineSynchService {
@Value("${spring.public-key}")
private String publicKey;
@Autowired
private OfflineSynchDao offlineSynchDao;
@Autowired
private DmpProjectDao dmpProjectDao;
@Autowired
private DmpDsAgentService dmpDsAgentServiceImp;
@Override
public PageInfoResponse<TaskListPageDto> queryTaskListPage(TaskListPageReq taskListPageReq) throws Exception {
PageInfoResponse<TaskListPageDto> pageInfoResponse = new PageInfoResponse<>();
......@@ -72,58 +77,23 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
}
@Override
public List<Map> querygSourceTableList(Integer sourceDbId,String targetName) throws Exception {
public JsonResult querygSourceTableList(Integer sourceDbId, String targetName) throws Exception {
//通过源数据库id ,查询数据源配置
DmpSyncingDatasource dmpSyncingDatasource = offlineSynchDao.queryDmpSyncingDatasource(sourceDbId);
if (StringUtils.isNotBlank(dmpSyncingDatasource.getPassword())) {
dmpSyncingDatasource.setPassword(new BaseService().decode(dmpSyncingDatasource.getPassword()));
DmpAgentDatasourceInfo dsInfo = offlineSynchDao.querySourceDbInfoBySourceId(sourceDbId);
//解码数据库密码
if (StringUtils.isNotBlank(dsInfo.getPassword())) {
dsInfo.setPassword(new BaseService().decode(dsInfo.getPassword(), publicKey));
}
DmpAgentDatasourceInfo dsInfo = this.dsInfoDTO(dmpSyncingDatasource);
if (StringUtils.isNotBlank(targetName))
if (StringUtils.isNotBlank(targetName)) {
dsInfo.setTargetFileName(targetName);
/*DmpAgentResult rst = dmpDsAgentServiceImp.getTableNameList(dsInfo);
}
DmpAgentResult rst = dmpDsAgentServiceImp.getTableNameList(dsInfo);
if (!rst.getCode().val().equals("200")) {
return new JsonResult(rst.getCode(), rst.getMessage());
} else {
rst.setResult(JsonMapper.fromJsonString(rst.getMessage(), List.class));
return new JsonResult(ResultCode.SUCCESS, rst);
}*/
return null;
}
private DmpAgentDatasourceInfo dsInfoDTO(DmpSyncingDatasource body) {
/*DmpSyncingDatasourceType type = dmpSyncingDatasourceTypeService.get(body.getDatasourceType());
DmpAgentDatasourceInfo ds = new DmpAgentDatasourceInfo();
ds.setDatasourceType(type.getDatasourceType());
ds.setDatasourceName(body.getDatasourceName());
ds.setDbName(body.getDbName());
ds.setJdbcUrl(body.getJdbcUrl());
ds.setUserName(body.getUserName());
ds.setPassword(body.getPassword());
ds.setDriverClassName(type.getDriverClassName());
ds.setHost(body.getHost());
ds.setPort(body.getPort());
ds.setDelimiter(body.getDelimiter());
ds.setProtocol(body.getProtocol());
ds.setProjectId(body.getProjectId() + "");
ds.setAccessId(body.getAccessId());
ds.setAccessKey(body.getAccessKey());
ds.setIsHaveHeader(body.getIsHaveHeader());
ds.setEndpoint(body.getEndpoint());
ds.setDefaultFs(body.getDefaultFs());
DmpProjectSystemInfo info = dmpProjectDao.queryProjectSystemInfo(body.getProjectId());
ds.setKerberosIsenable(info.getKerberosIsenable());
ds.setKerberosJaasConf(info.getKerberosJaasConf());
ds.setKerberosKrb5Conf(info.getKerberosKrb5Conf());
ds.setKerberosFqdn(info.getKerberosFqdn());
ds.setHdfsDefaultConf(""); // info.getHdfsDefaultConf());
ds.setHdfsConfPath(""); // info.getHdfsConfPath());
ds.setHdfsAuthPath(body.getAccessKey());
ds.setHdfsUserName(info.getHdfsUserName());
ds.setHdfsSyncingPath(info.getHdfsSyncingPath());
return ds;*/
return null;
}
}
......@@ -92,4 +92,42 @@
dmp_syncing_datasource
WHERE id = #{sourceDbId}
</select>
<select id="querySourceDbInfoBySourceId" parameterType="map" resultType="dmpAgentDatasourceInfo">
SELECT
t1.id,
t1.datasource_name,
t1.datasource_desc,
t1.jdbc_url,
t1.db_name,
t1.user_name,
t1.PASSWORD,
t1.endpoint,
t1.bucket,
t1.access_id,
t1.access_key,
t1.protocol,
t1.HOST,
t1.PORT,
t1.default_fs,
t1.table_schema,
t1.data_status,
t1.create_user_id,
t1.create_time,
t1.update_user_id,
t1.update_time,
t1.project_id,
t2.DATASOURCE_TYPE,
t2.DRIVER_CLASS_NAME,
t3.KERBEROS_ISENABLE,
t3.KERBEROS_KRB5_CONF,
t3.KERBEROS_JAAS_CONF,
t3.KERBEROS_FQDN,
t3.HDFS_USER_NAME,
t3.HDFS_SYNCING_PATH
FROM dmp_syncing_datasource t1
LEFT JOIN dmp_syncing_datasource_type t2 ON t1.datasource_type = t2.ID
LEFT JOIN dmp_project_system_info t3 ON t1.PROJECT_ID = t3.PROJECT_ID AND t3.data_status = '1'
WHERE 1 = 1 AND t1.id = #{sourceDbId}
</select>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment