commit
2c4132f6fa
|
@ -1,92 +1,90 @@
|
|||
//package net.srt.controller;
|
||||
//
|
||||
//import io.swagger.v3.oas.annotations.Operation;
|
||||
//import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
//import lombok.AllArgsConstructor;
|
||||
//import net.srt.framework.common.cache.bean.Neo4jInfo;
|
||||
//import net.srt.framework.common.utils.Result;
|
||||
//import net.srt.framework.common.utils.TreeNodeVo;
|
||||
//import net.srt.service.MetadataService;
|
||||
//
|
||||
//import net.srt.vo.MetadataVO;
|
||||
//import org.springframework.web.bind.annotation.*;
|
||||
//
|
||||
//import javax.validation.Valid;
|
||||
//import java.util.List;
|
||||
//
|
||||
//@RestController
|
||||
//@RequestMapping("metadata")
|
||||
//@Tag(name = "数据治理-元数据")
|
||||
//@AllArgsConstructor
|
||||
//public class MetadataController {
|
||||
//
|
||||
// private final MetadataService metadataService;
|
||||
//
|
||||
// @GetMapping("/list-child")
|
||||
// @Operation(summary = "根据父级id获取信息")
|
||||
// public Result<List<TreeNodeVo>> listByParentId(@RequestParam Long parentId){
|
||||
// List<TreeNodeVo> treeNodeVos = metadataService.listByParentId(parentId);
|
||||
// return Result.ok(treeNodeVos);
|
||||
// }
|
||||
//
|
||||
// @GetMapping("/list-floder")
|
||||
// @Operation(summary = "获取目录树")
|
||||
// public Result<List<TreeNodeVo>> listFloder(){
|
||||
// List<TreeNodeVo> treeNodeVos = metadataService.listFloder();
|
||||
// return Result.ok(treeNodeVos);
|
||||
// }
|
||||
//
|
||||
// @GetMapping("/list-db")
|
||||
// @Operation(summary = "获取库表目录树")
|
||||
// public Result<List<TreeNodeVo>> listDb(){
|
||||
// List<TreeNodeVo> treeNodeVos = metadataService.listDb();
|
||||
// return Result.ok(treeNodeVos);
|
||||
// }
|
||||
//
|
||||
// @GetMapping("/list-keyword")
|
||||
// @Operation(summary = "模糊查询")
|
||||
// public Result<List<TreeNodeVo>> listByKeyword(String keyword){
|
||||
// List<TreeNodeVo> treeNodeVos = metadataService.listByKeyword(keyword);
|
||||
// return Result.ok(treeNodeVos);
|
||||
// }
|
||||
//
|
||||
// @GetMapping("{id}")
|
||||
// @Operation(summary = "信息")
|
||||
// public Result<MetadataVO> get(@PathVariable("id") Long id){
|
||||
// return Result.ok(metadataService.get(id));
|
||||
// }
|
||||
//
|
||||
// @PostMapping
|
||||
// @Operation(summary = "保存")
|
||||
// public Result<String> save(@RequestBody MetadataVO vo){
|
||||
// metadataService.save(vo);
|
||||
// return Result.ok();
|
||||
// }
|
||||
//
|
||||
// @PutMapping
|
||||
// @Operation(summary = "修改")
|
||||
// public Result<String> update(@RequestBody @Valid MetadataVO vo) {
|
||||
// metadataService.update(vo);
|
||||
// return Result.ok();
|
||||
// }
|
||||
//
|
||||
// @DeleteMapping("{id}")
|
||||
// @Operation(summary = "删除")
|
||||
// public Result<String> delete(@PathVariable Long id) {
|
||||
// metadataService.delete(id);
|
||||
// return Result.ok();
|
||||
// }
|
||||
//
|
||||
// @PostMapping("/neo4j")
|
||||
// @Operation(summary = "更新neo4j的url")
|
||||
// public Result<String> upNeo4jInfo(@RequestBody Neo4jInfo neo4jInfo){
|
||||
// metadataService.upNeo4jInfo(neo4jInfo);
|
||||
// return Result.ok();
|
||||
// }
|
||||
//
|
||||
// @GetMapping("/neo4j")
|
||||
// @Operation(summary = "获取neo4j的url")
|
||||
// public Result<Neo4jInfo> getNeo4jInfo(){
|
||||
// return Result.ok(metadataService.getNeo4jInfo());
|
||||
// }
|
||||
//}
|
||||
package net.srt.controller;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.AllArgsConstructor;
|
||||
import net.srt.framework.common.cache.bean.Neo4jInfo;
|
||||
import net.srt.framework.common.utils.Result;
|
||||
import net.srt.framework.common.utils.TreeNodeVo;
|
||||
import net.srt.service.MetadataService;
|
||||
import net.srt.vo.MetadataVO;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("metadata")
|
||||
@Tag(name = "数据治理-元数据")
|
||||
@AllArgsConstructor
|
||||
public class MetadataController {
|
||||
private final MetadataService metadataService;
|
||||
|
||||
@GetMapping("/list-child")
|
||||
@Operation(summary = "根据父级id获取信息")
|
||||
public Result<List<TreeNodeVo>> listByParentId(@RequestParam Long parentId){
|
||||
List<TreeNodeVo> treeNodeVos = metadataService.listByParentId(parentId);
|
||||
return Result.ok(treeNodeVos);
|
||||
}
|
||||
|
||||
@GetMapping("/list-floder")
|
||||
@Operation(summary = "获取目录树")
|
||||
public Result<List<TreeNodeVo>> listFloder(){
|
||||
List<TreeNodeVo> treeNodeVos = metadataService.listFloder();
|
||||
return Result.ok(treeNodeVos);
|
||||
}
|
||||
|
||||
@GetMapping("/list-db")
|
||||
@Operation(summary = "获取库表目录树")
|
||||
public Result<List<TreeNodeVo>> listDb(){
|
||||
List<TreeNodeVo> treeNodeVos = metadataService.listDb();
|
||||
return Result.ok(treeNodeVos);
|
||||
}
|
||||
|
||||
@GetMapping("/list-keyword")
|
||||
@Operation(summary = "模糊查询")
|
||||
public Result<List<TreeNodeVo>> listByKeyword(String keyword){
|
||||
List<TreeNodeVo> treeNodeVos = metadataService.listByKeyword(keyword);
|
||||
return Result.ok(treeNodeVos);
|
||||
}
|
||||
|
||||
@GetMapping("{id}")
|
||||
@Operation(summary = "信息")
|
||||
public Result<MetadataVO> get(@PathVariable("id") Long id){
|
||||
return Result.ok(metadataService.get(id));
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Operation(summary = "保存")
|
||||
public Result<String> save(@RequestBody MetadataVO vo){
|
||||
metadataService.save(vo);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@Operation(summary = "修改")
|
||||
public Result<String> update(@RequestBody @Valid MetadataVO vo) {
|
||||
metadataService.update(vo);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@DeleteMapping("{id}")
|
||||
@Operation(summary = "删除")
|
||||
public Result<String> delete(@PathVariable Long id) {
|
||||
metadataService.delete(id);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@PostMapping("/neo4j")
|
||||
@Operation(summary = "更新neo4j的url")
|
||||
public Result<String> upNeo4jInfo(@RequestBody Neo4jInfo neo4jInfo){
|
||||
metadataService.upNeo4jInfo(neo4jInfo);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@GetMapping("/neo4j")
|
||||
@Operation(summary = "获取neo4j的url")
|
||||
public Result<Neo4jInfo> getNeo4jInfo(){
|
||||
return Result.ok(metadataService.getNeo4jInfo());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ import net.srt.framework.common.page.PageResult;
|
|||
import net.srt.framework.common.utils.Result;
|
||||
import net.srt.query.QualityConfigQuery;
|
||||
import net.srt.service.QualityConfigService;
|
||||
import net.srt.vo.QualityConfigVo;
|
||||
import net.srt.vo.QualityConfigVO;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
@ -28,26 +28,26 @@ public class QualityConfigController {
|
|||
|
||||
@GetMapping("page")
|
||||
@Operation(summary = "分页")
|
||||
public Result<PageResult<QualityConfigVo>> page(@Valid QualityConfigQuery query){
|
||||
PageResult<QualityConfigVo> page= qualityConfigService.page(query);
|
||||
public Result<PageResult<QualityConfigVO>> page(@Valid QualityConfigQuery query){
|
||||
PageResult<QualityConfigVO> page= qualityConfigService.page(query);
|
||||
return Result.ok(page);
|
||||
}
|
||||
|
||||
@GetMapping("{id}")
|
||||
@Operation(summary = "信息")
|
||||
public Result<QualityConfigVo> get(@PathVariable("id") Long id){
|
||||
public Result<QualityConfigVO> get(@PathVariable("id") Long id){
|
||||
return Result.ok(qualityConfigService.get(id));
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Operation(summary = "保存")
|
||||
public Result<String> save(@RequestBody QualityConfigVo vo){
|
||||
public Result<String> save(@RequestBody QualityConfigVO vo){
|
||||
qualityConfigService.save(vo);
|
||||
return Result.ok();
|
||||
}
|
||||
@PutMapping
|
||||
@Operation(summary = "修改")
|
||||
public Result<String> update(@RequestBody @Valid QualityConfigVo vo){
|
||||
public Result<String> update(@RequestBody @Valid QualityConfigVO vo){
|
||||
qualityConfigService.update(vo);
|
||||
return Result.ok();
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package net.srt.convert;
|
||||
|
||||
import net.srt.entity.QualityConfigEntity;
|
||||
import net.srt.vo.QualityConfigVo;
|
||||
import net.srt.vo.QualityConfigVO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
|
@ -17,9 +17,9 @@ import java.util.List;
|
|||
public interface QualityConfigConvert {
|
||||
QualityConfigConvert INSTANCE = Mappers.getMapper(QualityConfigConvert.class);
|
||||
|
||||
QualityConfigVo convert(QualityConfigEntity entity);
|
||||
QualityConfigVO convert(QualityConfigEntity entity);
|
||||
|
||||
QualityConfigEntity convert(QualityConfigVo vo);
|
||||
QualityConfigEntity convert(QualityConfigVO vo);
|
||||
|
||||
List<QualityConfigVo> convertList(List<QualityConfigEntity> list);
|
||||
List<QualityConfigVO> convertList(List<QualityConfigEntity> list);
|
||||
}
|
||||
|
|
|
@ -1,32 +1,38 @@
|
|||
//package net.srt.service;
|
||||
//
|
||||
//import net.srt.entity.MetadataEntity;
|
||||
//import net.srt.framework.common.cache.bean.Neo4jInfo;
|
||||
//import net.srt.framework.common.utils.TreeNodeVo;
|
||||
//import net.srt.framework.mybatis.service.BaseService;
|
||||
//import net.srt.vo.MetadataVO;
|
||||
//
|
||||
//import java.util.List;
|
||||
//
|
||||
//public interface MetadataService extends BaseService<MetadataEntity> {
|
||||
// List<TreeNodeVo> listByParentId(Long parentId);
|
||||
//
|
||||
// List<TreeNodeVo> listFloder();
|
||||
//
|
||||
// List<TreeNodeVo> listDb();
|
||||
//
|
||||
// List<TreeNodeVo> listByKeyword(String keyword);
|
||||
//
|
||||
// MetadataVO get(Long id);
|
||||
//
|
||||
// void save(MetadataVO vo);
|
||||
//
|
||||
//
|
||||
// void update(MetadataVO vo);
|
||||
//
|
||||
// void delete(Long id);
|
||||
//
|
||||
// void upNeo4jInfo(Neo4jInfo neo4jInfo);
|
||||
//
|
||||
// Neo4jInfo getNeo4jInfo();
|
||||
//}
|
||||
package net.srt.service;
|
||||
|
||||
import net.srt.entity.MetadataEntity;
|
||||
import net.srt.framework.common.cache.bean.Neo4jInfo;
|
||||
import net.srt.framework.common.utils.TreeNodeVo;
|
||||
import net.srt.framework.mybatis.service.BaseService;
|
||||
import net.srt.vo.MetadataVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @BelongsProject: srt_cloud
|
||||
* @BelongsPackage: net.srt.service
|
||||
* @Author: jpz
|
||||
* @CreateTime: 2023/12/24 14:35
|
||||
*/
|
||||
|
||||
public interface MetadataService extends BaseService<MetadataEntity> {
|
||||
List<TreeNodeVo> listByPatenId(Long parentId);
|
||||
|
||||
List<TreeNodeVo> listFloder();
|
||||
|
||||
List<TreeNodeVo> listDb();
|
||||
|
||||
List<TreeNodeVo> listKeyword(String keyword);
|
||||
|
||||
MetadataVO get(Long id);
|
||||
|
||||
void save(MetadataVO vo);
|
||||
|
||||
void update(MetadataVO vo);
|
||||
|
||||
void delete(Long id);
|
||||
|
||||
void updateNeo4j(Neo4jInfo neo4jInfo);
|
||||
|
||||
Neo4jInfo getNeo4j();
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import net.srt.entity.QualityConfigEntity;
|
|||
import net.srt.framework.common.page.PageResult;
|
||||
import net.srt.framework.mybatis.service.BaseService;
|
||||
import net.srt.query.QualityConfigQuery;
|
||||
import net.srt.vo.QualityConfigVo;
|
||||
import net.srt.vo.QualityConfigVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -15,13 +15,13 @@ import java.util.List;
|
|||
* @CreateTime: 2023/12/24 19:33
|
||||
*/
|
||||
public interface QualityConfigService extends BaseService<QualityConfigEntity> {
|
||||
PageResult<QualityConfigVo> page(QualityConfigQuery query);
|
||||
PageResult<QualityConfigVO> page(QualityConfigQuery query);
|
||||
|
||||
QualityConfigVo get(Long id);
|
||||
QualityConfigVO get(Long id);
|
||||
|
||||
void save(QualityConfigVo vo);
|
||||
void save(QualityConfigVO vo);
|
||||
|
||||
void update(QualityConfigVo vo);
|
||||
void update(QualityConfigVO vo);
|
||||
|
||||
void online(Long id);
|
||||
|
||||
|
|
|
@ -1,233 +1,234 @@
|
|||
//package net.srt.service.impl;
|
||||
//
|
||||
//import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
//import io.swagger.v3.oas.annotations.servers.Server;
|
||||
//import lombok.AllArgsConstructor;
|
||||
//import net.srt.api.module.data.governance.constant.BuiltInMetamodel;
|
||||
//import net.srt.convert.MetadataConvert;
|
||||
//import net.srt.dao.MetadataDao;
|
||||
//import net.srt.dao.MetadataPropertyDao;
|
||||
//import net.srt.entity.MetadataEntity;
|
||||
//import net.srt.entity.MetadataPropertyEntity;
|
||||
//import net.srt.framework.common.cache.bean.Neo4jInfo;
|
||||
//import net.srt.framework.common.exception.ServerException;
|
||||
//import net.srt.framework.common.utils.BeanUtil;
|
||||
//import net.srt.framework.common.utils.BuildTreeUtils;
|
||||
//import net.srt.framework.common.utils.TreeNodeVo;
|
||||
//import net.srt.framework.mybatis.service.impl.BaseServiceImpl;
|
||||
//import net.srt.framework.security.cache.TokenStoreCache;
|
||||
//import net.srt.service.MetadataService;
|
||||
//import net.srt.vo.MetadataVO;
|
||||
//import net.srt.vo.MetamodelPropertyVO;
|
||||
//import org.springframework.transaction.annotation.Transactional;
|
||||
//import org.springframework.util.CollectionUtils;
|
||||
//import srt.cloud.framework.dbswitch.common.util.StringUtil;
|
||||
//
|
||||
//import java.util.ArrayList;
|
||||
//import java.util.Comparator;
|
||||
//import java.util.List;
|
||||
//import java.util.stream.Collectors;
|
||||
//
|
||||
//@Server
|
||||
//@AllArgsConstructor
|
||||
//public class MetadataServiceImpl extends BaseServiceImpl<MetadataDao, MetadataEntity> implements MetadataService {
|
||||
//
|
||||
// private final MetadataDao metadataDao;
|
||||
// private final MetadataPropertyDao metadataPropertyDao;
|
||||
// private final TokenStoreCache tokenStoreCache;
|
||||
//
|
||||
// @Override
|
||||
// public List<TreeNodeVo> listByParentId(Long parentId) {
|
||||
// LambdaQueryWrapper<MetadataEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
// wrapper.eq(MetadataEntity::getParentId,parentId)
|
||||
// .orderByAsc(MetadataEntity::getOrderNo);
|
||||
// dataScopeWithOrgId(wrapper);
|
||||
// List<MetadataEntity> metadataEntities = baseMapper.selectList(wrapper);
|
||||
// return BeanUtil.copyListProperties(metadataEntities,TreeNodeVo::new, (oldItem, newItem) ->{
|
||||
// newItem.setLabel(oldItem.getName());
|
||||
// newItem.setValue(oldItem.getId());
|
||||
// newItem.setLeaf(BuiltInMetamodel.COLUMN.getId().equals(oldItem.getMetamodelId()));
|
||||
// if(newItem.getPath().contains("/")){
|
||||
// newItem.setParentPath(newItem.getPath().substring(0,newItem.getPath().lastIndexOf("/")));
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public List<TreeNodeVo> listFloder() {
|
||||
// LambdaQueryWrapper<MetadataEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
// wrapper.eq(MetadataEntity::getIfLeaf,1)
|
||||
// .orderByAsc(MetadataEntity::getOrderNo)
|
||||
// .orderByAsc(MetadataEntity::getId);
|
||||
// dataScopeWithOrgId(wrapper);
|
||||
// List<MetadataEntity> metadatas = baseMapper.selectList(wrapper);
|
||||
// List<TreeNodeVo> treeNodeVos = BeanUtil.copyListProperties(metadatas, TreeNodeVo::new, (oldItem, newItem) -> {
|
||||
// newItem.setLabel(oldItem.getName());
|
||||
// newItem.setValue(oldItem.getId());
|
||||
// if (newItem.getPath().contains("/")) {
|
||||
// newItem.setParentPath(newItem.getPath().substring(0, newItem.getPath().lastIndexOf("/")));
|
||||
// }
|
||||
// });
|
||||
// return BuildTreeUtils.buildTree(treeNodeVos);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public List<TreeNodeVo> listDb() {
|
||||
// LambdaQueryWrapper<MetadataEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
// wrapper.in(MetadataEntity::getMetamodelId,BuiltInMetamodel.SCHEMA.getId(),BuiltInMetamodel.TABLE.getId())
|
||||
// .or()
|
||||
// .isNull(MetadataEntity::getMetamodelId)
|
||||
// .orderByAsc(MetadataEntity::getOrderNo);
|
||||
// dataScopeWithOrgId(wrapper);
|
||||
// List<MetadataEntity> metadatas = baseMapper.selectList(wrapper);
|
||||
// List<TreeNodeVo> treeNodeVos = BeanUtil.copyListProperties(metadatas,TreeNodeVo::new, (oldItem, newItem) -> {
|
||||
// newItem.setLabel(oldItem.getName());
|
||||
// newItem.setValue(oldItem.getId());
|
||||
// newItem.setDisabled(!BuiltInMetamodel.TABLE.getId().equals(oldItem.getMetamodelId()));
|
||||
// if(newItem.getPath().contains("/")) {
|
||||
// newItem.setParentPath(newItem.getPath().substring(0,newItem.getPath().lastIndexOf("/")));
|
||||
// }
|
||||
// });
|
||||
// return BuildTreeUtils.buildTree(treeNodeVos);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public List<TreeNodeVo> listByKeyword(String keyword) {
|
||||
// if(StringUtil.isBlank(keyword)){
|
||||
// return listByParentId(0L);
|
||||
// }
|
||||
// LambdaQueryWrapper<MetadataEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
// wrapper.like(MetadataEntity::getName,keyword)
|
||||
// .or()
|
||||
// .like(MetadataEntity::getCode,keyword)
|
||||
// .orderByAsc(MetadataEntity::getOrderNo)
|
||||
// .orderByAsc(MetadataEntity::getId);
|
||||
// dataScopeWithOrgId(wrapper);
|
||||
// List<MetadataEntity> metadatas = baseMapper.selectList(wrapper);
|
||||
// List<MetadataEntity> resultList = new ArrayList<>();
|
||||
// //递归获取父级
|
||||
// for (MetadataEntity metadata : metadatas) {
|
||||
// recursionAddParent(metadata,resultList);
|
||||
// }
|
||||
// List<MetadataEntity> result = resultList.stream().sorted(Comparator.comparing(MetadataEntity::getOrderNo)).collect(Collectors.toList());
|
||||
// List<TreeNodeVo> treeNodeVos = BeanUtil.copyListProperties(result ,TreeNodeVo::new, (oldItem, newItem) -> {
|
||||
// newItem.setLabel(oldItem.getName());
|
||||
// newItem.setValue(oldItem.getId());
|
||||
// newItem.setLeaf(BuiltInMetamodel.COLUMN.getId().equals(oldItem.getMetamodelId()));
|
||||
// if(newItem.getPath().contains("/")) {
|
||||
// newItem.setParentPath(newItem.getPath().substring(0,newItem.getPath().lastIndexOf("/")));
|
||||
// }
|
||||
// });
|
||||
// return BuildTreeUtils.buildTree(treeNodeVos);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public MetadataVO get(Long id) {
|
||||
// MetadataEntity metadataEntity = getById(id);
|
||||
// MetadataVO metadataVO = MetadataConvert.INSTANCE.convert(metadataEntity);
|
||||
// metadataVO.setProperties(metadataPropertyDao.listPropertyById(id,metadataEntity.getMetamodelId()));
|
||||
// return metadataVO;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void save(MetadataVO vo) {
|
||||
// MetadataEntity entity = MetadataConvert.INSTANCE.convert(vo);
|
||||
// entity.setProjectId(getProjectId());
|
||||
// entity.setPath(recursionPath(entity,null));
|
||||
// buildField(entity);
|
||||
// MetadataEntity parentMetadata = baseMapper.selectById(vo.getParentId());
|
||||
// if(parentMetadata != null) {
|
||||
// entity.setDbType(parentMetadata.getDbType());
|
||||
// entity.setDatasourceId(parentMetadata.getDatasourceId());
|
||||
// entity.setCollectTaskId(parentMetadata.getCollectTaskId());
|
||||
// }
|
||||
// baseMapper.insert(entity);
|
||||
// buildProperties(entity,vo.getProperties());
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void update(MetadataVO vo) {
|
||||
// MetadataEntity entity = MetadataConvert.INSTANCE.convert(vo);
|
||||
// entity.setProjectId(getProjectId());
|
||||
// entity.setPath(recursionPath(entity,null));
|
||||
// buildField(entity);
|
||||
// updateById(entity);
|
||||
// buildProperties(entity,vo.getProperties());
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// @Transactional(rollbackFor = Exception.class)
|
||||
// public void delete(Long id) {
|
||||
// LambdaQueryWrapper<MetadataEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
// wrapper.eq(MetadataEntity::getParentId,id).last("limit 1");
|
||||
// if(baseMapper.selectOne(wrapper)!=null){
|
||||
// throw new ServerException("存在子节点,不可删除!");
|
||||
// }
|
||||
// removeById(id);
|
||||
// LambdaQueryWrapper<MetadataPropertyEntity> propertyWrapper = new LambdaQueryWrapper<>();
|
||||
// propertyWrapper.eq(MetadataPropertyEntity::getMetadataId,id);
|
||||
// metadataPropertyDao.delete(propertyWrapper);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void upNeo4jInfo(Neo4jInfo neo4jInfo) {
|
||||
// tokenStoreCache.saveNeo4jInfo(getProjectId(),neo4jInfo);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Neo4jInfo getNeo4jInfo() {
|
||||
// return tokenStoreCache.getNeo4jInfo(getProjectId());
|
||||
// }
|
||||
//
|
||||
// private void recursionAddParent(MetadataEntity metadataEntity, List<MetadataEntity> resultList){
|
||||
// if(resultList.stream().noneMatch(item -> metadataEntity.getId().equals(item.getId()))) {
|
||||
// resultList.add(metadataEntity);
|
||||
// }
|
||||
//
|
||||
// if(metadataEntity.getParentId()!=0){
|
||||
// MetadataEntity parent = getById(metadataEntity.getParentId());
|
||||
// recursionAddParent(parent,resultList);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private void buildField(MetadataEntity entity){
|
||||
// if(entity.getMetamodelId()!=null){
|
||||
// entity.setIcon(metadataDao.selectById(entity.getMetamodelId()).getIcon());
|
||||
// }
|
||||
// if(entity.getIfLeaf() == 1 && entity.getMetamodelId() == null) {
|
||||
// entity.setIcon("/src/assets/folder.png");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private String recursionPath(MetadataEntity metadataEntity, String path) {
|
||||
// if(StringUtil.isBlank(path)){
|
||||
// path = metadataEntity.getName();
|
||||
// }
|
||||
// if(metadataEntity.getParentId()!=0){
|
||||
// MetadataEntity parent = getById(metadataEntity.getParentId());
|
||||
// path = parent.getName() + "/" +path;
|
||||
// return recursionPath(parent,path);
|
||||
// }
|
||||
// return path;
|
||||
// }
|
||||
//
|
||||
// private void buildProperties(MetadataEntity entity, List<MetamodelPropertyVO> properties){
|
||||
// if(!CollectionUtils.isEmpty(properties)){
|
||||
// LambdaQueryWrapper<MetadataPropertyEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
// wrapper.eq(MetadataPropertyEntity::getMetadataId,entity.getId());
|
||||
// for (MetamodelPropertyVO property : properties) {
|
||||
// MetadataPropertyEntity metadataPropertyEntity = new MetadataPropertyEntity();
|
||||
// metadataPropertyEntity.setMetamodelPropertyId(property.getId());
|
||||
// metadataPropertyEntity.setMetadataId(entity.getId());
|
||||
// metadataPropertyEntity.setProperty(property.getValue());
|
||||
// metadataPropertyEntity.setProjectId(entity.getProjectId());
|
||||
// if(property.getMetadataPropertyId()!=null){
|
||||
// metadataPropertyEntity.setId(property.getMetadataPropertyId());
|
||||
// metadataPropertyDao.updateById(metadataPropertyEntity);
|
||||
// }else {
|
||||
// metadataPropertyDao.insert(metadataPropertyEntity);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
package net.srt.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import io.swagger.v3.oas.annotations.servers.Server;
|
||||
import lombok.AllArgsConstructor;
|
||||
import net.srt.api.module.data.governance.constant.BuiltInMetamodel;
|
||||
import net.srt.convert.MetadataConvert;
|
||||
import net.srt.dao.MetadataDao;
|
||||
import net.srt.dao.MetadataPropertyDao;
|
||||
import net.srt.entity.MetadataEntity;
|
||||
import net.srt.entity.MetadataPropertyEntity;
|
||||
import net.srt.framework.common.cache.bean.Neo4jInfo;
|
||||
import net.srt.framework.common.exception.ServerException;
|
||||
import net.srt.framework.common.utils.BeanUtil;
|
||||
import net.srt.framework.common.utils.BuildTreeUtils;
|
||||
import net.srt.framework.common.utils.TreeNodeVo;
|
||||
import net.srt.framework.mybatis.service.impl.BaseServiceImpl;
|
||||
import net.srt.framework.security.cache.TokenStoreCache;
|
||||
import net.srt.service.MetadataService;
|
||||
import net.srt.vo.MetadataVO;
|
||||
import net.srt.vo.MetamodelPropertyVO;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import srt.cloud.framework.dbswitch.common.util.StringUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class MetadataServiceImpl extends BaseServiceImpl<MetadataDao, MetadataEntity> implements MetadataService {
|
||||
|
||||
private final MetadataDao metadataDao;
|
||||
private final MetadataPropertyDao metadataPropertyDao;
|
||||
private final TokenStoreCache tokenStoreCache;
|
||||
|
||||
@Override
|
||||
public List<TreeNodeVo> listByPatenId(Long parentId) {
|
||||
LambdaQueryWrapper<MetadataEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(MetadataEntity::getParentId,parentId)
|
||||
.orderByAsc(MetadataEntity::getOrderNo);
|
||||
dataScopeWithOrgId(wrapper);
|
||||
List<MetadataEntity> metadataEntities = baseMapper.selectList(wrapper);
|
||||
return BeanUtil.copyListProperties(metadataEntities,TreeNodeVo::new, (oldItem, newItem) ->{
|
||||
newItem.setLabel(oldItem.getName());
|
||||
newItem.setValue(oldItem.getId());
|
||||
newItem.setLeaf(BuiltInMetamodel.COLUMN.getId().equals(oldItem.getMetamodelId()));
|
||||
if(newItem.getPath().contains("/")){
|
||||
newItem.setParentPath(newItem.getPath().substring(0,newItem.getPath().lastIndexOf("/")));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TreeNodeVo> listFloder() {
|
||||
LambdaQueryWrapper<MetadataEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(MetadataEntity::getIfLeaf,1)
|
||||
.orderByAsc(MetadataEntity::getOrderNo)
|
||||
.orderByAsc(MetadataEntity::getId);
|
||||
dataScopeWithOrgId(wrapper);
|
||||
List<MetadataEntity> metadatas = baseMapper.selectList(wrapper);
|
||||
List<TreeNodeVo> treeNodeVos = BeanUtil.copyListProperties(metadatas, TreeNodeVo::new, (oldItem, newItem) -> {
|
||||
newItem.setLabel(oldItem.getName());
|
||||
newItem.setValue(oldItem.getId());
|
||||
if (newItem.getPath().contains("/")) {
|
||||
newItem.setParentPath(newItem.getPath().substring(0, newItem.getPath().lastIndexOf("/")));
|
||||
}
|
||||
});
|
||||
return BuildTreeUtils.buildTree(treeNodeVos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TreeNodeVo> listDb() {
|
||||
LambdaQueryWrapper<MetadataEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.in(MetadataEntity::getMetamodelId,BuiltInMetamodel.SCHEMA.getId(),BuiltInMetamodel.TABLE.getId())
|
||||
.or()
|
||||
.isNull(MetadataEntity::getMetamodelId)
|
||||
.orderByAsc(MetadataEntity::getOrderNo);
|
||||
dataScopeWithOrgId(wrapper);
|
||||
List<MetadataEntity> metadatas = baseMapper.selectList(wrapper);
|
||||
List<TreeNodeVo> treeNodeVos = BeanUtil.copyListProperties(metadatas,TreeNodeVo::new, (oldItem, newItem) -> {
|
||||
newItem.setLabel(oldItem.getName());
|
||||
newItem.setValue(oldItem.getId());
|
||||
newItem.setDisabled(!BuiltInMetamodel.TABLE.getId().equals(oldItem.getMetamodelId()));
|
||||
if(newItem.getPath().contains("/")) {
|
||||
newItem.setParentPath(newItem.getPath().substring(0,newItem.getPath().lastIndexOf("/")));
|
||||
}
|
||||
});
|
||||
return BuildTreeUtils.buildTree(treeNodeVos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TreeNodeVo> listKeyword(String keyword) {
|
||||
if(StringUtil.isBlank(keyword)){
|
||||
return listByPatenId(0L);
|
||||
}
|
||||
LambdaQueryWrapper<MetadataEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.like(MetadataEntity::getName,keyword)
|
||||
.or()
|
||||
.like(MetadataEntity::getCode,keyword)
|
||||
.orderByAsc(MetadataEntity::getOrderNo)
|
||||
.orderByAsc(MetadataEntity::getId);
|
||||
dataScopeWithOrgId(wrapper);
|
||||
List<MetadataEntity> metadatas = baseMapper.selectList(wrapper);
|
||||
List<MetadataEntity> resultList = new ArrayList<>();
|
||||
//递归获取父级
|
||||
for (MetadataEntity metadata : metadatas) {
|
||||
recursionAddParent(metadata,resultList);
|
||||
}
|
||||
List<MetadataEntity> result = resultList.stream().sorted(Comparator.comparing(MetadataEntity::getOrderNo)).collect(Collectors.toList());
|
||||
List<TreeNodeVo> treeNodeVos = BeanUtil.copyListProperties(result ,TreeNodeVo::new, (oldItem, newItem) -> {
|
||||
newItem.setLabel(oldItem.getName());
|
||||
newItem.setValue(oldItem.getId());
|
||||
newItem.setLeaf(BuiltInMetamodel.COLUMN.getId().equals(oldItem.getMetamodelId()));
|
||||
if(newItem.getPath().contains("/")) {
|
||||
newItem.setParentPath(newItem.getPath().substring(0,newItem.getPath().lastIndexOf("/")));
|
||||
}
|
||||
});
|
||||
return BuildTreeUtils.buildTree(treeNodeVos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetadataVO get(Long id) {
|
||||
MetadataEntity metadataEntity = getById(id);
|
||||
MetadataVO metadataVO = MetadataConvert.INSTANCE.convert(metadataEntity);
|
||||
metadataVO.setProperties(metadataPropertyDao.listPropertyById(id,metadataEntity.getMetamodelId()));
|
||||
return metadataVO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(MetadataVO vo) {
|
||||
MetadataEntity entity = MetadataConvert.INSTANCE.convert(vo);
|
||||
entity.setProjectId(getProjectId());
|
||||
entity.setPath(recursionPath(entity,null));
|
||||
buildField(entity);
|
||||
MetadataEntity parentMetadata = baseMapper.selectById(vo.getParentId());
|
||||
if(parentMetadata != null) {
|
||||
entity.setDbType(parentMetadata.getDbType());
|
||||
entity.setDatasourceId(parentMetadata.getDatasourceId());
|
||||
entity.setCollectTaskId(parentMetadata.getCollectTaskId());
|
||||
}
|
||||
baseMapper.insert(entity);
|
||||
buildProperties(entity,vo.getProperties());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(MetadataVO vo) {
|
||||
MetadataEntity entity = MetadataConvert.INSTANCE.convert(vo);
|
||||
entity.setProjectId(getProjectId());
|
||||
entity.setPath(recursionPath(entity,null));
|
||||
buildField(entity);
|
||||
updateById(entity);
|
||||
buildProperties(entity,vo.getProperties());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void delete(Long id) {
|
||||
LambdaQueryWrapper<MetadataEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(MetadataEntity::getParentId,id).last("limit 1");
|
||||
if(baseMapper.selectOne(wrapper)!=null){
|
||||
throw new ServerException("存在子节点,不可删除!");
|
||||
}
|
||||
removeById(id);
|
||||
LambdaQueryWrapper<MetadataPropertyEntity> propertyWrapper = new LambdaQueryWrapper<>();
|
||||
propertyWrapper.eq(MetadataPropertyEntity::getMetadataId,id);
|
||||
metadataPropertyDao.delete(propertyWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateNeo4j(Neo4jInfo neo4jInfo) {
|
||||
tokenStoreCache.saveNeo4jInfo(getProjectId(),neo4jInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Neo4jInfo getNeo4j() {
|
||||
return tokenStoreCache.getNeo4jInfo(getProjectId());
|
||||
}
|
||||
|
||||
private void recursionAddParent(MetadataEntity metadataEntity, List<MetadataEntity> resultList){
|
||||
if(resultList.stream().noneMatch(item -> metadataEntity.getId().equals(item.getId()))) {
|
||||
resultList.add(metadataEntity);
|
||||
}
|
||||
|
||||
if(metadataEntity.getParentId()!=0){
|
||||
MetadataEntity parent = getById(metadataEntity.getParentId());
|
||||
recursionAddParent(parent,resultList);
|
||||
}
|
||||
}
|
||||
|
||||
private void buildField(MetadataEntity entity){
|
||||
if(entity.getMetamodelId()!=null){
|
||||
entity.setIcon(metadataDao.selectById(entity.getMetamodelId()).getIcon());
|
||||
}
|
||||
if(entity.getIfLeaf() == 1 && entity.getMetamodelId() == null) {
|
||||
entity.setIcon("/src/assets/folder.png");
|
||||
}
|
||||
}
|
||||
|
||||
private String recursionPath(MetadataEntity metadataEntity, String path) {
|
||||
if(StringUtil.isBlank(path)){
|
||||
path = metadataEntity.getName();
|
||||
}
|
||||
if(metadataEntity.getParentId()!=0){
|
||||
MetadataEntity parent = getById(metadataEntity.getParentId());
|
||||
path = parent.getName() + "/" +path;
|
||||
return recursionPath(parent,path);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
private void buildProperties(MetadataEntity entity, List<MetamodelPropertyVO> properties){
|
||||
if(!CollectionUtils.isEmpty(properties)){
|
||||
LambdaQueryWrapper<MetadataPropertyEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(MetadataPropertyEntity::getMetadataId,entity.getId());
|
||||
for (MetamodelPropertyVO property : properties) {
|
||||
MetadataPropertyEntity metadataPropertyEntity = new MetadataPropertyEntity();
|
||||
metadataPropertyEntity.setMetamodelPropertyId(property.getId());
|
||||
metadataPropertyEntity.setMetadataId(entity.getId());
|
||||
metadataPropertyEntity.setProperty(property.getValue());
|
||||
metadataPropertyEntity.setProjectId(entity.getProjectId());
|
||||
if(property.getMetadataPropertyId()!=null){
|
||||
metadataPropertyEntity.setId(property.getMetadataPropertyId());
|
||||
metadataPropertyDao.updateById(metadataPropertyEntity);
|
||||
}else {
|
||||
metadataPropertyDao.insert(metadataPropertyEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.sun.org.apache.bcel.internal.generic.LADD;
|
||||
import lombok.AllArgsConstructor;
|
||||
import net.srt.api.module.data.governance.constant.BuiltInQualityRule;
|
||||
import net.srt.api.module.data.governance.dto.quality.QualityConfigParam;
|
||||
|
@ -19,8 +18,7 @@ import net.srt.framework.common.page.PageResult;
|
|||
import net.srt.framework.mybatis.service.impl.BaseServiceImpl;
|
||||
import net.srt.query.QualityConfigQuery;
|
||||
import net.srt.service.QualityConfigService;
|
||||
import net.srt.vo.QualityConfigVo;
|
||||
import org.springframework.security.core.parameters.P;
|
||||
import net.srt.vo.QualityConfigVO;
|
||||
import org.springframework.stereotype.Service;
|
||||
import srt.cloud.framework.dbswitch.common.util.StringUtil;
|
||||
|
||||
|
@ -39,39 +37,39 @@ public class QualityConfigServiceimpl extends BaseServiceImpl<QualityConfigDao,
|
|||
private final QuartzDataGovernanceQualityApi quartzDataGovernanceQualityApi;
|
||||
private final MetadataDao metadataDao;
|
||||
@Override
|
||||
public PageResult<QualityConfigVo> page(QualityConfigQuery query) {
|
||||
public PageResult<QualityConfigVO> page(QualityConfigQuery query) {
|
||||
IPage<QualityConfigEntity> page=baseMapper.selectPage(getPage(query),getWrapper(query));
|
||||
return new PageResult<>(QualityConfigConvert.INSTANCE.convertList(page.getRecords()),page.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public QualityConfigVo get(Long id) {
|
||||
QualityConfigVo qualityConfigvo= QualityConfigConvert.INSTANCE.convert(baseMapper.selectById(id));
|
||||
List<Integer> metadataIds=qualityConfigvo.getMetadataIds();
|
||||
public QualityConfigVO get(Long id) {
|
||||
QualityConfigVO QualityConfigVO= QualityConfigConvert.INSTANCE.convert(baseMapper.selectById(id));
|
||||
List<Integer> metadataIds=QualityConfigVO.getMetadataIds();
|
||||
LambdaQueryWrapper<MetadataEntity> metadataWrapper= Wrappers.lambdaQuery();
|
||||
metadataWrapper.in(MetadataEntity::getId,metadataIds);
|
||||
List<MetadataEntity> metadataEntities=metadataDao.selectList(metadataWrapper);
|
||||
if (CollectionUtils.isEmpty(metadataEntities)){
|
||||
qualityConfigvo.setMetadataStrs("检测字段已删除,请检查数据信息");
|
||||
QualityConfigVO.setMetadataStrs("检测字段已删除,请检查数据信息");
|
||||
}else {
|
||||
qualityConfigvo.setMetadataStrs(metadataEntities.stream().map(MetadataEntity::getPath).collect(Collectors.joining(";")));
|
||||
QualityConfigVO.setMetadataStrs(metadataEntities.stream().map(MetadataEntity::getPath).collect(Collectors.joining(";")));
|
||||
}
|
||||
if (BuiltInQualityRule.ASSOCIATION_CONSISTENCY.getId().equals(qualityConfigvo.getRuleId())){
|
||||
QualityConfigParam param = qualityConfigvo.getParam();
|
||||
if (BuiltInQualityRule.ASSOCIATION_CONSISTENCY.getId().equals(QualityConfigVO.getRuleId())){
|
||||
QualityConfigParam param = QualityConfigVO.getParam();
|
||||
Integer columnMetaId = param.getColumnMetaId();
|
||||
MetadataEntity entity = metadataDao.selectById(columnMetaId);
|
||||
if (entity!= null){
|
||||
qualityConfigvo.setRelMetadataStr(entity.getPath());
|
||||
QualityConfigVO.setRelMetadataStr(entity.getPath());
|
||||
}else {
|
||||
qualityConfigvo.setMetadataStrs("关联字段已被删除,请检查元数据信息");
|
||||
QualityConfigVO.setMetadataStrs("关联字段已被删除,请检查元数据信息");
|
||||
}
|
||||
}
|
||||
|
||||
return qualityConfigvo;
|
||||
return QualityConfigVO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(QualityConfigVo vo) {
|
||||
public void save(QualityConfigVO vo) {
|
||||
QualityConfigEntity entity=QualityConfigConvert.INSTANCE.convert(vo);
|
||||
entity.setProjectId(getProjectId());
|
||||
if (!BuiltInQualityRule.UNIQUENESS.getId().equals(entity.getRuleId())&&!BuiltInQualityRule.LENGTH_CHECK.getId().equals(entity.getRuleId())&& !BuiltInQualityRule.ASSOCIATION_CONSISTENCY.getId().equals(entity.getRuleId())&&!BuiltInQualityRule.TIMELINESS.getId().equals(entity.getRuleId())){
|
||||
|
@ -81,7 +79,7 @@ public class QualityConfigServiceimpl extends BaseServiceImpl<QualityConfigDao,
|
|||
}
|
||||
|
||||
@Override
|
||||
public void update(QualityConfigVo vo) {
|
||||
public void update(QualityConfigVO vo) {
|
||||
if (!BuiltInQualityRule.UNIQUENESS.getId().equals(vo.getRuleId())&&!BuiltInQualityRule.LENGTH_CHECK.getId().equals(vo.getRuleId())&&!BuiltInQualityRule.ASSOCIATION_CONSISTENCY.getId().equals(vo.getRuleId())&&!BuiltInQualityRule.TIMELINESS.getId().equals(vo.getRuleId())){
|
||||
vo.setParam(null);
|
||||
}
|
||||
|
|
|
@ -25,71 +25,116 @@ import java.util.List;
|
|||
@AllArgsConstructor
|
||||
public class ApiGroupServiceImpl extends BaseServiceImpl<ApiGroupDao, ApiGroupEntity> implements ApiGroupService{
|
||||
private final ApiConfigService apiConfigService;
|
||||
/**
|
||||
* 获取API分组树形结构列表
|
||||
* @return API分组树形结构列表
|
||||
*/
|
||||
@Override
|
||||
public List<TreeNodeVo> listTree() {
|
||||
// 查询所有API分组实体对象,并转换为树节点VO对象列表
|
||||
List<TreeNodeVo> treeNodeVos = getTreeNodeVos();
|
||||
// 构建树形结构,并返回根节点列表
|
||||
return BuildTreeUtils.buildTree(treeNodeVos);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取API分组树节点VO对象列表
|
||||
* @return API分组树节点VO对象列表
|
||||
*/
|
||||
private List<TreeNodeVo> getTreeNodeVos() {
|
||||
LambdaQueryWrapper<ApiGroupEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
dataScopeWithoutOrgId(wrapper);
|
||||
wrapper.orderByAsc(ApiGroupEntity::getOrderNo);
|
||||
dataScopeWithoutOrgId(wrapper); // 加入数据权限过滤
|
||||
wrapper.orderByAsc(ApiGroupEntity::getOrderNo); // 按orderNo升序排序
|
||||
List<ApiGroupEntity> apiGroupEntities = baseMapper.selectList(wrapper);
|
||||
// 将实体对象列表转换为VO对象列表
|
||||
return BeanUtil.copyListProperties(apiGroupEntities, TreeNodeVo::new, (oldItem, newItem) -> {
|
||||
// 设置节点名称
|
||||
newItem.setLabel(oldItem.getName());
|
||||
// 设置节点值
|
||||
newItem.setValue(oldItem.getId());
|
||||
newItem.setDisabled(oldItem.getType() == 1);
|
||||
if (newItem.getPath().contains("/")) {
|
||||
newItem.setDisabled(oldItem.getType() == 1); // 如果是虚拟节点,设置禁用状态
|
||||
if (newItem.getPath().contains("/")) { // 设置父级节点路径
|
||||
newItem.setParentPath(newItem.getPath().substring(0, newItem.getPath().lastIndexOf("/")));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增API分组
|
||||
* @param vo API分组VO对象
|
||||
*/
|
||||
@Override
|
||||
public void save(ApiGroupVo vo) {
|
||||
// 将VO对象转换为实体对象
|
||||
ApiGroupEntity entity = ApiGroupConvert.INSTANCE.convert(vo);
|
||||
// 递归生成路径
|
||||
entity.setPath(recursionPath(entity, null));
|
||||
// 设置项目ID
|
||||
entity.setProjectId(getProjectId());
|
||||
// 执行插入操作
|
||||
baseMapper.insert(entity); // 使用 insertSelective() 方法进行插入操作
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新API分组
|
||||
* @param vo API分组VO对象
|
||||
*/
|
||||
@Override
|
||||
public void update(ApiGroupVo vo) {
|
||||
// 将VO对象转换为实体对象
|
||||
ApiGroupEntity entity = ApiGroupConvert.INSTANCE.convert(vo);
|
||||
// 递归生成路径
|
||||
entity.setPath(recursionPath(entity, null));
|
||||
// 设置项目ID
|
||||
entity.setProjectId(getProjectId());
|
||||
// 执行更新操作
|
||||
updateById(entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归生成API分组路径
|
||||
* @param groupEntity 分组实体对象
|
||||
* @param path 父级路径
|
||||
* @return 完整路径
|
||||
*/
|
||||
//1
|
||||
private String recursionPath(ApiGroupEntity groupEntity, String path) {
|
||||
if (StringUtil.isBlank(path)) {
|
||||
// 如果路径为空,则将路径设置为组实体的名称
|
||||
path = groupEntity.getName();
|
||||
}
|
||||
if (groupEntity.getParentId() != 0) {
|
||||
ApiGroupEntity parent = getById(groupEntity.getParentId());
|
||||
path = parent.getName() + "/" + path;
|
||||
return recursionPath(parent, path);
|
||||
// 如果组实体的父ID不为0
|
||||
// 查询父级组实体
|
||||
ApiGroupEntity parent = getById(groupEntity.getParentId()); // 通过父ID获取父级组实体
|
||||
path = parent.getName() + "/" + path; // 将父级组实体的名称与当前路径拼接起来,中间以斜杠分隔
|
||||
return recursionPath(parent, path); // 递归调用recursionPath方法,传入父级组实体和拼接后的路径
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID删除API分组
|
||||
* @param id API分组ID
|
||||
*/
|
||||
@Override
|
||||
public void delete(Long id) {
|
||||
//查询有没有子节点
|
||||
// 查询是否存在子节点
|
||||
LambdaQueryWrapper<ApiGroupEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(ApiGroupEntity::getParentId, id).last(" limit 1");
|
||||
ApiGroupEntity one = baseMapper.selectOne(wrapper);
|
||||
if (one != null) {
|
||||
throw new ServerException("存在子节点,不允许删除!");
|
||||
}
|
||||
//查询有没有api与之关联
|
||||
// 查询是否有API配置与之关联
|
||||
LambdaQueryWrapper<ApiConfigEntity> serviceApiConfigWrapper = new LambdaQueryWrapper<>();
|
||||
serviceApiConfigWrapper.eq(ApiConfigEntity::getGroupId, id).last(" limit 1");
|
||||
ApiConfigEntity apiConfigEntity = apiConfigService.getOne(serviceApiConfigWrapper);
|
||||
if (apiConfigEntity != null) {
|
||||
throw new ServerException("节点下有 api 与之关联,不允许删除!");
|
||||
}
|
||||
// 执行删除操作
|
||||
removeById(id);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -84,18 +84,12 @@ spring:
|
|||
- Path=/srt-cloud-datax-service/** # Adjust the path as needed
|
||||
filters:
|
||||
- StripPrefix=1
|
||||
- id: srt-data-development # New Gateway
|
||||
uri: lb://srt-data-development # Update with the correct URI for your new service
|
||||
predicates:
|
||||
- Path=/data-development/** # Adjust the path as needed
|
||||
filters:
|
||||
- StripPrefix=1
|
||||
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: 101.34.77.101:8848
|
||||
# 命名空间,默认:public
|
||||
namespace: 7e34f104-f333-4828-b36a-02146e521c9a
|
||||
namespace: 9de208a6-cb30-41ae-a880-78196c99c050
|
||||
service: ${spring.application.name}
|
||||
group: srt2.0
|
||||
|
||||
|
|
|
@ -9,11 +9,6 @@
|
|||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>net.srt</groupId>
|
||||
<artifactId>srt-cloud-api</artifactId>
|
||||
<version>2.0.0</version>
|
||||
</dependency>
|
||||
<!--数据血缘-->
|
||||
<dependency>
|
||||
<groupId>net.srt</groupId>
|
||||
|
|
|
@ -9,6 +9,7 @@ import org.mybatis.spring.annotation.MapperScan;
|
|||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -16,6 +17,8 @@ import static com.alibaba.druid.sql.SQLUtils.toSQLString;
|
|||
|
||||
@EnableDiscoveryClient
|
||||
@SpringBootApplication
|
||||
@EnableFeignClients
|
||||
|
||||
@MapperScan("net.srt.Fink.mapper")
|
||||
@MapperScan("net.srt.Hadoop.mapper")
|
||||
@MapperScan("net.srt.disposition.mapper")
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
package net.srt.disposition.controller;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import net.srt.disposition.dto.DataCheckSqlDto;
|
||||
import net.srt.disposition.entity.DataCheckSqlEntity;
|
||||
import net.srt.disposition.service.DataCheckSqlService;
|
||||
import net.srt.disposition.vo.DataCheckSqlVo;
|
||||
import net.srt.framework.common.utils.Result;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@RequestMapping("/task")
|
||||
public class DataCheckSqlController {
|
||||
|
||||
private DataCheckSqlService dataCheckSqlService;
|
||||
|
||||
@PostMapping("/explain-sql")
|
||||
public Result<DataCheckSqlVo> explainSql(DataCheckSqlDto dataCheckSqlDto) {
|
||||
return Result.ok(dataCheckSqlService.explainSql(dataCheckSqlDto));
|
||||
}
|
||||
}
|
|
@ -20,13 +20,13 @@ public class DataProductionTreeController {
|
|||
private DataProductionService dataProductionService;
|
||||
|
||||
@GetMapping
|
||||
public Result<List<TreeNodeVo>> listResult(){
|
||||
public Result<List<TreeNodeVo>> listResult(@RequestParam String t){
|
||||
List<TreeNodeVo> dispositionVos=dataProductionService.dataTreeList();
|
||||
return Result.ok(dispositionVos);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public Result add(@RequestBody DataProductionTreeDto dataProductionTreeDto){
|
||||
public Result<String> add(@RequestBody DataProductionTreeDto dataProductionTreeDto){
|
||||
dataProductionService.add(dataProductionTreeDto);
|
||||
return Result.ok();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
package net.srt.disposition.controller;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import net.srt.disposition.dto.DataSqlSaveDto;
|
||||
import net.srt.disposition.service.DataSaveService;
|
||||
import net.srt.framework.common.utils.Result;
|
||||
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.RestController;
|
||||
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@RequestMapping("/task")
|
||||
public class DataSaveController {
|
||||
private DataSaveService dataSaveService;
|
||||
@PostMapping
|
||||
public Result addSave(@RequestBody DataSqlSaveDto dataSqlSaveDto){
|
||||
dataSaveService.dataSaver(dataSqlSaveDto);
|
||||
return Result.ok();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package net.srt.disposition.convert;
|
||||
|
||||
import net.srt.disposition.dto.DataSqlSaveDto;
|
||||
import net.srt.disposition.dto.DispositionDto;
|
||||
import net.srt.disposition.entity.DataSqlSaveEntity;
|
||||
import net.srt.disposition.entity.DispositionEntity;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
public interface DataSqlSaveConvert {
|
||||
DataSqlSaveConvert INSTANCE = Mappers.getMapper(DataSqlSaveConvert.class);
|
||||
DataSqlSaveEntity convert(DataSqlSaveDto vo);
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package net.srt.disposition.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class DataCheckSqlDto {
|
||||
private Long alertGroupId;
|
||||
private String alias;
|
||||
private boolean batchModel;
|
||||
private Long catalogueId;
|
||||
private Integer checkPoint;
|
||||
private String clusterConfigurationId;
|
||||
private Long clusterId;
|
||||
private String configJson;
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date createTime;
|
||||
private Integer databaseId;
|
||||
private Integer deleted;
|
||||
private Integer dialect;
|
||||
private boolean enabled;
|
||||
private Integer envId;
|
||||
private boolean fragment;
|
||||
private Integer id;
|
||||
private Integer jarId;
|
||||
private String jobName;
|
||||
private Integer maxRowNum;
|
||||
private String name;
|
||||
private String note;
|
||||
private Integer openTrans;
|
||||
private Integer parallelism;
|
||||
private boolean processEnd;
|
||||
private Integer projectId;
|
||||
private Integer pvdataNum;
|
||||
private String savePointPath;
|
||||
private String savePointStrategy;
|
||||
private Integer sqlDbType;
|
||||
private String statement;
|
||||
private boolean statementSet;
|
||||
private Integer step;
|
||||
private String type;
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date updateTime;
|
||||
private Integer updater;
|
||||
private boolean useAutoCancel;
|
||||
private boolean useChangeLog;
|
||||
private boolean usrResult;
|
||||
private Integer version;
|
||||
private Integer versionId;
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package net.srt.disposition.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import net.srt.disposition.entity.DataDatabaseDevEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class DataSqlSaveDto {
|
||||
private String alias;
|
||||
private Integer catalogueId;
|
||||
private Integer databaseId;
|
||||
private List<DataDatabaseDevEntity> databaseList;
|
||||
private Integer dialect;
|
||||
private Integer id;
|
||||
private String name;
|
||||
private Integer openTrans;
|
||||
private boolean processEnd;
|
||||
private Integer pvdataNum;
|
||||
private Integer sqlDbType;
|
||||
private String statement;
|
||||
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package net.srt.disposition.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@TableName("data_check_sql")
|
||||
public class DataCheckSqlEntity {
|
||||
@TableId("id")
|
||||
private Integer id;
|
||||
private String type;
|
||||
private String sql;
|
||||
private String parse;
|
||||
private String explain;
|
||||
private String error;
|
||||
private String parseTrue;
|
||||
private String explainTrue;
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date explainTime;
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package net.srt.disposition.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import net.srt.framework.mybatis.entity.BaseEntity;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class DataDatabaseDevEntity {
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
private String creator;
|
||||
private String databaseDocument;
|
||||
private String databaseIndex;
|
||||
private String databaseIp;
|
||||
private String databaseKafka;
|
||||
private String databaseName;
|
||||
private String databasePort;
|
||||
private Integer databaseType;
|
||||
private Integer deleted;
|
||||
private Integer id;
|
||||
private String isJdbc;
|
||||
private String name;
|
||||
private String noReReason;
|
||||
private String password;
|
||||
private Integer projectId;
|
||||
private Integer status;
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
|
||||
private Date updateTime;
|
||||
private String updater;
|
||||
private String userName;
|
||||
private Integer version;
|
||||
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
package net.srt.disposition.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import net.srt.framework.mybatis.entity.BaseEntity;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@TableName("data_sql_save")
|
||||
public class DataSqlSaveEntity {
|
||||
@TableId("id")
|
||||
private Long id;
|
||||
private Long catalogueId;
|
||||
private String name;
|
||||
private Long projectId;
|
||||
private String alias;
|
||||
private Integer dialect;
|
||||
private Integer type;
|
||||
private Integer checkPoint;
|
||||
private Integer savePointStrategy;
|
||||
private String savePointPath;
|
||||
private Integer parallelism;
|
||||
private boolean fragment;
|
||||
private boolean statementSet;
|
||||
private boolean batchModel;
|
||||
private Long clusterId;
|
||||
private Long clusterConfigurationId;
|
||||
private Integer sqlDbType;
|
||||
private Long databaseId;
|
||||
private Integer openTrans;
|
||||
private Long jarId;
|
||||
private Long envId;
|
||||
private Long alertGroupId;
|
||||
private String configJson;
|
||||
private String note;
|
||||
private Integer step;
|
||||
private Long jobInstanceId;
|
||||
private boolean useAutoCancel;
|
||||
private boolean useChangeLog;
|
||||
private boolean useResult;
|
||||
private Integer pvdataNum;
|
||||
private boolean enabled;
|
||||
private Long versionId;
|
||||
private Integer version;
|
||||
private Integer deleted;
|
||||
private Long creator;
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date createTime;
|
||||
private Long updater;
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date updateTime;
|
||||
private String statement;
|
||||
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package net.srt.disposition.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import net.srt.disposition.entity.DataCheckSqlEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface DataCheckSqlMapper extends BaseMapper<DataCheckSqlEntity> {
|
||||
}
|
|
@ -2,6 +2,8 @@ package net.srt.disposition.mapper;
|
|||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import net.srt.disposition.entity.DataProductionTreeEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface DataProductionMapper extends BaseMapper<DataProductionTreeEntity> {
|
||||
}
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
package net.srt.disposition.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import net.srt.disposition.entity.DataSqlSaveEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface DataSaveServiceMapper extends BaseMapper<DataSqlSaveEntity> {
|
||||
}
|
|
@ -2,6 +2,8 @@ package net.srt.disposition.mapper;
|
|||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import net.srt.disposition.entity.DispositionEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface DispositionMapper extends BaseMapper<DispositionEntity> {
|
||||
}
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
package net.srt.disposition.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import net.srt.disposition.dto.DataCheckSqlDto;
|
||||
import net.srt.disposition.entity.DataCheckSqlEntity;
|
||||
import net.srt.disposition.vo.DataCheckSqlVo;
|
||||
|
||||
public interface DataCheckSqlService extends IService<DataCheckSqlEntity> {
|
||||
DataCheckSqlVo explainSql(DataCheckSqlDto dataCheckSqlDto);
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package net.srt.disposition.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import net.srt.disposition.dto.DataSqlSaveDto;
|
||||
import net.srt.disposition.entity.DataSqlSaveEntity;
|
||||
|
||||
public interface DataSaveService extends IService<DataSqlSaveEntity> {
|
||||
void dataSaver(DataSqlSaveDto dataSqlSaveDto);
|
||||
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
package net.srt.disposition.service.impl;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLStatement;
|
||||
import com.alibaba.druid.sql.parser.SQLParserUtils;
|
||||
import com.alibaba.druid.sql.parser.SQLStatementParser;
|
||||
import jdk.nashorn.internal.runtime.ParserException;
|
||||
import lombok.AllArgsConstructor;
|
||||
import net.srt.disposition.dto.DataCheckSqlDto;
|
||||
import net.srt.disposition.entity.DataCheckSqlEntity;
|
||||
import net.srt.disposition.mapper.DataCheckSqlMapper;
|
||||
import net.srt.disposition.service.DataCheckSqlService;
|
||||
import net.srt.disposition.vo.DataCheckSqlVo;
|
||||
import net.srt.framework.mybatis.service.impl.BaseServiceImpl;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import static com.alibaba.druid.sql.SQLUtils.toSQLString;
|
||||
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class DataCheckSqlServiceImpl extends BaseServiceImpl<DataCheckSqlMapper, DataCheckSqlEntity> implements DataCheckSqlService {
|
||||
@Override
|
||||
public DataCheckSqlVo explainSql(DataCheckSqlDto dataCheckSqlDto) {
|
||||
DataCheckSqlVo dataCheckSqlVo = new DataCheckSqlVo();
|
||||
try {
|
||||
SQLStatementParser mysql = SQLParserUtils.createSQLStatementParser(dataCheckSqlDto.getStatement(), "mysql");
|
||||
SQLStatement sqlStatement = mysql.parseStatement();
|
||||
if (sqlStatement instanceof Select) {
|
||||
dataCheckSqlVo.setType("SQLSelectStatement");
|
||||
}
|
||||
dataCheckSqlVo.setSql(dataCheckSqlDto.getStatement());
|
||||
dataCheckSqlVo.setParseTrue(true);
|
||||
dataCheckSqlVo.setExplainTrue(true);
|
||||
dataCheckSqlVo.setExplainTime(new Date());
|
||||
} catch (ParserException e) {
|
||||
System.out.println("SQL转换中发生了错误:"+e.getMessage());
|
||||
dataCheckSqlVo.setSql(dataCheckSqlDto.getStatement());
|
||||
dataCheckSqlVo.setError(e.getMessage());
|
||||
dataCheckSqlVo.setParseTrue(false);
|
||||
dataCheckSqlVo.setExplainTrue(false);
|
||||
dataCheckSqlVo.setExplainTime(new Date());
|
||||
}
|
||||
return dataCheckSqlVo;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package net.srt.disposition.service.impl;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import net.srt.disposition.convert.DataSqlSaveConvert;
|
||||
import net.srt.disposition.dto.DataSqlSaveDto;
|
||||
import net.srt.disposition.entity.DataSqlSaveEntity;
|
||||
import net.srt.disposition.mapper.DataSaveServiceMapper;
|
||||
import net.srt.disposition.service.DataSaveService;
|
||||
import net.srt.framework.mybatis.service.impl.BaseServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class DataSaveServiceImpl extends BaseServiceImpl<DataSaveServiceMapper,DataSqlSaveEntity> implements DataSaveService {
|
||||
|
||||
@Override
|
||||
public void dataSaver(DataSqlSaveDto dataSqlSaveDto) {
|
||||
DataSqlSaveEntity convert = DataSqlSaveConvert.INSTANCE.convert(dataSqlSaveDto);
|
||||
convert.setCreateTime(new Date());
|
||||
baseMapper.insert(convert);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package net.srt.disposition.vo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class DataCheckSqlVo {
|
||||
private Integer index;
|
||||
private String type;
|
||||
private String sql;
|
||||
private String parse;
|
||||
private String explain;
|
||||
private String error;
|
||||
private boolean parseTrue;
|
||||
private boolean explainTrue;
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date explainTime;
|
||||
}
|
|
@ -1,7 +1,3 @@
|
|||
auth:
|
||||
ignore_urls:
|
||||
- /auth/captcha
|
||||
- /auth/login
|
||||
- /auth/send/code
|
||||
- /auth/mobile
|
||||
- /upload/**
|
||||
- /data-development/**
|
||||
|
|
|
@ -2,11 +2,22 @@ server:
|
|||
port: 8094
|
||||
|
||||
spring:
|
||||
datasource:
|
||||
druid:
|
||||
stat-view-servlet:
|
||||
enabled: true
|
||||
loginUsername: bwie
|
||||
loginPassword: 123456
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://101.34.77.101:3306/12.5yk?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
|
||||
username: root
|
||||
password: cbx@123
|
||||
type: com.alibaba.druid.pool.DruidDataSource
|
||||
mvc:
|
||||
servlet:
|
||||
load-on-startup: 1
|
||||
application:
|
||||
name: srt-data-development
|
||||
name: srt-cloud-data-development
|
||||
profiles:
|
||||
active: dev
|
||||
cloud:
|
||||
|
@ -14,9 +25,9 @@ spring:
|
|||
discovery:
|
||||
server-addr: 101.34.77.101:8848
|
||||
# 命名空间,默认:public
|
||||
namespace: c5d32e76-b83c-4254-8176-1c6a2cee8e3b
|
||||
namespace: 9de208a6-cb30-41ae-a880-78196c99c050
|
||||
service: ${spring.application.name}
|
||||
group: srt2.1
|
||||
group: srt2.0
|
||||
config:
|
||||
server-addr: ${spring.cloud.nacos.discovery.server-addr}
|
||||
namespace: ${spring.cloud.nacos.discovery.namespace}
|
||||
|
@ -25,19 +36,4 @@ spring:
|
|||
extension-configs:
|
||||
- data-id: datasource.yaml
|
||||
refresh: true
|
||||
servlet:
|
||||
multipart:
|
||||
max-request-size: 100MB
|
||||
max-file-size: 1024MB
|
||||
storage:
|
||||
enabled: true
|
||||
config:
|
||||
# 存储类型:local、aliyun
|
||||
type: local
|
||||
# 访问域名
|
||||
domain: http://localhost:8082/sys
|
||||
# 配置访问前缀
|
||||
prefix:
|
||||
local:
|
||||
# 本地上传路径
|
||||
path: D://upload
|
||||
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
package com.text.dome;
|
||||
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLObject;
|
||||
import com.alibaba.druid.sql.ast.SQLStatement;
|
||||
import com.alibaba.druid.sql.parser.SQLParserUtils;
|
||||
import com.alibaba.druid.sql.parser.SQLStatementParser;
|
||||
import jdk.nashorn.internal.runtime.ParserException;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static com.alibaba.druid.sql.SQLUtils.toSQLString;
|
||||
|
||||
public class a {
|
||||
public static void main(String[] args) {
|
||||
String str = "create table `tb_user` (\n" +
|
||||
" `id` varchar(22) not null COMMENT '主键id',\n" +
|
||||
" `usercode` varchar(11) DEFAULT null COMMENT '手机号',\n" +
|
||||
" `name` varchar(10) DEFAULT nu";
|
||||
System.out.println("格式化之前:");
|
||||
System.out.println(str);
|
||||
System.out.println("格式化之后:");
|
||||
try {
|
||||
SQLStatementParser parser = SQLParserUtils.createSQLStatementParser(str, "mysql");
|
||||
List<SQLStatement> statementList = parser.parseStatementList();
|
||||
str = toSQLString((SQLObject) statementList, "mysql");
|
||||
System.out.println(str);
|
||||
} catch (ParserException e) {
|
||||
System.out.println("SQL转换中发生了错误:"+e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue