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
43c219ba
Commit
43c219ba
authored
Dec 25, 2020
by
mcb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
数据源编辑
parent
1418cbfc
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
120 additions
and
13 deletions
+120
-13
DataSourceController.java
...ules/controller/DataIntegration/DataSourceController.java
+37
-1
DmpSyncingDatasourceReq.java
...troller/DataIntegration/bean/DmpSyncingDatasourceReq.java
+11
-9
DmpSyncingDatasourceDao.java
.../java/com/jz/dmp/modules/dao/DmpSyncingDatasourceDao.java
+5
-2
DmpSyncingDatasourceService.java
...m/jz/dmp/modules/service/DmpSyncingDatasourceService.java
+5
-0
DmpSyncingDatasourceServiceImpl.java
...modules/service/impl/DmpSyncingDatasourceServiceImpl.java
+38
-1
DmpSyncingDatasourceDao.xml
src/main/resources/mapper/dmp/DmpSyncingDatasourceDao.xml
+24
-0
No files found.
src/main/java/com/jz/dmp/modules/controller/DataIntegration/DataSourceController.java
View file @
43c219ba
...
...
@@ -20,6 +20,8 @@ import org.springframework.validation.annotation.Validated;
import
org.springframework.web.bind.annotation.*
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* @Description:数据源
...
...
@@ -68,7 +70,7 @@ public class DataSourceController {
@ApiOperation
(
value
=
"批量删除数据源"
,
notes
=
"批量删除数据源"
)
@GetMapping
(
value
=
"/delDataSource"
)
public
JsonResult
delDataSource
(
@RequestParam
String
datasourceId
,
HttpServletRequest
httpRequest
)
throws
Exception
{
if
(
StringUtils
.
isEmpty
(
datasourceId
))
{
if
(
StringUtils
.
isEmpty
(
datasourceId
))
{
return
new
JsonResult
(
ResultCode
.
PARAMS_ERROR
);
}
JsonResult
result
=
dmpSyncingDatasourceService
.
delDataSourceById
(
datasourceId
);
...
...
@@ -122,4 +124,38 @@ public class DataSourceController {
JsonResult
result
=
dmpSyncingDatasourceService
.
testConnection
(
saveBody
);
return
result
;
}
/**
* 编辑数据源,根据id查询数据回显
*
* @return
*/
@ApiOperation
(
value
=
"编辑数据源--根据id查询数据回显"
,
notes
=
"编辑数据源--根据id查询数据回显"
)
@GetMapping
(
value
=
"/selectDataSourceInfoById"
)
public
JsonResult
getDataSourceInfoById
(
@RequestParam
String
datasourceId
,
@RequestParam
(
value
=
"projectId"
,
required
=
false
)
String
projectId
)
throws
Exception
{
if
(
StringUtils
.
isEmpty
(
datasourceId
))
{
return
new
JsonResult
(
ResultCode
.
PARAMS_ERROR
);
}
Map
map
=
new
HashMap
();
map
.
put
(
"datasourceId"
,
datasourceId
);
map
.
put
(
"projectId"
,
projectId
);
JsonResult
result
=
dmpSyncingDatasourceService
.
selectDataSourceInfoById
(
map
);
return
result
;
}
/**
* 编辑数据源
*
* @return
*/
@ApiOperation
(
value
=
"编辑数据源"
,
notes
=
"编辑数据源"
)
@PostMapping
(
value
=
"/updateDatasourceInfo"
)
public
JsonResult
updateDatasourceInfo
(
@RequestBody
@Validated
DmpSyncingDatasourceReq
saveBody
,
HttpServletRequest
httpRequest
)
throws
Exception
{
if
(
StringUtils
.
isEmpty
(
saveBody
.
getDatasourceId
()))
{
return
new
JsonResult
(
ResultCode
.
PARAMS_ERROR
);
}
JsonResult
result
=
dmpSyncingDatasourceService
.
updateDatasourceById
(
saveBody
);
return
result
;
}
}
src/main/java/com/jz/dmp/modules/controller/DataIntegration/bean/DmpSyncingDatasourceReq.java
View file @
43c219ba
...
...
@@ -20,12 +20,10 @@ public class DmpSyncingDatasourceReq implements Serializable {
* 数据源ID
*/
@ApiModelProperty
(
value
=
"数据源ID"
)
private
String
i
d
;
private
String
datasourceI
d
;
/**
* 数据源类型ID
*/
@NotNull
(
message
=
"数据源类型ID不能为空"
)
@NotEmpty
(
message
=
"数据源类型ID不能为空"
)
@ApiModelProperty
(
value
=
"数据源类型ID"
)
private
String
datasourceType
;
/**
...
...
@@ -43,6 +41,8 @@ public class DmpSyncingDatasourceReq implements Serializable {
/**
* JDBC URL
*/
@NotNull
(
message
=
"JDBC URL不能为空"
)
@NotEmpty
(
message
=
"JDBC URL不能为空"
)
@ApiModelProperty
(
value
=
"JDBC URL"
)
private
String
jdbcUrl
;
/**
...
...
@@ -53,11 +53,15 @@ public class DmpSyncingDatasourceReq implements Serializable {
/**
* 账号
*/
@NotNull
(
message
=
"账号不能为空"
)
@NotEmpty
(
message
=
"账号不能为空"
)
@ApiModelProperty
(
value
=
"账号"
)
private
String
userName
;
/**
* 密码
*/
@NotNull
(
message
=
"密码不能为空"
)
@NotEmpty
(
message
=
"密码不能为空"
)
@ApiModelProperty
(
value
=
"密码"
)
private
String
password
;
/**
...
...
@@ -109,8 +113,6 @@ public class DmpSyncingDatasourceReq implements Serializable {
/**
* 项目ID
*/
@NotNull
(
message
=
"项目ID不能为空"
)
@NotEmpty
(
message
=
"项目ID不能为空"
)
@ApiModelProperty
(
value
=
"项目ID"
)
private
String
projectId
;
...
...
@@ -121,12 +123,12 @@ public class DmpSyncingDatasourceReq implements Serializable {
@ApiModelProperty
(
value
=
"网络连接类型"
)
private
String
networkConnectionType
;
public
String
getId
()
{
return
i
d
;
public
String
get
Datasource
Id
()
{
return
datasourceI
d
;
}
public
void
set
Id
(
String
i
d
)
{
this
.
id
=
i
d
;
public
void
set
DatasourceId
(
String
datasourceI
d
)
{
this
.
datasourceId
=
datasourceI
d
;
}
public
String
getDatasourceType
()
{
...
...
src/main/java/com/jz/dmp/modules/dao/DmpSyncingDatasourceDao.java
View file @
43c219ba
...
...
@@ -97,7 +97,10 @@ public interface DmpSyncingDatasourceDao {
List
<
Map
>
queryGroupDatasourceType
()
throws
Exception
;
int
countDatasourceByName
(
@Param
(
"datasourceName"
)
String
datasourceName
,
@Param
(
"projectId"
)
String
projectId
);
int
countDatasourceByName
(
@Param
(
"datasourceName"
)
String
datasourceName
,
@Param
(
"projectId"
)
String
projectId
)
throws
Exception
;
DmpSyncingDatasourceType
queryDatasourceTypeById
(
@Param
(
"datasourceTypeId"
)
String
datasourceTypeId
)
throws
Exception
;
DataSourceListDto
selectDataSourceInfoById
(
Map
map
)
throws
Exception
;
DmpSyncingDatasourceType
queryDatasourceTypeById
(
@Param
(
"datasourceTypeId"
)
String
datasourceTypeId
);
}
\ No newline at end of file
src/main/java/com/jz/dmp/modules/service/DmpSyncingDatasourceService.java
View file @
43c219ba
...
...
@@ -10,6 +10,7 @@ import com.jz.dmp.modules.model.DmpSyncingDatasource;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.List
;
import
java.util.Map
;
/**
* 数据源配置(DmpSyncingDatasource)表服务接口
...
...
@@ -71,4 +72,8 @@ public interface DmpSyncingDatasourceService {
JsonResult
addDatasourceInfo
(
DmpSyncingDatasourceReq
saveBody
)
throws
Exception
;
JsonResult
testConnection
(
DmpSyncingDatasourceReq
saveBody
)
throws
Exception
;
JsonResult
selectDataSourceInfoById
(
Map
map
)
throws
Exception
;
JsonResult
updateDatasourceById
(
DmpSyncingDatasourceReq
saveBody
)
throws
Exception
;
}
\ No newline at end of file
src/main/java/com/jz/dmp/modules/service/impl/DmpSyncingDatasourceServiceImpl.java
View file @
43c219ba
...
...
@@ -220,7 +220,44 @@ public class DmpSyncingDatasourceServiceImpl implements DmpSyncingDatasourceServ
}
}
private
DmpAgentDatasourceInfo
dsInfoDTO
(
DmpSyncingDatasourceReq
body
)
{
@Override
public
JsonResult
selectDataSourceInfoById
(
Map
map
)
throws
Exception
{
DataSourceListDto
asd
=
dmpSyncingDatasourceDao
.
selectDataSourceInfoById
(
map
);
return
new
JsonResult
(
asd
);
}
/**
* 编辑数据源
*
* @return
*/
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
,
propagation
=
Propagation
.
REQUIRES_NEW
)
public
JsonResult
updateDatasourceById
(
DmpSyncingDatasourceReq
saveBody
)
throws
Exception
{
DmpSyncingDatasource
dsd
=
new
DmpSyncingDatasource
();
BeanUtils
.
copyProperties
(
saveBody
,
dsd
);
dsd
.
setUpdateTime
(
new
Date
());
if
(
StringUtils
.
isNotEmpty
(
saveBody
.
getDatasourceType
()))
{
dsd
.
setDatasourceType
(
Integer
.
valueOf
(
saveBody
.
getDatasourceType
()));
//数据源类型ID
}
if
(
StringUtils
.
isNotEmpty
(
saveBody
.
getProjectId
()))
{
dsd
.
setProjectId
(
Integer
.
valueOf
(
saveBody
.
getProjectId
()));
}
if
(
StringUtils
.
isNotEmpty
(
saveBody
.
getDatasourceId
())){
//数据源id
dsd
.
setId
(
Integer
.
valueOf
(
saveBody
.
getDatasourceId
()));
}
dsd
.
setDataStatus
(
"1"
);
int
len
=
dmpSyncingDatasourceDao
.
update
(
dsd
);
if
(
len
>
0
)
{
return
new
JsonResult
();
}
else
{
return
new
JsonResult
(
ResultCode
.
INTERNAL_SERVER_ERROR
);
}
}
private
DmpAgentDatasourceInfo
dsInfoDTO
(
DmpSyncingDatasourceReq
body
)
throws
Exception
{
//数据源类型ID去查询
DmpSyncingDatasourceType
type
=
dmpSyncingDatasourceDao
.
queryDatasourceTypeById
(
body
.
getDatasourceType
());
DmpAgentDatasourceInfo
ds
=
new
DmpAgentDatasourceInfo
();
...
...
src/main/resources/mapper/dmp/DmpSyncingDatasourceDao.xml
View file @
43c219ba
...
...
@@ -238,6 +238,9 @@
<if
test=
"projectId != null"
>
PROJECT_ID = #{projectId},
</if>
<if
test=
"networkConnectionType != null"
>
NETWORK_CONNECTION_TYPE = #{networkConnectionType},
</if>
</set>
where ID = #{id}
</update>
...
...
@@ -325,4 +328,25 @@
where id=#{datasourceTypeId}
</select>
<!--数据源列表查询-->
<select
id=
"selectDataSourceInfoById"
parameterType=
"map"
resultType=
"com.jz.dmp.modules.controller.DataIntegration.bean.DataSourceListDto"
>
select
b.datasource_catecode as datasourceCatecode,
b.datasource_type as datasourceTypeName,
a.datasource_name as datasourceName,
a.datasource_desc as datasourceDesc,
a.id as id,
a.datasource_type as datasourceTypeId,
a.jdbc_url as jdbcUrl,
a.db_name as dbName,
a.user_name as userName,
a.project_id as projectId
from dmp_syncing_datasource a
left join dmp_syncing_datasource_type b on a.datasource_type = b.id
where a.data_status = '1'
and a.id =#{datasourceId}
<if
test=
"projectId != null and projectId !=''"
>
and a.project_id = #{projectId}
</if>
</select>
</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