feat:增加了字典功能
parent
e689771020
commit
b4b3a54805
|
@ -0,0 +1,42 @@
|
|||
package com.etl.data.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 字典表
|
||||
* @author YunFei.Du
|
||||
* @date 21:27 2024/4/25
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@SuperBuilder
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("dictionary")
|
||||
public class Dictionary {
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
private Long id;
|
||||
/**
|
||||
* 数据源id
|
||||
*/
|
||||
private Long dataSourceId;
|
||||
|
||||
/**
|
||||
* 字典名称
|
||||
*/
|
||||
private String dictionaryName;
|
||||
|
||||
@TableField(select = false)
|
||||
private List< DictionaryInfo > dictionaryList;
|
||||
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
package com.etl.data.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* 字典详情表
|
||||
* @author YunFei.Du
|
||||
* @date 21:27 2024/4/25
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@SuperBuilder
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("dictionary_info")
|
||||
public class DictionaryInfo {
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
private Long id;
|
||||
/**
|
||||
* 字典表id
|
||||
*/
|
||||
private Long dictionaryId;
|
||||
/**
|
||||
* 标签
|
||||
*/
|
||||
private String label;
|
||||
/**
|
||||
* 值
|
||||
*/
|
||||
private Integer value;
|
||||
|
||||
/**
|
||||
* 是否编辑 (默认 0 不编辑)
|
||||
*/
|
||||
private Integer isEdit;
|
||||
|
||||
}
|
|
@ -9,18 +9,26 @@ import lombok.experimental.SuperBuilder;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName DataSourceDecoration
|
||||
* @Description 描述
|
||||
* @Author YunFei.Du
|
||||
* @Date 2024/4/23 14:39
|
||||
* 数据源修饰
|
||||
* @author YunFei.Du
|
||||
* @date 17:09 2024/4/25
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DataSourceDecoration {
|
||||
/**
|
||||
* 数据源
|
||||
*/
|
||||
private DataSource dataSource;
|
||||
/**
|
||||
* 数据库 修饰 集合
|
||||
*/
|
||||
private List<DataTableDecoration> dataTableList;
|
||||
/**
|
||||
* 数据源类型
|
||||
*/
|
||||
private String type;
|
||||
public static DataSourceDecoration dataSourceBuild(DataSource dataSource, List<DataTableDecoration> dataTables){
|
||||
return DataSourceDecoration.builder()
|
||||
|
|
|
@ -7,17 +7,22 @@ import lombok.NoArgsConstructor;
|
|||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* @ClassName DataTypeDecoration
|
||||
* @Description 描述
|
||||
* @Author YunFei.Du
|
||||
* @Date 2024/4/23 14:40
|
||||
* 数据库修饰
|
||||
* @author YunFei.Du
|
||||
* @date 17:09 2024/4/25
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DataTableDecoration {
|
||||
/**
|
||||
* 数据表
|
||||
*/
|
||||
private DataTable dataTable;
|
||||
/**
|
||||
* 数据库类型
|
||||
*/
|
||||
private String type;
|
||||
public static DataTableDecoration dataSourceBuild(DataTable dataTable){
|
||||
return DataTableDecoration.builder()
|
||||
|
|
|
@ -10,16 +10,22 @@ import lombok.experimental.SuperBuilder;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName DataSourceInfo
|
||||
* @Description 描述
|
||||
* @Author YunFei.Du
|
||||
* @Date 2024/4/23 14:30
|
||||
* 数据源信息
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DataSourceInfo {
|
||||
/**
|
||||
* 数据源基本信息
|
||||
*/
|
||||
private DataSource dataSource;
|
||||
/**
|
||||
* 数据库信息
|
||||
*/
|
||||
private List<DataTable> dataTableList;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
package com.etl.data.domain.model;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.etl.data.domain.Dictionary;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 字典表
|
||||
* @author YunFei.Du
|
||||
* @date 21:27 2024/4/25
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@SuperBuilder
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class DictionaryModel {
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
private Long id;
|
||||
/**
|
||||
* 数据源id
|
||||
*/
|
||||
private Long dataSourceId;
|
||||
|
||||
/**
|
||||
* 字典名称
|
||||
*/
|
||||
private String dictionaryName;
|
||||
|
||||
private List< Dictionary > dictionaries;
|
||||
|
||||
|
||||
}
|
|
@ -16,6 +16,9 @@ import lombok.experimental.SuperBuilder;
|
|||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DataSourceQueryReq {
|
||||
/**
|
||||
* 数据源名称
|
||||
*/
|
||||
private String fromSystem;
|
||||
private String name;
|
||||
private String dataSourceDatabaseName;
|
||||
|
|
|
@ -20,8 +20,19 @@ import java.util.List;
|
|||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class AssetsModelResp {
|
||||
/**
|
||||
* 数据库
|
||||
*/
|
||||
private DataTable dataTable;
|
||||
private List<AssetsModel> assetsModelList;
|
||||
|
||||
/**
|
||||
*
|
||||
* 通过数据库和数据模型构建
|
||||
* @param dTable
|
||||
* @param assetsModels
|
||||
* @return
|
||||
*/
|
||||
public static AssetsModelResp dataTableAndAssetsModelBuild(DataTable dTable,List<AssetsModel> assetsModels){
|
||||
return AssetsModelResp.builder()
|
||||
.dataTable(dTable)
|
||||
|
|
|
@ -21,25 +21,91 @@ import java.util.List;
|
|||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DataSourceResp {
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
private Long id;
|
||||
private Long typeId;
|
||||
private String dataType;
|
||||
private String dataSourceIp;
|
||||
private String dataSourcePort;
|
||||
private String dataSourceDatabaseName;
|
||||
private String dataSourceUsername;
|
||||
private String dataSourcePassword;
|
||||
private String additionalConfiguration;
|
||||
private String status;
|
||||
private Integer initialNumberOfConnections;
|
||||
private Integer maximumNumberOfConnections;
|
||||
private Integer maximumWaitingTime;
|
||||
private Integer maximumWaitingTimes;
|
||||
/**
|
||||
* 数据源名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
*数据源系统名称
|
||||
*/
|
||||
private String fromSystem;
|
||||
/**
|
||||
* 类型id
|
||||
*/
|
||||
private Long typeId;
|
||||
/**
|
||||
* 数据类型
|
||||
*/
|
||||
private String dataType;
|
||||
/**
|
||||
*数据源连接ip
|
||||
*/
|
||||
private String dataSourceIp;
|
||||
/**
|
||||
*端口号
|
||||
*/
|
||||
private String dataSourcePort;
|
||||
/**
|
||||
* 连接数据库名称
|
||||
*/
|
||||
private String dataSourceDatabaseName;
|
||||
/**
|
||||
* 数据源连接ip
|
||||
*/
|
||||
private String dataSourceUsername;
|
||||
/**
|
||||
* 数据源连接端口号
|
||||
*/
|
||||
private String dataSourcePassword;
|
||||
/**
|
||||
* 数据源额外配置
|
||||
*/
|
||||
private String additionalConfiguration;
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private String status;
|
||||
/**
|
||||
* 初始化连接数量
|
||||
*/
|
||||
private Integer initialNumberOfConnections;
|
||||
/**
|
||||
* 最大连接数量
|
||||
*/
|
||||
private Integer maximumNumberOfConnections;
|
||||
/**
|
||||
* 最大等待时间
|
||||
*/
|
||||
private Integer maximumWaitingTime;
|
||||
/**
|
||||
* 最大等待次数
|
||||
*/
|
||||
private Integer maximumWaitingTimes;
|
||||
|
||||
/**
|
||||
*备注
|
||||
*/
|
||||
private String remark;
|
||||
/**
|
||||
* 是否同步
|
||||
*/
|
||||
private Integer isSync;
|
||||
/**
|
||||
* 数据源拼接参数列表
|
||||
*/
|
||||
private List<DataSpliceParam> dataSpliceParamList;
|
||||
|
||||
/**
|
||||
* 构建数据源
|
||||
* @param dataSpliceParams
|
||||
* @param dataSource
|
||||
* @param dataType
|
||||
* @return
|
||||
*/
|
||||
public static DataSourceResp buildDataSourceResp(List<DataSpliceParam> dataSpliceParams, DataSource dataSource, DataType dataType){
|
||||
return DataSourceResp.builder()
|
||||
.id(dataSource.getId())
|
||||
|
@ -63,6 +129,12 @@ public class DataSourceResp {
|
|||
.isSync(dataSource.getIsSync())
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 表结构查询
|
||||
* @param dataSource
|
||||
* @return
|
||||
*/
|
||||
public static DataSourceResp tableStructureQueryReqBuild(TableStructureQueryReq dataSource){
|
||||
return DataSourceResp.builder()
|
||||
.id(dataSource.getId())
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
package com.etl.data.domain.resp;
|
||||
|
||||
import com.etl.data.domain.AssetsModel;
|
||||
import com.etl.data.domain.DataTable;
|
||||
import com.etl.data.domain.Dictionary;
|
||||
import com.etl.data.domain.DictionaryInfo;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 字典响应
|
||||
* @author YunFei.Du
|
||||
* @date 21:33 2024/4/25
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class DictionaryModelResp {
|
||||
private String dictionaryName;
|
||||
private List< DictionaryInfo > dictionaryList;
|
||||
|
||||
|
||||
|
||||
// public static AssetsModelResp dataTableAndAssetsModelBuild(DataTable dTable, List< AssetsModel > assetsModels){
|
||||
// return AssetsModelResp.builder()
|
||||
// .dataTable(dTable)
|
||||
// .assetsModelList(assetsModels)
|
||||
// .build();
|
||||
// }
|
||||
|
||||
}
|
|
@ -3,6 +3,7 @@ package com.etl.data;
|
|||
import com.etl.common.security.annotation.EnableCustomConfig;
|
||||
import com.etl.common.security.annotation.EnableMyFeignClients;
|
||||
import com.etl.common.swagger.annotation.EnableCustomSwagger2;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
|
@ -15,6 +16,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|||
@EnableCustomSwagger2
|
||||
@EnableMyFeignClients
|
||||
@SpringBootApplication
|
||||
@MapperScan("com.etl.data.mapper")
|
||||
public class ETLDataSourceApplication {
|
||||
public static void main (String[] args) {
|
||||
SpringApplication.run(ETLDataSourceApplication.class, args);
|
||||
|
|
|
@ -2,7 +2,11 @@ package com.etl.data.controller;
|
|||
|
||||
import com.etl.common.core.domain.Result;
|
||||
import com.etl.common.core.web.controller.BaseController;
|
||||
import com.etl.data.domain.Dictionary;
|
||||
import com.etl.data.domain.model.DictionaryModel;
|
||||
import com.etl.data.domain.resp.AssetsModelResp;
|
||||
|
||||
import com.etl.data.domain.resp.DictionaryModelResp;
|
||||
import com.etl.data.service.AssetsModelService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
@ -10,10 +14,9 @@ import org.springframework.web.bind.annotation.*;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName AssetsModelController
|
||||
* @Description 描述
|
||||
* @Author YunFei.Du
|
||||
* @Date 2024/4/23 20:08
|
||||
* 资产模型
|
||||
* @author YunFei.Du
|
||||
* @date 21:46 2024/4/25
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/assets")
|
||||
|
@ -26,8 +29,11 @@ public class AssetsModelController extends BaseController {
|
|||
public Result<List<AssetsModelResp>> getAssetsModelListByTableIds(@RequestBody List<Integer> tableIds){
|
||||
return assetsModelService.getAssetsModelListByTableIds(tableIds);
|
||||
}
|
||||
|
||||
@GetMapping("/getAssetsModelByDataTableId")
|
||||
public Result<AssetsModelResp> getAssetsModelByDataTableId(@RequestParam Integer id){
|
||||
return assetsModelService.getAssetsModelByDataTableId(id);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -19,10 +19,9 @@ import java.util.Date;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName DataSourceController
|
||||
* @Description 描述
|
||||
* @Author YunFei.Du
|
||||
* @Date 2024/4/20 11:06
|
||||
* 数据源
|
||||
* @author YunFei.Du
|
||||
* @date 21:47 2024/4/25
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/source")
|
||||
|
@ -30,11 +29,18 @@ public class DataSourceController extends BaseController {
|
|||
@Autowired
|
||||
private DataSourceService dataSourceService;
|
||||
|
||||
/**
|
||||
* 获取数据源列表
|
||||
* @param dataSourceQueryReq
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/list")
|
||||
public Result getDataSourceList (@RequestBody DataSourceQueryReq dataSourceQueryReq) {
|
||||
List<DataSourceResp> list = dataSourceService.list(dataSourceQueryReq);
|
||||
return success(list);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/insertDataSource")
|
||||
public Result insertDataSource(@RequestBody DataSource dataSource){
|
||||
if (dataSource.getId() != null){
|
||||
|
|
|
@ -12,10 +12,9 @@ import org.springframework.web.bind.annotation.RestController;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName DataTypeController
|
||||
* @Description 描述
|
||||
* @Author YunFei.Du
|
||||
* @Date 2024/4/20 12:55
|
||||
* 数据类型
|
||||
* @author YunFei.Du
|
||||
* @date 21:47 2024/4/25
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/dataType")
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
package com.etl.data.controller;
|
||||
|
||||
import com.etl.common.core.domain.Result;
|
||||
import com.etl.data.domain.Dictionary;
|
||||
import com.etl.data.mapper.DictionaryMapper;
|
||||
import com.etl.data.service.DictionaryService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName Dictionary
|
||||
* @Description 描述
|
||||
* @Author YunFei.Du
|
||||
* @Date 2024/4/26 15:41
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("dict")
|
||||
public class DictionaryController {
|
||||
@Autowired
|
||||
private DictionaryService dictionaryService;
|
||||
/**
|
||||
* 根据数据源id获取对应的字典模型
|
||||
* @param dataSourceId
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getDictionaryByDataSourceId")
|
||||
public Result< List< Dictionary > > getDictionaryByDataSourceId(@RequestParam Integer dataSourceId){
|
||||
return dictionaryService.getDictionaryByDataSourceId(dataSourceId);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package com.etl.data.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.etl.data.domain.Dictionary;
|
||||
import com.etl.data.domain.DictionaryInfo;
|
||||
|
||||
/**
|
||||
* @ClassName DataSourceMapper
|
||||
* @Description 描述
|
||||
* @Author YunFei.Du
|
||||
* @Date 2024/4/20 11:46
|
||||
*/
|
||||
public interface DictionaryInfoMapper extends BaseMapper< DictionaryInfo > {
|
||||
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package com.etl.data.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
import com.etl.data.domain.Dictionary;
|
||||
|
||||
/**
|
||||
* @ClassName DataSourceMapper
|
||||
* @Description 描述
|
||||
* @Author YunFei.Du
|
||||
* @Date 2024/4/20 11:46
|
||||
*/
|
||||
public interface DictionaryMapper extends BaseMapper< Dictionary > {
|
||||
|
||||
}
|
|
@ -3,7 +3,10 @@ package com.etl.data.service;
|
|||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.etl.common.core.domain.Result;
|
||||
import com.etl.data.domain.AssetsModel;
|
||||
import com.etl.data.domain.Dictionary;
|
||||
import com.etl.data.domain.model.DictionaryModel;
|
||||
import com.etl.data.domain.resp.AssetsModelResp;
|
||||
import com.etl.data.domain.resp.DictionaryModelResp;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -17,4 +20,6 @@ public interface AssetsModelService extends IService<AssetsModel> {
|
|||
Result<List<AssetsModelResp>> getAssetsModelListByTableIds(List<Integer> tableIds);
|
||||
|
||||
Result<AssetsModelResp> getAssetsModelByDataTableId(Integer id);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
package com.etl.data.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.etl.data.domain.Dictionary;
|
||||
import com.etl.data.domain.DictionaryInfo;
|
||||
|
||||
/**
|
||||
* @ClassName DataMansgerService
|
||||
* @Description 描述
|
||||
* @Author YunFei.Du
|
||||
* @Date 2024/4/20 11:48
|
||||
*/
|
||||
public interface DictionaryInfoService extends IService< DictionaryInfo > {
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package com.etl.data.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.etl.common.core.domain.Result;
|
||||
import com.etl.data.domain.DataType;
|
||||
import com.etl.data.domain.Dictionary;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName DataMansgerService
|
||||
* @Description 描述
|
||||
* @Author YunFei.Du
|
||||
* @Date 2024/4/20 11:48
|
||||
*/
|
||||
public interface DictionaryService extends IService< Dictionary > {
|
||||
Result< List< Dictionary > > getDictionaryByDataSourceId(Integer dataSourceId);
|
||||
}
|
|
@ -5,15 +5,26 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|||
import com.etl.common.core.domain.Result;
|
||||
import com.etl.data.domain.AssetsModel;
|
||||
import com.etl.data.domain.DataTable;
|
||||
import com.etl.data.domain.Dictionary;
|
||||
import com.etl.data.domain.DictionaryInfo;
|
||||
import com.etl.data.domain.model.DictionaryModel;
|
||||
import com.etl.data.domain.resp.AssetsModelResp;
|
||||
import com.etl.data.domain.resp.DictionaryModelResp;
|
||||
import com.etl.data.mapper.AssetsModelMapper;
|
||||
import com.etl.data.mapper.DictionaryInfoMapper;
|
||||
import com.etl.data.mapper.DictionaryMapper;
|
||||
import com.etl.data.service.AssetsModelService;
|
||||
import com.etl.data.service.DataTableService;
|
||||
import com.etl.data.service.DictionaryInfoService;
|
||||
import com.etl.data.service.DictionaryService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @ClassName AssetsModelServiceImpl
|
||||
|
@ -25,6 +36,17 @@ import java.util.List;
|
|||
public class AssetsModelServiceImpl extends ServiceImpl<AssetsModelMapper, AssetsModel> implements AssetsModelService {
|
||||
@Autowired
|
||||
private DataTableService dataTableService;
|
||||
|
||||
@Autowired
|
||||
private DictionaryService dictionaryService;
|
||||
|
||||
@Autowired
|
||||
private DictionaryMapper dictionaryMapper;
|
||||
|
||||
@Autowired
|
||||
private DictionaryInfoMapper dictionaryInfoMapper;
|
||||
@Autowired
|
||||
private DictionaryInfoService dictionaryInfoService;
|
||||
@Override
|
||||
public Result<List<AssetsModelResp>> getAssetsModelListByTableIds(List<Integer> tableId) {
|
||||
ArrayList<AssetsModelResp> assetsModelRespArrayList = new ArrayList<>();
|
||||
|
@ -51,4 +73,6 @@ public class AssetsModelServiceImpl extends ServiceImpl<AssetsModelMapper, Asset
|
|||
AssetsModelResp assetsModelResp = AssetsModelResp.dataTableAndAssetsModelBuild(dataTable, assetsModelList);
|
||||
return Result.success(assetsModelResp);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -60,7 +60,10 @@ public class DataSourceServiceImpl extends ServiceImpl<DataSourceMapper, DataSou
|
|||
dataSourceLambdaQueryWrapper.eq(DataSource::getName, dataSourceQueryReq.getName());
|
||||
}
|
||||
List<DataSource> list = this.list(dataSourceLambdaQueryWrapper);
|
||||
|
||||
|
||||
ArrayList<DataSourceResp> dataSourceRespList = new ArrayList<>();
|
||||
|
||||
//切割参数数据
|
||||
for (DataSource dataSource : list) {
|
||||
//查询数据源类型表
|
||||
|
@ -76,15 +79,19 @@ public class DataSourceServiceImpl extends ServiceImpl<DataSourceMapper, DataSou
|
|||
DataSourceResp dataSourceResp = DataSourceResp.buildDataSourceResp(dataSpliceParams, dataSource, byId);
|
||||
dataSourceRespList.add(dataSourceResp);
|
||||
}
|
||||
|
||||
return dataSourceRespList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result testConnect(DataSourceResp dataSourceResp) {
|
||||
|
||||
String username = dataSourceResp.getDataSourceUsername(); //用户名
|
||||
String password = dataSourceResp.getDataSourcePassword();//密码
|
||||
String dbName = dataSourceResp.getDataSourceDatabaseName(); //数据库名
|
||||
System.out.println("数据库名:" + dbName);
|
||||
|
||||
|
||||
Integer dbType = Math.toIntExact(dataSourceResp.getTypeId()); //数据库类型 1-mysql,2-oracle,3-postgressql
|
||||
String dbIp = dataSourceResp.getDataSourceIp(); //数据库地址
|
||||
String dbPort = dataSourceResp.getDataSourcePort(); //端口
|
||||
|
@ -114,14 +121,16 @@ public class DataSourceServiceImpl extends ServiceImpl<DataSourceMapper, DataSou
|
|||
boolean b = testDatasource(driveClass, jdbcUrl, username, password);
|
||||
System.out.println(b);
|
||||
if (!b) {
|
||||
return Result.error("连接失败");
|
||||
return Result.error();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
return Result.error("连接失败");
|
||||
return Result.error();
|
||||
}
|
||||
return Result.success("连接成功", "连接成功");
|
||||
return Result.success( );
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Connection queryStructure(DataSourceResp dataSourceResp, String infoDataBaseName) {
|
||||
try {
|
||||
//
|
||||
|
@ -305,7 +314,7 @@ public class DataSourceServiceImpl extends ServiceImpl<DataSourceMapper, DataSou
|
|||
for (int i = 0; i < resultSetCount.getMetaData().getColumnCount(); i++) {
|
||||
String columnName = resultSetCount.getMetaData().getColumnName(i + 1);
|
||||
if (columnName.equals(fieldsName)){
|
||||
javaType = resultSetCount.getMetaData().getColumnClassName(i+1);
|
||||
javaType = resultSetCount.getMetaData().getColumnClassName(i+1).substring ( 10 );
|
||||
}
|
||||
}
|
||||
// 默认值
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
package com.etl.data.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.etl.data.domain.Dictionary;
|
||||
import com.etl.data.domain.DictionaryInfo;
|
||||
import com.etl.data.mapper.DictionaryInfoMapper;
|
||||
import com.etl.data.mapper.DictionaryMapper;
|
||||
import com.etl.data.service.DictionaryInfoService;
|
||||
import com.etl.data.service.DictionaryService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @ClassName DictionaryServiceImpl
|
||||
* @Description 描述
|
||||
* @Author YunFei.Du
|
||||
* @Date 2024/4/26 9:40
|
||||
*/
|
||||
@Service
|
||||
public class DictionaryInfoServiceImpl extends ServiceImpl< DictionaryInfoMapper, DictionaryInfo > implements DictionaryInfoService {
|
||||
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
package com.etl.data.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.etl.common.core.domain.Result;
|
||||
import com.etl.common.security.utils.DictUtils;
|
||||
import com.etl.data.domain.Dictionary;
|
||||
import com.etl.data.domain.DictionaryInfo;
|
||||
import com.etl.data.mapper.DictionaryInfoMapper;
|
||||
import com.etl.data.mapper.DictionaryMapper;
|
||||
import com.etl.data.service.DictionaryService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @ClassName DictionaryServiceImpl
|
||||
* @Description 描述
|
||||
* @Author YunFei.Du
|
||||
* @Date 2024/4/26 9:40
|
||||
*/
|
||||
@Service
|
||||
public class DictionaryServiceImpl extends ServiceImpl< DictionaryMapper, Dictionary > implements DictionaryService {
|
||||
|
||||
@Autowired
|
||||
private DictionaryMapper dictionaryMapper;
|
||||
@Autowired
|
||||
private DictionaryInfoMapper dictionaryInfoMapper;
|
||||
|
||||
@Override
|
||||
public Result< List< Dictionary > > getDictionaryByDataSourceId(Integer dataSourceId) {
|
||||
|
||||
List< Dictionary > dictionaryList = dictionaryMapper.selectList ( new LambdaQueryWrapper< Dictionary > ( ).eq ( Dictionary::getDataSourceId, dataSourceId ) );
|
||||
if (!dictionaryList.isEmpty ()){
|
||||
List< DictionaryInfo > dictionaryInfos = dictionaryInfoMapper.selectList ( new LambdaQueryWrapper< DictionaryInfo > ( ).in ( DictionaryInfo::getDictionaryId, dictionaryList.stream ().map ( Dictionary::getId ).collect ( Collectors.toList () ) ) );
|
||||
dictionaryList.stream ()
|
||||
.forEach ( dictionary -> {
|
||||
List< DictionaryInfo > list = dictionaryInfos.stream ( ).filter ( dictionaryInfo -> dictionaryInfo.getDictionaryId ( ) == dictionary.getId ( ) ).toList ( );
|
||||
dictionary.setDictionaryList ( list );
|
||||
|
||||
});
|
||||
}
|
||||
return Result.success (dictionaryList );
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue