fix:字典表完善

master
Jiang Peng 2024-04-27 10:09:22 +08:00
parent c5488049c1
commit 646e4c2c41
25 changed files with 406 additions and 252 deletions

View File

@ -68,12 +68,13 @@ public class AssetModelController extends BaseController
/**
*
*/
@PutMapping
@PutMapping("UpdateAssetModel")
public Result edit(@RequestBody AssetModel assetModel)
{
return toAjax(assetModelService.updateAssetModel(assetModel));
}
/**
*
*/

View File

@ -0,0 +1,96 @@
package com.muyu.etl.controller;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.etl.domain.Dictionary;
import com.muyu.etl.service.DictionaryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* Controller
*
* @author ruoyi
* @date 2024-04-24
*/
@RestController
@RequestMapping("/dictionary")
public class DictionaryController extends BaseController
{
@Autowired
private DictionaryService dictionaryService;
/**
*
*/
@GetMapping("/list")
public Result<TableDataInfo<Dictionary>> getDictionaryList(Dictionary dictionary)
{
startPage();
List<Dictionary> list = dictionaryService.selectDictionaryList(dictionary);
return getDataTable(list);
}
/**
*
*/
@PostMapping("/export")
public void export(HttpServletResponse response, Dictionary dictionary)
{
List<Dictionary> list = dictionaryService.selectDictionaryList(dictionary);
ExcelUtil<Dictionary> util = new ExcelUtil<Dictionary>(Dictionary.class);
util.exportExcel(response, list, "【请填写功能名称】数据");
}
/**
*
*/
@GetMapping(value = "/{id}")
public Result getInfo(@PathVariable("id") Long id)
{
return success(dictionaryService.selectDictionaryById(id));
}
/**
*
*/
@PostMapping("/dictionary")
public Result add(@RequestBody Dictionary dictionary)
{
return toAjax(dictionaryService.insertDictionary(dictionary));
}
/**
*
*/
@PutMapping
public Result edit(@RequestBody Dictionary dictionary)
{
return toAjax(dictionaryService.updateDictionary(dictionary));
}
/**
*
*/
@DeleteMapping("/{ids}")
public Result remove(@PathVariable Long[] ids)
{
return toAjax(dictionaryService.deleteDictionaryByIds(ids));
}
@GetMapping("GetDictionaryList")
public Result getDictionaryList(@RequestParam("dataSourceId") Long dataSourceId){
return dictionaryService.getDictionaryList(dataSourceId);
}
// @GetMapping("delDict")
// public Result delDict(Long id){
// return dictionaryService.delDict(id);
// }
}

View File

@ -0,0 +1,85 @@
package com.muyu.etl.controller;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.etl.domain.DictionaryData;
import com.muyu.etl.service.DictionaryDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* Controller
*
* @author ruoyi
* @date 2024-04-24
*/
@RestController
@RequestMapping("/data")
public class DictionaryDataController extends BaseController
{
@Autowired
private DictionaryDataService dictionaryDataService;
/**
*
*/
@GetMapping("/list")
public Result<TableDataInfo<DictionaryData>> list(DictionaryData dictionaryData)
{
startPage();
List<DictionaryData> list = dictionaryDataService.selectDictionaryDataList(dictionaryData);
return getDataTable(list);
}
/**
*
*/
@PostMapping("/export")
public void export(HttpServletResponse response, DictionaryData dictionaryData)
{
List<DictionaryData> list = dictionaryDataService.selectDictionaryDataList(dictionaryData);
ExcelUtil<DictionaryData> util = new ExcelUtil<DictionaryData>(DictionaryData.class);
util.exportExcel(response, list, "【请填写功能名称】数据");
}
/**
*
*/
@GetMapping(value = "/{id}")
public Result getInfo(@PathVariable("id") Long id)
{
return success(dictionaryDataService.selectDictionaryDataById(id));
}
/**
*
*/
@PostMapping
public Result add(@RequestBody DictionaryData dictionaryData)
{
return toAjax(dictionaryDataService.insertDictionaryData(dictionaryData));
}
/**
*
*/
@PutMapping
public Result edit(@RequestBody DictionaryData dictionaryData)
{
return toAjax(dictionaryDataService.updateDictionaryData(dictionaryData));
}
/**
*
*/
@DeleteMapping("/{ids}")
public Result remove(@PathVariable Long[] ids)
{
return toAjax(dictionaryDataService.deleteDictionaryDataByIds(ids));
}
}

View File

@ -3,6 +3,8 @@ package com.muyu.etl.domain;
import com.muyu.common.core.web.domain.BaseEntity;
import lombok.Data;
import java.util.List;
/**
* @ClassName AssetModel
* @Description
@ -24,6 +26,8 @@ public class AssetModel extends BaseEntity {
private String defaultValue;
private String isDict;
private String dictKey;
private Long dictionaryId;
private List<DictionaryData> dictionaryDatas;
public Long getId() {
return id;

View File

@ -1,11 +1,24 @@
package com.muyu.etl.domain;
import com.muyu.common.core.web.domain.BaseEntity;
import com.muyu.common.security.utils.SecurityUtils;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Date;
/**
* @ClassName DataAsset
* @Description
* @Author HaoRan.Zhang
* @Date 2024/4/22 20:41
*/
@Data
@SuperBuilder
@AllArgsConstructor
@NoArgsConstructor
public class DataAsset extends BaseEntity {
@ -63,4 +76,20 @@ public class DataAsset extends BaseEntity {
public void setFields(Long fields) {
this.fields = fields;
}
public DataAsset dataAssetBuild(DataSource dataSource,ResultSet resultSet){
try {
return DataAsset.builder()
.tableName(resultSet.getString("t_name"))
.tableComment(resultSet.getString("table_comment") == null ? "-":resultSet.getString("table_comment"))
.tableCount(Long.valueOf(resultSet.getString("table_rows")))
.fields(Long.valueOf(resultSet.getString("fields")))
.dataSourceId(dataSource.getId())
.createBy(SecurityUtils.getUsername())
.createTime(new Date())
.build();
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
}

View File

@ -31,5 +31,5 @@ public class DataSource extends BaseEntity {
private String tableName;
private List<TableDetail> tableList;
private String modeName;
private String JdbcDriver;
private String jdbcDriver;
}

View File

@ -7,34 +7,34 @@ import lombok.NoArgsConstructor;
import java.util.List;
/**
* @ClassName Dictionary
* @Description
* @Author HaoRan.Zhang
* @Date 2024/4/25 15:02
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@NoArgsConstructor
public class Dictionary extends BaseEntity {
/**
*
*/
private Long id;
/**
*
*/
private String dictionaryName;
/**
* key
* Key
*/
private String dictionaryKey;
/**
* ID
*/
private Long dataSourceId;
/**
*
*/
private List<DictionaryData> dictionaryDataList;
}

View File

@ -5,13 +5,20 @@ import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* @ClassName DictionaryData
* @Description
* @Author HaoRan.Zhang
* @Date 2024/4/25 15:05
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@NoArgsConstructor
public class DictionaryData extends BaseEntity {
private Long id;
/**
* Id
*/
@ -32,4 +39,6 @@ public class DictionaryData extends BaseEntity {
*/
private Boolean isEdit = false;
private List<Dictionary> dictionaryDatas;
}

View File

@ -68,4 +68,7 @@ public interface AssetModelMapper
int clearTable1(@Param("id") Long[] id);
void batchInsert(@Param("tableAssets") List<AssetModel> tableAssets);
void updateAssetModelDiction(Long id);
}

View File

@ -66,6 +66,6 @@ public interface DataAssetMapper
void batchInsert(@Param("dataAssets") ArrayList<DataAsset> dataAssets);
List<DataAsset> selectById(Long id);
}

View File

@ -77,4 +77,6 @@ public interface DataSourceMapper
List<DataAsset> selectDataAssetBachId(@Param("longs") List<Long> longs);
List<DataSource> selectId(Long id);
}

View File

@ -6,7 +6,6 @@ import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface DictionaryDataMapper {
/**
*
*
@ -57,4 +56,8 @@ public interface DictionaryDataMapper {
List<DictionaryData> getDictionaryDataList(@Param("dictionaryIds") List<Long> dictionaryIds);
void delDict(@Param("longs") List<Long> longs);
void deleteDictionaryDataBy(Long id);
}

View File

@ -6,7 +6,6 @@ import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface DictionaryMapper {
/**
*
*
@ -58,4 +57,6 @@ public interface DictionaryMapper {
List<Dictionary> getDictionaryList(@Param("dataSourceId") Long dataSourceId);
List<Dictionary> getDictionaryDataList(@Param("string") List<String> string);
}

View File

@ -64,17 +64,14 @@ public interface DataSourceService
*/
public int deleteDataSourceById(Long id);
Result test(DataSource dataSource);
Result assetsList(DataSource dataSource);
Result structureList(DataSource dataSource);
Result synchronization(DataSource dataSource);
Result dataAssetList(DataSource dataSource);
Result assetModelList(DataAsset dataAsset);

View File

@ -1,11 +1,12 @@
package com.muyu.etl.service;
import com.muyu.etl.domain.DictionaryData;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public interface DictionaryDataService {
/**
*
*
@ -53,5 +54,4 @@ public interface DictionaryDataService {
* @return
*/
public int deleteDictionaryDataById(Long id);
}

View File

@ -6,7 +6,6 @@ import com.muyu.etl.domain.Dictionary;
import java.util.List;
public interface DictionaryService {
/**
*
*
@ -55,7 +54,8 @@ public interface DictionaryService {
*/
public int deleteDictionaryById(Long id);
Result getDictionaryList(Long dataSourceId);
Result delDict(Long id);
}

View File

@ -5,6 +5,7 @@ import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.DateUtils;
import com.muyu.common.security.utils.SecurityUtils;
import com.muyu.etl.domain.*;
import com.muyu.etl.domain.Dictionary;
import com.muyu.etl.mapper.AssetModelMapper;
import com.muyu.etl.mapper.DataAssetMapper;
import com.muyu.etl.mapper.DataSourceMapper;
@ -24,14 +25,19 @@ import java.util.*;
*/
@Service
public class DataSourceServiceImpl implements DataSourceService{
@Autowired
private DataSourceMapper dataSourceMapper;
@Autowired
private AssetModelMapper assetModelMapper;
@Autowired
private DataAssetMapper dataAssetMapper;
@Autowired
private DictionaryServiceImpl dictionaryService;
/**
*
*
@ -66,6 +72,11 @@ public class DataSourceServiceImpl implements DataSourceService{
public int insertDataSource(DataSource dataSource) {
dataSource.setCreateTime(DateUtils.getNowDate());
dataSource.setCreateBy(SecurityUtils.getUsername());
if("Mysql".equals(dataSource.getType())){
dataSource.setJdbcDriver("com.mysql.cj.jdbc.Driver");
}else {
dataSource.setJdbcDriver("org.postgresql.Driver");
}
return dataSourceMapper.insertDataSource(dataSource);
}
@ -80,6 +91,11 @@ public class DataSourceServiceImpl implements DataSourceService{
{
dataSource.setUpdateTime(DateUtils.getNowDate());
dataSource.setUpdateBy(SecurityUtils.getUsername());
if("Mysql".equals(dataSource.getType())){
dataSource.setJdbcDriver("com.mysql.cj.jdbc.Driver");
}else {
dataSource.setJdbcDriver("org.postgresql.Driver");
}
return dataSourceMapper.updateDataSource(dataSource);
}
@ -202,8 +218,10 @@ public class DataSourceServiceImpl implements DataSourceService{
return "byte[]";
case "longtext":
return "Clob";
// ... 其他类型映射包括日期、时间、字符串、二进制、Blob、枚举、集合等
case "double":
return "double";
default:
//抛出新的IlLegalArgumentException(“不支持的数据类型:”+mappingType)
throw new IllegalArgumentException("Unsupported data type: " + mappingType);
}
}
@ -220,6 +238,7 @@ public class DataSourceServiceImpl implements DataSourceService{
// 设置MySQL JDBC驱动类名和数据库连接URL
String jdbcDriver="com.mysql.cj.jdbc.Driver";
String url = "jdbc:mysql://"+dataSource.getLinkAddress()+":"+dataSource.getPort()+"/"+dataSource.getDatabaseName();
Connection con = null;
ArrayList<AssetModel> tableAssets = new ArrayList<>();
try{
@ -238,9 +257,9 @@ public class DataSourceServiceImpl implements DataSourceService{
// 遍历查询结果,创建并填充资产模型列表
while (resultSet.next()){
AssetModel assetModel = new AssetModel();
assetModel.setComment(resultSet.getString("COLUMN_COMMENT"));
assetModel.setName(resultSet.getString("COLUMN_NAME"));
// int decimalPlaces = resultSet.getInt("DECIMAL_PLACES");
// 设置列长度或精度
if (resultSet.getString("CHARACTER_MAXIMUM_LENGTH")!=null){
assetModel.setLength(resultSet.getString("CHARACTER_MAXIMUM_LENGTH"));
@ -249,6 +268,12 @@ public class DataSourceServiceImpl implements DataSourceService{
}else{
assetModel.setLength("-");
}
if (resultSet.getString("NUMERIC_SCALE")!=null){
assetModel.setDecimalPlaces(resultSet.getString("NUMERIC_SCALE"));
}else{
assetModel.setDecimalPlaces("0");
}
// 设置是否可为空
if (resultSet.getString("IS_NULLABLE").equals("YES")){
assetModel.setIsNull("Y");
@ -257,6 +282,7 @@ public class DataSourceServiceImpl implements DataSourceService{
}
// 设置是否有默认值
if (resultSet.getString("COLUMN_DEFAULT")!=null){
assetModel.setDefaultValue(resultSet.getString("COLUMN_DEFAULT"));
}else{
assetModel.setDefaultValue("-");
@ -264,10 +290,11 @@ public class DataSourceServiceImpl implements DataSourceService{
// 初始化其他属性
assetModel.setIsDict("");
assetModel.setDictKey("");
assetModel.setType("s");
assetModel.setDecimalPlaces("0");
// assetModel.setDecimalPlaces("0");
String dataType = mapDataTypeToJavaClass(resultSet.getString("DATA_TYPE"));
System.out.println("==================================="+dataType);
assetModel.setMappingType(dataType);
assetModel.setType(resultSet.getString("DATA_TYPE"));
// 设置是否为主键
@ -397,7 +424,24 @@ public class DataSourceServiceImpl implements DataSourceService{
//数据同步
@Override
public Result synchronization(DataSource dataSource) {
Long id1 = dataSource.getId();
List<DataSource> dataSources = dataSourceMapper.selectId(dataSource.getId());
List<Long> longs = dataSources.stream().map(DataSource::getId).toList();
System.out.println("数据源的ID"+longs);
ArrayList<Long> longArrayList = new ArrayList<>();
for (Long aLong : longs) {
List<DataAsset> dataAssets = dataAssetMapper.selectById(aLong);
List<Long> longList = dataAssets.stream().map(DataAsset::getId).toList();
System.out.println("数据模型的Id"+longList);
longArrayList.addAll(longList);
}
Long[] longs2 = longArrayList.toArray(Long[]::new);
if (longs2.length != 0){
assetModelMapper.clearTable1(longs2);
}
String username = dataSource.getUsername();
String password = dataSource.getPassword();
String jdbcDriver = "com.mysql.cj.jdbc.Driver";
@ -418,30 +462,11 @@ public class DataSourceServiceImpl implements DataSourceService{
ResultSet resultSet = preparedStatement.executeQuery();
// 遍历结果集将每条记录转换为DataAsset对象并添加到数据列表中
while (resultSet.next()){
DataAsset dataAsset = new DataAsset();
// 设置表名
dataAsset.setTableName(resultSet.getString("t_name"));
// 设置表注释
dataAsset.setTableComment(resultSet.getString("table_comment"));
// 设置表行数
dataAsset.setTableCount(resultSet.getLong("table_rows"));
// 设置字段数
dataAsset.setFields(resultSet.getLong("fields"));
// 设置数据源ID
dataAsset.setDataSourceId(dataSource.getId());
// 设置创建者为当前登录用户
dataAsset.setCreateBy(SecurityUtils.getUsername());
// 设置创建时间为当前时间
dataAsset.setCreateTime(new Date());
// 将DataAsset对象添加到数据列表中
dataAssets.add(dataAsset);
dataAssets.add(new DataAsset().dataAssetBuild(dataSource,resultSet));
}
// 将 DataAsset 对象的 ID 提取出来并转换为 Long 数组
Long id = dataSource.getId();
Long[] a = new Long[1];
a[0] = id;
int i = dataSourceMapper.clearTable(a);
int i = dataSourceMapper.clearTable(new Long[]{dataSource.getId()});
dataSourceMapper.batchAdd(dataAssets);
for (DataAsset dataAsset : dataAssets) {
List<AssetModel> tableAssets = getTableAssets(dataSource, dataAsset.getTableName());
@ -467,6 +492,19 @@ public class DataSourceServiceImpl implements DataSourceService{
AssetModel assetModel = new AssetModel();
assetModel.setDataAssetId(dataAsset.getId());
List<AssetModel> assetModels = assetModelMapper.selectAssetModelList(assetModel);
List<String> strings = assetModels.stream().map(AssetModel::getDictKey).toList();
if (!strings.isEmpty()){
Result<List<Dictionary>> dictionaryDataList = dictionaryService.getDictionaryDataList(strings);
List<Dictionary> data = dictionaryDataList.getData();
assetModels.stream().forEach(assetModel1 -> {
data.stream().forEach(dictionary -> {
if (assetModel1.getDictKey().equals(dictionary.getDictionaryKey())) {
assetModel.setDictionaryDatas(dictionary.getDictionaryDataList());
}
});
});
}
return Result.success(assetModels);
}
@ -478,7 +516,8 @@ public class DataSourceServiceImpl implements DataSourceService{
* @return Result Statistics
*/
public Result statisticsInfo() {
long sum; long sum1;
long datasum;
long assetssum;
// 查询所有的数据源
List<DataSource> dataSources = dataSourceMapper.selectDataSourceList(new DataSource());
// 查出数据源ID列表
@ -491,14 +530,14 @@ public class DataSourceServiceImpl implements DataSourceService{
statistics.setDataAsset((long) longs.size());
System.out.println(statistics.getDataAsset());
// 统计所有数据资产的字段总数
sum = dataAssets.stream().mapToLong(dataAsset -> Long.valueOf(dataAsset.getFields())).sum();
datasum = dataAssets.stream().mapToLong(dataAsset -> Long.valueOf(dataAsset.getFields())).sum();
// 统计所有数据资产的表数量
sum1 = dataAssets.stream().mapToLong(dataAsset -> Long.valueOf(dataAsset.getTableCount())).sum();
System.out.println("数据"+sum);
System.out.println("资产"+sum1);
assetssum = dataAssets.stream().mapToLong(dataAsset -> Long.valueOf(dataAsset.getTableCount())).sum();
System.out.println("数据"+datasum);
System.out.println("资产"+assetssum);
// 设置数据模型数量和资产模型数量
statistics.setDataModel(sum);
statistics.setAssetModel(sum1);
statistics.setDataModel(datasum);
statistics.setAssetModel(assetssum);
// 返回携带统计信息的成功结果
return Result.success(statistics);
}

View File

@ -4,7 +4,6 @@ import com.muyu.common.core.utils.DateUtils;
import com.muyu.common.security.utils.SecurityUtils;
import com.muyu.etl.domain.DictionaryData;
import com.muyu.etl.mapper.DictionaryDataMapper;
import com.muyu.etl.mapper.DictionaryMapper;
import com.muyu.etl.service.DictionaryDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -13,7 +12,6 @@ import java.util.List;
@Service
public class DictionaryDataServiceImpl implements DictionaryDataService {
@Autowired
private DictionaryDataMapper dictionaryDataMapper;
@ -92,5 +90,4 @@ public class DictionaryDataServiceImpl implements DictionaryDataService {
{
return dictionaryDataMapper.deleteDictionaryDataById(id);
}
}

View File

@ -1,18 +1,18 @@
package com.muyu.etl.service.impl;
import java.util.List;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.DateUtils;
import com.muyu.common.security.utils.SecurityUtils;
import com.muyu.etl.domain.Dictionary;
import com.muyu.etl.domain.DictionaryData;
import com.muyu.etl.mapper.AssetModelMapper;
import com.muyu.etl.mapper.DictionaryDataMapper;
import com.muyu.etl.mapper.DictionaryMapper;
import com.muyu.etl.service.DictionaryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.muyu.etl.mapper.DictionaryMapper;
import com.muyu.etl.domain.Dictionary;
import com.muyu.etl.service.DictionaryService;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
* Service
@ -21,14 +21,17 @@ import org.springframework.transaction.annotation.Transactional;
* @date 2024-04-25
*/
@Service
public class DictionaryServiceImpl implements DictionaryService {
public class DictionaryServiceImpl implements DictionaryService
{
@Autowired
private DictionaryMapper dictionaryMapper;
@Autowired
private DictionaryDataMapper dictionaryDataMapper;
@Autowired
private AssetModelMapper assetModelMapper;
/**
*
*
@ -101,18 +104,49 @@ public class DictionaryServiceImpl implements DictionaryService {
@Override
public Result getDictionaryList(Long dataSourceId) {
List<Dictionary> dictionaryList = dictionaryMapper.getDictionaryList(dataSourceId);
if (!dictionaryList.isEmpty()){
List<Long> longs = dictionaryList.stream()
List<Dictionary> dictionaryList = dictionaryMapper.getDictionaryList(dataSourceId);
if (!dictionaryList.isEmpty()){
List<Long> longs = dictionaryList.stream()
.map(Dictionary::getId).toList();
List<DictionaryData> dictionaryDataList = dictionaryDataMapper.getDictionaryDataList(longs);
dictionaryList.stream()
.forEach(dictionary->{
dictionaryDataList.stream().filter(dictionaryData -> dictionaryData.getDictionaryId().equals(dictionary.getId()) ).toList();
dictionary.setDictionaryDataList(dictionaryDataList);
});
}
return Result.success(dictionaryList);
}
@Override
public Result delDict(Long id) {
dictionaryDataMapper.deleteDictionaryDataBy(id);
dictionaryMapper.deleteDictionaryById(id);
assetModelMapper.updateAssetModelDiction(id);
return Result.success();
}
/**
*
*/
public Result getDictionaryDataList(List<String> string){
// 通过字符串列表查询字典数据列表
List<Dictionary> dictionaryDataList = dictionaryMapper.getDictionaryDataList(string);
if (!dictionaryDataList.isEmpty()){
// 将字典数据列表中的每个字典项的ID提取出来形成一个新的ID列表
List<Long> longs = dictionaryDataList.stream()
.map(Dictionary::getId).toList();
List<DictionaryData> dictionaryDataList = dictionaryDataMapper.getDictionaryDataList(longs);
dictionaryList.stream()
.forEach(dictionary->{
dictionaryDataList.stream().filter(dictionaryData -> dictionaryData.getDictionaryId().equals(dictionary.getId()) ).toList();
dictionary.setDictionaryDataList(dictionaryDataList);
// 根据ID列表查询相应的字典详细数据列表
List<DictionaryData> dictionaryDataList1 = dictionaryDataMapper.getDictionaryDataList(longs);
// 为每个字典项设置其详细的字典数据列表
dictionaryDataList.stream()
.forEach(dictionary -> {
dictionaryDataList1.stream().filter(dictionaryData -> dictionaryData.getDictionaryId().equals(dictionary.getId())).toList();
dictionary.setDictionaryDataList(dictionaryDataList1);
});
}
return Result.success(dictionaryList);
// 返回成功结果,包含处理后的字典数据列表
return Result.success(dictionaryDataList);
}
}

View File

@ -181,6 +181,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</trim>
where id = #{id}
</update>
<update id="updateAssetModelDiction">
update asset_model_copy1 set is_dict = '',dictionary_id = null where dictionary_id = #{id}
</update>
<delete id="deleteAssetModelById" parameterType="Long">
delete from asset_model_copy1 where id = #{id}

View File

@ -37,6 +37,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectDataAssetVo"/>
where id = #{id}
</select>
<select id="selectById" resultType="com.muyu.etl.domain.DataAsset">
select * from data_asset where data_source_id= #{id}
</select>
<insert id="insertDataAsset" parameterType="com.muyu.etl.domain.DataAsset" useGeneratedKeys="true" keyProperty="id">
insert into data_asset

View File

@ -152,42 +152,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</trim>
</foreach>
</insert>
<!-- <insert id="batchInsert" parameterType="com.muyu.etl.domain.DataAsset" useGeneratedKeys="true" keyProperty="id">-->
<!-- insert into `asset_model` (-->
<!-- `data_asset_id`,-->
<!-- `name`,-->
<!-- comment,-->
<!-- is_primary_key,-->
<!-- `type`,-->
<!-- mapping_type,-->
<!-- `length`,-->
<!-- decimal_places,-->
<!-- is_null,-->
<!-- is_dict,-->
<!-- default_value,-->
<!-- dict_key,-->
<!-- create_by,-->
<!-- create_time-->
<!-- ) values -->
<!-- <foreach collection="tableAssets" item="item" separator=",">-->
<!-- (-->
<!-- #{item.dataAssetId},-->
<!-- #{item.name},-->
<!-- #{item.comment},-->
<!-- #{item.isPrimaryKey},-->
<!-- #{item.type},-->
<!-- #{item.mappingType},-->
<!-- #{item.length},-->
<!-- #{item.decimalPlaces},-->
<!-- #{item.isNull},-->
<!-- #{item.isDict},-->
<!-- #{item.defaultValue},-->
<!-- #{item.dictKey},-->
<!-- #{item.createBy},-->
<!-- #{item.createTime}-->
<!-- )-->
<!-- </foreach>-->
<!-- </insert>-->
<insert id="batchAdd" useGeneratedKeys="true" keyProperty="id">
insert into data_asset
<trim prefix="(" suffix=")" suffixOverrides=",">

View File

@ -95,4 +95,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach>
</delete>
<delete id="delDict">
delete dictionarydata where dictionary_id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<delete id="deleteDictionaryDataBy">
delete from dictionarydata where dictionary_id = #{id}
</delete>
</mapper>

View File

@ -39,6 +39,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and data_source_id = #{dataSourceId}
</where>
</select>
<select id="getDictionaryDataList" resultType="com.muyu.etl.domain.Dictionary">
<include refid="selectDictionaryVo"></include>
<where>
and dictionary_key in
<foreach item="string" collection="string" open="(" separator="," close=")">
#{string}
</foreach>
</where>
</select>
<insert id="insertDictionary" parameterType="com.muyu.etl.domain.Dictionary" useGeneratedKeys="true" keyProperty="id">
insert into dictionary

View File

@ -1,136 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.muyu.etl.mapper.DataSourceMapper">
<resultMap type="com.muyu.etl.domain.DataSource" id="DataSourceResult">
<result property="id" column="id" />
<result property="dataSourceName" column="data_source_name" />
<result property="linkAddress" column="link_address" />
<result property="port" column="port" />
<result property="databaseName" column="database_name" />
<result property="username" column="username" />
<result property="password" column="password" />
<result property="connectionParam" column="connection_param" />
<result property="initNum" column="init_num" />
<result property="maxNum" column="max_num" />
<result property="maxWaitTime" column="max_wait_time" />
<result property="maxWaitSize" column="max_wait_size" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
<result property="type" column="type" />
<result property="systemName" column="system_name" />
</resultMap>
<sql id="selectDataSourceVo">
select id, data_source_name, link_address, port, database_name, username, password, connection_param, init_num, max_num, max_wait_time, max_wait_size, create_by, create_time, update_by, update_time, remark, type, system_name from data_source
</sql>
<select id="selectDataSourceList" parameterType="com.muyu.etl.domain.DataSource" resultMap="DataSourceResult">
<include refid="selectDataSourceVo"/>
<where>
<if test="dataSourceName != null and dataSourceName != ''"> and data_source_name like concat('%', #{dataSourceName}, '%')</if>
<if test="linkAddress != null and linkAddress != ''"> and link_address = #{linkAddress}</if>
<if test="port != null and port != ''"> and port = #{port}</if>
<if test="databaseName != null and databaseName != ''"> and database_name like concat('%', #{databaseName}, '%')</if>
<if test="username != null and username != ''"> and username like concat('%', #{username}, '%')</if>
<if test="password != null and password != ''"> and password = #{password}</if>
<if test="connectionParam != null and connectionParam != ''"> and connection_param = #{connectionParam}</if>
<if test="initNum != null "> and init_num = #{initNum}</if>
<if test="maxNum != null "> and max_num = #{maxNum}</if>
<if test="maxWaitTime != null "> and max_wait_time = #{maxWaitTime}</if>
<if test="maxWaitSize != null "> and max_wait_size = #{maxWaitSize}</if>
<if test="type != null and type != ''"> and type = #{type}</if>
<if test="systemName != null and systemName != ''"> and system_name like concat('%', #{systemName}, '%')</if>
</where>
</select>
<select id="selectDataSourceById" parameterType="Long" resultMap="DataSourceResult">
<include refid="selectDataSourceVo"/>
where id = #{id}
</select>
<insert id="insertDataSource" parameterType="com.muyu.etl.domain.DataSource" useGeneratedKeys="true" keyProperty="id">
insert into data_source
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="dataSourceName != null">data_source_name,</if>
<if test="linkAddress != null">link_address,</if>
<if test="port != null">port,</if>
<if test="databaseName != null">database_name,</if>
<if test="username != null">username,</if>
<if test="password != null">password,</if>
<if test="connectionParam != null">connection_param,</if>
<if test="initNum != null">init_num,</if>
<if test="maxNum != null">max_num,</if>
<if test="maxWaitTime != null">max_wait_time,</if>
<if test="maxWaitSize != null">max_wait_size,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="remark != null">remark,</if>
<if test="type != null">type,</if>
<if test="systemName != null">system_name,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="dataSourceName != null">#{dataSourceName},</if>
<if test="linkAddress != null">#{linkAddress},</if>
<if test="port != null">#{port},</if>
<if test="databaseName != null">#{databaseName},</if>
<if test="username != null">#{username},</if>
<if test="password != null">#{password},</if>
<if test="connectionParam != null">#{connectionParam},</if>
<if test="initNum != null">#{initNum},</if>
<if test="maxNum != null">#{maxNum},</if>
<if test="maxWaitTime != null">#{maxWaitTime},</if>
<if test="maxWaitSize != null">#{maxWaitSize},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="remark != null">#{remark},</if>
<if test="type != null">#{type},</if>
<if test="systemName != null">#{systemName},</if>
</trim>
</insert>
<update id="updateDataSource" parameterType="com.muyu.etl.domain.DataSource">
update data_source
<trim prefix="SET" suffixOverrides=",">
<if test="dataSourceName != null">data_source_name = #{dataSourceName},</if>
<if test="linkAddress != null">link_address = #{linkAddress},</if>
<if test="port != null">port = #{port},</if>
<if test="databaseName != null">database_name = #{databaseName},</if>
<if test="username != null">username = #{username},</if>
<if test="password != null">password = #{password},</if>
<if test="connectionParam != null">connection_param = #{connectionParam},</if>
<if test="initNum != null">init_num = #{initNum},</if>
<if test="maxNum != null">max_num = #{maxNum},</if>
<if test="maxWaitTime != null">max_wait_time = #{maxWaitTime},</if>
<if test="maxWaitSize != null">max_wait_size = #{maxWaitSize},</if>
<if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="type != null">type = #{type},</if>
<if test="systemName != null">system_name = #{systemName},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteDataSourceById" parameterType="Long">
delete from data_source where id = #{id}
</delete>
<delete id="deleteDataSourceByIds" parameterType="String">
delete from data_source where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>