Commit 69976e70 authored by mcb's avatar mcb

no message

parent 40eb0b54
......@@ -5,11 +5,14 @@ import com.jz.dmp.agent.DmpAgentResult;
import com.jz.dmp.modules.model.DmpAgentDatasourceInfo;
public interface DmpDsAgentService {
//jdbc连接
public DmpAgentResult testConnect(DmpAgentDatasourceInfo ds);
//获取数据源表库名称
public DmpAgentResult getTableNameList(DmpAgentDatasourceInfo ds);
//获取数据源表字段
public DmpAgentResult getTableColumnList(DmpAgentDatasourceInfo ds, String tableName);
public DmpAgentResult previewData(DmpAgentDatasourceInfo ds, String tableName);
......
......@@ -61,7 +61,7 @@ public class OfflineSynchController {
*/
@ApiOperation(value = "获取源数据库名称-下拉框", notes = "获取源数据库名称")
@GetMapping(value = "/sourceDbList")
@ApiImplicitParam(name = "projectId", value = "项目id",required = true)
@ApiImplicitParam(name = "projectId", value = "项目id", required = true)
public JsonResult<List<SourceDbNameListDto>> getSourceDbList(@RequestParam Integer projectId) throws Exception {
JsonResult<List<SourceDbNameListDto>> jsonResult = offlineSynchService.querygSourceDbList(projectId);
return jsonResult;
......@@ -75,7 +75,7 @@ public class OfflineSynchController {
*/
@ApiOperation(value = "根据源数据库id,获取源数据表-下拉框", notes = "根据源数据库id,获取源数据表")
@GetMapping(value = "/sourceTableList")
@ApiImplicitParam(name = "sourceDbId", value = "源数据库id")
@ApiImplicitParam(name = "sourceDbId", value = "源数据库id", required = true)
public JsonResult getSourceTableList(@RequestParam Long sourceDbId, @RequestParam(value = "targetName", required = false) String targetName) throws Exception {
JsonResult list = offlineSynchService.querygSourceTableList(sourceDbId, targetName);
return list;
......
......@@ -3,9 +3,11 @@ package com.jz.dmp.modules.controller.dataService;
import com.jz.common.constant.JsonResult;
import com.jz.common.constant.ResultCode;
import com.jz.dmp.modules.controller.DataIntegration.bean.SourceDbNameListDto;
import com.jz.dmp.modules.controller.DataIntegration.bean.SoureAndTargetColumnsReq;
import com.jz.dmp.modules.controller.dataService.bean.*;
import com.jz.dmp.modules.service.DmpApiMangeService;
import com.jz.dmp.modules.service.DmpApiServiceMangeService;
import com.jz.dmp.modules.service.OfflineSynchService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
......@@ -14,6 +16,7 @@ import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
......@@ -42,6 +45,9 @@ public class DmpApiServiceMangeController {
@Autowired
private DmpApiMangeService dmpApiMangeService;
@Autowired
private OfflineSynchService offlineSynchService;
/**
* 保存API(第三方)基本信息
*
......@@ -164,18 +170,19 @@ public class DmpApiServiceMangeController {
}
/**
* 获取数据源配置——下拉框
* 获取数据源——下拉框
*
* @return
* @author Bellamy
*/
@ApiOperation(value = "获取数据源配置-下拉框", notes = "获取数据源配置")
@ApiOperation(value = "获取数据源库-下拉框", notes = "获取数据源库")
@GetMapping(value = "/sourceDbList")
@ApiImplicitParam(name = "projectId", value = "项目id", required = true)
public JsonResult<List<SourceDbNameListDto>> getSourceDbList(@RequestParam Integer projectId) {
@ApiImplicitParams({@ApiImplicitParam(name = "projectId", value = "项目id", required = true),
@ApiImplicitParam(name = "dbName", value = "数据源类型名称", required = true)})
public JsonResult<List<SourceDbNameListDto>> getSourceDbList(@RequestParam Integer projectId,@RequestParam String dbName) {
JsonResult jsonResult = new JsonResult();
try {
jsonResult = dmpApiServiceMangeService.querygSourceDbList(projectId);
jsonResult = dmpApiServiceMangeService.querygSourceDbList(projectId,dbName);
} catch (Exception e) {
jsonResult.setMessage("查询失败");
jsonResult.setCode(ResultCode.INTERNAL_SERVER_ERROR);
......@@ -184,4 +191,52 @@ public class DmpApiServiceMangeController {
return jsonResult;
}
/**
* 配置数据源——下拉框
*
* @return
* @author Bellamy
* @since 2021-01-21
*/
@ApiOperation(value = "配置数据源-下拉框", notes = "配置数据源")
@GetMapping(value = "/sourceSetting")
public JsonResult getSourceSetting() throws Exception {
return dmpApiServiceMangeService.getSourceSetting();
}
/**
* 根据数据源库id,获取数据源表——下拉框
*
* @return
* @author Bellamy
*/
@ApiOperation(value = "根据数据源库id,获取数据源表-下拉框", notes = "根据数据源库id,获取数据源表")
@GetMapping(value = "/sourceTableList")
@ApiImplicitParam(name = "sourceDbId", value = "数据源库id", required = true)
public JsonResult getSourceTableList(@RequestParam Long sourceDbId, @RequestParam(value = "targetName", required = false) String targetName) throws Exception {
JsonResult jsonResult = new JsonResult();
try {
jsonResult = offlineSynchService.querygSourceTableList(sourceDbId, targetName);
} catch (Exception e) {
jsonResult.setMessage(e.getMessage());
jsonResult.setCode(ResultCode.INTERNAL_SERVER_ERROR);
e.printStackTrace();
}
return jsonResult;
}
/**
* 获取数据源表字段
*
* @return
* @author Bellamy
* @since 2021-01-21
*/
@ApiOperation(value = "获取数据源表字段", notes = "获取数据源表字段")
@PostMapping(value = "/getTableColumns")
public JsonResult getTableColumns(@RequestBody @Validated SoureTableColumnsReq req) throws Exception {
JsonResult list = offlineSynchService.querySoureTableColumns(req);
return list;
}
}
\ No newline at end of file
......@@ -19,53 +19,53 @@ import java.io.Serializable;
public class ApiInterfaceReq implements Serializable {
@ApiModelProperty(value = "接口描述",required = false)
@ApiModelProperty(value = "接口描述", required = false)
public String apiDesc;
@ApiModelProperty(value = "传输方式:http https",required = true)
@ApiModelProperty(value = "传输方式:http https", required = true)
@NotNull(message = "传输方式不能为空")
public String transMode;
@ApiModelProperty(value = "加密方式0 无,1:MD5 2:RSA",required = true)
@ApiModelProperty(value = "加密方式0 无,1:MD5 2:RSA", required = true)
@NotNull(message = "加密方式不能为空")
public String signType;
@ApiModelProperty(value = "接入类型:对应字典表key",required = true)
@ApiModelProperty(value = "接入类型:对应字典表key", required = true)
@NotNull(message = "接入类型不能为空")
public String joinType;
@ApiModelProperty(value = "目标地址",required = true)
@NotNull(message="目标地址不能为空")
@ApiModelProperty(value = "目标地址", required = true)
@NotNull(message = "目标地址不能为空")
public String targetUrl;
@ApiModelProperty(value = "超时时间",required = true)
@NotNull(message="超时时间不能为空")
@ApiModelProperty(value = "超时时间", required = true)
@NotNull(message = "超时时间不能为空")
public String timeout;
@ApiModelProperty(value = "限流类型:DAY 按天,MONTH 按月, YEAR 按年",required = true)
@ApiModelProperty(value = "限流类型:DAY 按天,MONTH 按月, YEAR 按年", required = true)
@NotNull(message = "限流类型不能为空")
public String reqType;
@ApiModelProperty(value = "限制次数",required = false)
@ApiModelProperty(value = "限制次数", required = false)
public Long reqFrequency;
@ApiModelProperty(value = "api描述",required = false)
@ApiModelProperty(value = "api描述", required = false)
public String apiFunction;
@ApiModelProperty(value = "父类文件id,一级文件夹传入0",required = false)
@ApiModelProperty(value = "父类文件id,一级文件夹传入0", required = false)
public Long parentId;
@ApiModelProperty(value = "文件id",required = false)
@ApiModelProperty(value = "文件id", required = false)
public Long fileId;
@ApiModelProperty(value = "项目id",required = true)
@NotNull(message="项目id不能为空")
@ApiModelProperty(value = "项目id", required = true)
@NotNull(message = "项目id不能为空")
public Long projectId;
@ApiModelProperty(value = "状态",required = false)
@ApiModelProperty(value = "状态", required = false)
public String status;
@ApiModelProperty(value = "更新时传入api自增id",required = false)
@ApiModelProperty(value = "更新时传入api自增id", required = false)
public Long id;
@ApiModelProperty(value = "创建用户")
......@@ -73,7 +73,10 @@ public class ApiInterfaceReq implements Serializable {
@ApiModelProperty(value = "api类型:1.数据银行制作大数据表 " +
"2 数据银行制作数据包,3,数据银行制作自定义API " +
"4 API实时接入 6 标签查询 9自定义",hidden = true)
"4 API实时接入 6 标签查询 9自定义", hidden = true)
public String apiType;
@ApiModelProperty(value = "请求方式")
public String reqMethod;
}
......@@ -29,4 +29,10 @@ public class AuthListInfoReq extends BasePageBean implements Serializable {
@ApiModelProperty(value = "API名称", required = false)
private String apiName;
@ApiModelProperty(value = "项目id")
private String projectId;
@ApiModelProperty(value = "文件id")
private String fileId;
}
package com.jz.dmp.modules.controller.dataService.bean;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* @ClassName: SoureTableColumnsReq
* @Description: 获取数据源表字段
* @Author:Bellamy
* @Date 2020/12/21
* @Version 1.0
*/
@ApiModel(value = "获取数据源表字段-请求参数对象", description = "获取数据源表字段-请求参数对象")
public class SoureTableColumnsReq implements Serializable {
private static final long serialVersionUID = -3931329194480499602L;
/*
* 源数据库ID
* */
@NotNull(message = "源数据库ID不能为空")
@ApiModelProperty(value = "源数据库ID")
private Long sourceDbId;
@NotNull(message = "表名称不能为空")
@NotEmpty(message = "表名称不能为空")
@ApiModelProperty(value = "表名称")
private String targetTableName;
private String fileType;
private String csvDelimiter;
private String csvIsHaveHeader;
public Long getSourceDbId() {
return sourceDbId;
}
public void setSourceDbId(Long sourceDbId) {
this.sourceDbId = sourceDbId;
}
public String getTargetTableName() {
return targetTableName;
}
public void setTargetTableName(String targetTableName) {
this.targetTableName = targetTableName;
}
public String getFileType() {
return fileType;
}
public void setFileType(String fileType) {
this.fileType = fileType;
}
public String getCsvDelimiter() {
return csvDelimiter;
}
public void setCsvDelimiter(String csvDelimiter) {
this.csvDelimiter = csvDelimiter;
}
public String getCsvIsHaveHeader() {
return csvIsHaveHeader;
}
public void setCsvIsHaveHeader(String csvIsHaveHeader) {
this.csvIsHaveHeader = csvIsHaveHeader;
}
}
......@@ -56,10 +56,19 @@ public interface DmpApiServiceMangeService {
JsonResult getCountAPiCallStat() throws Exception;
/**
* 获取数据源配置——下拉框
* 获取数据源——下拉框
*
* @return
* @author Bellamy
*/
JsonResult querygSourceDbList(Integer projectId) throws Exception;
JsonResult querygSourceDbList(Integer projectId,String dbName) throws Exception;
/**
* 配置数据源——下拉框
*
* @return
* @author Bellamy
* @since 2021-01-21
*/
JsonResult getSourceSetting() throws Exception;
}
\ No newline at end of file
......@@ -4,6 +4,7 @@ import com.jz.common.constant.JsonResult;
import com.jz.common.page.BasePageBean;
import com.jz.common.page.PageInfoResponse;
import com.jz.dmp.modules.controller.DataIntegration.bean.*;
import com.jz.dmp.modules.controller.dataService.bean.SoureTableColumnsReq;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
......@@ -92,4 +93,13 @@ public interface OfflineSynchService {
* @author Bellamy
*/
JsonResult updateSyncTask(SyncDmpTaskAddReq syncDmpTaskAddReq) throws Exception;
/**
* 获取数据源表字段
*
* @return
* @author Bellamy
* @since 2021-01-21
*/
JsonResult querySoureTableColumns(SoureTableColumnsReq req) throws Exception;
}
......@@ -22,10 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* @ClassName: DmpApiServiceMangeServiceImpl
......@@ -59,6 +56,7 @@ public class DmpApiServiceMangeServiceImpl implements DmpApiServiceMangeService
@Autowired
private OfflineSynchDao offlineSynchDao;
/**
* 保存API(第三方)基本信息
*
......@@ -239,17 +237,31 @@ public class DmpApiServiceMangeServiceImpl implements DmpApiServiceMangeService
}
/**
* 获取数据源配置——下拉框
* 获取数据源——下拉框
*
* @return
* @author Bellamy
*/
@Override
public JsonResult querygSourceDbList(Integer projectId) throws Exception {
public JsonResult querygSourceDbList(Integer projectId,String dbName) throws Exception {
Map map = new HashMap();
map.put("projectId", projectId); //项目id
map.put("datasource", apiBigSetting.split(","));
map.put("dbName", dbName);
List<SourceDbNameListDto> list = offlineSynchDao.querygSourceDbList(map);
return JsonResult.ok(list);
}
/**
* 配置数据源——下拉框
*
* @return
* @author Bellamy
* @since 2021-01-21
*/
@Override
public JsonResult getSourceSetting() throws Exception {
String[] arr = apiBigSetting.split(",");
List<String> list = Arrays.asList(arr);
return JsonResult.ok(list);
}
}
\ No newline at end of file
package com.jz.dmp.modules.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.jz.agent.service.DmpDsAgentService;
......@@ -18,6 +19,7 @@ import com.jz.common.utils.web.XmlUtils;
import com.jz.dmp.agent.DmpAgentResult;
import com.jz.dmp.modules.controller.DataIntegration.bean.*;
import com.jz.dmp.modules.controller.DataIntegration.bean.flow.FlowExecution;
import com.jz.dmp.modules.controller.dataService.bean.SoureTableColumnsReq;
import com.jz.dmp.modules.dao.*;
import com.jz.dmp.modules.model.*;
import com.jz.dmp.modules.service.DmpDevelopTaskService;
......@@ -128,6 +130,9 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
public JsonResult querygSourceTableList(Long sourceDbId, String targetName) throws Exception {
//通过源数据库id ,查询数据源配置
DmpAgentDatasourceInfo dsInfo = offlineSynchDao.querySourceDbInfoBySourceId(sourceDbId);
if (dsInfo == null) {
throw new RuntimeException("数据源配置信息不存在!");
}
//解码源数据库密码
if (StringUtils.isNotBlank(dsInfo.getPassword())) {
dsInfo.setPassword(new BaseService().decode(dsInfo.getPassword(), publicKey));
......@@ -141,8 +146,8 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
return new JsonResult(rst.getCode(), rst.getMessage());
} else {
//成功
rst.setResult(JsonMapper.fromJsonString(rst.getMessage(), List.class));
return new JsonResult(ResultCode.SUCCESS, rst);
//rst.setResult(JsonMapper.fromJsonString(rst.getMessage(), List.class));
return new JsonResult(ResultCode.SUCCESS, JsonMapper.fromJsonString(rst.getMessage(), List.class));
}
}
......@@ -690,4 +695,43 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
//批量新增任务与规则关系表
dvTaskRuleTService.saveRule(list);
}
/**
* 获取数据源表字段
*
* @return
* @author Bellamy
* @since 2021-01-21
*/
@Override
public JsonResult querySoureTableColumns(SoureTableColumnsReq req) throws Exception {
//通过源数据库id ,查询数据源配置
DmpAgentDatasourceInfo dsInfo = offlineSynchDao.querySourceDbInfoBySourceId(req.getSourceDbId());
if (dsInfo == null) {
throw new RuntimeException("数据源配置信息不存在!");
}
dsInfo.setFileType(req.getFileType());
dsInfo.setDelimiter(req.getCsvDelimiter());
dsInfo.setIsHaveHeader(req.getCsvIsHaveHeader());
//解码源数据库密码
if (StringUtils.isNotBlank(dsInfo.getPassword())) {
dsInfo.setPassword(new BaseService().decode(dsInfo.getPassword(), publicKey));
}
//创建jdbc,获取数据源表字段
DmpAgentResult rst = dmpDsAgentServiceImp.getTableColumnList(dsInfo, req.getTargetTableName());
if (!rst.getCode().val().equals("200")) {
return new JsonResult(rst.getCode(), rst.getMessage());
} else {
//成功
List<Map> returnList = (List<Map>) JsonMapper.fromJsonString(rst.getMessage(), List.class);
if (returnList != null && returnList.size() > 0) {
for (int i = 0; i < returnList.size(); i++) {
Map map = returnList.get(i);
map.put("id", i + 1);
}
}
return JsonResult.ok(returnList);
}
}
}
......@@ -52,12 +52,7 @@
<if test = 'isEnableSource != null and isEnableSource == "1"'> and dsdt.is_enable_source = '1' </if>
<if test = "isEnableTarget != null and isEnableTarget=='1'.toString()"> and dsdt.is_enable_target = '1' </if>
where ds.data_status = '1' and ds.project_id = #{projectId}
<if test="datasource != null and datasource !='' ">
and dsdt.datasource in
<foreach collection="datasource" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="dbName != null and dbName !='' "> and dsdt.datasource = #{dbName} </if>
<if test = 'datasourceType != null and datasourceType > 0 '> and ds.DATASOURCE_TYPE = #{datasourceType} </if>
</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