Commit aa80f0d8 authored by mcb's avatar mcb

no message

parent 610a5c1b
...@@ -28,9 +28,9 @@ public class GlobalExceptionHandler { ...@@ -28,9 +28,9 @@ public class GlobalExceptionHandler {
private static Logger logger = LoggerFactory.getLogger(GlobalExceptionHandler.class); private static Logger logger = LoggerFactory.getLogger(GlobalExceptionHandler.class);
/** /**
* 403 - Bad Request * 缺少请求参数
*/ */
@ResponseStatus(HttpStatus.BAD_REQUEST) @ResponseStatus(HttpStatus.OK)
@ExceptionHandler(MissingServletRequestParameterException.class) @ExceptionHandler(MissingServletRequestParameterException.class)
public JsonResult handleMissingServletRequestParameterException(MissingServletRequestParameterException e) { public JsonResult handleMissingServletRequestParameterException(MissingServletRequestParameterException e) {
logger.error("缺少请求参数", e); logger.error("缺少请求参数", e);
...@@ -48,9 +48,9 @@ public class GlobalExceptionHandler { ...@@ -48,9 +48,9 @@ public class GlobalExceptionHandler {
} }
/** /**
* 403 - Bad Request * 参数验证失败
*/ */
@ResponseStatus(HttpStatus.BAD_REQUEST) @ResponseStatus(HttpStatus.OK)
@ExceptionHandler(MethodArgumentNotValidException.class) @ExceptionHandler(MethodArgumentNotValidException.class)
public JsonResult handleMethodArgumentNotValidException(MethodArgumentNotValidException e) { public JsonResult handleMethodArgumentNotValidException(MethodArgumentNotValidException e) {
logger.error("参数验证失败", e); logger.error("参数验证失败", e);
...@@ -82,7 +82,7 @@ public class GlobalExceptionHandler { ...@@ -82,7 +82,7 @@ public class GlobalExceptionHandler {
/** /**
* 403 - Bad Request * 403 - Bad Request
*/ */
@ResponseStatus(HttpStatus.BAD_REQUEST) @ResponseStatus(HttpStatus.OK)
@ExceptionHandler(ValidationException.class) @ExceptionHandler(ValidationException.class)
public JsonResult handleValidationException(ValidationException e) { public JsonResult handleValidationException(ValidationException e) {
logger.error("参数验证失败", e); logger.error("参数验证失败", e);
...@@ -95,7 +95,7 @@ public class GlobalExceptionHandler { ...@@ -95,7 +95,7 @@ public class GlobalExceptionHandler {
@ResponseStatus(HttpStatus.METHOD_NOT_ALLOWED) @ResponseStatus(HttpStatus.METHOD_NOT_ALLOWED)
@ExceptionHandler(HttpRequestMethodNotSupportedException.class) @ExceptionHandler(HttpRequestMethodNotSupportedException.class)
public JsonResult handleHttpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException e) { public JsonResult handleHttpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException e) {
logger.error("不支持当前请求方�?", e); logger.error("不支持当前请求方", e);
return new JsonResult(ResultCode.NOT_SUPPORTED, "request_method_not_supported:"); return new JsonResult(ResultCode.NOT_SUPPORTED, "request_method_not_supported:");
} }
...@@ -116,7 +116,7 @@ public class GlobalExceptionHandler { ...@@ -116,7 +116,7 @@ public class GlobalExceptionHandler {
@ExceptionHandler(ServiceException.class) @ExceptionHandler(ServiceException.class)
public JsonResult handleServiceException(ServiceException e) { public JsonResult handleServiceException(ServiceException e) {
logger.error("业务逻辑异常", e); logger.error("业务逻辑异常", e);
return new JsonResult(ResultCode.INTERNAL_SERVER_ERROR, "业务逻辑异常�?"); return new JsonResult(ResultCode.INTERNAL_SERVER_ERROR, "业务逻辑异常!");
} }
/** /**
...@@ -126,7 +126,7 @@ public class GlobalExceptionHandler { ...@@ -126,7 +126,7 @@ public class GlobalExceptionHandler {
@ExceptionHandler(Exception.class) @ExceptionHandler(Exception.class)
public JsonResult handleException(Exception e) { public JsonResult handleException(Exception e) {
logger.error("通用逻辑异常", e); logger.error("通用逻辑异常", e);
return new JsonResult(ResultCode.INTERNAL_SERVER_ERROR, "参数错误"); return new JsonResult(ResultCode.INTERNAL_SERVER_ERROR, "通用逻辑异常");
} }
/** /**
...@@ -135,7 +135,7 @@ public class GlobalExceptionHandler { ...@@ -135,7 +135,7 @@ public class GlobalExceptionHandler {
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
@ExceptionHandler(DataIntegrityViolationException.class) @ExceptionHandler(DataIntegrityViolationException.class)
public JsonResult handleException(DataIntegrityViolationException e) { public JsonResult handleException(DataIntegrityViolationException e) {
logger.error("操作数据库出现异�?:", e); logger.error("操作数据库出现异:", e);
return new JsonResult(ResultCode.NOT_SUPPORTED, "操作数据库出现异常:字段重复、有外键关联�?"); return new JsonResult(ResultCode.NOT_SUPPORTED, "操作数据库出现异常:字段重复、有外键关联�?");
} }
} }
...@@ -9,6 +9,7 @@ import com.jz.dmp.modules.controller.DataIntegration.bean.RealTimeSyncListDto; ...@@ -9,6 +9,7 @@ import com.jz.dmp.modules.controller.DataIntegration.bean.RealTimeSyncListDto;
import com.jz.dmp.modules.controller.DataIntegration.bean.RealTimeSyncListReq; import com.jz.dmp.modules.controller.DataIntegration.bean.RealTimeSyncListReq;
import com.jz.dmp.modules.controller.DataIntegration.bean.RealTimeTableInfoReq; import com.jz.dmp.modules.controller.DataIntegration.bean.RealTimeTableInfoReq;
import com.jz.dmp.modules.model.DmpRealtimeSyncInfo; import com.jz.dmp.modules.model.DmpRealtimeSyncInfo;
import com.jz.dmp.modules.model.RealTimeSyncModel;
import com.jz.dmp.modules.service.DmpRealtimeSyncInfoService; import com.jz.dmp.modules.service.DmpRealtimeSyncInfoService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
...@@ -18,6 +19,7 @@ import org.apache.commons.lang3.StringUtils; ...@@ -18,6 +19,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.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
...@@ -50,7 +52,7 @@ public class RealTimeSyncController { ...@@ -50,7 +52,7 @@ public class RealTimeSyncController {
*/ */
@ApiOperation(value = "实时同步任务列表分页查询", notes = "实时同步任务列表分页查询") @ApiOperation(value = "实时同步任务列表分页查询", notes = "实时同步任务列表分页查询")
@PostMapping(value = "/realTimeSyncListPage") @PostMapping(value = "/realTimeSyncListPage")
public PageInfoResponse<RealTimeSyncListDto> getDataSourceListPage(@RequestBody RealTimeSyncListReq req, HttpServletRequest httpRequest) throws Exception { public PageInfoResponse<RealTimeSyncListDto> getDataSourceListPage(@RequestBody @Validated RealTimeSyncListReq req, HttpServletRequest httpRequest) throws Exception {
PageInfoResponse<RealTimeSyncListDto> pageInfo = new PageInfoResponse<RealTimeSyncListDto>(); PageInfoResponse<RealTimeSyncListDto> pageInfo = new PageInfoResponse<RealTimeSyncListDto>();
if (StringUtils.isEmpty(req.getProjectId())) { if (StringUtils.isEmpty(req.getProjectId())) {
pageInfo.setMessage("项目id不能为空!"); pageInfo.setMessage("项目id不能为空!");
...@@ -141,22 +143,40 @@ public class RealTimeSyncController { ...@@ -141,22 +143,40 @@ public class RealTimeSyncController {
} }
/** /**
* 根据数据源id获取表详细信息 * 新增--选择源表信息
* *
* @return * @return
* @author Bellamy * @author Bellamy
* @since 2021-01-06 * @since 2021-01-06
*/ */
@ApiOperation(value = "新增--获取表信息", notes = "新增--获取表信息") @ApiOperation(value = "新增--选择源表信息", notes = "新增--选择源表信息")
@PostMapping(value = "/getSourceDbTableList") @PostMapping(value = "/getSourceDbTableList")
public JsonResult getTableInfo(@RequestBody RealTimeTableInfoReq req, HttpServletRequest httpRequest) throws Exception { public JsonResult<RealTimeSyncModel> getTableInfo(@RequestBody @Validated RealTimeTableInfoReq req, HttpServletRequest httpRequest) throws Exception {
if (StringUtils.isEmpty(req.getProjectId())) { if (StringUtils.isEmpty(req.getProjectId())) {
return new JsonResult(ResultCode.PARAMS_ERROR, "项目id不能为空!"); return new JsonResult(ResultCode.PARAMS_ERROR, "项目id不能为空!");
} }
if (StringUtils.isEmpty(req.getSrcDatasourceId())) { if (StringUtils.isEmpty(req.getSrcDatasourceId())) {
return new JsonResult(ResultCode.PARAMS_ERROR, "来源数据源id不能为空!"); return new JsonResult(ResultCode.PARAMS_ERROR, "来源数据源id不能为空!");
} }
JsonResult jsonResult = dmpRealtimeSyncInfoService.queryTableInfoByParams(req); JsonResult<RealTimeSyncModel> jsonResult = dmpRealtimeSyncInfoService.queryTableInfoByParams(req);
return jsonResult;
}
/**
* 新增--选择目标信息
*
* @return
* @author Bellamy
* @since 2021-01-07
*/
@ApiOperation(value = "新增--选择目标信息", notes = "新增--选择目标信息")
@GetMapping(value = "/targetDatasourceInfo")
@ApiImplicitParam(name = "projectId", value = "项目id",required = true)
public JsonResult getTargetDatasourceInfo(@RequestParam String projectId) throws Exception {
if (StringUtils.isEmpty(projectId)) {
return new JsonResult(ResultCode.PARAMS_ERROR, "项目id不能为空!");
}
JsonResult jsonResult = dmpRealtimeSyncInfoService.selectTargetDatasourceInfo(projectId);
return jsonResult; return jsonResult;
} }
......
...@@ -5,6 +5,7 @@ import com.jz.dmp.modules.controller.DataIntegration.bean.DataSourceNameListDto; ...@@ -5,6 +5,7 @@ import com.jz.dmp.modules.controller.DataIntegration.bean.DataSourceNameListDto;
import com.jz.dmp.modules.controller.DataIntegration.bean.RealTimeSyncListDto; import com.jz.dmp.modules.controller.DataIntegration.bean.RealTimeSyncListDto;
import com.jz.dmp.modules.controller.DataIntegration.bean.RealTimeSyncListReq; import com.jz.dmp.modules.controller.DataIntegration.bean.RealTimeSyncListReq;
import com.jz.dmp.modules.model.DmpRealtimeSyncInfo; import com.jz.dmp.modules.model.DmpRealtimeSyncInfo;
import com.jz.dmp.modules.model.RealTimeSyncDataSourceModel;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
...@@ -109,7 +110,7 @@ public interface DmpRealtimeSyncInfoDao { ...@@ -109,7 +110,7 @@ public interface DmpRealtimeSyncInfoDao {
* @author Bellamy * @author Bellamy
* @since 2021-01-06 * @since 2021-01-06
*/ */
Map querygSourceDbInfoById(@Param("srcDataSourceId") String srcDataSourceId) throws Exception; RealTimeSyncDataSourceModel querygSourceDbInfoById(@Param("srcDataSourceId") String srcDataSourceId) throws Exception;
List<Map> queryRealTimeInfoByDataSourceId(@Param("srcDatasourceId") String srcDatasourceId, @Param("targetDatasourceId") String targetDatasourceId); List<Map> queryRealTimeInfoByDataSourceId(@Param("srcDatasourceId") String srcDatasourceId, @Param("targetDatasourceId") String targetDatasourceId);
......
package com.jz.dmp.modules.model;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
/**
* 实时同步表信息 列级别的信息
*/
@ApiModel(value = "实时同步表下列级别的信息", description = "实时同步表下列级别的信息")
public class RealTimeSyncColumnModel implements Serializable {
private static final long serialVersionUID = 7171169593984549127L;
/**
* 表名
*/
@ApiModelProperty(value = "表名")
private String tableName;
/**
* 当前表的所有列
*/
@ApiModelProperty(value = "当前表的所有列")
private List<String> allColumns;
/**
* 当前表是字符串类型的列
*/
@ApiModelProperty(value = "当前表是字符串类型的列")
private List<Map<String, Object>> strColumns;
public String getTableName() {
return tableName;
}
public void setTableName(String tableName) {
this.tableName = tableName;
}
public List<String> getAllColumns() {
return allColumns;
}
public void setAllColumns(List<String> allColumns) {
this.allColumns = allColumns;
}
public List<Map<String, Object>> getStrColumns() {
return strColumns;
}
public void setStrColumns(List<Map<String, Object>> strColumns) {
this.strColumns = strColumns;
}
}
package com.jz.dmp.modules.model;
import java.util.Date;
/**
* 实时同步表信息 列级别的信息
*/
public class RealTimeSyncDataSourceModel {
/**
* 数据源id
*/
private Integer id;
/**
* 数据源名称
*/
private String datasourceName;
/**
* 数据源描述
*/
private String datasourceDesc;
/**
* 数据源类型
*/
private Integer datasourceType;
/**
* jdbc 连接字符串
*/
private String jdbcUrl;
/**
* 数据库名称
*/
private String dbName;
/**
* 数据库用户名
*/
private String userName;
/**
* 数据库密码
*/
private String password;
/**
* 数据库主机地址
*/
private String host;
/**
* 数据库端口
*/
private String port;
/**
* 项目id
*/
private Integer projectId;
/**
* jdbc驱动名称
*/
private String driverName;
/**
* 数据源类型名称
*/
private String dataSourceTypeName;
public Integer getDatasourceType() {
return datasourceType;
}
public void setDatasourceType(Integer datasourceType) {
this.datasourceType = datasourceType;
}
public String getJdbcUrl() {
return jdbcUrl;
}
public void setJdbcUrl(String jdbcUrl) {
this.jdbcUrl = jdbcUrl;
}
public String getDbName() {
return dbName;
}
public void setDbName(String dbName) {
this.dbName = dbName;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getHost() {
return host;
}
public void setHost(String host) {
this.host = host;
}
public String getPort() {
return port;
}
public void setPort(String port) {
this.port = port;
}
public Integer getProjectId() {
return projectId;
}
public void setProjectId(Integer projectId) {
this.projectId = projectId;
}
public String getDriverName() {
return driverName;
}
public void setDriverName(String driverName) {
this.driverName = driverName;
}
public String getDataSourceTypeName() {
return dataSourceTypeName;
}
public void setDataSourceTypeName(String dataSourceTypeName) {
this.dataSourceTypeName = dataSourceTypeName;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getDatasourceName() {
return datasourceName;
}
public void setDatasourceName(String datasourceName) {
this.datasourceName = datasourceName;
}
public String getDatasourceDesc() {
return datasourceDesc;
}
public void setDatasourceDesc(String datasourceDesc) {
this.datasourceDesc = datasourceDesc;
}
}
package com.jz.dmp.modules.model; package com.jz.dmp.modules.model;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.List; import java.util.List;
@ApiModel(value = "新增--新增选择源表返回参数", description = "新增--新增选择源表返回参数")
public class RealTimeSyncModel { public class RealTimeSyncModel {
/** /**
* 数据源Id * 来源数据源id
*/ */
private Integer dataSourceId; @ApiModelProperty(value = "来源数据源id")
private Integer srcdatasourceId;
/** /**
* 数据源名称 * 来源数据源名称
*/ */
@ApiModelProperty(value = "来源数据源名称")
private String dataSourceName; private String dataSourceName;
/** /**
* 数据库名称 * 数据库名称
*/ */
@ApiModelProperty(value = "数据库名称")
private String dbName ; private String dbName ;
/** /**
* 数据源下的表信息 * 来源数据源下的表信息
*/ */
@ApiModelProperty(value = "来源数据源下的表信息")
private List<RealTimeSyncTableModel> tables; private List<RealTimeSyncTableModel> tables;
public Integer getSrcdatasourceId() {
public Integer getDataSourceId() { return srcdatasourceId;
return dataSourceId;
} }
public void setSrcdatasourceId(Integer srcdatasourceId) {
public void setDataSourceId(Integer dataSourceId) { this.srcdatasourceId = srcdatasourceId;
this.dataSourceId = dataSourceId;
} }
public String getDataSourceName() { public String getDataSourceName() {
return dataSourceName; return dataSourceName;
} }
......
package com.jz.dmp.modules.model; package com.jz.dmp.modules.model;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
/** /**
* 实时同步表信息 表级别的信息 * 实时同步表信息 表级别的信息
*/ */
public class RealTimeSyncTableModel { @ApiModel(value = "实时同步表级别的信息", description = "实时同步表级别的信息")
public class RealTimeSyncTableModel implements Serializable {
private static final long serialVersionUID = -5882129191251102234L;
/** /**
* 表名 * 表名
*/ */
@ApiModelProperty(value = "表名")
private String tableName; private String tableName;
/** /**
* 主键名称 * 主键名称
*/ */
@ApiModelProperty(value = "主键名称")
private String pkName; private String pkName;
/** /**
* 是否提交同步过同步 * 是否提交同步过同步
*/ */
@ApiModelProperty(value = "是否提交同步过同步")
private boolean isSubmited; private boolean ifSubmited;
/** /**
* 是否是黑名单 * 是否是黑名单
*/ */
private boolean isBlacklist; @ApiModelProperty(value = "是否是黑名单")
private boolean ifBlacklist;
/** /**
* 脱敏字段 * 脱敏字段
*/ */
@ApiModelProperty(value = "脱敏字段")
private String desensitizationField; private String desensitizationField;
/** /**
* 脱敏算法 * 脱敏算法
*/ */
@ApiModelProperty(value = "脱敏算法")
private String arithmetic; private String arithmetic;
/** /**
* 表下的所有列信息 * 表下的所有列信息
*/ */
//private RealTimeSyncColumnModel columnInfo; @ApiModelProperty(value = "表下的所有列信息")
private RealTimeSyncColumnModel columnInfo;
public String getTableName() { public String getTableName() {
...@@ -58,44 +71,43 @@ public class RealTimeSyncTableModel { ...@@ -58,44 +71,43 @@ public class RealTimeSyncTableModel {
this.pkName = pkName; this.pkName = pkName;
} }
/*public RealTimeSyncColumnModel getColumnInfo() { public String getDesensitizationField() {
return columnInfo; return desensitizationField;
} }
public void setColumnInfo(RealTimeSyncColumnModel columnInfo) { public void setDesensitizationField(String desensitizationField) {
this.columnInfo = columnInfo; this.desensitizationField = desensitizationField;
}
*/
public boolean isSubmited() {
return isSubmited;
} }
public void setIsSubmited(boolean isSubmited) { public String getArithmetic() {
this.isSubmited = isSubmited; return arithmetic;
} }
public boolean isBlacklist() { public void setArithmetic(String arithmetic) {
return isBlacklist; this.arithmetic = arithmetic;
} }
public void setIsBlacklist(boolean isBlacklist) { public RealTimeSyncColumnModel getColumnInfo() {
this.isBlacklist = isBlacklist; return columnInfo;
} }
public String getDesensitizationField() { public void setColumnInfo(RealTimeSyncColumnModel columnInfo) {
return desensitizationField; this.columnInfo = columnInfo;
} }
public void setDesensitizationField(String desensitizationField) { public boolean isIfSubmited() {
this.desensitizationField = desensitizationField; return ifSubmited;
} }
public String getArithmetic() { public void setIfSubmited(boolean ifSubmited) {
return arithmetic; this.ifSubmited = ifSubmited;
} }
public void setArithmetic(String arithmetic) { public boolean isIfBlacklist() {
this.arithmetic = arithmetic; return ifBlacklist;
} }
public void setIfBlacklist(boolean ifBlacklist) {
this.ifBlacklist = ifBlacklist;
}
} }
...@@ -7,6 +7,7 @@ import com.jz.dmp.modules.controller.DataIntegration.bean.RealTimeSyncListDto; ...@@ -7,6 +7,7 @@ import com.jz.dmp.modules.controller.DataIntegration.bean.RealTimeSyncListDto;
import com.jz.dmp.modules.controller.DataIntegration.bean.RealTimeSyncListReq; import com.jz.dmp.modules.controller.DataIntegration.bean.RealTimeSyncListReq;
import com.jz.dmp.modules.controller.DataIntegration.bean.RealTimeTableInfoReq; import com.jz.dmp.modules.controller.DataIntegration.bean.RealTimeTableInfoReq;
import com.jz.dmp.modules.model.DmpRealtimeSyncInfo; import com.jz.dmp.modules.model.DmpRealtimeSyncInfo;
import com.jz.dmp.modules.model.RealTimeSyncModel;
import java.util.List; import java.util.List;
...@@ -83,11 +84,20 @@ public interface DmpRealtimeSyncInfoService { ...@@ -83,11 +84,20 @@ public interface DmpRealtimeSyncInfoService {
JsonResult<List<DataSourceNameListDto>> queryDatasourceNameList(String projectId, String type) throws Exception; JsonResult<List<DataSourceNameListDto>> queryDatasourceNameList(String projectId, String type) throws Exception;
/** /**
* 根据数据源id获取表详细信息 * 新增--选择源表信息
* *
* @return * @return
* @author Bellamy * @author Bellamy
* @since 2021-01-06 * @since 2021-01-06
*/ */
JsonResult queryTableInfoByParams(RealTimeTableInfoReq req) throws Exception; JsonResult<RealTimeSyncModel> queryTableInfoByParams(RealTimeTableInfoReq req) throws Exception;
/**
* 新增--选择目标信息
*
* @return
* @author Bellamy
* @since 2021-01-07
*/
JsonResult selectTargetDatasourceInfo(String projectId) throws Exception;
} }
\ No newline at end of file
package com.jz.dmp.modules.service.impl; package com.jz.dmp.modules.service.impl;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
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.utils.realTime.DBUtil;
import com.jz.dmp.modules.controller.DataIntegration.bean.DataSourceNameListDto; import com.jz.dmp.modules.controller.DataIntegration.bean.DataSourceNameListDto;
import com.jz.dmp.modules.controller.DataIntegration.bean.RealTimeSyncListDto; import com.jz.dmp.modules.controller.DataIntegration.bean.RealTimeSyncListDto;
import com.jz.dmp.modules.controller.DataIntegration.bean.RealTimeSyncListReq; import com.jz.dmp.modules.controller.DataIntegration.bean.RealTimeSyncListReq;
import com.jz.dmp.modules.controller.DataIntegration.bean.RealTimeTableInfoReq; import com.jz.dmp.modules.controller.DataIntegration.bean.RealTimeTableInfoReq;
import com.jz.dmp.modules.dao.DmpProjectDao;
import com.jz.dmp.modules.dao.DmpRealtimeSyncInfoDao; import com.jz.dmp.modules.dao.DmpRealtimeSyncInfoDao;
import com.jz.dmp.modules.model.DmpRealtimeSyncInfo; import com.jz.dmp.modules.model.*;
import com.jz.dmp.modules.service.DmpRealtimeSyncInfoService; import com.jz.dmp.modules.service.DmpRealtimeSyncInfoService;
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.Propagation; import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -35,9 +38,15 @@ import java.util.regex.Pattern; ...@@ -35,9 +38,15 @@ import java.util.regex.Pattern;
@Transactional @Transactional
public class DmpRealtimeSyncInfoServiceImpl implements DmpRealtimeSyncInfoService { public class DmpRealtimeSyncInfoServiceImpl implements DmpRealtimeSyncInfoService {
@Value("${spring.public-key}")
private String publicKey;
@Autowired @Autowired
private DmpRealtimeSyncInfoDao dmpRealtimeSyncInfoDao; private DmpRealtimeSyncInfoDao dmpRealtimeSyncInfoDao;
@Autowired
private DmpProjectDao dmpProjectDao;
/** /**
* 通过ID查询单条数据 * 通过ID查询单条数据
* *
...@@ -159,19 +168,19 @@ public class DmpRealtimeSyncInfoServiceImpl implements DmpRealtimeSyncInfoServic ...@@ -159,19 +168,19 @@ public class DmpRealtimeSyncInfoServiceImpl implements DmpRealtimeSyncInfoServic
} }
/** /**
* 根据数据源id获取表详细信息 * 新增--选择源表信息
* *
* @return * @return
* @author Bellamy * @author Bellamy
* @since 2021-01-06 * @since 2021-01-06
*/ */
@Override @Override
public JsonResult queryTableInfoByParams(RealTimeTableInfoReq req) throws Exception { public JsonResult<RealTimeSyncModel> queryTableInfoByParams(RealTimeTableInfoReq req) throws Exception {
Map<String, Map<String, String>> paramsMap = null; Map<String, Map<String, String>> paramsMap = null;
//根据数据源id获取数据信息 //根据来源数据源id获取数据信息
Map sourceDbInfo = dmpRealtimeSyncInfoDao.querygSourceDbInfoById(req.getSrcDatasourceId()); RealTimeSyncDataSourceModel sourceDbInfo = dmpRealtimeSyncInfoDao.querygSourceDbInfoById(req.getSrcDatasourceId());
sourceDbInfo.setPassword(new BaseService().decode(sourceDbInfo.getPassword(), publicKey));
//数据源对应的表详细信息 //数据源对应的表详细信息 判断表的记录在同步任务中是否存在记录,如果已经存在,说明同步过
List<Map> list = dmpRealtimeSyncInfoDao.queryRealTimeInfoByDataSourceId(req.getSrcDatasourceId(), req.getTargetDatasourceId()); List<Map> list = dmpRealtimeSyncInfoDao.queryRealTimeInfoByDataSourceId(req.getSrcDatasourceId(), req.getTargetDatasourceId());
if (list.size() > 0 && list != null) { if (list.size() > 0 && list != null) {
paramsMap = new HashMap<>(); paramsMap = new HashMap<>();
...@@ -181,7 +190,7 @@ public class DmpRealtimeSyncInfoServiceImpl implements DmpRealtimeSyncInfoServic ...@@ -181,7 +190,7 @@ public class DmpRealtimeSyncInfoServiceImpl implements DmpRealtimeSyncInfoServic
} }
} }
Map<String, String> blackMapSetting = null; Map<String, String> blackMapSetting = null;
//查询源数据源的黑名单表 //查询源数据源的黑名单表
Map blackTableMap = dmpRealtimeSyncInfoDao.queryBlackTableByDataSourceId(req.getSrcDatasourceId()); Map blackTableMap = dmpRealtimeSyncInfoDao.queryBlackTableByDataSourceId(req.getSrcDatasourceId());
if (blackTableMap.size() > 0 && blackTableMap != null) { if (blackTableMap.size() > 0 && blackTableMap != null) {
String blacklistTable = blackTableMap.get("blacklistTable").toString(); String blacklistTable = blackTableMap.get("blacklistTable").toString();
...@@ -195,7 +204,29 @@ public class DmpRealtimeSyncInfoServiceImpl implements DmpRealtimeSyncInfoServic ...@@ -195,7 +204,29 @@ public class DmpRealtimeSyncInfoServiceImpl implements DmpRealtimeSyncInfoServic
} }
} }
} }
//DBUtil.getDataSourceTables(sourceDbInfo,req.getToQueryTableName(),true,paramsMap,req.getBlacklistTables(),req.getSelectTablesName(),blackMapSetting); //来源数据源下的表信息
return null; List<RealTimeSyncTableModel> dataSourceTables = DBUtil.getDataSourceTables(sourceDbInfo, req.getToQueryTableName(), true, paramsMap, req.getBlacklistTables(), req.getSelectTablesName(), blackMapSetting);
RealTimeSyncModel realTimeSyncModel = new RealTimeSyncModel();
realTimeSyncModel.setSrcdatasourceId(Integer.valueOf(req.getSrcDatasourceId()));
realTimeSyncModel.setDataSourceName(sourceDbInfo.getDatasourceName());
realTimeSyncModel.setDbName(sourceDbInfo.getDbName());
realTimeSyncModel.setTables(dataSourceTables); //来源数据源下的表信息
return new JsonResult(realTimeSyncModel);
}
/**
* 新增--选择目标信息
*
* @return
* @author Bellamy
* @since 2021-01-07
*/
@Override
public JsonResult selectTargetDatasourceInfo(String projectId) throws Exception {
DmpProjectSystemInfo dmpProjectSystemInfo = dmpProjectDao.queryProjectSystemInfo(Long.valueOf(projectId));
String kafkaConnectUrl = dmpProjectSystemInfo.getKafkaConnectorUrl(); //kafka 连接信息
String [] arr = kafkaConnectUrl.split(",");
return new JsonResult(arr);
} }
} }
\ No newline at end of file
...@@ -364,22 +364,23 @@ ...@@ -364,22 +364,23 @@
</select> </select>
<!--根据数据源id获取数据信息--> <!--根据数据源id获取数据信息-->
<select id="querygSourceDbInfoById" parameterType="map" resultType="map"> <select id="querygSourceDbInfoById" parameterType="map" resultType="com.jz.dmp.modules.model.RealTimeSyncDataSourceModel">
select select
ds.id as id, ds.id as id,
ds.datasource_name as datasourceName,
ds.jdbc_url as jdbcUrl, ds.jdbc_url as jdbcUrl,
ds.user_name as userName, ds.user_name as userName,
ds.password, ds.password,
ds.db_name as dbName, ds.db_name as dbName,
dsdt.datasource as datasourceTypeName, dsdt.datasource_type as datasourceTypeName,
dsdt.driver_class_name as driverClassName, dsdt.driver_class_name as driverName
dsdt.datasource,
from dmp_syncing_datasource ds from dmp_syncing_datasource ds
inner join dmp_syncing_datasource_type dsdt on ds.datasource_type = dsdt.id inner join dmp_syncing_datasource_type dsdt on ds.datasource_type = dsdt.id
where 1=1 and ds.data_status = '1' dsd.ID = #{srcDataSourceId} where 1=1 and ds.data_status = '1'
and ds.ID = #{srcDataSourceId}
</select> </select>
<select id="queryListById11" resultType="java.util.Map"> <select id="queryRealTimeInfoByDataSourceId" resultType="java.util.Map">
select select
src_table_name as srcTableName, src_table_name as srcTableName,
connector_job_id as connectorJobId, connector_job_id as connectorJobId,
...@@ -387,8 +388,9 @@ ...@@ -387,8 +388,9 @@
arithmetic arithmetic
from dmp_realtime_sync_info from dmp_realtime_sync_info
where 1=1 and type =2 where 1=1 and type =2
<if test="targetDataSourceId != null"> and target_datasource_id = #{targetDataSourceId} </if> and src_datasource_id = #{srcDatasourceId}
<if test="srcTableName != null"> and src_table_name = #{srcTableName} </if> <if test="targetDatasourceId != null"> and target_datasource_id = #{targetDatasourceId} </if>
<!--<if test="srcTableName != null"> and src_table_name = #{srcTableName} </if>-->
</select> </select>
<!-- 查询源数据源的黑名单表 --> <!-- 查询源数据源的黑名单表 -->
......
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