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
This diff is collapsed.
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