Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
datax-cloud
Overview
Overview
Details
Activity
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
黄营
datax-cloud
Commits
53c72c3b
Commit
53c72c3b
authored
Mar 14, 2020
by
yuwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
项目初始化
parent
182e8efc
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
412 additions
and
0 deletions
+412
-0
DataSourceDto.java
.../cn/datax/service/data/factory/api/dto/DataSourceDto.java
+41
-0
DataSchema.java
.../cn/datax/service/data/factory/api/entity/DataSchema.java
+11
-0
DataSourceEntity.java
...tax/service/data/factory/api/entity/DataSourceEntity.java
+47
-0
DataSourceQuery.java
...datax/service/data/factory/api/query/DataSourceQuery.java
+20
-0
DataSourceVo.java
...va/cn/datax/service/data/factory/api/vo/DataSourceVo.java
+31
-0
DataSourceController.java
...service/data/factory/controller/DataSourceController.java
+128
-0
DataSourceDao.java
...java/cn/datax/service/data/factory/dao/DataSourceDao.java
+18
-0
DataSourceService.java
...datax/service/data/factory/service/DataSourceService.java
+25
-0
DataSourceServiceImpl.java
...vice/data/factory/service/impl/DataSourceServiceImpl.java
+61
-0
DataSourceMapper.xml
...ry-service/src/main/resources/mapper/DataSourceMapper.xml
+30
-0
No files found.
datax-modules/data-factory-service-parent/data-factory-service-api/src/main/java/cn/datax/service/data/factory/api/dto/DataSourceDto.java
0 → 100644
View file @
53c72c3b
package
cn
.
datax
.
service
.
data
.
factory
.
api
.
dto
;
import
cn.datax.common.validate.ValidateGroupForSave
;
import
cn.datax.common.validate.ValidateGroupForUpdate
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
javax.validation.Valid
;
import
javax.validation.constraints.NotBlank
;
import
java.io.Serializable
;
/**
* <p>
* 数据源信息表 实体DTO
* </p>
*
* @author yuwei
* @since 2020-03-14
*/
@ApiModel
(
value
=
"数据源信息表Model"
)
@Data
public
class
DataSourceDto
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
@ApiModelProperty
(
value
=
"主键ID"
)
@NotBlank
(
message
=
"主键ID不能为空"
,
groups
=
{
ValidateGroupForUpdate
.
class
})
private
String
id
;
@ApiModelProperty
(
value
=
"数据源类型"
)
@NotBlank
(
message
=
"数据源类型不能为空"
,
groups
=
{
ValidateGroupForSave
.
class
,
ValidateGroupForUpdate
.
class
})
private
String
sourceType
;
@ApiModelProperty
(
value
=
"数据源名称"
)
@NotBlank
(
message
=
"数据源名称不能为空"
,
groups
=
{
ValidateGroupForSave
.
class
,
ValidateGroupForUpdate
.
class
})
private
String
sourceName
;
@ApiModelProperty
(
value
=
"数据源描述"
)
@NotBlank
(
message
=
"数据源描述不能为空"
,
groups
=
{
ValidateGroupForSave
.
class
,
ValidateGroupForUpdate
.
class
})
private
String
sourceDesc
;
@ApiModelProperty
(
value
=
"数据源连接信息"
)
@Valid
private
DataSchemaDto
sourceSchema
;
}
datax-modules/data-factory-service-parent/data-factory-service-api/src/main/java/cn/datax/service/data/factory/api/entity/DataSchema.java
View file @
53c72c3b
package
cn
.
datax
.
service
.
data
.
factory
.
api
.
entity
;
import
cn.datax.common.exception.DataException
;
import
cn.hutool.core.util.StrUtil
;
import
lombok.Data
;
import
java.io.Serializable
;
...
...
@@ -12,4 +14,13 @@ public class DataSchema implements Serializable {
private
String
jdbcUrl
;
private
String
username
;
private
String
password
;
/**
* 参数合法性校验
*/
public
void
viald
()
{
if
(
StrUtil
.
isBlank
(
jdbcUrl
)
||
StrUtil
.
isBlank
(
username
)
||
StrUtil
.
isBlank
(
password
))
{
throw
new
DataException
(
"参数不完整"
);
}
}
}
datax-modules/data-factory-service-parent/data-factory-service-api/src/main/java/cn/datax/service/data/factory/api/entity/DataSourceEntity.java
0 → 100644
View file @
53c72c3b
package
cn
.
datax
.
service
.
data
.
factory
.
api
.
entity
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
cn.datax.common.base.BaseEntity
;
import
com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.experimental.Accessors
;
/**
* <p>
* 数据源信息表
* </p>
*
* @author yuwei
* @since 2020-03-14
*/
@Data
@EqualsAndHashCode
(
callSuper
=
true
)
@Accessors
(
chain
=
true
)
@TableName
(
value
=
"data_source"
,
autoResultMap
=
true
)
public
class
DataSourceEntity
extends
BaseEntity
{
private
static
final
long
serialVersionUID
=
1L
;
/**
* 数据源类型
*/
private
String
sourceType
;
/**
* 数据源名称
*/
private
String
sourceName
;
/**
* 数据源描述
*/
private
String
sourceDesc
;
/**
* 数据源连接信息
*/
@TableField
(
typeHandler
=
JacksonTypeHandler
.
class
)
private
DataSchema
sourceSchema
;
}
datax-modules/data-factory-service-parent/data-factory-service-api/src/main/java/cn/datax/service/data/factory/api/query/DataSourceQuery.java
0 → 100644
View file @
53c72c3b
package
cn
.
datax
.
service
.
data
.
factory
.
api
.
query
;
import
cn.datax.common.base.BaseQueryParams
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
/**
* <p>
* 数据源信息表 查询实体
* </p>
*
* @author yuwei
* @since 2020-03-14
*/
@Data
@EqualsAndHashCode
(
callSuper
=
true
)
public
class
DataSourceQuery
extends
BaseQueryParams
{
private
static
final
long
serialVersionUID
=
1L
;
}
datax-modules/data-factory-service-parent/data-factory-service-api/src/main/java/cn/datax/service/data/factory/api/vo/DataSourceVo.java
0 → 100644
View file @
53c72c3b
package
cn
.
datax
.
service
.
data
.
factory
.
api
.
vo
;
import
cn.datax.service.data.factory.api.entity.DataSchema
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.time.LocalDateTime
;
/**
* <p>
* 数据源信息表 实体VO
* </p>
*
* @author yuwei
* @since 2020-03-14
*/
@Data
public
class
DataSourceVo
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
private
String
id
;
private
Integer
status
;
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
LocalDateTime
createTime
;
private
String
sourceType
;
private
String
sourceName
;
private
String
sourceDesc
;
private
DataSchema
sourceSchema
;
}
datax-modules/data-factory-service-parent/data-factory-service/src/main/java/cn/datax/service/data/factory/controller/DataSourceController.java
0 → 100644
View file @
53c72c3b
package
cn
.
datax
.
service
.
data
.
factory
.
controller
;
import
cn.datax.common.core.JsonPage
;
import
cn.datax.common.core.R
;
import
cn.datax.common.validate.ValidateGroupForSave
;
import
cn.datax.common.validate.ValidateGroupForUpdate
;
import
cn.datax.service.data.factory.api.dto.DataSourceDto
;
import
cn.datax.service.data.factory.api.entity.DataSourceEntity
;
import
cn.datax.service.data.factory.api.query.DataSourceQuery
;
import
cn.datax.service.data.factory.api.vo.DataSourceVo
;
import
cn.datax.service.data.factory.mapstruct.DataSourceMapper
;
import
cn.datax.service.data.factory.service.DataSourceService
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
cn.datax.common.base.BaseController
;
import
java.util.List
;
import
java.util.stream.Collectors
;
/**
* <p>
* 数据源信息表 前端控制器
* </p>
*
* @author yuwei
* @since 2020-03-14
*/
@Api
(
tags
=
{
"数据源信息表"
})
@RestController
@RequestMapping
(
"/dataSource"
)
public
class
DataSourceController
extends
BaseController
{
@Autowired
private
DataSourceService
dataSourceService
;
@Autowired
private
DataSourceMapper
dataSourceMapper
;
/**
* 通过ID查询信息
*
* @param id
* @return
*/
@ApiOperation
(
value
=
"获取详细信息"
,
notes
=
"根据url的id来获取详细信息"
)
@ApiImplicitParam
(
name
=
"id"
,
value
=
"ID"
,
required
=
true
,
dataType
=
"String"
,
paramType
=
"path"
)
@GetMapping
(
"/{id}"
)
public
R
getDataSourceById
(
@PathVariable
String
id
)
{
DataSourceEntity
dataSourceEntity
=
dataSourceService
.
getById
(
id
);
return
R
.
ok
().
setData
(
dataSourceMapper
.
toVO
(
dataSourceEntity
));
}
/**
* 分页查询信息
*
* @param dataSourceQuery
* @return
*/
@ApiOperation
(
value
=
"分页查询"
,
notes
=
""
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"dataSourceQuery"
,
value
=
"查询实体dataSourceQuery"
,
required
=
true
,
dataTypeClass
=
DataSourceQuery
.
class
)
})
@GetMapping
(
"/page"
)
public
R
getRolePage
(
DataSourceQuery
dataSourceQuery
)
{
QueryWrapper
<
DataSourceEntity
>
queryWrapper
=
new
QueryWrapper
<>();
IPage
<
DataSourceEntity
>
page
=
dataSourceService
.
page
(
new
Page
<>(
dataSourceQuery
.
getPageNum
(),
dataSourceQuery
.
getPageSize
()),
queryWrapper
);
List
<
DataSourceVo
>
collect
=
page
.
getRecords
().
stream
().
map
(
dataSourceMapper:
:
toVO
).
collect
(
Collectors
.
toList
());
JsonPage
<
DataSourceVo
>
jsonPage
=
new
JsonPage
<>(
page
.
getCurrent
(),
page
.
getSize
(),
page
.
getTotal
(),
collect
);
return
R
.
ok
().
setData
(
jsonPage
);
}
/**
* 添加
* @param dataSource
* @return
*/
@ApiOperation
(
value
=
"添加信息"
,
notes
=
"根据dataSource对象添加信息"
)
@ApiImplicitParam
(
name
=
"dataSource"
,
value
=
"详细实体dataSource"
,
required
=
true
,
dataType
=
"DataSourceDto"
)
@PostMapping
()
public
R
saveDataSource
(
@RequestBody
@Validated
({
ValidateGroupForSave
.
class
})
DataSourceDto
dataSource
)
{
dataSourceService
.
saveDataSource
(
dataSource
);
return
R
.
ok
();
}
/**
* 修改
* @param dataSource
* @return
*/
@ApiOperation
(
value
=
"修改信息"
,
notes
=
"根据url的id来指定修改对象,并根据传过来的信息来修改详细信息"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"id"
,
value
=
"ID"
,
required
=
true
,
dataType
=
"String"
,
paramType
=
"path"
),
@ApiImplicitParam
(
name
=
"dataSource"
,
value
=
"详细实体dataSource"
,
required
=
true
,
dataType
=
"DataSourceDto"
)
})
@PutMapping
(
"/{id}"
)
public
R
updateDataSource
(
@PathVariable
String
id
,
@RequestBody
@Validated
({
ValidateGroupForUpdate
.
class
})
DataSourceDto
dataSource
)
{
dataSourceService
.
updateDataSource
(
dataSource
);
return
R
.
ok
();
}
/**
* 删除
* @param id
* @return
*/
@ApiOperation
(
value
=
"删除"
,
notes
=
"根据url的id来指定删除对象"
)
@ApiImplicitParam
(
name
=
"id"
,
value
=
"ID"
,
required
=
true
,
dataType
=
"String"
,
paramType
=
"path"
)
@DeleteMapping
(
"/{id}"
)
public
R
deleteDataSourceById
(
@PathVariable
String
id
)
{
dataSourceService
.
deleteDataSourceById
(
id
);
return
R
.
ok
();
}
@PostMapping
(
"/checkConnection"
)
public
R
checkConnection
(
@RequestBody
@Validated
({
ValidateGroupForSave
.
class
})
DataSourceDto
dataSource
)
{
R
r
=
dataSourceService
.
checkConnection
(
dataSource
);
return
r
;
}
}
datax-modules/data-factory-service-parent/data-factory-service/src/main/java/cn/datax/service/data/factory/dao/DataSourceDao.java
0 → 100644
View file @
53c72c3b
package
cn
.
datax
.
service
.
data
.
factory
.
dao
;
import
cn.datax.common.base.BaseDao
;
import
cn.datax.service.data.factory.api.entity.DataSourceEntity
;
import
org.apache.ibatis.annotations.Mapper
;
/**
* <p>
* 数据源信息表 Mapper 接口
* </p>
*
* @author yuwei
* @since 2020-03-14
*/
@Mapper
public
interface
DataSourceDao
extends
BaseDao
<
DataSourceEntity
>
{
}
datax-modules/data-factory-service-parent/data-factory-service/src/main/java/cn/datax/service/data/factory/service/DataSourceService.java
0 → 100644
View file @
53c72c3b
package
cn
.
datax
.
service
.
data
.
factory
.
service
;
import
cn.datax.common.core.R
;
import
cn.datax.service.data.factory.api.dto.DataSourceDto
;
import
cn.datax.service.data.factory.api.entity.DataSourceEntity
;
import
cn.datax.common.base.BaseService
;
/**
* <p>
* 数据源信息表 服务类
* </p>
*
* @author yuwei
* @since 2020-03-14
*/
public
interface
DataSourceService
extends
BaseService
<
DataSourceEntity
>
{
void
saveDataSource
(
DataSourceDto
dataSource
);
void
updateDataSource
(
DataSourceDto
dataSource
);
void
deleteDataSourceById
(
String
id
);
R
checkConnection
(
DataSourceDto
dataSource
);
}
datax-modules/data-factory-service-parent/data-factory-service/src/main/java/cn/datax/service/data/factory/service/impl/DataSourceServiceImpl.java
0 → 100644
View file @
53c72c3b
package
cn
.
datax
.
service
.
data
.
factory
.
service
.
impl
;
import
cn.datax.common.core.R
;
import
cn.datax.service.data.factory.api.dto.DataSourceDto
;
import
cn.datax.service.data.factory.api.entity.DataSchema
;
import
cn.datax.service.data.factory.api.entity.DataSourceEntity
;
import
cn.datax.service.data.factory.dao.DataSourceDao
;
import
cn.datax.service.data.factory.service.DataSourceService
;
import
cn.datax.service.data.factory.mapstruct.DataSourceMapper
;
import
cn.datax.common.base.BaseServiceImpl
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
/**
* <p>
* 数据源信息表 服务实现类
* </p>
*
* @author yuwei
* @since 2020-03-14
*/
@Service
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
readOnly
=
true
,
rollbackFor
=
Exception
.
class
)
public
class
DataSourceServiceImpl
extends
BaseServiceImpl
<
DataSourceDao
,
DataSourceEntity
>
implements
DataSourceService
{
@Autowired
private
DataSourceDao
dataSourceDao
;
@Autowired
private
DataSourceMapper
dataSourceMapper
;
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
saveDataSource
(
DataSourceDto
dataSourceDto
)
{
DataSourceEntity
dataSource
=
dataSourceMapper
.
toEntity
(
dataSourceDto
);
dataSourceDao
.
insert
(
dataSource
);
}
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
updateDataSource
(
DataSourceDto
dataSourceDto
)
{
DataSourceEntity
dataSource
=
dataSourceMapper
.
toEntity
(
dataSourceDto
);
dataSourceDao
.
updateById
(
dataSource
);
}
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
deleteDataSourceById
(
String
id
)
{
dataSourceDao
.
deleteById
(
id
);
}
@Override
public
R
checkConnection
(
DataSourceDto
dataSourceDto
)
{
DataSourceEntity
dataSource
=
dataSourceMapper
.
toEntity
(
dataSourceDto
);
DataSchema
sourceSchema
=
dataSource
.
getSourceSchema
();
sourceSchema
.
viald
();
return
null
;
}
}
datax-modules/data-factory-service-parent/data-factory-service/src/main/resources/mapper/DataSourceMapper.xml
0 → 100644
View file @
53c72c3b
<?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=
"cn.datax.service.data.factory.dao.DataSourceDao"
>
<!-- 通用查询映射结果 -->
<resultMap
id=
"BaseResultMap"
type=
"cn.datax.service.data.factory.api.entity.DataSourceEntity"
>
<result
column=
"id"
property=
"id"
/>
<result
column=
"status"
property=
"status"
/>
<result
column=
"create_by"
property=
"createBy"
/>
<result
column=
"create_time"
property=
"createTime"
/>
<result
column=
"update_by"
property=
"updateBy"
/>
<result
column=
"update_time"
property=
"updateTime"
/>
<result
column=
"source_type"
property=
"sourceType"
/>
<result
column=
"source_name"
property=
"sourceName"
/>
<result
column=
"source_desc"
property=
"sourceDesc"
/>
<result
column=
"source_schema"
property=
"sourceSchema"
typeHandler=
"com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler"
/>
</resultMap>
<!-- 通用查询结果列 -->
<sql
id=
"Base_Column_List"
>
id,
status,
create_by,
create_time,
update_by,
update_time,
source_type, source_name, source_desc, source_schema
</sql>
</mapper>
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