Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jz-dmp-service
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
姚本章
jz-dmp-service
Commits
a81458f4
Commit
a81458f4
authored
Dec 22, 2020
by
mcb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
源数据表 查询
parent
8c0cdf1e
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
90 additions
and
54 deletions
+90
-54
pom.xml
pom.xml
+21
-0
JsonResult.java
src/main/java/com/jz/common/constant/JsonResult.java
+3
-0
BaseService.java
src/main/java/com/jz/common/persistence/BaseService.java
+5
-4
OfflineSynchController.java
...es/controller/DataIntegration/OfflineSynchController.java
+1
-1
OfflineSynchDao.java
src/main/java/com/jz/dmp/modules/dao/OfflineSynchDao.java
+3
-0
OfflineSynchService.java
.../java/com/jz/dmp/modules/service/OfflineSynchService.java
+1
-1
OfflineSynchServiceImpl.java
.../jz/dmp/modules/service/impl/OfflineSynchServiceImpl.java
+18
-48
OfflineSynchMapper.xml
src/main/resources/mapper/dmp/OfflineSynchMapper.xml
+38
-0
No files found.
pom.xml
View file @
a81458f4
...
@@ -221,6 +221,27 @@
...
@@ -221,6 +221,27 @@
<artifactId>
hibernate-validator
</artifactId>
<artifactId>
hibernate-validator
</artifactId>
<version>
6.1.6.Final
</version>
<version>
6.1.6.Final
</version>
</dependency>
</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>
</dependencies>
<build>
<build>
...
...
src/main/java/com/jz/common/constant/JsonResult.java
View file @
a81458f4
...
@@ -53,6 +53,9 @@ public class JsonResult<T> {
...
@@ -53,6 +53,9 @@ public class JsonResult<T> {
this
.
setData
(
data
);
this
.
setData
(
data
);
}
}
public
JsonResult
(
com
.
jz
.
dmp
.
agent
.
ResultCode
code
,
String
message
)
{
}
public
String
getCode
()
{
public
String
getCode
()
{
return
code
;
return
code
;
}
}
...
...
src/main/java/com/jz/common/persistence/BaseService.java
View file @
a81458f4
...
@@ -4,6 +4,7 @@ import org.apache.commons.lang3.StringUtils;
...
@@ -4,6 +4,7 @@ import org.apache.commons.lang3.StringUtils;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.crypto.Cipher
;
import
javax.crypto.Cipher
;
...
@@ -18,8 +19,8 @@ public class BaseService {
...
@@ -18,8 +19,8 @@ public class BaseService {
protected
Logger
logger
=
LoggerFactory
.
getLogger
(
getClass
());
protected
Logger
logger
=
LoggerFactory
.
getLogger
(
getClass
());
@Value
(
"${spring.public-key}"
)
/*
@Value("${spring.public-key}")
private
String
publicKey
;
private String publicKey;
*/
public
BigDecimal
format
(
Object
obj
)
{
public
BigDecimal
format
(
Object
obj
)
{
BigDecimal
bak
=
new
BigDecimal
(
0
);
BigDecimal
bak
=
new
BigDecimal
(
0
);
...
@@ -41,7 +42,7 @@ public class BaseService {
...
@@ -41,7 +42,7 @@ public class BaseService {
return
bak
;
return
bak
;
}
}
public
String
encode
(
String
pass
)
{
public
String
encode
(
String
pass
,
String
publicKey
)
{
String
str
=
""
;
String
str
=
""
;
try
{
try
{
Key
key
=
new
SecretKeySpec
(
Base64
.
getMimeDecoder
().
decode
(
publicKey
),
"DESede"
);
Key
key
=
new
SecretKeySpec
(
Base64
.
getMimeDecoder
().
decode
(
publicKey
),
"DESede"
);
...
@@ -54,7 +55,7 @@ public class BaseService {
...
@@ -54,7 +55,7 @@ public class BaseService {
return
str
;
return
str
;
}
}
public
String
decode
(
String
pass
)
{
public
String
decode
(
String
pass
,
String
publicKey
)
{
String
str
=
""
;
String
str
=
""
;
try
{
try
{
Key
key
=
new
SecretKeySpec
(
Base64
.
getMimeDecoder
().
decode
(
publicKey
),
"DESede"
);
Key
key
=
new
SecretKeySpec
(
Base64
.
getMimeDecoder
().
decode
(
publicKey
),
"DESede"
);
...
...
src/main/java/com/jz/dmp/modules/controller/DataIntegration/OfflineSynchController.java
View file @
a81458f4
...
@@ -73,7 +73,7 @@ public class OfflineSynchController {
...
@@ -73,7 +73,7 @@ public class OfflineSynchController {
@GetMapping
(
value
=
"/sourceTableList"
)
@GetMapping
(
value
=
"/sourceTableList"
)
@ApiImplicitParam
(
name
=
"sourceDbId"
,
value
=
"源数据库id"
)
@ApiImplicitParam
(
name
=
"sourceDbId"
,
value
=
"源数据库id"
)
public
JsonResult
getSourceTableList
(
@RequestParam
Integer
sourceDbId
,
@RequestParam
(
value
=
"targetName"
,
required
=
false
)
String
targetName
)
throws
Exception
{
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
);
return
new
JsonResult
(
ResultCode
.
SUCCESS
,
list
);
}
}
}
}
src/main/java/com/jz/dmp/modules/dao/OfflineSynchDao.java
View file @
a81458f4
...
@@ -3,6 +3,7 @@ package com.jz.dmp.modules.dao;
...
@@ -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.SourceDbNameListDto
;
import
com.jz.dmp.modules.controller.DataIntegration.bean.TaskListPageDto
;
import
com.jz.dmp.modules.controller.DataIntegration.bean.TaskListPageDto
;
import
com.jz.dmp.modules.controller.DataIntegration.bean.TaskListPageReq
;
import
com.jz.dmp.modules.controller.DataIntegration.bean.TaskListPageReq
;
import
com.jz.dmp.modules.model.DmpAgentDatasourceInfo
;
import
com.jz.dmp.modules.model.DmpSyncingDatasource
;
import
com.jz.dmp.modules.model.DmpSyncingDatasource
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Param
;
...
@@ -20,4 +21,6 @@ public interface OfflineSynchDao {
...
@@ -20,4 +21,6 @@ public interface OfflineSynchDao {
List
<
SourceDbNameListDto
>
querygSourceDbList
(
Map
map
)
throws
Exception
;
List
<
SourceDbNameListDto
>
querygSourceDbList
(
Map
map
)
throws
Exception
;
DmpSyncingDatasource
queryDmpSyncingDatasource
(
@Param
(
"sourceDbId"
)
Integer
sourceDbId
)
throws
Exception
;
DmpSyncingDatasource
queryDmpSyncingDatasource
(
@Param
(
"sourceDbId"
)
Integer
sourceDbId
)
throws
Exception
;
DmpAgentDatasourceInfo
querySourceDbInfoBySourceId
(
@Param
(
"sourceDbId"
)
Integer
sourceDbId
)
throws
Exception
;
}
}
\ No newline at end of file
src/main/java/com/jz/dmp/modules/service/OfflineSynchService.java
View file @
a81458f4
...
@@ -21,5 +21,5 @@ public interface OfflineSynchService {
...
@@ -21,5 +21,5 @@ public interface OfflineSynchService {
JsonResult
querygSourceDbList
(
Integer
projectId
)
throws
Exception
;
JsonResult
querygSourceDbList
(
Integer
projectId
)
throws
Exception
;
List
<
Map
>
querygSourceTableList
(
Integer
sourceDbId
,
String
targetName
)
throws
Exception
;
JsonResult
querygSourceTableList
(
Integer
sourceDbId
,
String
targetName
)
throws
Exception
;
}
}
src/main/java/com/jz/dmp/modules/service/impl/OfflineSynchServiceImpl.java
View file @
a81458f4
package
com
.
jz
.
dmp
.
modules
.
service
.
impl
;
package
com
.
jz
.
dmp
.
modules
.
service
.
impl
;
import
com.fasterxml.jackson.databind.json.JsonMapper
;
import
com.github.pagehelper.PageHelper
;
import
com.github.pagehelper.PageHelper
;
import
com.github.pagehelper.PageInfo
;
import
com.github.pagehelper.PageInfo
;
import
com.jz.agent.service.DmpDsAgentService
;
import
com.jz.common.constant.JsonResult
;
import
com.jz.common.constant.JsonResult
;
import
com.jz.common.constant.ResultCode
;
import
com.jz.common.constant.ResultCode
;
import
com.jz.common.page.PageInfoResponse
;
import
com.jz.common.page.PageInfoResponse
;
import
com.jz.common.persistence.BaseService
;
import
com.jz.common.persistence.BaseService
;
import
com.jz.common.utils.JsonMapper
;
import
com.jz.dmp.agent.DmpAgentResult
;
import
com.jz.dmp.agent.DmpAgentResult
;
import
com.jz.dmp.modules.controller.DataIntegration.bean.SourceDbNameListDto
;
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.TaskListPageDto
;
...
@@ -14,12 +15,10 @@ import com.jz.dmp.modules.controller.DataIntegration.bean.TaskListPageReq;
...
@@ -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.DmpProjectDao
;
import
com.jz.dmp.modules.dao.OfflineSynchDao
;
import
com.jz.dmp.modules.dao.OfflineSynchDao
;
import
com.jz.dmp.modules.model.DmpAgentDatasourceInfo
;
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
com.jz.dmp.modules.service.OfflineSynchService
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
...
@@ -38,12 +37,18 @@ import java.util.Map;
...
@@ -38,12 +37,18 @@ import java.util.Map;
@Transactional
@Transactional
public
class
OfflineSynchServiceImpl
implements
OfflineSynchService
{
public
class
OfflineSynchServiceImpl
implements
OfflineSynchService
{
@Value
(
"${spring.public-key}"
)
private
String
publicKey
;
@Autowired
@Autowired
private
OfflineSynchDao
offlineSynchDao
;
private
OfflineSynchDao
offlineSynchDao
;
@Autowired
@Autowired
private
DmpProjectDao
dmpProjectDao
;
private
DmpProjectDao
dmpProjectDao
;
@Autowired
private
DmpDsAgentService
dmpDsAgentServiceImp
;
@Override
@Override
public
PageInfoResponse
<
TaskListPageDto
>
queryTaskListPage
(
TaskListPageReq
taskListPageReq
)
throws
Exception
{
public
PageInfoResponse
<
TaskListPageDto
>
queryTaskListPage
(
TaskListPageReq
taskListPageReq
)
throws
Exception
{
PageInfoResponse
<
TaskListPageDto
>
pageInfoResponse
=
new
PageInfoResponse
<>();
PageInfoResponse
<
TaskListPageDto
>
pageInfoResponse
=
new
PageInfoResponse
<>();
...
@@ -72,58 +77,23 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
...
@@ -72,58 +77,23 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
}
}
@Override
@Override
public
List
<
Map
>
querygSourceTableList
(
Integer
sourceDbId
,
String
targetName
)
throws
Exception
{
public
JsonResult
querygSourceTableList
(
Integer
sourceDbId
,
String
targetName
)
throws
Exception
{
//通过源数据库id ,查询数据源配置
//通过源数据库id ,查询数据源配置
Dmp
SyncingDatasource
dmpSyncingDatasource
=
offlineSynchDao
.
queryDmpSyncingDatasource
(
sourceDbId
);
Dmp
AgentDatasourceInfo
dsInfo
=
offlineSynchDao
.
querySourceDbInfoBySourceId
(
sourceDbId
);
//解码数据库密码
if
(
StringUtils
.
isNotBlank
(
d
mpSyncingDatasource
.
getPassword
()))
{
if
(
StringUtils
.
isNotBlank
(
d
sInfo
.
getPassword
()))
{
d
mpSyncingDatasource
.
setPassword
(
new
BaseService
().
decode
(
dmpSyncingDatasource
.
getPassword
()
));
d
sInfo
.
setPassword
(
new
BaseService
().
decode
(
dsInfo
.
getPassword
(),
publicKey
));
}
}
DmpAgentDatasourceInfo
dsInfo
=
this
.
dsInfoDTO
(
dmpSyncingDatasource
);
if
(
StringUtils
.
isNotBlank
(
targetName
))
{
if
(
StringUtils
.
isNotBlank
(
targetName
))
dsInfo
.
setTargetFileName
(
targetName
);
dsInfo
.
setTargetFileName
(
targetName
);
/*DmpAgentResult rst = dmpDsAgentServiceImp.getTableNameList(dsInfo);
}
DmpAgentResult
rst
=
dmpDsAgentServiceImp
.
getTableNameList
(
dsInfo
);
if
(!
rst
.
getCode
().
val
().
equals
(
"200"
))
{
if
(!
rst
.
getCode
().
val
().
equals
(
"200"
))
{
return
new
JsonResult
(
rst
.
getCode
(),
rst
.
getMessage
());
return
new
JsonResult
(
rst
.
getCode
(),
rst
.
getMessage
());
}
else
{
}
else
{
rst
.
setResult
(
JsonMapper
.
fromJsonString
(
rst
.
getMessage
(),
List
.
class
));
rst
.
setResult
(
JsonMapper
.
fromJsonString
(
rst
.
getMessage
(),
List
.
class
));
return
new
JsonResult
(
ResultCode
.
SUCCESS
,
rst
);
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
;
}
}
}
}
src/main/resources/mapper/dmp/OfflineSynchMapper.xml
View file @
a81458f4
...
@@ -92,4 +92,42 @@
...
@@ -92,4 +92,42 @@
dmp_syncing_datasource
dmp_syncing_datasource
WHERE id = #{sourceDbId}
WHERE id = #{sourceDbId}
</select>
</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>
</mapper>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment