Commit ec2fd30f authored by mcb's avatar mcb

获取源数据库下拉框

parent cbd215fb
package com.jz.common.constant; package com.jz.common.constant;
public class JsonResult { import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
@ApiModel(value = "接口返回对象", description = "接口返回对象")
@JsonInclude(JsonInclude.Include.NON_NULL)
public class JsonResult<T> {
/**
* 返回代码
*/
@ApiModelProperty(value = "返回代码")
private String code; private String code;
/**
* 返回处理消息
*/
@ApiModelProperty(value = "返回处理消息")
private String message; private String message;
private Object data;
/**
* 返回数据对象 data
*/
@ApiModelProperty(value = "返回数据对象")
private T data;
public JsonResult() { public JsonResult() {
this.setCode(ResultCode.SUCCESS); this.setCode(ResultCode.SUCCESS);
this.setMessage("成功?"); this.setMessage("成功?");
} }
public JsonResult(ResultCode code) { public JsonResult(ResultCode code) {
...@@ -21,13 +41,13 @@ public class JsonResult { ...@@ -21,13 +41,13 @@ public class JsonResult {
this.setMessage(message); this.setMessage(message);
} }
public JsonResult(ResultCode code, Object data) { public JsonResult(ResultCode code, T data) {
this.setCode(code); this.setCode(code);
this.setMessage(code.msg()); this.setMessage(code.msg());
this.setData(data); this.setData(data);
} }
public JsonResult(ResultCode code, String message, Object data) { public JsonResult(ResultCode code, String message, T data) {
this.setCode(code); this.setCode(code);
this.setMessage(message); this.setMessage(message);
this.setData(data); this.setData(data);
...@@ -49,11 +69,11 @@ public class JsonResult { ...@@ -49,11 +69,11 @@ public class JsonResult {
this.message = message; this.message = message;
} }
public Object getData() { public T getData() {
return data; return data;
} }
public void setData(Object data) { public void setData(T data) {
this.data = data; this.data = data;
} }
......
...@@ -3,19 +3,19 @@ package com.jz.dmp.modules.controller.DataIntegration; ...@@ -3,19 +3,19 @@ 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.constant.ResultCode;
import com.jz.common.page.PageInfoResponse; import com.jz.common.page.PageInfoResponse;
import com.jz.dmp.modules.controller.DataIntegration.bean.SourceDbNameListDto;
import com.jz.dmp.modules.controller.DataIntegration.bean.TaskListPageDto; import com.jz.dmp.modules.controller.DataIntegration.bean.TaskListPageDto;
import com.jz.dmp.modules.controller.DataIntegration.bean.TaskListPageReq; import com.jz.dmp.modules.controller.DataIntegration.bean.TaskListPageReq;
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.ApiImplicitParam;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
...@@ -28,25 +28,39 @@ import java.util.Map; ...@@ -28,25 +28,39 @@ import java.util.Map;
@RequestMapping("/offlineSynch") @RequestMapping("/offlineSynch")
@Api(tags = "数据集成--离线同步") @Api(tags = "数据集成--离线同步")
public class OfflineSynchController { public class OfflineSynchController {
@Autowired
private OfflineSynchService offlineSynchService;
/** @Autowired
* 任务列表分页查询 private OfflineSynchService offlineSynchService;
* @return
*/ /**
@ApiOperation(value = "任务列表分页查询", notes = "任务列表分页查询") * 任务列表分页查询
@PostMapping(value = "/taskListPage") *
public PageInfoResponse<TaskListPageDto> getTaskListPage(@RequestBody @Validated TaskListPageReq taskListPageReq) { * @return
PageInfoResponse<TaskListPageDto> pageInfo = new PageInfoResponse<TaskListPageDto>(); */
try { @ApiOperation(value = "任务列表分页查询", notes = "任务列表分页查询")
pageInfo = offlineSynchService.queryTaskListPage(taskListPageReq); @PostMapping(value = "/taskListPage")
} catch (Exception e) { public PageInfoResponse<TaskListPageDto> getTaskListPage(@RequestBody @Validated TaskListPageReq taskListPageReq) {
pageInfo.setMessage("查询失败"); PageInfoResponse<TaskListPageDto> pageInfo = new PageInfoResponse<TaskListPageDto>();
pageInfo.setCode(ResultCode.INTERNAL_SERVER_ERROR); try {
e.printStackTrace(); pageInfo = offlineSynchService.queryTaskListPage(taskListPageReq);
} } catch (Exception e) {
return pageInfo; pageInfo.setMessage("查询失败");
} pageInfo.setCode(ResultCode.INTERNAL_SERVER_ERROR);
e.printStackTrace();
}
return pageInfo;
}
/**
* 获取源数据库名称——下拉框
*
* @return
*/
@ApiOperation(value = "获取源数据库名称-下拉框", notes = "获取源数据库名称")
@GetMapping(value = "/sourceDbList")
@ApiImplicitParam(name = "projectId",value = "项目id")
public JsonResult<List<SourceDbNameListDto>> getSourceDbList(@RequestParam Integer projectId) throws Exception {
JsonResult<List<SourceDbNameListDto>> jsonResult = offlineSynchService.querygSourceDbList(projectId);
return jsonResult;
}
} }
package com.jz.dmp.modules.dao; package com.jz.dmp.modules.dao;
import com.jz.dmp.modules.controller.DataIntegration.bean.SourceDbNameListDto;
import com.jz.dmp.modules.controller.DataIntegration.bean.TaskListPageDto; import com.jz.dmp.modules.controller.DataIntegration.bean.TaskListPageDto;
import com.jz.dmp.modules.controller.DataIntegration.bean.TaskListPageReq; import com.jz.dmp.modules.controller.DataIntegration.bean.TaskListPageReq;
...@@ -13,4 +14,6 @@ import java.util.Map; ...@@ -13,4 +14,6 @@ import java.util.Map;
public interface OfflineSynchDao { public interface OfflineSynchDao {
List<TaskListPageDto> queryTaskListPage(TaskListPageReq taskListPageReq) throws Exception; List<TaskListPageDto> queryTaskListPage(TaskListPageReq taskListPageReq) throws Exception;
List<SourceDbNameListDto> querygSourceDbList(Map map) throws Exception;
} }
\ No newline at end of file
package com.jz.dmp.modules.service; package com.jz.dmp.modules.service;
import com.jz.common.constant.JsonResult;
import com.jz.common.page.PageInfoResponse; import com.jz.common.page.PageInfoResponse;
import com.jz.dmp.modules.controller.DataIntegration.bean.TaskListPageDto; import com.jz.dmp.modules.controller.DataIntegration.bean.TaskListPageDto;
import com.jz.dmp.modules.controller.DataIntegration.bean.TaskListPageReq; import com.jz.dmp.modules.controller.DataIntegration.bean.TaskListPageReq;
...@@ -14,4 +15,6 @@ import com.jz.dmp.modules.controller.DataIntegration.bean.TaskListPageReq; ...@@ -14,4 +15,6 @@ import com.jz.dmp.modules.controller.DataIntegration.bean.TaskListPageReq;
public interface OfflineSynchService { public interface OfflineSynchService {
PageInfoResponse<TaskListPageDto> queryTaskListPage(TaskListPageReq taskListPageReq) throws Exception; PageInfoResponse<TaskListPageDto> queryTaskListPage(TaskListPageReq taskListPageReq) throws Exception;
JsonResult querygSourceDbList(Integer projectId) throws Exception;
} }
...@@ -3,8 +3,10 @@ package com.jz.dmp.modules.service.impl; ...@@ -3,8 +3,10 @@ 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.Constants; import com.jz.common.constant.Constants;
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.dmp.modules.controller.DataIntegration.bean.SourceDbNameListDto;
import com.jz.dmp.modules.controller.DataIntegration.bean.TaskListPageDto; import com.jz.dmp.modules.controller.DataIntegration.bean.TaskListPageDto;
import com.jz.dmp.modules.controller.DataIntegration.bean.TaskListPageReq; import com.jz.dmp.modules.controller.DataIntegration.bean.TaskListPageReq;
import com.jz.dmp.modules.dao.OfflineSynchDao; import com.jz.dmp.modules.dao.OfflineSynchDao;
...@@ -48,4 +50,13 @@ public class OfflineSynchServiceImpl implements OfflineSynchService { ...@@ -48,4 +50,13 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
pageInfoResponse.setData(pageInfo); pageInfoResponse.setData(pageInfo);
return pageInfoResponse; return pageInfoResponse;
} }
@Override
public JsonResult<List<SourceDbNameListDto>> querygSourceDbList(Integer projectId) throws Exception {
Map map = new HashMap();
map.put("projectId", projectId); //项目id
map.put("isEnableSource", "1");
List<SourceDbNameListDto> list = offlineSynchDao.querygSourceDbList(map);
return new JsonResult(ResultCode.SUCCESS, list);
}
} }
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!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.OfflineSynchDao"> <mapper namespace="com.jz.dmp.modules.dao.OfflineSynchDao">
<!--离线任务列表-->
<select id="queryTaskListPage" resultType="com.jz.dmp.modules.controller.DataIntegration.bean.TaskListPageDto" <select id="queryTaskListPage" resultType="com.jz.dmp.modules.controller.DataIntegration.bean.TaskListPageDto"
parameterType="com.jz.dmp.modules.controller.DataIntegration.bean.TaskListPageReq"> parameterType="com.jz.dmp.modules.controller.DataIntegration.bean.TaskListPageReq">
SELECT SELECT
...@@ -36,4 +37,28 @@ ...@@ -36,4 +37,28 @@
ORDER BY ddt.create_time DESC ORDER BY ddt.create_time DESC
</select> </select>
<!--获取源数据库名称-->
<select id="querygSourceDbList" parameterType="map" resultType="com.jz.dmp.modules.controller.DataIntegration.bean.SourceDbNameListDto">
select
ds.id as id,
ds.datasource_name as datasourceNameOrg,
ds.jdbc_url as jdbcUrl,
dsdt.datasource as datasourceTypeName,
concat(ds.datasource_name, ' (', dsdt.datasource, ')') as datasourceName,
dsdt.datasource_type as datasourceType,
dsdt.datasource_catecode as datasourceCatecode
from dmp_syncing_datasource ds
inner join dmp_syncing_datasource_type dsdt on ds.datasource_type = dsdt.id
<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 = 'datasourceType != null and datasourceType > 0 '>
and ds.DATASOURCE_TYPE = #{datasourceType}
</if>
</select>
</mapper> </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