jpz最新5.0
parent
308e870dff
commit
385d0f2dfd
|
@ -0,0 +1,26 @@
|
|||
package net.srt.api;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import net.srt.api.module.data.governance.DataMetadataApi;
|
||||
import net.srt.api.module.data.governance.dto.DataGovernanceMetadataDto;
|
||||
import net.srt.convert.MetadataConvert;
|
||||
import net.srt.framework.common.utils.Result;
|
||||
import net.srt.service.MetadataService;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @ClassName DataAccessApiImpl
|
||||
* @Author zrx
|
||||
* @Date 2022/10/26 11:50
|
||||
*/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
public class DataGovernanceMetadataApiImpl implements DataMetadataApi {
|
||||
|
||||
private final MetadataService metadataService;
|
||||
|
||||
@Override
|
||||
public Result<DataGovernanceMetadataDto> getById(Integer id) {
|
||||
return Result.ok(MetadataConvert.INSTANCE.convertDto(metadataService.getById(id)));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,138 @@
|
|||
package net.srt.api;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import net.srt.api.module.data.governance.DataMetadataCollectApi;
|
||||
import net.srt.api.module.data.governance.constant.DbType;
|
||||
import net.srt.api.module.data.governance.dto.DataGovernanceMetadataCollectDto;
|
||||
import net.srt.api.module.data.governance.dto.DataGovernanceMetadataCollectRecordDto;
|
||||
import net.srt.api.module.data.governance.dto.DataGovernanceMetadataDto;
|
||||
import net.srt.api.module.data.governance.dto.DataGovernanceMetadataPropertyDto;
|
||||
import net.srt.convert.MetadataCollectConvert;
|
||||
import net.srt.convert.MetadataCollectRecordConvert;
|
||||
import net.srt.convert.MetadataConvert;
|
||||
import net.srt.convert.MetadataPropertyConvert;
|
||||
import net.srt.entity.MetadataCollectEntity;
|
||||
import net.srt.entity.MetadataCollectRecordEntity;
|
||||
import net.srt.entity.MetadataEntity;
|
||||
import net.srt.entity.MetadataPropertyEntity;
|
||||
import net.srt.framework.common.utils.Result;
|
||||
import net.srt.service.MetadataCollectRecordService;
|
||||
import net.srt.service.MetadataCollectService;
|
||||
import net.srt.service.MetadataPropertyService;
|
||||
import net.srt.service.MetadataService;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName DataAccessApiImpl
|
||||
* @Author zrx
|
||||
* @Date 2022/10/26 11:50
|
||||
*/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
public class DataGovernanceMetadataCollectApiImpl implements DataMetadataCollectApi {
|
||||
|
||||
private final MetadataService metadataService;
|
||||
private final MetadataPropertyService metadataPropertyService;
|
||||
private final MetadataCollectService metadataCollectService;
|
||||
private final MetadataCollectRecordService collectRecordService;
|
||||
|
||||
@Override
|
||||
public Result<DataGovernanceMetadataCollectDto> getById(Long id) {
|
||||
return Result.ok(MetadataCollectConvert.INSTANCE.convertDto(metadataCollectService.getById(id)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataGovernanceMetadataCollectRecordDto addCollectRecord(DataGovernanceMetadataCollectRecordDto collectRecordDto) {
|
||||
MetadataCollectRecordEntity entity = MetadataCollectRecordConvert.INSTANCE.convert(collectRecordDto);
|
||||
collectRecordService.save(entity);
|
||||
collectRecordDto.setId(entity.getId());
|
||||
return collectRecordDto;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void upCollectRecord(DataGovernanceMetadataCollectRecordDto collectRecordDto) {
|
||||
collectRecordService.updateById(MetadataCollectRecordConvert.INSTANCE.convert(collectRecordDto));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<DataGovernanceMetadataDto> getByParentIdAndDatasourceId(Long parnetId, Long datasourceId) {
|
||||
LambdaQueryWrapper<MetadataEntity> wrapper = Wrappers.lambdaQuery();
|
||||
wrapper.eq(MetadataEntity::getParentId, parnetId).eq(MetadataEntity::getDatasourceId, datasourceId).last("limit 1");
|
||||
return Result.ok(MetadataConvert.INSTANCE.convertDto(metadataService.getOne(wrapper)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<DataGovernanceMetadataDto> getMetadataById(Long metadataId) {
|
||||
return Result.ok(MetadataConvert.INSTANCE.convertDto(metadataService.getById(metadataId)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<DataGovernanceMetadataDto> getByParentIdAndOtherInfo(Long parnetId, Long datasourceId, String code, Long metamodelId) {
|
||||
LambdaQueryWrapper<MetadataEntity> wrapper = Wrappers.lambdaQuery();
|
||||
wrapper.eq(MetadataEntity::getParentId, parnetId).eq(datasourceId != null, MetadataEntity::getDatasourceId, datasourceId)
|
||||
.eq(MetadataEntity::getCode, code)
|
||||
.eq(datasourceId == null, MetadataEntity::getDbType, DbType.MIDDLE_DB.getValue())
|
||||
.eq(MetadataEntity::getMetamodelId, metamodelId)
|
||||
.last("limit 1");
|
||||
return Result.ok(MetadataConvert.INSTANCE.convertDto(metadataService.getOne(wrapper)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataGovernanceMetadataDto addOrUpdateMetadata(DataGovernanceMetadataDto metadataDto) {
|
||||
MetadataEntity entity = MetadataConvert.INSTANCE.convert(metadataDto);
|
||||
if (metadataDto.getId() != null) {
|
||||
metadataService.updateById(entity);
|
||||
} else {
|
||||
metadataService.save(entity);
|
||||
}
|
||||
metadataDto.setId(entity.getId());
|
||||
return metadataDto;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<DataGovernanceMetadataPropertyDto> getByPropertyIdAndMetadataId(Long propertyId, Long metadataId) {
|
||||
LambdaQueryWrapper<MetadataPropertyEntity> wrapper = Wrappers.lambdaQuery();
|
||||
wrapper.eq(MetadataPropertyEntity::getMetamodelPropertyId, propertyId).eq(MetadataPropertyEntity::getMetadataId, metadataId).last("limit 1");
|
||||
return Result.ok(MetadataPropertyConvert.INSTANCE.convertDto(metadataPropertyService.getOne(wrapper)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addOrUpdateMetadataProperty(DataGovernanceMetadataPropertyDto metadataPropertyDto) {
|
||||
if (metadataPropertyDto.getId() == null) {
|
||||
metadataPropertyService.save(MetadataPropertyConvert.INSTANCE.convert(metadataPropertyDto));
|
||||
} else {
|
||||
metadataPropertyService.updateById(MetadataPropertyConvert.INSTANCE.convert(metadataPropertyDto));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<List<DataGovernanceMetadataDto>> listParentIdAndDatasourceId(Long parentId, Long datasourceId, Long metamodelId) {
|
||||
LambdaQueryWrapper<MetadataEntity> wrapper = Wrappers.lambdaQuery();
|
||||
wrapper.eq(MetadataEntity::getParentId, parentId).eq(MetadataEntity::getDatasourceId, datasourceId).eq(MetadataEntity::getMetamodelId, metamodelId);
|
||||
return Result.ok(MetadataConvert.INSTANCE.convertDtoList(metadataService.list(wrapper)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteMetadata(Long id) {
|
||||
metadataService.deleteAll(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<DataGovernanceMetadataCollectDto> getByDatasourceId(Long id) {
|
||||
LambdaQueryWrapper<MetadataCollectEntity> wrapper = Wrappers.lambdaQuery();
|
||||
wrapper.eq(MetadataCollectEntity::getDatabaseId, id).last("limit 1");
|
||||
return Result.ok(MetadataCollectConvert.INSTANCE.convertDto(metadataCollectService.getOne(wrapper)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<DataGovernanceMetadataDto> getMetadataByDatasourceId(Long id) {
|
||||
LambdaQueryWrapper<MetadataEntity> wrapper = Wrappers.lambdaQuery();
|
||||
wrapper.eq(MetadataEntity::getDatasourceId, id).last("limit 1");
|
||||
return Result.ok(MetadataConvert.INSTANCE.convertDto(metadataService.getOne(wrapper)));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
package net.srt.api;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import net.srt.api.module.data.governance.DataQualityApi;
|
||||
import net.srt.api.module.data.governance.dto.DataGovernanceQualityConfigDto;
|
||||
import net.srt.api.module.data.governance.dto.DataGovernanceQualityTaskColumnDto;
|
||||
import net.srt.api.module.data.governance.dto.DataGovernanceQualityTaskDto;
|
||||
import net.srt.api.module.data.governance.dto.DataGovernanceQualityTaskTableDto;
|
||||
import net.srt.convert.QualityConfigConvert;
|
||||
import net.srt.convert.QualityTaskColumnConvert;
|
||||
import net.srt.convert.QualityTaskConvert;
|
||||
import net.srt.convert.QualityTaskTableConvert;
|
||||
import net.srt.entity.QualityTaskColumnEntity;
|
||||
import net.srt.entity.QualityTaskEntity;
|
||||
import net.srt.entity.QualityTaskTableEntity;
|
||||
import net.srt.framework.common.utils.Result;
|
||||
import net.srt.service.QualityConfigService;
|
||||
import net.srt.service.QualityTaskColumnService;
|
||||
import net.srt.service.QualityTaskService;
|
||||
import net.srt.service.QualityTaskTableService;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName DataGovernanceQualityApiImpl
|
||||
* @Author zrx
|
||||
* @Date 2022/10/26 11:50
|
||||
*/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
public class DataGovernanceQualityApiImpl implements DataQualityApi {
|
||||
|
||||
private final QualityConfigService qualityConfigService;
|
||||
private final QualityTaskService qualityTaskService;
|
||||
private final QualityTaskTableService taskTableService;
|
||||
private final QualityTaskColumnService taskColumnService;
|
||||
|
||||
@Override
|
||||
public Result<DataGovernanceQualityConfigDto> getById(Long id) {
|
||||
return Result.ok(QualityConfigConvert.INSTANCE.convertDto(qualityConfigService.getById(id)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<DataGovernanceQualityTaskDto> addQualityTask(DataGovernanceQualityTaskDto qualityTaskDto) {
|
||||
QualityTaskEntity entity = QualityTaskConvert.INSTANCE.convert(qualityTaskDto);
|
||||
qualityTaskService.save(entity);
|
||||
qualityTaskDto.setId(entity.getId());
|
||||
return Result.ok(qualityTaskDto);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<String> updateQualityTask(DataGovernanceQualityTaskDto qualityTaskDto) {
|
||||
QualityTaskEntity entity = QualityTaskConvert.INSTANCE.convert(qualityTaskDto);
|
||||
qualityTaskService.updateById(entity);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<DataGovernanceQualityTaskTableDto> addTaskTable(DataGovernanceQualityTaskTableDto qualityTaskTableDto) {
|
||||
QualityTaskTableEntity entity = QualityTaskTableConvert.INSTANCE.convert(qualityTaskTableDto);
|
||||
taskTableService.save(entity);
|
||||
qualityTaskTableDto.setId(entity.getId());
|
||||
return Result.ok(qualityTaskTableDto);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<String> updateQualityTaskTable(DataGovernanceQualityTaskTableDto taskTable) {
|
||||
QualityTaskTableEntity entity = QualityTaskTableConvert.INSTANCE.convert(taskTable);
|
||||
taskTableService.updateById(entity);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<String> addQualityTaskColumns(List<DataGovernanceQualityTaskColumnDto> columnDtos) {
|
||||
List<QualityTaskColumnEntity> columnEntities = QualityTaskColumnConvert.INSTANCE.convertListByDtos(columnDtos);
|
||||
taskColumnService.saveBatch(columnEntities);
|
||||
return Result.ok();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package net.srt.constant;
|
||||
|
||||
|
||||
/**
|
||||
* FlinkType
|
||||
*
|
||||
* @author zrx
|
||||
**/
|
||||
public enum StandardDataType {
|
||||
|
||||
/**
|
||||
* 数字
|
||||
*/
|
||||
NUMBER(1, "数字","INT,LONG.NUMBER,BIGINT"),
|
||||
/**
|
||||
* 字符串
|
||||
*/
|
||||
STRING(2, "字符串","CHAR,VARCHAR,NVARCHAR,TEXT,LONGTEXT"),
|
||||
/**
|
||||
* 日期
|
||||
*/
|
||||
DATE(3, "日期","DATE,DATETIME.TIMESTAMP"),
|
||||
/**
|
||||
* 小数
|
||||
*/
|
||||
NUMBER_SACLE(4, "小数","DOUBLE,NUMBER"),
|
||||
;
|
||||
|
||||
|
||||
private final Integer value;
|
||||
private final String longValue;
|
||||
private final String dbDataTypes;
|
||||
|
||||
StandardDataType(Integer value, String longValue,String dbDataTypes) {
|
||||
this.value = value;
|
||||
this.longValue = longValue;
|
||||
this.dbDataTypes = dbDataTypes;
|
||||
}
|
||||
|
||||
public Integer getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public String getLongValue() {
|
||||
return longValue;
|
||||
}
|
||||
|
||||
public String getDbDataTypes() {
|
||||
return dbDataTypes;
|
||||
}
|
||||
|
||||
public static StandardDataType getByCode(String value) {
|
||||
for (StandardDataType standardDataType : StandardDataType.values()) {
|
||||
if (standardDataType.getValue().equals(Integer.parseInt(value))) {
|
||||
return standardDataType;
|
||||
}
|
||||
}
|
||||
return StandardDataType.STRING;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue