Commit 0638dbda by 袁伟铭

对接调试共享平台接口

parent fc48f8c1
......@@ -13,6 +13,8 @@ import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* @author wilmiam
* @since 2021/9/7 17:17
......@@ -33,7 +35,8 @@ public class DbInfoController {
AssertUtils.hasText(vo.getDbName(), "缺少数据库名称");
AssertUtils.hasText(vo.getDbUser(), "缺少账号");
AssertUtils.hasText(vo.getDbPwd(), "缺少密码");
AssertUtils.hasText(vo.getDeptId(), "缺少部门ID");
AssertUtils.hasText(vo.getCategoryId(), "缺少目录ID");
AssertUtils.hasText(vo.getSystemId(), "缺少系统ID");
dbInfoService.addDbInfo(vo);
return ResultVo.success();
......@@ -54,6 +57,12 @@ public class DbInfoController {
return ResultVo.success(dbInfoService.getDbInfoList(vo));
}
@ApiOperation("获取全部数据库列表")
@PostMapping(value = "/getAllDbInfoList")
public ResultVo<List<DbInfo>> getAllDbInfoList(@RequestBody DbInfoFindVo vo) {
return ResultVo.success(dbInfoService.getAllDbInfoList(vo));
}
@ApiOperation("获取数据库信息")
@PostMapping(value = "/getDbInfoInfo/{id}")
public ResultVo<DbInfo> getDbInfoInfo(@PathVariable String id) {
......@@ -62,10 +71,11 @@ public class DbInfoController {
@ApiOperation("注册库表资源")
@PostMapping(value = "/share/registerDbInfo")
public ResultVo registerDbInfo(@RequestBody IdVo vo) {
public ResultVo registerDbInfo(@RequestBody IdVo vo, @RequestParam String mappingId) {
AssertUtils.isTrue(CollUtil.isNotEmpty(vo.getIds()), "至少选择一项");
AssertUtils.hasText(mappingId, "缺少映射ID");
dbInfoService.registerDbInfo(vo.getIds());
dbInfoService.registerDbInfo(vo.getIds(), mappingId);
return ResultVo.success();
}
......
......@@ -138,6 +138,12 @@ public class StandardDataController {
return ResultVo.success(standardDataService.getStandardDataMappingList(vo));
}
@ApiOperation("获取所有数据元映射列表")
@PostMapping(value = "/getAllStandardDataMappingList")
public ResultVo<List<StandardDataMapping>> getAllStandardDataMappingList(@RequestBody StandardDataMappingFindVo vo) {
return ResultVo.success(standardDataService.getAllStandardDataMappingList(vo));
}
@ApiOperation("获取数据元映射信息")
@GetMapping(value = "/getStandardDataMappingInfo/{standardMappingDataId}")
public ResultVo<StandardDataMapping> getStandardDataMappingInfo(@PathVariable String standardMappingDataId) {
......
......@@ -32,7 +32,7 @@ public class SystemController {
return ResultVo.success(systemInfoService.getSystemList(vo));
}
@ApiOperation("获取系统列表")
@ApiOperation("获取全部系统列表")
@PostMapping(value = "/getAllSystemList")
public ResultVo<List<SystemInfo>> getAllSystemList(@RequestBody SystemInfoFindVo vo) {
return ResultVo.success(systemInfoService.getAllSystemList(vo));
......
......@@ -60,10 +60,22 @@ public class DbInfo {
private String dbPwd;
/**
* 规定机构部门
* 目录ID
*/
@ApiModelProperty("规定机构部门")
private String deptId;
@ApiModelProperty("目录ID")
private String categoryId;
/**
* 系统ID
*/
@ApiModelProperty("系统ID")
private String systemId;
/**
* 主题分类
*/
@ApiModelProperty("主题分类")
private String business;
/**
* 描述
......
......@@ -87,7 +87,7 @@ public class StandardData {
* 是否非空
*/
@ApiModelProperty("是否非空")
private Boolean notNull;
private String notNull;
/**
* 数据标准编目
......
package com.zq.resource.service;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.zq.common.utils.AssertUtils;
import com.zq.common.utils.PagingUtils;
import com.zq.common.vo.PageVo;
import com.zq.resource.dao.DbInfoDao;
import com.zq.resource.entity.DbInfo;
import com.zq.resource.constant.ShareApiEnum;
import com.zq.resource.dao.*;
import com.zq.resource.entity.*;
import com.zq.resource.utils.ShareApiUtils;
import com.zq.resource.vo.DbInfoFindVo;
import com.zq.resource.vo.ShareApiResponse;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
......@@ -26,8 +31,18 @@ import java.util.Set;
public class DbInfoService {
private final DbInfoDao dbInfoDao;
private final DataCategoryDao dataCategoryDao;
private final SystemInfoDao systemInfoDao;
private final OrgDeptDao orgDeptDao;
private final StandardDataMappingDao standardDataMappingDao;
private final StandardDataDao standardDataDao;
public void addDbInfo(DbInfo vo) {
DataCategory dataCategory = dataCategoryDao.selectById(vo.getCategoryId());
AssertUtils.notNull(dataCategory, "目录不存在");
SystemInfo systemInfo = systemInfoDao.selectById(vo.getSystemId());
AssertUtils.notNull(systemInfo, "系统不存在");
vo.setCreateTime(DateUtil.date());
vo.setUpdateTime(DateUtil.date());
......@@ -43,7 +58,9 @@ public class DbInfoService {
dbInfo.setDbName(vo.getDbName());
dbInfo.setDbUser(vo.getDbUser());
dbInfo.setDbPwd(vo.getDbPwd());
dbInfo.setDeptId(vo.getDeptId());
dbInfo.setCategoryId(vo.getCategoryId());
dbInfo.setSystemId(vo.getSystemId());
dbInfo.setBusiness(vo.getBusiness());
dbInfo.setRemark(vo.getRemark());
dbInfo.setUpdateTime(DateUtil.date());
......@@ -69,19 +86,73 @@ public class DbInfoService {
return PagingUtils.paging(vo, dbInfoDao, DbInfo.class, lambdaQuery);
}
public List<DbInfo> getAllDbInfoList(DbInfoFindVo vo) {
LambdaQueryWrapper<DbInfo> lambdaQuery = Wrappers.lambdaQuery(DbInfo.class);
if (StringUtils.isNotBlank(vo.getDbIp())) {
lambdaQuery.like(DbInfo::getDbIp, vo.getDbIp());
vo.setDbIp(null);
}
if (StringUtils.isNotBlank(vo.getDbName())) {
lambdaQuery.like(DbInfo::getDbName, vo.getDbName());
vo.setDbName(null);
}
if (StringUtils.isNotBlank(vo.getRemark())) {
lambdaQuery.like(DbInfo::getRemark, vo.getRemark());
vo.setRemark(null);
}
DbInfo dbInfo = BeanUtil.copyProperties(vo, DbInfo.class);
lambdaQuery.setEntity(dbInfo);
return dbInfoDao.selectList(lambdaQuery);
}
public DbInfo getDbInfoInfo(String id) {
return dbInfoDao.selectById(id);
}
public void registerDbInfo(Set<String> ids) {
public void registerDbInfo(Set<String> ids, String mappingId) {
for (String id : ids) {
DbInfo dbInfo = dbInfoDao.selectById(id);
if (dbInfo != null && StringUtils.isBlank(dbInfo.getCascadeguid())) {
Map<Object, Object> params = new HashMap<>();
DataCategory dataCategory = dataCategoryDao.selectById(dbInfo.getCategoryId());
AssertUtils.hasText(dataCategory.getCascadeguid(), "目录未注册");
SystemInfo systemInfo = systemInfoDao.selectById(dbInfo.getSystemId());
AssertUtils.hasText(systemInfo.getCascadeguid(), "系统未注册");
OrgDept orgDept = orgDeptDao.selectById(dataCategory.getDeptId());
StandardDataMapping standardDataMapping = standardDataMappingDao.selectById(mappingId);
Map<String, Object> params = new HashMap<>();
params.put("resource_name", dataCategory.getCataTitle());
params.put("cata_id", dataCategory.getCascadeguid());
params.put("resour_system_id", systemInfo.getCascadeguid());
params.put("credit_code", orgDept.getCreditCode());
params.put("business", dbInfo.getBusiness());
params.put("connecttion_name", standardDataMapping.getConnecttionName());
params.put("db_ip", dbInfo.getDbIp());
params.put("db_port", dbInfo.getDbPort());
params.put("db_name", dbInfo.getDbName());
params.put("db_user", dbInfo.getDbUser());
params.put("db_pwd", dbInfo.getDbPwd());
params.put("usessl", standardDataMapping.getUsessl());
params.put("tableJson", getTableJson(standardDataMapping));
ShareApiResponse shareApiResponse = ShareApiUtils.doPost(params, ShareApiEnum.TABLE_REGISTER);
if (shareApiResponse.isSuccess()) {
dbInfo.setCascadeguid(shareApiResponse.getString("cascadeguid"));
dbInfo.setUpdateTime(DateUtil.date());
dbInfoDao.updateById(dbInfo);
}
}
}
}
public Map<String, Object> getTableJson(StandardDataMapping standardDataMapping) {
standardDataDao.selectList(Wrappers.lambdaQuery(StandardData.builder().build()));
return null;
}
public void cancelDbInfo(Set<String> ids) {
for (String id : ids) {
......
......@@ -176,6 +176,32 @@ public class StandardDataService {
return PagingUtils.paging(vo, standardDataMappingDao, StandardDataMapping.class, lambdaQuery);
}
public List<StandardDataMapping> getAllStandardDataMappingList(StandardDataMappingFindVo vo) {
LambdaQueryWrapper<StandardDataMapping> lambdaQuery = Wrappers.lambdaQuery(StandardDataMapping.class);
if (StringUtils.isNotBlank(vo.getTableName())) {
lambdaQuery.like(StandardDataMapping::getTableName, vo.getTableName());
vo.setTableName(null);
}
if (StringUtils.isNotBlank(vo.getTableSqlname())) {
lambdaQuery.like(StandardDataMapping::getTableSqlname, vo.getTableSqlname());
vo.setTableSqlname(null);
}
if (StringUtils.isNotBlank(vo.getConnecttionName())) {
lambdaQuery.like(StandardDataMapping::getConnecttionName, vo.getConnecttionName());
vo.setConnecttionName(null);
}
if (StringUtils.isNotBlank(vo.getCreditCode())) {
lambdaQuery.like(StandardDataMapping::getCreditCode, vo.getCreditCode());
vo.setCreditCode(null);
}
StandardDataMapping standardDataMapping = BeanUtil.copyProperties(vo, StandardDataMapping.class);
lambdaQuery.setEntity(standardDataMapping);
return standardDataMappingDao.selectList(lambdaQuery);
}
public StandardDataMapping getStandardDataMappingInfo(String standardMappingDataId) {
return standardDataMappingDao.selectById(standardMappingDataId);
}
......
......@@ -111,7 +111,7 @@ public class ShareApiUtils {
ShareApiResponse shareApiResponse = JSON.parseObject(result, ShareApiResponse.class);
if (isTipError) {
AssertUtils.isTrue(shareApiResponse.isSuccess(), 5000, shareApiResponse.getMessage());
AssertUtils.isTrue(shareApiResponse.isSuccess(), 5000, StringUtils.isNotBlank(shareApiResponse.getMessage()) ? shareApiResponse.getMessage() : shareApiResponse.getError());
}
return shareApiResponse;
......
......@@ -47,10 +47,10 @@ public class DataCategoryGroupVo {
private String parentName;
/**
* 目录分类授权部门的社会信用代码
* 目录分类授权部门的ID
*/
@ApiModelProperty("目录分类授权部门的社会信用代码")
private String creditCode;
@ApiModelProperty("目录分类授权部门的ID")
private String deptId;
/**
* 目录分类描述
......
......@@ -58,10 +58,16 @@ public class DbInfoFindVo extends PageReqVo {
private String dbPwd;
/**
* 规定机构部门
* 目录ID
*/
@ApiModelProperty("规定机构部门")
private String deptId;
@ApiModelProperty("目录ID")
private String categoryId;
/**
* 系统ID
*/
@ApiModelProperty("系统ID")
private String systemId;
/**
* 描述
......
......@@ -106,9 +106,9 @@ public class SystemInfoFindVo extends PageReqVo {
private Date updateTime;
/**
* 共享状态: 0-未注册, 1-已注册
* 状态: 1-正常, 2-删除
*/
@ApiModelProperty("共享状态: 0-未注册, 1-已注册")
private Integer shareStatus;
@ApiModelProperty("状态: 1-正常, 2-删除")
private Integer state;
}
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