Commit 58d6a611 authored by mcb's avatar mcb

数据源列表查询

parent 9f6b65bf
package com.jz.dmp.modules.controller.DataIntegration; package com.jz.dmp.modules.controller.DataIntegration;
import com.jz.common.constant.JsonResult; import com.jz.common.constant.JsonResult;
import com.jz.common.constant.ResultCode;
import com.jz.common.page.BasePageBean;
import com.jz.common.page.PageInfoResponse;
import com.jz.dmp.modules.controller.DataIntegration.bean.DataSourceListDto;
import com.jz.dmp.modules.controller.DataIntegration.bean.DataSourceListReq;
import com.jz.dmp.modules.controller.DataIntegration.bean.DvRuleTDto;
import com.jz.dmp.modules.service.DmpSyncingDatasourceService;
import com.jz.dmp.modules.service.OfflineSynchService; import com.jz.dmp.modules.service.OfflineSynchService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
/** /**
* @Description:数据源 * @Description:数据源
* @ClassName: DataSourceController * @ClassName: DataSourceController
...@@ -16,20 +27,34 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -16,20 +27,34 @@ import org.springframework.web.bind.annotation.RestController;
* @Date 2020/12/20 * @Date 2020/12/20
*/ */
@RestController @RestController
@RequestMapping("/dataSource") @RequestMapping("/dataSourceMange")
@Api(tags = "数据集成--数据源") @Api(tags = "数据集成--数据源")
public class DataSourceController { public class DataSourceController {
@Autowired
private OfflineSynchService offlineSynchService;
/** @Autowired
* 数据源列表分页查询 private DmpSyncingDatasourceService dmpSyncingDatasourceService;
* @return
*/ /**
@ApiOperation(value = "数据源列表分页查询", notes = "数据源列表分页查询") * 数据源列表分页查询
@PostMapping(value = "/delRedisKeys") *
public JsonResult delRedisKeys(String key) { * @return
return new JsonResult(); */
} @ApiOperation(value = "数据源列表分页查询", notes = "数据源列表分页查询")
@PostMapping(value = "/dataSourceListPage")
public PageInfoResponse<DataSourceListDto> getDataSourceListPage(@RequestBody DataSourceListReq req, HttpServletRequest httpRequest) throws Exception {
PageInfoResponse<DataSourceListDto> pageInfo = new PageInfoResponse<DataSourceListDto>();
if (StringUtils.isEmpty(req.getProjectId())) {
pageInfo.setMessage("项目id不能为空!");
pageInfo.setCode(ResultCode.PARAMS_ERROR);
return pageInfo;
}
try {
pageInfo = dmpSyncingDatasourceService.queryDataSourceListPage(req, httpRequest);
} catch (Exception e) {
pageInfo.setMessage("查询失败");
pageInfo.setCode(ResultCode.INTERNAL_SERVER_ERROR);
e.printStackTrace();
}
return pageInfo;
}
} }
package com.jz.dmp.modules.controller.DataIntegration.bean;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.math.BigDecimal;
/**
* @ClassName: DataSourceListDto
* @Description: 数据源列表返回参数对象
* @Author:Bellamy
* @Date 2020/12/24
* @Version 1.0
*/
@ApiModel(value = "数据源列表返回参数对象", description = "数据源列表返回参数对象")
public class DataSourceListDto {
/**
* 数据源id
*/
@ApiModelProperty(value = "数据源id")
private Long id;
/**
* 数据源名称
*/
@ApiModelProperty(value = "数据源名称")
private String datasourceName;
/**
* 数据源类型名称
*/
@ApiModelProperty(value = "数据源类型名称")
private String datasourceTypeName;
/**
* 数据源类型id
*/
@ApiModelProperty(value = "数据源类型id")
private String datasourceTypeId;
/**
* 数据源分类
*/
@ApiModelProperty(value = "数据源分类")
private String datasourceCatecode;
/**
* 数据源描述
*/
@ApiModelProperty(value = "数据源描述")
private String datasourceDesc;
/**
* 连接信息
*/
@ApiModelProperty(value = "连接信息")
private String jdbcUrl;
/**
* 用户名
*/
@ApiModelProperty(value = "用户名")
private String userName;
/**
* 创建时间
*/
@ApiModelProperty(value = "创建时间")
private String createTime;
/**
* 更新时间
*/
@ApiModelProperty(value = "更新时间")
private String uptdateTime;
/**
* 数据库名称
*/
@ApiModelProperty(value = "数据库名称")
private String dbName;
/**
* 项目id
*/
@ApiModelProperty(value = "项目id")
private String projectId;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getDatasourceName() {
return datasourceName;
}
public void setDatasourceName(String datasourceName) {
this.datasourceName = datasourceName;
}
public String getDatasourceTypeName() {
return datasourceTypeName;
}
public void setDatasourceTypeName(String datasourceTypeName) {
this.datasourceTypeName = datasourceTypeName;
}
public String getDatasourceTypeId() {
return datasourceTypeId;
}
public void setDatasourceTypeId(String datasourceTypeId) {
this.datasourceTypeId = datasourceTypeId;
}
public String getDatasourceCatecode() {
return datasourceCatecode;
}
public void setDatasourceCatecode(String datasourceCatecode) {
this.datasourceCatecode = datasourceCatecode;
}
public String getDatasourceDesc() {
return datasourceDesc;
}
public void setDatasourceDesc(String datasourceDesc) {
this.datasourceDesc = datasourceDesc;
}
public String getJdbcUrl() {
return jdbcUrl;
}
public void setJdbcUrl(String jdbcUrl) {
this.jdbcUrl = jdbcUrl;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getCreateTime() {
return createTime;
}
public void setCreateTime(String createTime) {
this.createTime = createTime;
}
public String getUptdateTime() {
return uptdateTime;
}
public void setUptdateTime(String uptdateTime) {
this.uptdateTime = uptdateTime;
}
public String getDbName() {
return dbName;
}
public void setDbName(String dbName) {
this.dbName = dbName;
}
public String getProjectId() {
return projectId;
}
public void setProjectId(String projectId) {
this.projectId = projectId;
}
}
package com.jz.dmp.modules.controller.DataIntegration.bean;
import com.jz.common.page.BasePageBean;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
/**
* @ClassName: DataSourceListReq
* @Description: 数据源列表请求参数
* @Author:Bellamy
* @Date 2020/12/24
* @Version 1.0
*/
@ApiModel(value = "数据源列表请求参数", description = "数据源列表请求参数")
public class DataSourceListReq extends BasePageBean {
/*
* 数据源类型
* */
@ApiModelProperty(value = "数据源类型")
private String datasourceTypeId;
/*
* 数据源名称
* */
@ApiModelProperty(value = "数据源名称")
private String datasourceName;
/*
* 项目id
* */
@ApiModelProperty(value = "项目id")
@NotNull(message = "项目id不能为空")
private String projectId;
public String getDatasourceName() {
return datasourceName;
}
public void setDatasourceName(String datasourceName) {
this.datasourceName = datasourceName;
}
public String getDatasourceTypeId() {
return datasourceTypeId;
}
public void setDatasourceTypeId(String datasourceTypeId) {
this.datasourceTypeId = datasourceTypeId;
}
public String getProjectId() {
return projectId;
}
public void setProjectId(String projectId) {
this.projectId = projectId;
}
}
package com.jz.dmp.modules.dao;
import com.jz.dmp.modules.controller.DataIntegration.bean.DataSourceListDto;
import com.jz.dmp.modules.controller.DataIntegration.bean.DataSourceListReq;
import com.jz.dmp.modules.model.DmpSyncingDatasource;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 数据源配置(DmpSyncingDatasource)表数据库访问层
*
* @author Bellamy
* @since 2020-12-24 14:09:59
*/
public interface DmpSyncingDatasourceDao {
/**
* 通过ID查询单条数据
*
* @param id 主键
* @return 实例对象
*/
DmpSyncingDatasource queryById(Integer id);
/**
* 查询指定行数据
*
* @param offset 查询起始位置
* @param limit 查询条数
* @return 对象列表
*/
List<DmpSyncingDatasource> queryAllByLimit(@Param("offset") int offset, @Param("limit") int limit);
/**
* 通过实体作为筛选条件查询
*
* @param dmpSyncingDatasource 实例对象
* @return 对象列表
*/
List<DmpSyncingDatasource> queryAll(DmpSyncingDatasource dmpSyncingDatasource);
/**
* 新增数据
*
* @param dmpSyncingDatasource 实例对象
* @return 影响行数
*/
int insert(DmpSyncingDatasource dmpSyncingDatasource);
/**
* 批量新增数据(MyBatis原生foreach方法)
*
* @param entities List<DmpSyncingDatasource> 实例对象列表
* @return 影响行数
*/
int insertBatch(@Param("entities") List<DmpSyncingDatasource> entities);
/**
* 批量新增或按主键更新数据(MyBatis原生foreach方法)
*
* @param entities List<DmpSyncingDatasource> 实例对象列表
* @return 影响行数
*/
int insertOrUpdateBatch(@Param("entities") List<DmpSyncingDatasource> entities);
/**
* 修改数据
*
* @param dmpSyncingDatasource 实例对象
* @return 影响行数
*/
int update(DmpSyncingDatasource dmpSyncingDatasource);
/**
* 通过主键删除数据
*
* @param id 主键
* @return 影响行数
*/
int deleteById(Integer id);
/**
* 数据源列表查询
*
* @param req
*/
List<DataSourceListDto> queryDataSourceListPage(DataSourceListReq req) throws Exception;
}
\ No newline at end of file
package com.jz.dmp.modules.service;
import com.jz.common.page.PageInfoResponse;
import com.jz.dmp.modules.controller.DataIntegration.bean.DataSourceListDto;
import com.jz.dmp.modules.controller.DataIntegration.bean.DataSourceListReq;
import com.jz.dmp.modules.model.DmpSyncingDatasource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
/**
* 数据源配置(DmpSyncingDatasource)表服务接口
*
* @author Bellamy
* @since 2020-12-24 14:09:59
*/
public interface DmpSyncingDatasourceService {
/**
* 通过ID查询单条数据
*
* @param id 主键
* @return 实例对象
*/
DmpSyncingDatasource queryById(Integer id);
/**
* 查询多条数据
*
* @param offset 查询起始位置
* @param limit 查询条数
* @return 对象列表
*/
List<DmpSyncingDatasource> queryAllByLimit(int offset, int limit);
/**
* 新增数据
*
* @param dmpSyncingDatasource 实例对象
* @return 实例对象
*/
DmpSyncingDatasource insert(DmpSyncingDatasource dmpSyncingDatasource);
/**
* 修改数据
*
* @param dmpSyncingDatasource 实例对象
* @return 实例对象
*/
DmpSyncingDatasource update(DmpSyncingDatasource dmpSyncingDatasource);
/**
* 通过主键删除数据
*
* @param id 主键
* @return 是否成功
*/
boolean deleteById(Integer id);
PageInfoResponse<DataSourceListDto> queryDataSourceListPage(DataSourceListReq req, HttpServletRequest httpRequest) throws Exception;
}
\ No newline at end of file
package com.jz.dmp.modules.service.impl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.jz.common.constant.ResultCode;
import com.jz.common.page.PageInfoResponse;
import com.jz.dmp.modules.controller.DataIntegration.bean.DataSourceListDto;
import com.jz.dmp.modules.controller.DataIntegration.bean.DataSourceListReq;
import com.jz.dmp.modules.controller.DataIntegration.bean.TaskListPageDto;
import com.jz.dmp.modules.dao.DmpSyncingDatasourceDao;
import com.jz.dmp.modules.model.DmpSyncingDatasource;
import com.jz.dmp.modules.service.DmpSyncingDatasourceService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 数据源配置(DmpSyncingDatasource)表服务实现类
*
* @author Bellamy
* @since 2020-12-24 14:09:59
*/
@Service("dmpSyncingDatasourceService")
@Transactional
public class DmpSyncingDatasourceServiceImpl implements DmpSyncingDatasourceService {
private static Logger logger = LoggerFactory.getLogger(DmpSyncingDatasourceServiceImpl.class);
@Autowired
private DmpSyncingDatasourceDao dmpSyncingDatasourceDao;
/**
* 通过ID查询单条数据
*
* @param id 主键
* @return 实例对象
*/
@Override
public DmpSyncingDatasource queryById(Integer id) {
return this.dmpSyncingDatasourceDao.queryById(id);
}
/**
* 查询多条数据
*
* @param offset 查询起始位置
* @param limit 查询条数
* @return 对象列表
*/
@Override
public List<DmpSyncingDatasource> queryAllByLimit(int offset, int limit) {
return this.dmpSyncingDatasourceDao.queryAllByLimit(offset, limit);
}
/**
* 新增数据
*
* @param dmpSyncingDatasource 实例对象
* @return 实例对象
*/
@Override
public DmpSyncingDatasource insert(DmpSyncingDatasource dmpSyncingDatasource) {
this.dmpSyncingDatasourceDao.insert(dmpSyncingDatasource);
return dmpSyncingDatasource;
}
/**
* 修改数据
*
* @param dmpSyncingDatasource 实例对象
* @return 实例对象
*/
@Override
public DmpSyncingDatasource update(DmpSyncingDatasource dmpSyncingDatasource) {
this.dmpSyncingDatasourceDao.update(dmpSyncingDatasource);
return this.queryById(dmpSyncingDatasource.getId());
}
/**
* 通过主键删除数据
*
* @param id 主键
* @return 是否成功
*/
@Override
public boolean deleteById(Integer id) {
return this.dmpSyncingDatasourceDao.deleteById(id) > 0;
}
/**
* 数据源列表查询
*
* @param req
*/
@Override
public PageInfoResponse<DataSourceListDto> queryDataSourceListPage(DataSourceListReq req, HttpServletRequest httpRequest) throws Exception {
PageInfoResponse<DataSourceListDto> pageInfoResponse = new PageInfoResponse<>();
PageHelper.startPage(req.getPageNum(), req.getPageSize());
req.setDatasourceName(req.getDatasourceName().trim());
List<DataSourceListDto> list = dmpSyncingDatasourceDao.queryDataSourceListPage(req);
PageInfo<DataSourceListDto> pageInfo = new PageInfo<>(list);
pageInfoResponse.setCode(ResultCode.SUCCESS);
pageInfoResponse.setMessage("查询成功");
pageInfoResponse.setData(pageInfo);
return pageInfoResponse;
}
}
\ No newline at end of file
<?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.jz.dmp.modules.dao.DmpSyncingDatasourceDao">
<resultMap type="com.jz.dmp.modules.model.DmpSyncingDatasource" id="DmpSyncingDatasourceMap">
<result property="id" column="ID" jdbcType="INTEGER"/>
<result property="datasourceType" column="DATASOURCE_TYPE" jdbcType="INTEGER"/>
<result property="datasourceName" column="DATASOURCE_NAME" jdbcType="VARCHAR"/>
<result property="datasourceDesc" column="DATASOURCE_DESC" jdbcType="VARCHAR"/>
<result property="jdbcUrl" column="JDBC_URL" jdbcType="VARCHAR"/>
<result property="dbName" column="DB_NAME" jdbcType="VARCHAR"/>
<result property="userName" column="USER_NAME" jdbcType="VARCHAR"/>
<result property="password" column="PASSWORD" jdbcType="VARCHAR"/>
<result property="endpoint" column="ENDPOINT" jdbcType="VARCHAR"/>
<result property="bucket" column="BUCKET" jdbcType="VARCHAR"/>
<result property="accessId" column="ACCESS_ID" jdbcType="VARCHAR"/>
<result property="accessKey" column="ACCESS_KEY" jdbcType="VARCHAR"/>
<result property="protocol" column="PROTOCOL" jdbcType="VARCHAR"/>
<result property="host" column="HOST" jdbcType="VARCHAR"/>
<result property="port" column="PORT" jdbcType="VARCHAR"/>
<result property="defaultFs" column="DEFAULT_FS" jdbcType="VARCHAR"/>
<result property="tableSchema" column="TABLE_SCHEMA" jdbcType="VARCHAR"/>
<result property="dataStatus" column="DATA_STATUS" jdbcType="VARCHAR"/>
<result property="createUserId" column="CREATE_USER_ID" jdbcType="VARCHAR"/>
<result property="createTime" column="CREATE_TIME" jdbcType="TIMESTAMP"/>
<result property="updateUserId" column="UPDATE_USER_ID" jdbcType="VARCHAR"/>
<result property="updateTime" column="UPDATE_TIME" jdbcType="TIMESTAMP"/>
<result property="projectId" column="PROJECT_ID" jdbcType="INTEGER"/>
</resultMap>
<!--查询单个-->
<select id="queryById" resultMap="DmpSyncingDatasourceMap">
select
ID, DATASOURCE_TYPE, DATASOURCE_NAME, DATASOURCE_DESC, JDBC_URL, DB_NAME, USER_NAME, PASSWORD, ENDPOINT, BUCKET, ACCESS_ID, ACCESS_KEY, PROTOCOL, HOST, PORT, DEFAULT_FS, TABLE_SCHEMA, DATA_STATUS, CREATE_USER_ID, CREATE_TIME, UPDATE_USER_ID, UPDATE_TIME, PROJECT_ID
from dmp_web.dmp_syncing_datasource
where ID = #{id}
</select>
<!--查询指定行数据-->
<select id="queryAllByLimit" resultMap="DmpSyncingDatasourceMap">
select
ID, DATASOURCE_TYPE, DATASOURCE_NAME, DATASOURCE_DESC, JDBC_URL, DB_NAME, USER_NAME, PASSWORD, ENDPOINT, BUCKET, ACCESS_ID, ACCESS_KEY, PROTOCOL, HOST, PORT, DEFAULT_FS, TABLE_SCHEMA, DATA_STATUS, CREATE_USER_ID, CREATE_TIME, UPDATE_USER_ID, UPDATE_TIME, PROJECT_ID
from dmp_web.dmp_syncing_datasource
limit #{offset}, #{limit}
</select>
<!--通过实体作为筛选条件查询-->
<select id="queryAll" resultMap="DmpSyncingDatasourceMap">
select
ID, DATASOURCE_TYPE, DATASOURCE_NAME, DATASOURCE_DESC, JDBC_URL, DB_NAME, USER_NAME, PASSWORD, ENDPOINT, BUCKET,
ACCESS_ID, ACCESS_KEY, PROTOCOL, HOST, PORT, DEFAULT_FS, TABLE_SCHEMA, DATA_STATUS, CREATE_USER_ID, CREATE_TIME,
UPDATE_USER_ID, UPDATE_TIME, PROJECT_ID
from dmp_web.dmp_syncing_datasource
<where>
<if test="id != null">
and ID = #{id}
</if>
<if test="datasourceType != null">
and DATASOURCE_TYPE = #{datasourceType}
</if>
<if test="datasourceName != null and datasourceName != ''">
and DATASOURCE_NAME = #{datasourceName}
</if>
<if test="datasourceDesc != null and datasourceDesc != ''">
and DATASOURCE_DESC = #{datasourceDesc}
</if>
<if test="jdbcUrl != null and jdbcUrl != ''">
and JDBC_URL = #{jdbcUrl}
</if>
<if test="dbName != null and dbName != ''">
and DB_NAME = #{dbName}
</if>
<if test="userName != null and userName != ''">
and USER_NAME = #{userName}
</if>
<if test="password != null and password != ''">
and PASSWORD = #{password}
</if>
<if test="endpoint != null and endpoint != ''">
and ENDPOINT = #{endpoint}
</if>
<if test="bucket != null and bucket != ''">
and BUCKET = #{bucket}
</if>
<if test="accessId != null and accessId != ''">
and ACCESS_ID = #{accessId}
</if>
<if test="accessKey != null and accessKey != ''">
and ACCESS_KEY = #{accessKey}
</if>
<if test="protocol != null and protocol != ''">
and PROTOCOL = #{protocol}
</if>
<if test="host != null and host != ''">
and HOST = #{host}
</if>
<if test="port != null and port != ''">
and PORT = #{port}
</if>
<if test="defaultFs != null and defaultFs != ''">
and DEFAULT_FS = #{defaultFs}
</if>
<if test="tableSchema != null and tableSchema != ''">
and TABLE_SCHEMA = #{tableSchema}
</if>
<if test="dataStatus != null and dataStatus != ''">
and DATA_STATUS = #{dataStatus}
</if>
<if test="createUserId != null and createUserId != ''">
and CREATE_USER_ID = #{createUserId}
</if>
<if test="createTime != null">
and CREATE_TIME = #{createTime}
</if>
<if test="updateUserId != null and updateUserId != ''">
and UPDATE_USER_ID = #{updateUserId}
</if>
<if test="updateTime != null">
and UPDATE_TIME = #{updateTime}
</if>
<if test="projectId != null">
and PROJECT_ID = #{projectId}
</if>
</where>
</select>
<!--新增所有列-->
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
insert into dmp_web.dmp_syncing_datasource(DATASOURCE_TYPE, DATASOURCE_NAME, DATASOURCE_DESC, JDBC_URL, DB_NAME, USER_NAME, PASSWORD, ENDPOINT, BUCKET, ACCESS_ID, ACCESS_KEY, PROTOCOL, HOST, PORT, DEFAULT_FS, TABLE_SCHEMA, DATA_STATUS, CREATE_USER_ID, CREATE_TIME, UPDATE_USER_ID, UPDATE_TIME, PROJECT_ID)
values (#{datasourceType}, #{datasourceName}, #{datasourceDesc}, #{jdbcUrl}, #{dbName}, #{userName}, #{password}, #{endpoint}, #{bucket}, #{accessId}, #{accessKey}, #{protocol}, #{host}, #{port}, #{defaultFs}, #{tableSchema}, #{dataStatus}, #{createUserId}, #{createTime}, #{updateUserId}, #{updateTime}, #{projectId})
</insert>
<insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
insert into dmp_web.dmp_syncing_datasource(DATASOURCE_TYPE, DATASOURCE_NAME, DATASOURCE_DESC, JDBC_URL, DB_NAME,
USER_NAME, PASSWORD, ENDPOINT, BUCKET, ACCESS_ID, ACCESS_KEY, PROTOCOL, HOST, PORT, DEFAULT_FS, TABLE_SCHEMA,
DATA_STATUS, CREATE_USER_ID, CREATE_TIME, UPDATE_USER_ID, UPDATE_TIME, PROJECT_ID)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.datasourceType}, #{entity.datasourceName}, #{entity.datasourceDesc}, #{entity.jdbcUrl},
#{entity.dbName}, #{entity.userName}, #{entity.password}, #{entity.endpoint}, #{entity.bucket},
#{entity.accessId}, #{entity.accessKey}, #{entity.protocol}, #{entity.host}, #{entity.port},
#{entity.defaultFs}, #{entity.tableSchema}, #{entity.dataStatus}, #{entity.createUserId},
#{entity.createTime}, #{entity.updateUserId}, #{entity.updateTime}, #{entity.projectId})
</foreach>
</insert>
<insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
insert into dmp_web.dmp_syncing_datasource(DATASOURCE_TYPE, DATASOURCE_NAME, DATASOURCE_DESC, JDBC_URL, DB_NAME,
USER_NAME, PASSWORD, ENDPOINT, BUCKET, ACCESS_ID, ACCESS_KEY, PROTOCOL, HOST, PORT, DEFAULT_FS, TABLE_SCHEMA,
DATA_STATUS, CREATE_USER_ID, CREATE_TIME, UPDATE_USER_ID, UPDATE_TIME, PROJECT_ID)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.datasourceType}, #{entity.datasourceName}, #{entity.datasourceDesc}, #{entity.jdbcUrl},
#{entity.dbName}, #{entity.userName}, #{entity.password}, #{entity.endpoint}, #{entity.bucket},
#{entity.accessId}, #{entity.accessKey}, #{entity.protocol}, #{entity.host}, #{entity.port},
#{entity.defaultFs}, #{entity.tableSchema}, #{entity.dataStatus}, #{entity.createUserId},
#{entity.createTime}, #{entity.updateUserId}, #{entity.updateTime}, #{entity.projectId})
</foreach>
on duplicate key update
DATASOURCE_TYPE = values(DATASOURCE_TYPE) , DATASOURCE_NAME = values(DATASOURCE_NAME) , DATASOURCE_DESC =
values(DATASOURCE_DESC) , JDBC_URL = values(JDBC_URL) , DB_NAME = values(DB_NAME) , USER_NAME =
values(USER_NAME) , PASSWORD = values(PASSWORD) , ENDPOINT = values(ENDPOINT) , BUCKET = values(BUCKET) ,
ACCESS_ID = values(ACCESS_ID) , ACCESS_KEY = values(ACCESS_KEY) , PROTOCOL = values(PROTOCOL) , HOST =
values(HOST) , PORT = values(PORT) , DEFAULT_FS = values(DEFAULT_FS) , TABLE_SCHEMA = values(TABLE_SCHEMA) ,
DATA_STATUS = values(DATA_STATUS) , CREATE_USER_ID = values(CREATE_USER_ID) , CREATE_TIME = values(CREATE_TIME)
, UPDATE_USER_ID = values(UPDATE_USER_ID) , UPDATE_TIME = values(UPDATE_TIME) , PROJECT_ID = values(PROJECT_ID)
</insert>
<!--通过主键修改数据-->
<update id="update">
update dmp_web.dmp_syncing_datasource
<set>
<if test="datasourceType != null">
DATASOURCE_TYPE = #{datasourceType},
</if>
<if test="datasourceName != null and datasourceName != ''">
DATASOURCE_NAME = #{datasourceName},
</if>
<if test="datasourceDesc != null and datasourceDesc != ''">
DATASOURCE_DESC = #{datasourceDesc},
</if>
<if test="jdbcUrl != null and jdbcUrl != ''">
JDBC_URL = #{jdbcUrl},
</if>
<if test="dbName != null and dbName != ''">
DB_NAME = #{dbName},
</if>
<if test="userName != null and userName != ''">
USER_NAME = #{userName},
</if>
<if test="password != null and password != ''">
PASSWORD = #{password},
</if>
<if test="endpoint != null and endpoint != ''">
ENDPOINT = #{endpoint},
</if>
<if test="bucket != null and bucket != ''">
BUCKET = #{bucket},
</if>
<if test="accessId != null and accessId != ''">
ACCESS_ID = #{accessId},
</if>
<if test="accessKey != null and accessKey != ''">
ACCESS_KEY = #{accessKey},
</if>
<if test="protocol != null and protocol != ''">
PROTOCOL = #{protocol},
</if>
<if test="host != null and host != ''">
HOST = #{host},
</if>
<if test="port != null and port != ''">
PORT = #{port},
</if>
<if test="defaultFs != null and defaultFs != ''">
DEFAULT_FS = #{defaultFs},
</if>
<if test="tableSchema != null and tableSchema != ''">
TABLE_SCHEMA = #{tableSchema},
</if>
<if test="dataStatus != null and dataStatus != ''">
DATA_STATUS = #{dataStatus},
</if>
<if test="createUserId != null and createUserId != ''">
CREATE_USER_ID = #{createUserId},
</if>
<if test="createTime != null">
CREATE_TIME = #{createTime},
</if>
<if test="updateUserId != null and updateUserId != ''">
UPDATE_USER_ID = #{updateUserId},
</if>
<if test="updateTime != null">
UPDATE_TIME = #{updateTime},
</if>
<if test="projectId != null">
PROJECT_ID = #{projectId},
</if>
</set>
where ID = #{id}
</update>
<!--通过主键删除-->
<delete id="deleteById">
delete from dmp_web.dmp_syncing_datasource where ID = #{id}
</delete>
<!--数据源列表查询-->
<select id="queryDataSourceListPage" parameterType="com.jz.dmp.modules.controller.DataIntegration.bean.DataSourceListReq"
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,
date_format(a.CREATE_TIME,'%Y-%m-%d %H:%i:%s') as createTime,
date_format(a.update_time,'%Y-%m-%d %H:%i:%s') as updateTime,
a.project_id as projectId
from dmp_syncing_datasource a
inner join dmp_syncing_datasource_type b on a.datasource_type = b.id
where a.data_status = '1'
and a.project_id = #{projectId}
<if test="datasourceTypeId != null and datasourceTypeId !=''">and a.datasource_type = #{datasourceTypeId}</if>
<if test="datasourceName != null and datasourceName !=''">and a.datasource_name like CONCAT('%',#{datasourceName},'%')</if>
</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