Commit 72413f6c authored by mcb's avatar mcb

commit

parent ddde5e1e
......@@ -5,10 +5,12 @@ 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.*;
import com.jz.dmp.modules.service.DmpNavigationTreeService;
import com.jz.dmp.modules.controller.dataService.bean.SoureTableColumnsReq;
import com.jz.dmp.modules.service.DmpSyncingDatasourceTypeService;
import com.jz.dmp.modules.service.OfflineSynchService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -16,9 +18,7 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @Description:离线同步
......@@ -34,6 +34,9 @@ public class OfflineSynchController {
@Autowired
private OfflineSynchService offlineSynchService;
@Autowired
private DmpSyncingDatasourceTypeService dmpSyncingDatasourceTypeService;
/**
* 离线同步任务列表分页查询
*
......@@ -62,12 +65,29 @@ public class OfflineSynchController {
*/
@ApiOperation(value = "获取源数据库名称-下拉框", notes = "获取源数据库名称")
@GetMapping(value = "/sourceDbList")
@ApiImplicitParam(name = "projectId", value = "项目id", required = true)
public JsonResult<List<SourceDbNameListDto>> getSourceDbList(@RequestParam Integer projectId) throws Exception {
JsonResult<List<SourceDbNameListDto>> jsonResult = offlineSynchService.querygSourceDbList(projectId);
@ApiImplicitParams({@ApiImplicitParam(name = "projectId", value = "项目id", required = true)
,@ApiImplicitParam(name = "datasourceTypeId", value = "数据源类型id")
,@ApiImplicitParam(name = "type", value = "01:来源,02目标")
})
public JsonResult<List<SourceDbNameListDto>> getSourceDbList(@RequestParam Integer projectId,@RequestParam(required = false) String type, @RequestParam String datasourceTypeId) throws Exception {
JsonResult<List<SourceDbNameListDto>> jsonResult = offlineSynchService.querygSourceDbList(projectId,datasourceTypeId);
return jsonResult;
}
/**
* 获取数据源——下拉框
*
* @return
* @since 2021-01-21
* @author Bellamy
*/
@ApiOperation(value = "获取数据源—下拉框", notes = "获取数据源—下拉框")
@GetMapping(value = "/datasourceList")
public JsonResult getDatasourceList() throws Exception {
JsonResult list = dmpSyncingDatasourceTypeService.queryDatasourceList();
return list;
}
/**
* 根据源数据库id,获取源数据表——下拉框
*
......@@ -76,7 +96,7 @@ public class OfflineSynchController {
*/
@ApiOperation(value = "根据源数据库id,获取源数据表-下拉框", notes = "根据源数据库id,获取源数据表")
@GetMapping(value = "/sourceTableList")
@ApiImplicitParam(name = "sourceDbId", value = "源数据库id", required = true)
@ApiImplicitParams({@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;
......@@ -175,16 +195,23 @@ public class OfflineSynchController {
}
/**
* 获取源表和目标表的字段
* 获取数据源表字段
*
* @return
* @author Bellamy
*/
@ApiOperation(value = "获取源表和目标表的字段", notes = "获取源表和目标表的字段")
@ApiOperation(value = "获取数据源表字段", notes = "获取数据源表字段")
@PostMapping(value = "/getSoureAndTargetColumns")
public JsonResult getSoureAndTargetColumns(@RequestBody @Validated SoureAndTargetColumnsReq soureAndTargetColumnsReq) throws Exception {
JsonResult list = offlineSynchService.querySoureAndTargetColumnsByParams(soureAndTargetColumnsReq);
return list;
public JsonResult getSoureAndTargetColumns(@RequestBody @Validated SoureTableColumnsReq soureAndTargetColumnsReq) throws Exception {
JsonResult jsonResult = new JsonResult();
try {
jsonResult = offlineSynchService.querySoureTableColumns(soureAndTargetColumnsReq);
} catch (Exception e) {
jsonResult.setMessage(e.getMessage());
jsonResult.setCode(ResultCode.INTERNAL_SERVER_ERROR);
e.printStackTrace();
}
return jsonResult;
}
/**
......
......@@ -4,6 +4,7 @@ import com.jz.dmp.modules.model.DmpSyncingDatasourceType;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* 数据源类型(DmpSyncingDatasourceType)表数据库访问层
......@@ -79,4 +80,5 @@ public interface DmpSyncingDatasourceTypeDao {
*/
int deleteById(Integer id);
List<DmpSyncingDatasourceType> queryAllByParams(Map params) throws Exception;
}
\ No newline at end of file
package com.jz.dmp.modules.model;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
/**
......@@ -8,15 +11,18 @@ import java.io.Serializable;
* @author Bellamy
* @since 2020-12-21 18:39:06
*/
@ApiModel("数据源类型")
public class DmpSyncingDatasourceType implements Serializable {
private static final long serialVersionUID = 526021146272437267L;
/**
* ID
*/
@ApiModelProperty(value = "id")
private Integer id;
/**
* 数据源名称
*/
@ApiModelProperty(value = "数据源名称")
private String datasource;
/**
* 数据源分类
......
package com.jz.dmp.modules.service;
import com.jz.common.constant.JsonResult;
import com.jz.dmp.modules.model.DmpSyncingDatasourceType;
import java.util.List;
......@@ -54,4 +55,12 @@ public interface DmpSyncingDatasourceTypeService {
*/
boolean deleteById(Integer id);
/**
* 获取数据源——下拉框
*
* @return
* @since 2021-01-21
* @author Bellamy
*/
JsonResult queryDatasourceList() throws Exception;
}
\ No newline at end of file
......@@ -32,7 +32,7 @@ public interface OfflineSynchService {
* @return
* @author Bellamy
*/
JsonResult querygSourceDbList(Integer projectId) throws Exception;
JsonResult querygSourceDbList(Integer projectId,String databaseTypeName) throws Exception;
/**
* 根据源数据库id,获取源数据表——下拉框
......
package com.jz.dmp.modules.service.impl;
import com.jz.common.constant.JsonResult;
import com.jz.dmp.modules.dao.DmpSyncingDatasourceTypeDao;
import com.jz.dmp.modules.model.DmpSyncingDatasourceType;
import com.jz.dmp.modules.service.DmpSyncingDatasourceTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 数据源类型(DmpSyncingDatasourceType)表服务实现类
......@@ -76,4 +79,18 @@ public class DmpSyncingDatasourceTypeServiceImpl implements DmpSyncingDatasource
public boolean deleteById(Integer id) {
return this.dmpSyncingDatasourceTypeDao.deleteById(id) > 0;
}
/**
* 获取数据源——下拉框
*
* @return
* @author Bellamy
* @since 2021-01-21
*/
@Override
public JsonResult queryDatasourceList() throws Exception {
Map params = new HashMap<>();
List<DmpSyncingDatasourceType> list = dmpSyncingDatasourceTypeDao.queryAllByParams(params);
return JsonResult.ok(list);
}
}
\ No newline at end of file
......@@ -114,10 +114,10 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
* 获取源数据库名称——下拉框
*/
@Override
public JsonResult<List<SourceDbNameListDto>> querygSourceDbList(Integer projectId) throws Exception {
public JsonResult<List<SourceDbNameListDto>> querygSourceDbList(Integer projectId,String datasourceTypeId) throws Exception {
Map map = new HashMap();
map.put("projectId", projectId); //项目id
//map.put("isEnableSource", "1");
map.put("datasourceTypeId", datasourceTypeId);
List<SourceDbNameListDto> list = offlineSynchDao.querygSourceDbList(map);
return new JsonResult(ResultCode.SUCCESS, list);
}
......@@ -728,6 +728,8 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
Map map = returnList.get(i);
map.put("id", i + 1);
}
} else {
throw new RuntimeException("无数据!");
}
return JsonResult.ok(returnList);
}
......
......@@ -92,6 +92,15 @@
</where>
</select>
<select id="queryAllByParams" resultType="com.jz.dmp.modules.model.DmpSyncingDatasourceType">
select
id, datasource, datasource_catecode, datasource_catename, datasource_type, img_url, data_status, is_enabled,
datasource_catetype, driver_class_name, is_enable_test, default_source_script, default_target_script,
is_enable_source, is_enable_target
from dmp_syncing_datasource_type
where 1=1 and DATA_STATUS='1'
</select>
<!--新增所有列-->
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
insert into dmp_syncing_datasource_type(DATASOURCE, DATASOURCE_CATECODE, DATASOURCE_CATENAME, DATASOURCE_TYPE, IMG_URL, DATA_STATUS, IS_ENABLED, DATASOURCE_CATETYPE, DRIVER_CLASS_NAME, IS_ENABLE_TEST, DEFAULT_SOURCE_SCRIPT, DEFAULT_TARGET_SCRIPT, IS_ENABLE_SOURCE, IS_ENABLE_TARGET)
......
......@@ -53,6 +53,7 @@
<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="dbName != null and dbName !='' "> and dsdt.datasource = #{dbName} </if>
<if test="datasourceTypeId != null and datasourceTypeId != '' ">and dsdt.id=#{datasourceTypeId}</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