Merge remote-tracking branch 'origin/dev' into dev
# Conflicts: # srt-cloud-data-service/src/main/java/net/srt/service/impl/ApiGroupServiceImpl.javadev
commit
95d4600a89
1
pom.xml
1
pom.xml
|
@ -24,6 +24,7 @@
|
||||||
<module>srt-cloud-gateway</module>
|
<module>srt-cloud-gateway</module>
|
||||||
<module>srt-data-development</module>
|
<module>srt-data-development</module>
|
||||||
<module>srt-cloud-data-governance</module>
|
<module>srt-cloud-data-governance</module>
|
||||||
|
<module>srt-cloud-data-service</module>
|
||||||
<module>srt-cloud-data-server</module>
|
<module>srt-cloud-data-server</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||||
public class GovernanceApplication {
|
public class GovernanceApplication {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(GovernanceApplication.class, args);
|
SpringApplication.run(GovernanceApplication.class, args);
|
||||||
|
System.out.println("原神启动!!!!!!!!!!!!!");
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ import net.srt.framework.common.page.PageResult;
|
||||||
import net.srt.framework.common.utils.Result;
|
import net.srt.framework.common.utils.Result;
|
||||||
import net.srt.query.QualityConfigQuery;
|
import net.srt.query.QualityConfigQuery;
|
||||||
import net.srt.service.QualityConfigService;
|
import net.srt.service.QualityConfigService;
|
||||||
import net.srt.vo.QualityConfigVo;
|
import net.srt.vo.QualityConfigVO;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
|
@ -28,26 +28,26 @@ public class QualityConfigController {
|
||||||
|
|
||||||
@GetMapping("page")
|
@GetMapping("page")
|
||||||
@Operation(summary = "分页")
|
@Operation(summary = "分页")
|
||||||
public Result<PageResult<QualityConfigVo>> page(@Valid QualityConfigQuery query){
|
public Result<PageResult<QualityConfigVO>> page(@Valid QualityConfigQuery query){
|
||||||
PageResult<QualityConfigVo> page= qualityConfigService.page(query);
|
PageResult<QualityConfigVO> page= qualityConfigService.page(query);
|
||||||
return Result.ok(page);
|
return Result.ok(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("{id}")
|
@GetMapping("{id}")
|
||||||
@Operation(summary = "信息")
|
@Operation(summary = "信息")
|
||||||
public Result<QualityConfigVo> get(@PathVariable("id") Long id){
|
public Result<QualityConfigVO> get(@PathVariable("id") Long id){
|
||||||
return Result.ok(qualityConfigService.get(id));
|
return Result.ok(qualityConfigService.get(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping
|
@PostMapping
|
||||||
@Operation(summary = "保存")
|
@Operation(summary = "保存")
|
||||||
public Result<String> save(@RequestBody QualityConfigVo vo){
|
public Result<String> save(@RequestBody QualityConfigVO vo){
|
||||||
qualityConfigService.save(vo);
|
qualityConfigService.save(vo);
|
||||||
return Result.ok();
|
return Result.ok();
|
||||||
}
|
}
|
||||||
@PutMapping
|
@PutMapping
|
||||||
@Operation(summary = "修改")
|
@Operation(summary = "修改")
|
||||||
public Result<String> update(@RequestBody @Valid QualityConfigVo vo){
|
public Result<String> update(@RequestBody @Valid QualityConfigVO vo){
|
||||||
qualityConfigService.update(vo);
|
qualityConfigService.update(vo);
|
||||||
return Result.ok();
|
return Result.ok();
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,10 @@ package net.srt.controller;
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import net.srt.convert.StandardConvert;
|
||||||
|
import net.srt.entity.DatastandardEntity;
|
||||||
|
import net.srt.entity.StandardEntity;
|
||||||
|
import net.srt.framework.common.utils.BeanUtil;
|
||||||
import net.srt.framework.common.utils.Result;
|
import net.srt.framework.common.utils.Result;
|
||||||
import net.srt.framework.common.utils.TreeNodeVo;
|
import net.srt.framework.common.utils.TreeNodeVo;
|
||||||
import net.srt.service.StandardService;
|
import net.srt.service.StandardService;
|
||||||
|
@ -9,6 +13,8 @@ import net.srt.vo.StandardManagementVo;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -30,6 +36,13 @@ public class StandardController {
|
||||||
return Result.ok(standardService.listTree());
|
return Result.ok(standardService.listTree());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("{id}")
|
||||||
|
@Operation(summary = "信息")
|
||||||
|
public Result<StandardManagementVo> get(@PathVariable("id") Long id){
|
||||||
|
StandardEntity entity = standardService.getById(id);
|
||||||
|
|
||||||
|
return Result.ok(StandardConvert.INSTANCE.convert(entity));
|
||||||
|
}
|
||||||
|
|
||||||
@PostMapping
|
@PostMapping
|
||||||
@Operation(summary = "保存")
|
@Operation(summary = "保存")
|
||||||
|
@ -45,9 +58,9 @@ public class StandardController {
|
||||||
return Result.ok();
|
return Result.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping
|
@DeleteMapping("/{id}")
|
||||||
@Operation(summary = "删除")
|
@Operation(summary = "删除")
|
||||||
public Result<String> delete(Long id) {
|
public Result<String> delete(@PathVariable Long id) {
|
||||||
standardService.delete(id);
|
standardService.delete(id);
|
||||||
return Result.ok();
|
return Result.ok();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package net.srt.convert;
|
package net.srt.convert;
|
||||||
|
|
||||||
import net.srt.entity.QualityConfigEntity;
|
import net.srt.entity.QualityConfigEntity;
|
||||||
import net.srt.vo.QualityConfigVo;
|
import net.srt.vo.QualityConfigVO;
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.factory.Mappers;
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
|
@ -17,9 +17,9 @@ import java.util.List;
|
||||||
public interface QualityConfigConvert {
|
public interface QualityConfigConvert {
|
||||||
QualityConfigConvert INSTANCE = Mappers.getMapper(QualityConfigConvert.class);
|
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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,5 +12,4 @@ import org.apache.ibatis.annotations.Mapper;
|
||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface StandardDao extends BaseMapper<StandardEntity> {
|
public interface StandardDao extends BaseMapper<StandardEntity> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,10 +25,10 @@ public class BusinessInitializer implements ApplicationRunner {
|
||||||
* init task monitor
|
* init task monitor
|
||||||
*/
|
*/
|
||||||
private void initScheduleMonitor() {
|
private void initScheduleMonitor() {
|
||||||
//处理没执行完的采集任务
|
// //处理没执行完的采集任务
|
||||||
metadataCollectRecordService.dealNotFinished();
|
// metadataCollectRecordService.dealNotFinished();
|
||||||
//处理没执行完的质量检测任务
|
// //处理没执行完的质量检测任务
|
||||||
qualityTaskService.dealNotFinished();
|
// qualityTaskService.dealNotFinished();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,25 +8,31 @@ import net.srt.vo.MetadataVO;
|
||||||
|
|
||||||
import java.util.List;
|
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> {
|
public interface MetadataService extends BaseService<MetadataEntity> {
|
||||||
List<TreeNodeVo> listByParentId(Long parentId);
|
List<TreeNodeVo> listByPatenId(Long parentId);
|
||||||
|
|
||||||
List<TreeNodeVo> listFloder();
|
List<TreeNodeVo> listFloder();
|
||||||
|
|
||||||
List<TreeNodeVo> listDb();
|
List<TreeNodeVo> listDb();
|
||||||
|
|
||||||
List<TreeNodeVo> listByKeyword(String keyword);
|
List<TreeNodeVo> listKeyword(String keyword);
|
||||||
|
|
||||||
MetadataVO get(Long id);
|
MetadataVO get(Long id);
|
||||||
|
|
||||||
void save(MetadataVO vo);
|
void save(MetadataVO vo);
|
||||||
|
|
||||||
|
|
||||||
void update(MetadataVO vo);
|
void update(MetadataVO vo);
|
||||||
|
|
||||||
void delete(Long id);
|
void delete(Long id);
|
||||||
|
|
||||||
void upNeo4jInfo(Neo4jInfo neo4jInfo);
|
void updateNeo4j(Neo4jInfo neo4jInfo);
|
||||||
|
|
||||||
Neo4jInfo getNeo4jInfo();
|
Neo4jInfo getNeo4j();
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ import net.srt.entity.QualityConfigEntity;
|
||||||
import net.srt.framework.common.page.PageResult;
|
import net.srt.framework.common.page.PageResult;
|
||||||
import net.srt.framework.mybatis.service.BaseService;
|
import net.srt.framework.mybatis.service.BaseService;
|
||||||
import net.srt.query.QualityConfigQuery;
|
import net.srt.query.QualityConfigQuery;
|
||||||
import net.srt.vo.QualityConfigVo;
|
import net.srt.vo.QualityConfigVO;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -15,13 +15,13 @@ import java.util.List;
|
||||||
* @CreateTime: 2023/12/24 19:33
|
* @CreateTime: 2023/12/24 19:33
|
||||||
*/
|
*/
|
||||||
public interface QualityConfigService extends BaseService<QualityConfigEntity> {
|
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);
|
void online(Long id);
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ public class MetadataServiceImpl extends BaseServiceImpl<MetadataDao, MetadataEn
|
||||||
private final TokenStoreCache tokenStoreCache;
|
private final TokenStoreCache tokenStoreCache;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<TreeNodeVo> listByParentId(Long parentId) {
|
public List<TreeNodeVo> listByPatenId(Long parentId) {
|
||||||
LambdaQueryWrapper<MetadataEntity> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<MetadataEntity> wrapper = new LambdaQueryWrapper<>();
|
||||||
wrapper.eq(MetadataEntity::getParentId,parentId)
|
wrapper.eq(MetadataEntity::getParentId,parentId)
|
||||||
.orderByAsc(MetadataEntity::getOrderNo);
|
.orderByAsc(MetadataEntity::getOrderNo);
|
||||||
|
@ -93,9 +93,9 @@ public class MetadataServiceImpl extends BaseServiceImpl<MetadataDao, MetadataEn
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<TreeNodeVo> listByKeyword(String keyword) {
|
public List<TreeNodeVo> listKeyword(String keyword) {
|
||||||
if(StringUtil.isBlank(keyword)){
|
if(StringUtil.isBlank(keyword)){
|
||||||
return listByParentId(0L);
|
return listByPatenId(0L);
|
||||||
}
|
}
|
||||||
LambdaQueryWrapper<MetadataEntity> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<MetadataEntity> wrapper = new LambdaQueryWrapper<>();
|
||||||
wrapper.like(MetadataEntity::getName,keyword)
|
wrapper.like(MetadataEntity::getName,keyword)
|
||||||
|
@ -171,12 +171,12 @@ public class MetadataServiceImpl extends BaseServiceImpl<MetadataDao, MetadataEn
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void upNeo4jInfo(Neo4jInfo neo4jInfo) {
|
public void updateNeo4j(Neo4jInfo neo4jInfo) {
|
||||||
tokenStoreCache.saveNeo4jInfo(getProjectId(),neo4jInfo);
|
tokenStoreCache.saveNeo4jInfo(getProjectId(),neo4jInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Neo4jInfo getNeo4jInfo() {
|
public Neo4jInfo getNeo4j() {
|
||||||
return tokenStoreCache.getNeo4jInfo(getProjectId());
|
return tokenStoreCache.getNeo4jInfo(getProjectId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.sun.org.apache.bcel.internal.generic.LADD;
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import net.srt.api.module.data.governance.constant.BuiltInQualityRule;
|
import net.srt.api.module.data.governance.constant.BuiltInQualityRule;
|
||||||
import net.srt.api.module.data.governance.dto.quality.QualityConfigParam;
|
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.framework.mybatis.service.impl.BaseServiceImpl;
|
||||||
import net.srt.query.QualityConfigQuery;
|
import net.srt.query.QualityConfigQuery;
|
||||||
import net.srt.service.QualityConfigService;
|
import net.srt.service.QualityConfigService;
|
||||||
import net.srt.vo.QualityConfigVo;
|
import net.srt.vo.QualityConfigVO;
|
||||||
import org.springframework.security.core.parameters.P;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import srt.cloud.framework.dbswitch.common.util.StringUtil;
|
import srt.cloud.framework.dbswitch.common.util.StringUtil;
|
||||||
|
|
||||||
|
@ -39,39 +37,39 @@ public class QualityConfigServiceimpl extends BaseServiceImpl<QualityConfigDao,
|
||||||
private final QuartzDataGovernanceQualityApi quartzDataGovernanceQualityApi;
|
private final QuartzDataGovernanceQualityApi quartzDataGovernanceQualityApi;
|
||||||
private final MetadataDao metadataDao;
|
private final MetadataDao metadataDao;
|
||||||
@Override
|
@Override
|
||||||
public PageResult<QualityConfigVo> page(QualityConfigQuery query) {
|
public PageResult<QualityConfigVO> page(QualityConfigQuery query) {
|
||||||
IPage<QualityConfigEntity> page=baseMapper.selectPage(getPage(query),getWrapper(query));
|
IPage<QualityConfigEntity> page=baseMapper.selectPage(getPage(query),getWrapper(query));
|
||||||
return new PageResult<>(QualityConfigConvert.INSTANCE.convertList(page.getRecords()),page.getTotal());
|
return new PageResult<>(QualityConfigConvert.INSTANCE.convertList(page.getRecords()),page.getTotal());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public QualityConfigVo get(Long id) {
|
public QualityConfigVO get(Long id) {
|
||||||
QualityConfigVo qualityConfigvo= QualityConfigConvert.INSTANCE.convert(baseMapper.selectById(id));
|
QualityConfigVO QualityConfigVO= QualityConfigConvert.INSTANCE.convert(baseMapper.selectById(id));
|
||||||
List<Integer> metadataIds=qualityConfigvo.getMetadataIds();
|
List<Integer> metadataIds=QualityConfigVO.getMetadataIds();
|
||||||
LambdaQueryWrapper<MetadataEntity> metadataWrapper= Wrappers.lambdaQuery();
|
LambdaQueryWrapper<MetadataEntity> metadataWrapper= Wrappers.lambdaQuery();
|
||||||
metadataWrapper.in(MetadataEntity::getId,metadataIds);
|
metadataWrapper.in(MetadataEntity::getId,metadataIds);
|
||||||
List<MetadataEntity> metadataEntities=metadataDao.selectList(metadataWrapper);
|
List<MetadataEntity> metadataEntities=metadataDao.selectList(metadataWrapper);
|
||||||
if (CollectionUtils.isEmpty(metadataEntities)){
|
if (CollectionUtils.isEmpty(metadataEntities)){
|
||||||
qualityConfigvo.setMetadataStrs("检测字段已删除,请检查数据信息");
|
QualityConfigVO.setMetadataStrs("检测字段已删除,请检查数据信息");
|
||||||
}else {
|
}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())){
|
if (BuiltInQualityRule.ASSOCIATION_CONSISTENCY.getId().equals(QualityConfigVO.getRuleId())){
|
||||||
QualityConfigParam param = qualityConfigvo.getParam();
|
QualityConfigParam param = QualityConfigVO.getParam();
|
||||||
Integer columnMetaId = param.getColumnMetaId();
|
Integer columnMetaId = param.getColumnMetaId();
|
||||||
MetadataEntity entity = metadataDao.selectById(columnMetaId);
|
MetadataEntity entity = metadataDao.selectById(columnMetaId);
|
||||||
if (entity!= null){
|
if (entity!= null){
|
||||||
qualityConfigvo.setRelMetadataStr(entity.getPath());
|
QualityConfigVO.setRelMetadataStr(entity.getPath());
|
||||||
}else {
|
}else {
|
||||||
qualityConfigvo.setMetadataStrs("关联字段已被删除,请检查元数据信息");
|
QualityConfigVO.setMetadataStrs("关联字段已被删除,请检查元数据信息");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return qualityConfigvo;
|
return QualityConfigVO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void save(QualityConfigVo vo) {
|
public void save(QualityConfigVO vo) {
|
||||||
QualityConfigEntity entity=QualityConfigConvert.INSTANCE.convert(vo);
|
QualityConfigEntity entity=QualityConfigConvert.INSTANCE.convert(vo);
|
||||||
entity.setProjectId(getProjectId());
|
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())){
|
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
|
@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())){
|
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);
|
vo.setParam(null);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import lombok.AllArgsConstructor;
|
||||||
import net.srt.controller.StandardController;
|
import net.srt.controller.StandardController;
|
||||||
import net.srt.convert.StandardConvert;
|
import net.srt.convert.StandardConvert;
|
||||||
import net.srt.dao.StandardDao;
|
import net.srt.dao.StandardDao;
|
||||||
|
import net.srt.entity.MetamodelEntity;
|
||||||
import net.srt.entity.StandardEntity;
|
import net.srt.entity.StandardEntity;
|
||||||
import net.srt.framework.common.exception.ServerException;
|
import net.srt.framework.common.exception.ServerException;
|
||||||
import net.srt.framework.common.utils.BeanUtil;
|
import net.srt.framework.common.utils.BeanUtil;
|
||||||
|
@ -66,7 +67,7 @@ public class StandardServiceImpl extends BaseServiceImpl<StandardDao, StandardEn
|
||||||
StandardEntity entity = StandardConvert.INSTANCE.convert(vo);
|
StandardEntity entity = StandardConvert.INSTANCE.convert(vo);
|
||||||
entity.setPath(recursionPath(entity, null));
|
entity.setPath(recursionPath(entity, null));
|
||||||
entity.setProjectId(getProjectId());
|
entity.setProjectId(getProjectId());
|
||||||
updateById(entity);
|
baseMapper.updateById(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -91,6 +92,7 @@ public class StandardServiceImpl extends BaseServiceImpl<StandardDao, StandardEn
|
||||||
if (one != null) {
|
if (one != null) {
|
||||||
throw new ServerException("存在子节点,不允许删除!");
|
throw new ServerException("存在子节点,不允许删除!");
|
||||||
}
|
}
|
||||||
|
//删除
|
||||||
removeById(id);
|
removeById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,149 +25,95 @@ import java.util.List;
|
||||||
public class ApiConfigController {
|
public class ApiConfigController {
|
||||||
private final ApiConfigService apiConfigService;
|
private final ApiConfigService apiConfigService;
|
||||||
|
|
||||||
/**
|
|
||||||
* 分页查询接口配置列表
|
|
||||||
* @param query 查询条件
|
|
||||||
* @return 接口配置列表分页结果
|
|
||||||
*/
|
|
||||||
@GetMapping("page")
|
@GetMapping("page")
|
||||||
@Operation(summary = "分页查询接口配置列表")
|
@Operation(summary = "分页")
|
||||||
@PreAuthorize("hasAuthority('data-service:api-config:page')")
|
@PreAuthorize("hasAuthority('data-service:api-config:page')")
|
||||||
public Result<PageResult<ApiConfigVo>> page(@Valid ApiConfigQuery query) {
|
public Result<PageResult<ApiConfigVo>> page(@Valid ApiConfigQuery query) {
|
||||||
PageResult<ApiConfigVo> page = apiConfigService.page(query); // 调用service层方法获取分页结果
|
PageResult<ApiConfigVo> page = apiConfigService.page(query);
|
||||||
return Result.ok(page); // 封装返回结果并返回
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
return Result.ok(page);
|
||||||
* 根据resourceId分页获取接口配置列表
|
}
|
||||||
* @param query 查询条件
|
|
||||||
* @return 符合条件的接口配置列表的分页结果
|
|
||||||
*/
|
|
||||||
@GetMapping("page-resource")
|
@GetMapping("page-resource")
|
||||||
@Operation(summary = "根据resourceId分页获取接口配置列表")
|
@Operation(summary = "根据resourceId分页获取")
|
||||||
public Result<PageResult<ApiConfigVo>> pageResource(@Valid ApiConfigQuery query){
|
public Result<PageResult<ApiConfigVo>> pageResource(@Valid ApiConfigQuery query){
|
||||||
PageResult<ApiConfigVo> page = apiConfigService.pageResource(query); // 调用service层方法根据resourceId分页获取接口配置列表
|
PageResult<ApiConfigVo> page = apiConfigService.pageResource(query);
|
||||||
return Result.ok(page); // 封装返回结果并返回
|
|
||||||
|
return Result.ok(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@GetMapping("page-auth")
|
||||||
* 根据id获取接口配置信息
|
@Operation(summary = "根据resourceId分页获取")
|
||||||
* @param id 接口配置id
|
public Result<PageResult<ApiConfigVo>> pageAuth(@Valid ApiConfigQuery query) {
|
||||||
* @return 对应id的接口配置信息
|
PageResult<ApiConfigVo> page = apiConfigService.page(query);
|
||||||
*/
|
|
||||||
|
return Result.ok(page);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("{id}")
|
@GetMapping("{id}")
|
||||||
@Operation(summary = "根据id获取接口配置信息")
|
@Operation(summary = "信息")
|
||||||
@PreAuthorize("hasAnyAuthority('data-service:api-config:info')")
|
@PreAuthorize("hasAnyAuthority('data-service:api-config:info')")
|
||||||
public Result<ApiConfigVo> get(@PathVariable("id") Long id){
|
public Result<ApiConfigVo> get(@PathVariable("id") Long id){
|
||||||
ApiConfigEntity entity=apiConfigService.getById(id); // 根据id获取接口配置实体对象
|
ApiConfigEntity entity=apiConfigService.getById(id);
|
||||||
return Result.ok(ApiConfigConvert.INSTANCE.convert(entity)); // 封装返回结果并返回
|
return Result.ok(ApiConfigConvert.INSTANCE.convert(entity));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 保存接口配置信息
|
|
||||||
* @param vo 接口配置信息
|
|
||||||
* @return 保存结果
|
|
||||||
*/
|
|
||||||
@PostMapping
|
@PostMapping
|
||||||
@Operation(summary = "保存接口配置信息")
|
@Operation(summary = "保存")
|
||||||
@PreAuthorize("hasAnyAuthority('data-service:api-config:save')")
|
@PreAuthorize("hasAnyAuthority('data-service:api-config:save')")
|
||||||
public Result<String> save(@RequestBody ApiConfigVo vo) {
|
public Result<String> save(@RequestBody ApiConfigVo vo) {
|
||||||
apiConfigService.save(vo); // 调用service层方法保存接口配置信息
|
apiConfigService.save(vo);
|
||||||
return Result.ok(); // 封装返回结果并返回
|
return Result.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改接口配置信息
|
|
||||||
* @param vo 接口配置信息
|
|
||||||
* @return 修改结果
|
|
||||||
*/
|
|
||||||
@PutMapping
|
@PutMapping
|
||||||
@Operation(summary = "修改接口配置信息")
|
@Operation(summary = "修改")
|
||||||
@PreAuthorize("hasAnyAuthority('data-service:api-config:update')")
|
@PreAuthorize("hasAnyAuthority('data-service:api-config:update')")
|
||||||
public Result<String> update(@RequestBody ApiConfigVo vo){
|
public Result<String> update(@RequestBody ApiConfigVo vo){
|
||||||
apiConfigService.update(vo); // 调用service层方法修改接口配置信息
|
apiConfigService.update(vo);
|
||||||
return Result.ok(); // 封装返回结果并返回
|
return Result.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除接口配置信息
|
|
||||||
* @param idList 待删除的接口配置id列表
|
|
||||||
* @return 删除结果
|
|
||||||
*/
|
|
||||||
@DeleteMapping
|
@DeleteMapping
|
||||||
@Operation(summary = "删除接口配置信息")
|
@Operation(summary = "删除")
|
||||||
@PreAuthorize("hasAnyAuthority('data-service:api-config:delete')")
|
@PreAuthorize("hasAnyAuthority('data-service:api-config:delete')")
|
||||||
public Result<String> delete(@RequestBody List<Long> idList){
|
public Result<String> delete(@RequestBody List<Long> idList){
|
||||||
apiConfigService.delete(idList); // 调用service层方法删除接口配置信息
|
apiConfigService.delete(idList);
|
||||||
return Result.ok(); // 封装返回结果并返回
|
return Result.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取服务的IP和端口号
|
|
||||||
* @return IP和端口号
|
|
||||||
*/
|
|
||||||
@GetMapping("getIpPort")
|
@GetMapping("getIpPort")
|
||||||
@Operation(summary = "获取服务的IP和端口号")
|
|
||||||
public Result<String> getIpPort() {
|
public Result<String> getIpPort() {
|
||||||
return Result.ok(apiConfigService.getIpPort()); // 封装返回结果并返回
|
return Result.ok(apiConfigService.getIpPort());
|
||||||
}
|
}
|
||||||
|
@Operation(summary = "获取服务的ip和端口号")
|
||||||
/**
|
|
||||||
* 获取服务的IP和端口号
|
|
||||||
* @return IP和端口号
|
|
||||||
*/
|
|
||||||
@GetMapping("/ip-port")
|
@GetMapping("/ip-port")
|
||||||
@Operation(summary = "获取服务的IP和端口号")
|
|
||||||
public Result<String> ipPort() {
|
public Result<String> ipPort() {
|
||||||
return Result.ok(apiConfigService.ipPort()); // 封装返回结果并返回
|
return Result.ok(apiConfigService.ipPort());
|
||||||
}
|
}
|
||||||
|
@Operation(summary = "上线")
|
||||||
/**
|
|
||||||
* 上线指定id的接口配置
|
|
||||||
* @param id 待上线的接口配置id
|
|
||||||
* @return 上线结果
|
|
||||||
*/
|
|
||||||
@PutMapping("/{id}/online")
|
|
||||||
@Operation(summary = "上线指定id的接口配置")
|
|
||||||
@PreAuthorize("hasAnyAuthority('data-service:api-config:online')")
|
@PreAuthorize("hasAnyAuthority('data-service:api-config:online')")
|
||||||
|
@PutMapping("/{id}/online")
|
||||||
public Result<String> online(@PathVariable Long id) {
|
public Result<String> online(@PathVariable Long id) {
|
||||||
apiConfigService.online(id); // 调用service层方法上线指定id的接口配置
|
apiConfigService.online(id);
|
||||||
return Result.ok(); // 封装返回结果并返回
|
return Result.ok();
|
||||||
}
|
}
|
||||||
|
@Operation(summary = "下线")
|
||||||
/**
|
|
||||||
* 下线指定id的接口配置
|
|
||||||
* @param id 待下线的接口配置id
|
|
||||||
* @return 下线结果
|
|
||||||
*/
|
|
||||||
@PutMapping("/{id}/offline")
|
|
||||||
@Operation(summary = "下线指定id的接口配置")
|
|
||||||
@PreAuthorize("hasAnyAuthority('data-service:api-config:offline')")
|
@PreAuthorize("hasAnyAuthority('data-service:api-config:offline')")
|
||||||
|
@PutMapping("/{id}/offline")
|
||||||
public Result<String> offline(@PathVariable Long id){
|
public Result<String> offline(@PathVariable Long id){
|
||||||
apiConfigService.offline(id); // 调用service层方法下线指定id的接口配置
|
apiConfigService.offline(id);
|
||||||
return Result.ok(); // 封装返回结果并返回
|
return Result.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Operation(summary = "执行sql")
|
||||||
* 执行SQL查询
|
|
||||||
* @param dto SQL查询参数
|
|
||||||
* @return SQL查询结果
|
|
||||||
*/
|
|
||||||
@PostMapping("/sql/execute")
|
@PostMapping("/sql/execute")
|
||||||
@Operation(summary = "执行SQL查询")
|
|
||||||
public Result<JdbcSelectResult> sqlExecute(@RequestBody SqlDto dto) {
|
public Result<JdbcSelectResult> sqlExecute(@RequestBody SqlDto dto) {
|
||||||
return Result.ok(apiConfigService.sqlExecute(dto)); // 封装返回结果并返回
|
return Result.ok(apiConfigService.sqlExecute(dto));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Operation(summary = "导出 api 文档")
|
||||||
* 导出指定id列表对应的API文档
|
|
||||||
* @param ids 待导出API文档的id列表
|
|
||||||
* @param response HTTP响应对象
|
|
||||||
*/
|
|
||||||
@PostMapping(value = "/export-docs")
|
@PostMapping(value = "/export-docs")
|
||||||
@Operation(summary = "导出API文档")
|
|
||||||
public void exportDocs(@RequestBody List<Long> ids, HttpServletResponse response) {
|
public void exportDocs(@RequestBody List<Long> ids, HttpServletResponse response) {
|
||||||
apiConfigService.exportDocs(ids, response); // 调用service层方法导出API文档
|
apiConfigService.exportDocs(ids, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,66 +28,42 @@ import java.util.List;
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class ApiGroupController {
|
public class ApiGroupController {
|
||||||
private final ApiGroupService apiGroupService;
|
private final ApiGroupService apiGroupService;
|
||||||
/**
|
@GetMapping
|
||||||
* 查询文件分组树
|
|
||||||
* @return 文件分组树的列表结果
|
|
||||||
*/
|
|
||||||
@GetMapping("api-group")
|
|
||||||
@Operation(summary = "查询文件分组树")
|
@Operation(summary = "查询文件分组树")
|
||||||
public Result<List<TreeNodeVo>> listTree() {
|
public Result<List<TreeNodeVo>> listTree() {
|
||||||
return Result.ok(apiGroupService.listTree()); // 调用service层方法查询文件分组树并返回结果
|
return Result.ok(apiGroupService.listTree());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据id获取文件分组信息
|
|
||||||
* @param id 文件分组id
|
|
||||||
* @return 对应id的文件分组信息
|
|
||||||
*/
|
|
||||||
@GetMapping("{id}")
|
@GetMapping("{id}")
|
||||||
@Operation(summary = "信息")
|
@Operation(summary = "信息")
|
||||||
@PreAuthorize("hasAuthority('data-service:api-group:info')")
|
@PreAuthorize("hasAuthority('data-service:api-group:info')")
|
||||||
public Result<ApiGroupVo> get(@PathVariable("id") Long id){
|
public Result<ApiGroupVo> get(@PathVariable("id") Long id){
|
||||||
ApiGroupEntity entity = apiGroupService.getById(id); // 根据id获取文件分组实体对象
|
ApiGroupEntity entity = apiGroupService.getById(id);
|
||||||
return Result.ok(ApiGroupConvert.INSTANCE.convert(entity)); // 封装返回结果并返回
|
|
||||||
|
return Result.ok(ApiGroupConvert.INSTANCE.convert(entity));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 保存文件分组信息
|
|
||||||
* @param vo 文件分组信息
|
|
||||||
* @return 保存结果
|
|
||||||
*/
|
|
||||||
@PostMapping
|
@PostMapping
|
||||||
@Operation(summary = "保存")
|
@Operation(summary = "保存")
|
||||||
@PreAuthorize("hasAuthority('data-service:api-group:save')")
|
@PreAuthorize("hasAuthority('data-service:api-group:save')")
|
||||||
public Result<String> save(@RequestBody ApiGroupVo vo) {
|
public Result<String> save(@RequestBody ApiGroupVo vo) {
|
||||||
apiGroupService.save(vo); // 调用service层方法保存文件分组信息
|
apiGroupService.save(vo);
|
||||||
return Result.ok(); // 封装返回结果并返回
|
return Result.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改文件分组信息
|
|
||||||
* @param vo 文件分组信息
|
|
||||||
* @return 修改结果
|
|
||||||
*/
|
|
||||||
@PutMapping
|
@PutMapping
|
||||||
@Operation(summary = "修改")
|
@Operation(summary = "修改")
|
||||||
@PreAuthorize("hasAuthority('data-service:api-group:update')")
|
@PreAuthorize("hasAuthority('data-service:api-group:update')")
|
||||||
public Result<String> update(@RequestBody @Valid ApiGroupVo vo) {
|
public Result<String> update(@RequestBody @Valid ApiGroupVo vo) {
|
||||||
apiGroupService.update(vo); // 调用service层方法修改文件分组信息
|
apiGroupService.update(vo);
|
||||||
return Result.ok(); // 封装返回结果并返回
|
return Result.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除文件分组信息
|
|
||||||
* @param id 待删除的文件分组id
|
|
||||||
* @return 删除结果
|
|
||||||
*/
|
|
||||||
@DeleteMapping("/{id}")
|
@DeleteMapping("/{id}")
|
||||||
@Operation(summary = "删除")
|
@Operation(summary = "删除")
|
||||||
@PreAuthorize("hasAuthority('data-service:api-group:delete')")
|
@PreAuthorize("hasAuthority('data-service:api-group:delete')")
|
||||||
public Result<String> delete(@PathVariable Long id) {
|
public Result<String> delete(@PathVariable Long id) {
|
||||||
apiGroupService.delete(id); // 调用service层方法删除文件分组信息
|
apiGroupService.delete(id);
|
||||||
return Result.ok(); // 封装返回结果并返回
|
return Result.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
package net.srt.controller;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import net.srt.dao.DataServiceAppDao;
|
||||||
|
import net.srt.framework.common.utils.Result;
|
||||||
|
import net.srt.service.DataServiceAppService;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName : DataServiceApiController
|
||||||
|
* @Description :
|
||||||
|
* @Author : FJJ
|
||||||
|
* @Date: 2023-12-26 20:38
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("api")
|
||||||
|
@Tag(name = "api")
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class DataServiceApiController {
|
||||||
|
private final DataServiceAppService dataServiceAppService;
|
||||||
|
@GetMapping("/token/generate")
|
||||||
|
public Result<String> tokenGenerate(@RequestParam String appKey, @RequestParam String appSecret) {
|
||||||
|
return Result.ok(dataServiceAppService.tokenGenerate(appKey, appSecret));
|
||||||
|
}
|
||||||
|
}
|
|
@ -8,7 +8,9 @@ import net.srt.framework.common.page.PageResult;
|
||||||
import net.srt.framework.common.utils.Result;
|
import net.srt.framework.common.utils.Result;
|
||||||
import net.srt.query.DataServiceAppQuery;
|
import net.srt.query.DataServiceAppQuery;
|
||||||
import net.srt.service.DataServiceAppService;
|
import net.srt.service.DataServiceAppService;
|
||||||
|
import net.srt.vo.DataServiceApiAuthVo;
|
||||||
import net.srt.vo.DataServiceAppVo;
|
import net.srt.vo.DataServiceAppVo;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
|
@ -61,16 +63,18 @@ public class DataServiceAppController {
|
||||||
return Result.ok();
|
return Result.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("/auth")
|
@PostMapping("/auth")
|
||||||
@Operation(summary = "添加授权")
|
@Operation(summary = "添加授权")
|
||||||
public Result<String> addAuth(@RequestBody DataServiceAppVo authVO){
|
public Result<String> addAuth(@RequestBody DataServiceApiAuthVo authVO){
|
||||||
dataServiceAppService.addAuth(authVO);
|
dataServiceAppService.addAuth(authVO);
|
||||||
return Result.ok();
|
return Result.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/auth")
|
@PutMapping("/auth")
|
||||||
@Operation(summary = "修改授权")
|
@Operation(summary = "修改授权")
|
||||||
public Result<String> upAuth(@RequestBody DataServiceAppVo authVO){
|
public Result<String> upAuth(@RequestBody DataServiceApiAuthVo authVO){
|
||||||
dataServiceAppService.upAuth(authVO);
|
dataServiceAppService.upAuth(authVO);
|
||||||
return Result.ok();
|
return Result.ok();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,26 @@
|
||||||
package net.srt.convert;
|
package net.srt.convert;
|
||||||
|
|
||||||
|
import net.srt.entity.DataServiceApiAuthEntity;
|
||||||
|
import net.srt.vo.DataServiceApiAuthVo;
|
||||||
|
import org.mapstruct.Mapper;
|
||||||
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ClassName : DataServiceApiAuthConvert
|
* @ClassName : DataServiceApiAuthConvert
|
||||||
* @Description :
|
* @Description :
|
||||||
* @Author : FJJ
|
* @Author : FJJ
|
||||||
* @Date: 2023-12-26 15:23
|
* @Date: 2023-12-26 19:45
|
||||||
*/
|
*/
|
||||||
|
@Mapper
|
||||||
public interface DataServiceApiAuthConvert {
|
public interface DataServiceApiAuthConvert {
|
||||||
|
DataServiceApiAuthConvert INSTANCE = Mappers.getMapper(DataServiceApiAuthConvert.class);
|
||||||
|
|
||||||
|
|
||||||
|
DataServiceApiAuthEntity convert(DataServiceApiAuthVo vo);
|
||||||
|
|
||||||
|
DataServiceApiAuthVo convert(DataServiceApiAuthEntity entity);
|
||||||
|
|
||||||
|
List<DataServiceApiAuthVo> convertList(List<DataServiceApiAuthEntity> list);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ public interface DataServiceAppConvert {
|
||||||
|
|
||||||
DataServiceAppEntity convert(DataServiceAppVo vo);
|
DataServiceAppEntity convert(DataServiceAppVo vo);
|
||||||
|
|
||||||
|
|
||||||
DataServiceAppVo convert(DataServiceAppEntity entity);
|
DataServiceAppVo convert(DataServiceAppEntity entity);
|
||||||
|
|
||||||
List<DataServiceAppVo> convertList(List<DataServiceAppEntity> list);
|
List<DataServiceAppVo> convertList(List<DataServiceAppEntity> list);
|
||||||
|
|
|
@ -3,6 +3,7 @@ package net.srt.dao;
|
||||||
import net.srt.entity.ApiConfigEntity;
|
import net.srt.entity.ApiConfigEntity;
|
||||||
import net.srt.framework.mybatis.dao.BaseDao;
|
import net.srt.framework.mybatis.dao.BaseDao;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -12,4 +13,8 @@ public interface ApiConfigDao extends BaseDao<ApiConfigEntity> {
|
||||||
List<ApiConfigEntity> getResourceList(Map<String, Object> params);
|
List<ApiConfigEntity> getResourceList(Map<String, Object> params);
|
||||||
|
|
||||||
ApiConfigEntity getById(Long id);
|
ApiConfigEntity getById(Long id);
|
||||||
|
|
||||||
|
void updateById(@Param("apiId") Long apiId, @Param("id") Long id);
|
||||||
|
|
||||||
|
List<ApiConfigEntity> getAuthList(Map<String, Object> params);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,15 @@
|
||||||
package net.srt.dao;
|
package net.srt.dao;
|
||||||
|
|
||||||
|
import net.srt.entity.DataServiceApiAuthEntity;
|
||||||
|
import net.srt.framework.mybatis.dao.BaseDao;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ClassName : DataServiceApiAuthDao
|
* @ClassName : DataServiceApiAuthDao
|
||||||
* @Description :
|
* @Description :
|
||||||
* @Author : FJJ
|
* @Author : FJJ
|
||||||
* @Date: 2023-12-26 15:23
|
* @Date: 2023-12-26 15:23
|
||||||
*/
|
*/
|
||||||
public interface DataServiceApiAuthDao {
|
@Mapper
|
||||||
|
public interface DataServiceApiAuthDao extends BaseDao<DataServiceApiAuthEntity> {
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,5 +13,5 @@ import org.apache.ibatis.annotations.Param;
|
||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface DataServiceAppDao extends BaseDao<DataServiceAppEntity> {
|
public interface DataServiceAppDao extends BaseDao<DataServiceAppEntity> {
|
||||||
DataServiceAppEntity selectByApplyId(@Param("applyId") Long applyId);
|
// DataServiceAppEntity selectByApplyId(@Param("applyId") Long applyId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,164 +12,37 @@ import java.util.Date;
|
||||||
@Data
|
@Data
|
||||||
public class ApiConfigDto implements Serializable {
|
public class ApiConfigDto implements Serializable {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
/**
|
|
||||||
* 数据库主键id
|
|
||||||
*/
|
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
/**
|
|
||||||
* 文件分组id
|
|
||||||
*/
|
|
||||||
private Long groupId;
|
private Long groupId;
|
||||||
|
|
||||||
/**
|
|
||||||
* 文件路径
|
|
||||||
*/
|
|
||||||
private String path;
|
private String path;
|
||||||
|
|
||||||
/**
|
|
||||||
* 文件类型,如:sql、http等
|
|
||||||
*/
|
|
||||||
private String type;
|
private String type;
|
||||||
|
|
||||||
/**
|
|
||||||
* 文件名称
|
|
||||||
*/
|
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
/**
|
|
||||||
* 文件备注
|
|
||||||
*/
|
|
||||||
private String note;
|
private String note;
|
||||||
|
|
||||||
/**
|
|
||||||
* SQL语句内容
|
|
||||||
*/
|
|
||||||
private String sqlText;
|
private String sqlText;
|
||||||
|
|
||||||
/**
|
|
||||||
* SQL语句分隔符
|
|
||||||
*/
|
|
||||||
private String sqlSeparator;
|
private String sqlSeparator;
|
||||||
|
|
||||||
/**
|
|
||||||
* SQL最大行数
|
|
||||||
*/
|
|
||||||
private Integer sqlMaxRow;
|
private Integer sqlMaxRow;
|
||||||
|
|
||||||
/**
|
|
||||||
* SQL语句参数
|
|
||||||
*/
|
|
||||||
private String sqlParam;
|
private String sqlParam;
|
||||||
|
|
||||||
/**
|
|
||||||
* JSON参数
|
|
||||||
*/
|
|
||||||
private String jsonParam;
|
private String jsonParam;
|
||||||
|
|
||||||
/**
|
|
||||||
* HTTP响应结果
|
|
||||||
*/
|
|
||||||
private String responseResult;
|
private String responseResult;
|
||||||
|
|
||||||
/**
|
|
||||||
* 内容类型
|
|
||||||
*/
|
|
||||||
private String contentType;
|
private String contentType;
|
||||||
|
|
||||||
/**
|
|
||||||
* 状态,1启用,0禁用
|
|
||||||
*/
|
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
/**
|
|
||||||
* 发布时间
|
|
||||||
*/
|
|
||||||
private Date releaseTime;
|
private Date releaseTime;
|
||||||
|
|
||||||
/**
|
|
||||||
* 发布用户id
|
|
||||||
*/
|
|
||||||
private Long releaseUserId;
|
private Long releaseUserId;
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据库类型
|
|
||||||
*/
|
|
||||||
private Integer sqlDbType;
|
private Integer sqlDbType;
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据库id
|
|
||||||
*/
|
|
||||||
private Long databaseId;
|
private Long databaseId;
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否私有文件,1是,0否
|
|
||||||
*/
|
|
||||||
private Integer privates;
|
private Integer privates;
|
||||||
|
|
||||||
/**
|
|
||||||
* 开启事务,1是,0否
|
|
||||||
*/
|
|
||||||
private Integer openTrans;
|
private Integer openTrans;
|
||||||
|
|
||||||
/**
|
|
||||||
* 项目id
|
|
||||||
*/
|
|
||||||
private Long projectId;
|
private Long projectId;
|
||||||
|
|
||||||
/**
|
|
||||||
* 版本号
|
|
||||||
*/
|
|
||||||
private Integer version;
|
private Integer version;
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否删除,1是,0否
|
|
||||||
*/
|
|
||||||
private Integer deleted;
|
private Integer deleted;
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建者id
|
|
||||||
*/
|
|
||||||
private Long creator;
|
private Long creator;
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建时间
|
|
||||||
*/
|
|
||||||
private Date createTime;
|
private Date createTime;
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新者id
|
|
||||||
*/
|
|
||||||
private Long updater;
|
private Long updater;
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新时间
|
|
||||||
*/
|
|
||||||
private Date updateTime;
|
private Date updateTime;
|
||||||
|
|
||||||
/**
|
|
||||||
* 请求次数
|
|
||||||
*/
|
|
||||||
private Integer requestedTimes;
|
private Integer requestedTimes;
|
||||||
|
|
||||||
/**
|
|
||||||
* 请求成功次数
|
|
||||||
*/
|
|
||||||
private Integer requestedSuccessTimes;
|
private Integer requestedSuccessTimes;
|
||||||
|
|
||||||
/**
|
|
||||||
* 请求失败次数
|
|
||||||
*/
|
|
||||||
private Integer requestedFailedTimes;
|
private Integer requestedFailedTimes;
|
||||||
|
|
||||||
/**
|
|
||||||
* 授权id
|
|
||||||
*/
|
|
||||||
private Long authId;
|
private Long authId;
|
||||||
|
|
||||||
/**
|
|
||||||
* 分组名
|
|
||||||
*/
|
|
||||||
private String group;
|
private String group;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,24 +10,8 @@ import java.io.Serializable;
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public class AppToken implements Serializable {
|
public class AppToken implements Serializable {
|
||||||
/**
|
|
||||||
* 应用id
|
|
||||||
*/
|
|
||||||
private Long appId;
|
private Long appId;
|
||||||
|
|
||||||
/**
|
|
||||||
* 应用密钥
|
|
||||||
*/
|
|
||||||
private String appKey;
|
private String appKey;
|
||||||
|
|
||||||
/**
|
|
||||||
* 访问令牌
|
|
||||||
*/
|
|
||||||
private String token;
|
private String token;
|
||||||
|
|
||||||
/**
|
|
||||||
* 过期时间戳
|
|
||||||
*/
|
|
||||||
private Long expireAt;
|
private Long expireAt;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,44 +4,12 @@ import lombok.Data;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class SqlDto {
|
public class SqlDto {
|
||||||
/**
|
|
||||||
* 数据库类型
|
|
||||||
*/
|
|
||||||
private Integer sqlDbType;
|
private Integer sqlDbType;
|
||||||
|
|
||||||
/**
|
|
||||||
* 项目id
|
|
||||||
*/
|
|
||||||
private Long projectId;
|
private Long projectId;
|
||||||
|
|
||||||
/**
|
|
||||||
* SQL语句
|
|
||||||
*/
|
|
||||||
private String statement;
|
private String statement;
|
||||||
|
|
||||||
/**
|
|
||||||
* SQL语句分隔符
|
|
||||||
*/
|
|
||||||
private String sqlSeparator;
|
private String sqlSeparator;
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据库id
|
|
||||||
*/
|
|
||||||
private Long databaseId;
|
private Long databaseId;
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否开启事务,1是,0否
|
|
||||||
*/
|
|
||||||
private Integer openTrans;
|
private Integer openTrans;
|
||||||
|
|
||||||
/**
|
|
||||||
* JSON参数
|
|
||||||
*/
|
|
||||||
private String jsonParams;
|
private String jsonParams;
|
||||||
|
|
||||||
/**
|
|
||||||
* SQL最大行数
|
|
||||||
*/
|
|
||||||
private Integer sqlMaxRow;
|
private Integer sqlMaxRow;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,70 +0,0 @@
|
||||||
//package net.srt.entity;
|
|
||||||
//
|
|
||||||
//import com.baomidou.mybatisplus.annotation.FieldFill;
|
|
||||||
//import com.baomidou.mybatisplus.annotation.FieldStrategy;
|
|
||||||
//import com.baomidou.mybatisplus.annotation.TableField;
|
|
||||||
//import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
//import lombok.Data;
|
|
||||||
//import lombok.EqualsAndHashCode;
|
|
||||||
//import net.srt.framework.mybatis.entity.BaseEntity;
|
|
||||||
//
|
|
||||||
//import java.util.Date;
|
|
||||||
//
|
|
||||||
///**
|
|
||||||
// * @ClassName : DataServiceApiAuthEnitiy
|
|
||||||
// * @Description :
|
|
||||||
// * @Author : FJJ
|
|
||||||
// * @Date: 2023-12-24 11:30
|
|
||||||
// */
|
|
||||||
//@EqualsAndHashCode(callSuper=false)
|
|
||||||
//@Data
|
|
||||||
//@TableName("data_service_api_auth1")
|
|
||||||
//public class DataServiceApiAuthEnitiy extends BaseEntity {
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * app的id
|
|
||||||
// */
|
|
||||||
// private Long appId;
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 分组id
|
|
||||||
// */
|
|
||||||
// private Long groupId;
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * api的id
|
|
||||||
// */
|
|
||||||
// private Long apiId;
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 调用次数 不限次数为-1
|
|
||||||
// */
|
|
||||||
// private Integer requestTimes;
|
|
||||||
//
|
|
||||||
// @TableField(updateStrategy = FieldStrategy.IGNORED)
|
|
||||||
// private Date startTime;
|
|
||||||
// @TableField(updateStrategy = FieldStrategy.IGNORED)
|
|
||||||
// private Date endTime;
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 已调用次数
|
|
||||||
// */
|
|
||||||
// @TableField(updateStrategy = FieldStrategy.NEVER)
|
|
||||||
// private Integer requestedTimes;
|
|
||||||
// @TableField(updateStrategy = FieldStrategy.NEVER)
|
|
||||||
// private Integer requestedSuccessTimes;
|
|
||||||
// @TableField(updateStrategy = FieldStrategy.NEVER)
|
|
||||||
// private Integer requestedFailedTimes;
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 所属项目id
|
|
||||||
// */
|
|
||||||
// private Long projectId;
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 真删
|
|
||||||
// */
|
|
||||||
// @TableField(fill = FieldFill.INSERT)
|
|
||||||
// private Integer deleted;
|
|
||||||
//
|
|
||||||
//}
|
|
|
@ -4,6 +4,7 @@ import net.srt.entity.DataServiceAppEntity;
|
||||||
import net.srt.framework.common.page.PageResult;
|
import net.srt.framework.common.page.PageResult;
|
||||||
import net.srt.framework.mybatis.service.BaseService;
|
import net.srt.framework.mybatis.service.BaseService;
|
||||||
import net.srt.query.DataServiceAppQuery;
|
import net.srt.query.DataServiceAppQuery;
|
||||||
|
import net.srt.vo.DataServiceApiAuthVo;
|
||||||
import net.srt.vo.DataServiceAppVo;
|
import net.srt.vo.DataServiceAppVo;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -23,9 +24,11 @@ public interface DataServiceAppService extends BaseService<DataServiceAppEntity>
|
||||||
|
|
||||||
void delete(List<Long> idList);
|
void delete(List<Long> idList);
|
||||||
|
|
||||||
void addAuth(DataServiceAppVo authVO);
|
void addAuth(DataServiceApiAuthVo authVO);
|
||||||
|
|
||||||
void upAuth(DataServiceAppVo authVO);
|
void upAuth(DataServiceApiAuthVo authVO);
|
||||||
|
|
||||||
void cancelAuth(Long authId);
|
void cancelAuth(Long authId);
|
||||||
|
|
||||||
|
String tokenGenerate(String appKey, String appSecret);
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,10 +43,6 @@ public class ApiConfigServiceImpl extends BaseServiceImpl<ApiConfigDao, ApiConfi
|
||||||
private final DiscoveryClient discoveryClient;
|
private final DiscoveryClient discoveryClient;
|
||||||
private final ApiConfigDao apiConfigDao;
|
private final ApiConfigDao apiConfigDao;
|
||||||
private final Map<String, ApiConfigEntity> mappings = new ConcurrentHashMap<>();
|
private final Map<String, ApiConfigEntity> mappings = new ConcurrentHashMap<>();
|
||||||
/**
|
|
||||||
* 获取服务实例的IP和端口
|
|
||||||
* @return IP和端口
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String getIpPort() {
|
public String getIpPort() {
|
||||||
List<ServiceInstance> instances = discoveryClient.getInstances(ServerNames.GATEWAY_SERVER_NAME);
|
List<ServiceInstance> instances = discoveryClient.getInstances(ServerNames.GATEWAY_SERVER_NAME);
|
||||||
|
@ -55,10 +51,7 @@ public class ApiConfigServiceImpl extends BaseServiceImpl<ApiConfigDao, ApiConfi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 将API配置设置为上线状态并更新路由映射
|
|
||||||
* @param id API配置ID
|
|
||||||
*/
|
|
||||||
public void online(Long id) {
|
public void online(Long id) {
|
||||||
ApiConfigEntity apiConfigEntity = apiConfigDao.getById(id);
|
ApiConfigEntity apiConfigEntity = apiConfigDao.getById(id);
|
||||||
if (apiConfigEntity != null) {
|
if (apiConfigEntity != null) {
|
||||||
|
@ -100,41 +93,36 @@ public class ApiConfigServiceImpl extends BaseServiceImpl<ApiConfigDao, ApiConfi
|
||||||
private String getRouteKey(String type, String path) {
|
private String getRouteKey(String type, String path) {
|
||||||
return type.toUpperCase() + "_" + path.toLowerCase();
|
return type.toUpperCase() + "_" + path.toLowerCase();
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* 将API配置设置为下线状态
|
|
||||||
* @param id API配置ID
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void offline(Long id) {
|
public void offline(Long id) { // 修正参数类型为 Long id
|
||||||
// 根据id获取API配置实体对象
|
|
||||||
ApiConfigEntity apiConfigEntity = apiConfigDao.getById(id);
|
ApiConfigEntity apiConfigEntity = apiConfigDao.getById(id);
|
||||||
if (apiConfigEntity != null) {
|
if (apiConfigEntity != null) {
|
||||||
// 将API配置实体对象的状态设置为下线
|
|
||||||
apiConfigEntity.setStatus(0);
|
apiConfigEntity.setStatus(0);
|
||||||
apiConfigEntity.setReleaseTime(null);
|
apiConfigEntity.setReleaseTime(null);
|
||||||
apiConfigEntity.setReleaseUserId(null);
|
apiConfigEntity.setReleaseUserId(null);
|
||||||
// 更新API配置实体对象
|
|
||||||
apiConfigDao.updateById(apiConfigEntity);
|
apiConfigDao.updateById(apiConfigEntity);
|
||||||
} else {
|
}else{
|
||||||
// 如果没有找到对应的API配置实体对象,抛出404异常
|
|
||||||
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Resource not found");
|
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Resource not found");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// @Override
|
||||||
|
// public void online(Long id) {
|
||||||
|
// ApiConfigEntity apiConfigEntity = new ApiConfigEntity();
|
||||||
|
// apiConfigEntity.setId(id);
|
||||||
|
// apiConfigEntity.setStatus(1);
|
||||||
|
// apiConfigEntity.setReleaseTime(new Date());
|
||||||
|
// apiConfigEntity.setReleaseUserId(SecurityUser.getUserId());
|
||||||
|
//
|
||||||
|
// apiConfigDao.updateById(apiConfigEntity);
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取服务实例的IP和端口
|
|
||||||
* @return IP和端口
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String ipPort() {
|
public String ipPort() {
|
||||||
// 获取网关服务实例列表
|
|
||||||
List<ServiceInstance> instances = discoveryClient.getInstances(ServerNames.GATEWAY_SERVER_NAME);
|
List<ServiceInstance> instances = discoveryClient.getInstances(ServerNames.GATEWAY_SERVER_NAME);
|
||||||
// 获取第一个网关服务实例的主机和端口,并返回拼接后的字符串
|
|
||||||
return instances.get(0).getHost() + ":" + instances.get(0).getPort();
|
return instances.get(0).getHost() + ":" + instances.get(0).getPort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JdbcSelectResult sqlExecute(SqlDto dto) {
|
public JdbcSelectResult sqlExecute(SqlDto dto) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -180,21 +168,18 @@ public class ApiConfigServiceImpl extends BaseServiceImpl<ApiConfigDao, ApiConfi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 分页查询API配置
|
|
||||||
* @param query 查询条件
|
|
||||||
* @return API配置分页结果
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public PageResult<ApiConfigVo> page(ApiConfigQuery query) {
|
public PageResult<ApiConfigVo> page(ApiConfigQuery query) {
|
||||||
// 执行分页查询,并获取分页对象
|
// 查询参数
|
||||||
IPage<ApiConfigEntity> page = baseMapper.selectPage(getPage(query), getWrapper(query));
|
Map<String, Object> params = getParams(query);
|
||||||
// 将实体对象列表转换为VO对象列表
|
// 分页查询
|
||||||
List<ApiConfigVo> apiConfigVos = ApiConfigConvert.INSTANCE.convertList(page.getRecords());
|
query.setOrder("dsac.id");
|
||||||
// 返回VO对象列表和总记录数构成的分页结果对象
|
IPage<ApiConfigEntity> page = getPage(query);
|
||||||
return new PageResult<>(apiConfigVos, page.getTotal());
|
params.put(Constant.PAGE, page);
|
||||||
|
// 数据列表
|
||||||
|
List<ApiConfigEntity> list = baseMapper.getAuthList(params);
|
||||||
|
return new PageResult<>(ApiConfigConvert.INSTANCE.convertList(list), page.getTotal());
|
||||||
}
|
}
|
||||||
|
|
||||||
private LambdaQueryWrapper getWrapper(ApiConfigQuery query) {
|
private LambdaQueryWrapper getWrapper(ApiConfigQuery query) {
|
||||||
LambdaQueryWrapper<ApiConfigEntity> wrapper = Wrappers.lambdaQuery();
|
LambdaQueryWrapper<ApiConfigEntity> wrapper = Wrappers.lambdaQuery();
|
||||||
wrapper.like(StringUtil.isNotBlank(query.getName()), ApiConfigEntity::getName, query.getName());
|
wrapper.like(StringUtil.isNotBlank(query.getName()), ApiConfigEntity::getName, query.getName());
|
||||||
|
@ -211,32 +196,17 @@ public class ApiConfigServiceImpl extends BaseServiceImpl<ApiConfigDao, ApiConfi
|
||||||
return wrapper;
|
return wrapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增API配置
|
|
||||||
* @param vo API配置VO对象
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void save(ApiConfigVo vo) {
|
public void save(ApiConfigVo vo) {
|
||||||
// 将VO对象转换为实体对象
|
|
||||||
ApiConfigEntity entity = ApiConfigConvert.INSTANCE.convert(vo);
|
ApiConfigEntity entity = ApiConfigConvert.INSTANCE.convert(vo);
|
||||||
// 设置项目ID
|
|
||||||
entity.setProjectId(getProjectId());
|
entity.setProjectId(getProjectId());
|
||||||
// 执行插入操作
|
|
||||||
baseMapper.insert(entity);
|
baseMapper.insert(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新API配置
|
|
||||||
* @param vo API配置VO对象
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void update(ApiConfigVo vo) {
|
public void update(ApiConfigVo vo) {
|
||||||
// 将VO对象转换为实体对象
|
|
||||||
ApiConfigEntity entity = ApiConfigConvert.INSTANCE.convert(vo);
|
ApiConfigEntity entity = ApiConfigConvert.INSTANCE.convert(vo);
|
||||||
// 设置项目ID
|
|
||||||
entity.setProjectId(getProjectId());
|
entity.setProjectId(getProjectId());
|
||||||
// 执行更新操作
|
|
||||||
updateById(entity);
|
updateById(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -245,52 +215,31 @@ public class ApiConfigServiceImpl extends BaseServiceImpl<ApiConfigDao, ApiConfi
|
||||||
removeByIds(idList);
|
removeByIds(idList);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 分页查询API资源
|
|
||||||
* @param query 查询条件
|
|
||||||
* @return API资源分页结果
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public PageResult<ApiConfigVo> pageResource(ApiConfigQuery query) {
|
public PageResult<ApiConfigVo> pageResource(ApiConfigQuery query) {
|
||||||
// 获取查询参数
|
// 查询参数
|
||||||
Map<String, Object> params = getParams(query);
|
Map<String, Object> params = getParams(query);
|
||||||
// 获取分页对象
|
|
||||||
IPage<ApiConfigEntity> page = getPage(query);
|
IPage<ApiConfigEntity> page = getPage(query);
|
||||||
params.put(Constant.PAGE, page);
|
params.put(Constant.PAGE, page);
|
||||||
// 查询数据列表
|
// 数据列表
|
||||||
List<ApiConfigEntity> list = baseMapper.getResourceList(params);
|
List<ApiConfigEntity> list = baseMapper.getResourceList(params);
|
||||||
// 将数据列表转换为VO对象列表
|
|
||||||
List<ApiConfigVo> apiConfigVos = ApiConfigConvert.INSTANCE.convertList(list);
|
List<ApiConfigVo> apiConfigVos = ApiConfigConvert.INSTANCE.convertList(list);
|
||||||
// 遍历VO对象列表,设置所属组信息
|
|
||||||
for (ApiConfigVo apiConfigVo : apiConfigVos) {
|
for (ApiConfigVo apiConfigVo : apiConfigVos) {
|
||||||
ApiGroupEntity groupEntity = apiGroupDao.selectById(apiConfigVo.getGroupId());
|
ApiGroupEntity groupEntity = apiGroupDao.selectById(apiConfigVo.getGroupId());
|
||||||
apiConfigVo.setGroup(groupEntity != null ? groupEntity.getPath() : null);
|
apiConfigVo.setGroup(groupEntity != null ? groupEntity.getPath() : null);
|
||||||
}
|
}
|
||||||
// 返回VO对象列表和总记录数构成的分页结果对象
|
|
||||||
return new PageResult<>(apiConfigVos, page.getTotal());
|
return new PageResult<>(apiConfigVos, page.getTotal());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据组ID获取有效的API配置列表
|
|
||||||
* @param id 组ID
|
|
||||||
* @return API配置列表
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public List<ApiConfigEntity> listActiveByGroupId(Long id) {
|
public List<ApiConfigEntity> listActiveByGroupId(Long id) {
|
||||||
// 创建LambdaQueryWrapper对象
|
|
||||||
LambdaQueryWrapper<ApiConfigEntity> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<ApiConfigEntity> wrapper = new LambdaQueryWrapper<>();
|
||||||
// 设置查询条件:状态为1(有效),组ID为指定ID,并按照ID降序排序
|
wrapper.eq(ApiConfigEntity::getStatus, 1).eq(ApiConfigEntity::getGroupId, id).orderByDesc(ApiConfigEntity::getId);
|
||||||
wrapper.eq(ApiConfigEntity::getStatus, 1)
|
|
||||||
.eq(ApiConfigEntity::getGroupId, id)
|
|
||||||
.orderByDesc(ApiConfigEntity::getId);
|
|
||||||
// 应用数据范围控制(排除组织ID)
|
|
||||||
dataScopeWithoutOrgId(wrapper);
|
dataScopeWithoutOrgId(wrapper);
|
||||||
// 执行查询并返回结果列表
|
|
||||||
return baseMapper.selectList(wrapper);
|
return baseMapper.selectList(wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private Map<String, Object> getParams(ApiConfigQuery query) {
|
private Map<String, Object> getParams(ApiConfigQuery query) {
|
||||||
Map<String, Object> params = new HashMap<>();
|
Map<String, Object> params = new HashMap<>();
|
||||||
params.put("ifMarket", query.getIfMarket());
|
params.put("ifMarket", query.getIfMarket());
|
||||||
|
|
|
@ -4,8 +4,13 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
|
import net.srt.convert.DataServiceApiAuthConvert;
|
||||||
import net.srt.convert.DataServiceAppConvert;
|
import net.srt.convert.DataServiceAppConvert;
|
||||||
|
import net.srt.dao.ApiConfigDao;
|
||||||
|
import net.srt.dao.DataServiceApiAuthDao;
|
||||||
import net.srt.dao.DataServiceAppDao;
|
import net.srt.dao.DataServiceAppDao;
|
||||||
|
import net.srt.dto.AppToken;
|
||||||
|
import net.srt.entity.DataServiceApiAuthEntity;
|
||||||
import net.srt.entity.DataServiceAppEntity;
|
import net.srt.entity.DataServiceAppEntity;
|
||||||
import net.srt.framework.common.exception.ServerException;
|
import net.srt.framework.common.exception.ServerException;
|
||||||
import net.srt.framework.common.page.PageResult;
|
import net.srt.framework.common.page.PageResult;
|
||||||
|
@ -13,7 +18,9 @@ import net.srt.framework.mybatis.service.impl.BaseServiceImpl;
|
||||||
import net.srt.framework.security.user.SecurityUser;
|
import net.srt.framework.security.user.SecurityUser;
|
||||||
import net.srt.query.DataServiceAppQuery;
|
import net.srt.query.DataServiceAppQuery;
|
||||||
import net.srt.service.DataServiceAppService;
|
import net.srt.service.DataServiceAppService;
|
||||||
|
import net.srt.vo.DataServiceApiAuthVo;
|
||||||
import net.srt.vo.DataServiceAppVo;
|
import net.srt.vo.DataServiceAppVo;
|
||||||
|
import org.apache.commons.lang.RandomStringUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import srt.cloud.framework.dbswitch.common.util.StringUtil;
|
import srt.cloud.framework.dbswitch.common.util.StringUtil;
|
||||||
|
|
||||||
|
@ -30,6 +37,8 @@ import java.util.List;
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class DataServiceAppServiceImpl extends BaseServiceImpl<DataServiceAppDao, DataServiceAppEntity> implements DataServiceAppService {
|
public class DataServiceAppServiceImpl extends BaseServiceImpl<DataServiceAppDao, DataServiceAppEntity> implements DataServiceAppService {
|
||||||
private final DataServiceAppDao dataServiceAppDao;
|
private final DataServiceAppDao dataServiceAppDao;
|
||||||
|
private final ApiConfigDao apiConfigDao;
|
||||||
|
private final DataServiceApiAuthDao dataServiceApiAuthDao;
|
||||||
@Override
|
@Override
|
||||||
public PageResult<DataServiceAppVo> page(DataServiceAppQuery query) {
|
public PageResult<DataServiceAppVo> page(DataServiceAppQuery query) {
|
||||||
IPage<DataServiceAppEntity> page=baseMapper.selectPage(getPage(query),null);
|
IPage<DataServiceAppEntity> page=baseMapper.selectPage(getPage(query),null);
|
||||||
|
@ -56,14 +65,18 @@ public class DataServiceAppServiceImpl extends BaseServiceImpl<DataServiceAppDao
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addAuth(DataServiceAppVo authVO) {
|
public void addAuth(DataServiceApiAuthVo authVO) {
|
||||||
authVO.setProjectId(getProjectId());
|
authVO.setProjectId(getProjectId());
|
||||||
dataServiceAppDao.insert(DataServiceAppConvert.INSTANCE.convert(authVO));
|
DataServiceApiAuthEntity entity = DataServiceApiAuthConvert.INSTANCE.convert(authVO);
|
||||||
|
dataServiceApiAuthDao.insert(entity);
|
||||||
|
Long id = entity.getId();
|
||||||
|
apiConfigDao.updateById(authVO.getApiId(),id);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void upAuth(DataServiceAppVo authVO) {
|
public void upAuth(DataServiceApiAuthVo authVO) {
|
||||||
dataServiceAppDao.updateById(DataServiceAppConvert.INSTANCE.convert(authVO));
|
dataServiceApiAuthDao.updateById(DataServiceApiAuthConvert.INSTANCE.convert(authVO));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -71,14 +84,42 @@ public class DataServiceAppServiceImpl extends BaseServiceImpl<DataServiceAppDao
|
||||||
dataServiceAppDao.deleteById(authId);
|
dataServiceAppDao.deleteById(authId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String tokenGenerate(String appKey, String appSecret) {
|
||||||
|
LambdaQueryWrapper<DataServiceAppEntity> wrapper = Wrappers.lambdaQuery();
|
||||||
|
wrapper.eq(DataServiceAppEntity::getAppKey,appKey).last("limit 1");
|
||||||
|
DataServiceAppEntity dataServiceAppEntity = baseMapper.selectOne(wrapper);
|
||||||
|
if (dataServiceAppEntity==null){
|
||||||
|
throw new RuntimeException("appKey不存在");
|
||||||
|
}
|
||||||
|
if (!appSecret.equals(dataServiceAppEntity.getAppSecret())){
|
||||||
|
throw new ServerException("appSecret错误");
|
||||||
|
}
|
||||||
|
//生成token
|
||||||
|
String token = RandomStringUtils.random(32, true, true);
|
||||||
|
AppToken appToken = new AppToken();
|
||||||
|
appToken.setToken(token);
|
||||||
|
appToken.setAppKey(appKey);
|
||||||
|
appToken.setAppId(dataServiceAppEntity.getId());
|
||||||
|
if (dataServiceAppEntity.getExpireDuration()==0){
|
||||||
|
appToken.setExpireAt(0L);
|
||||||
|
} else if (dataServiceAppEntity.getExpireDuration()== -1) {
|
||||||
|
appToken.setExpireAt(-1L);
|
||||||
|
}else if (dataServiceAppEntity.getExpireDuration()>0){
|
||||||
|
long l = System.currentTimeMillis() + dataServiceAppEntity.getExpireDuration() * 1000;
|
||||||
|
appToken.setExpireAt(l);
|
||||||
|
}
|
||||||
|
return appToken.getToken();
|
||||||
|
}
|
||||||
|
|
||||||
// private LambdaQueryWrapper<DataServiceAppEntity> getWrapper(DataServiceAppQuery query) {
|
|
||||||
// LambdaQueryWrapper<DataServiceAppEntity> wrapper = Wrappers.lambdaQuery();
|
private LambdaQueryWrapper<DataServiceAppEntity> getWrapper(DataServiceAppQuery query) {
|
||||||
// wrapper.like(StringUtil.isNotBlank(query.getName()), DataServiceAppEntity::getName, query.getName())
|
LambdaQueryWrapper<DataServiceAppEntity> wrapper = Wrappers.lambdaQuery();
|
||||||
// .eq(DataServiceAppEntity::getIfMarket, query.getIfMarket() != null ? query.getIfMarket() : 0)
|
wrapper.like(StringUtil.isNotBlank(query.getName()), DataServiceAppEntity::getName, query.getName())
|
||||||
// .eq(query.getIfMarket() != null, DataServiceAppEntity::getCreator, SecurityUser.getUserId())
|
.eq(DataServiceAppEntity::getIfMarket, query.getIfMarket() != null ? query.getIfMarket() : 0)
|
||||||
// .eq(StringUtil.isNotBlank(query.getAppKey()), DataServiceAppEntity::getAppKey, query.getAppKey())
|
.eq(query.getIfMarket() != null, DataServiceAppEntity::getCreator, SecurityUser.getUserId())
|
||||||
// .orderByDesc(DataServiceAppEntity::getCreateTime).orderByDesc(DataServiceAppEntity::getId);
|
.eq(StringUtil.isNotBlank(query.getAppKey()), DataServiceAppEntity::getAppKey, query.getAppKey())
|
||||||
// return wrapper;
|
.orderByDesc(DataServiceAppEntity::getCreateTime).orderByDesc(DataServiceAppEntity::getId);
|
||||||
// }
|
return wrapper;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,145 @@
|
||||||
|
package net.srt.utils;
|
||||||
|
|
||||||
|
import javax.crypto.Cipher;
|
||||||
|
import java.security.Key;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName : EncrypDES
|
||||||
|
* @Description :
|
||||||
|
* @Author : FJJ
|
||||||
|
* @Date: 2023-12-25 09:31
|
||||||
|
*/
|
||||||
|
public class EncrypDES {
|
||||||
|
|
||||||
|
// 字符串默认键值
|
||||||
|
private static String strDefaultKey = "inventec2020@#$%^&";
|
||||||
|
|
||||||
|
//加密工具
|
||||||
|
private Cipher encryptCipher = null;
|
||||||
|
|
||||||
|
// 解密工具
|
||||||
|
private Cipher decryptCipher = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 默认构造方法,使用默认密钥
|
||||||
|
*/
|
||||||
|
public EncrypDES() throws Exception {
|
||||||
|
this(strDefaultKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 指定密钥构造方法
|
||||||
|
* @param strKey 指定的密钥
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
|
||||||
|
public EncrypDES(String strKey) throws Exception {
|
||||||
|
|
||||||
|
// Security.addProvider(new com.sun.crypto.provider.SunJCE());
|
||||||
|
Key key = getKey(strKey.getBytes());
|
||||||
|
encryptCipher = Cipher.getInstance("DES");
|
||||||
|
encryptCipher.init(Cipher.ENCRYPT_MODE, key);
|
||||||
|
decryptCipher = Cipher.getInstance("DES");
|
||||||
|
decryptCipher.init(Cipher.DECRYPT_MODE, key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将byte数组转换为表示16进制值的字符串, 如:byte[]{8,18}转换为:0813,和public static byte[]
|
||||||
|
*
|
||||||
|
* hexStr2ByteArr(String strIn) 互为可逆的转换过程
|
||||||
|
*
|
||||||
|
* @param arrB 需要转换的byte数组
|
||||||
|
* @return 转换后的字符串
|
||||||
|
* @throws Exception 本方法不处理任何异常,所有异常全部抛出
|
||||||
|
*/
|
||||||
|
public static String byteArr2HexStr(byte[] arrB) throws Exception {
|
||||||
|
int iLen = arrB.length;
|
||||||
|
// 每个byte用2个字符才能表示,所以字符串的长度是数组长度的2倍
|
||||||
|
StringBuffer sb = new StringBuffer(iLen * 2);
|
||||||
|
for (int i = 0; i < iLen; i++) {
|
||||||
|
int intTmp = arrB[i];
|
||||||
|
// 把负数转换为正数
|
||||||
|
while (intTmp < 0) {
|
||||||
|
intTmp = intTmp + 256;
|
||||||
|
}
|
||||||
|
// 小于0F的数需要在前面补0
|
||||||
|
if (intTmp < 16) {
|
||||||
|
sb.append("0");
|
||||||
|
}
|
||||||
|
sb.append(Integer.toString(intTmp, 16));
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将表示16进制值的字符串转换为byte数组,和public static String byteArr2HexStr(byte[] arrB)
|
||||||
|
* 互为可逆的转换过程
|
||||||
|
* @param strIn 需要转换的字符串
|
||||||
|
* @return 转换后的byte数组
|
||||||
|
*/
|
||||||
|
public static byte[] hexStr2ByteArr(String strIn) throws Exception {
|
||||||
|
byte[] arrB = strIn.getBytes();
|
||||||
|
int iLen = arrB.length;
|
||||||
|
// 两个字符表示一个字节,所以字节数组长度是字符串长度除以2
|
||||||
|
byte[] arrOut = new byte[iLen / 2];
|
||||||
|
for (int i = 0; i < iLen; i = i + 2) {
|
||||||
|
String strTmp = new String(arrB, i, 2);
|
||||||
|
arrOut[i / 2] = (byte) Integer.parseInt(strTmp, 16);
|
||||||
|
}
|
||||||
|
return arrOut;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* 加密字节数组
|
||||||
|
* @param arrB 需加密的字节数组
|
||||||
|
* @return 加密后的字节数组
|
||||||
|
*/
|
||||||
|
public byte[] encrypt(byte[] arrB) throws Exception {
|
||||||
|
return encryptCipher.doFinal(arrB);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 加密字符串
|
||||||
|
* @param strIn 需加密的字符串
|
||||||
|
* @return 加密后的字符串
|
||||||
|
*/
|
||||||
|
public String encrypt(String strIn) throws Exception {
|
||||||
|
return byteArr2HexStr(encrypt(strIn.getBytes()));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解密字节数组
|
||||||
|
* @param arrB 需解密的字节数组
|
||||||
|
* @return 解密后的字节数组
|
||||||
|
*/
|
||||||
|
public byte[] decrypt(byte[] arrB) throws Exception {
|
||||||
|
return decryptCipher.doFinal(arrB);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解密字符串
|
||||||
|
* @param strIn 需解密的字符串
|
||||||
|
* @return 解密后的字符串
|
||||||
|
*/
|
||||||
|
public String decrypt(String strIn) throws Exception {
|
||||||
|
return new String(decrypt(hexStr2ByteArr(strIn)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从指定字符串生成密钥,密钥所需的字节数组长度为8位 不足8位时后面补0,超出8位只取前8位
|
||||||
|
* @param arrBTmp 构成该字符串的字节数组
|
||||||
|
* @return 生成的密钥
|
||||||
|
*/
|
||||||
|
private Key getKey(byte[] arrBTmp) throws Exception {
|
||||||
|
// 创建一个空的8位字节数组(默认值为0)
|
||||||
|
byte[] arrB = new byte[8];
|
||||||
|
// 将原始字节数组转换为8位
|
||||||
|
for (int i = 0; i < arrBTmp.length && i < arrB.length; i++) {
|
||||||
|
arrB[i] = arrBTmp[i];
|
||||||
|
}
|
||||||
|
// 生成密钥
|
||||||
|
Key key = new javax.crypto.spec.SecretKeySpec(arrB, "DES");
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
}
|
|
@ -42,6 +42,8 @@ public class DataServiceApiAuthVo implements Serializable {
|
||||||
@Schema(description = "所属项目id")
|
@Schema(description = "所属项目id")
|
||||||
private Long projectId;
|
private Long projectId;
|
||||||
|
|
||||||
|
private Long authId;
|
||||||
|
|
||||||
@Schema(description = "版本号")
|
@Schema(description = "版本号")
|
||||||
private Integer version;
|
private Integer version;
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,9 @@
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
|
||||||
<mapper namespace="net.srt.dao.ApiConfigDao">
|
<mapper namespace="net.srt.dao.ApiConfigDao">
|
||||||
|
<update id="updateById">
|
||||||
|
update data_service_api_config set auth_id=#{apiId} where id=#{id}
|
||||||
|
</update>
|
||||||
<select id="getResourceList" resultType="net.srt.entity.ApiConfigEntity">
|
<select id="getResourceList" resultType="net.srt.entity.ApiConfigEntity">
|
||||||
<choose>
|
<choose>
|
||||||
<when test="queryApply!=null and queryApply==1">
|
<when test="queryApply!=null and queryApply==1">
|
||||||
|
@ -25,4 +28,60 @@
|
||||||
<select id="getById" resultType="net.srt.entity.ApiConfigEntity">
|
<select id="getById" resultType="net.srt.entity.ApiConfigEntity">
|
||||||
SELECT * FROM data_service_api_config WHERE id = #{id}
|
SELECT * FROM data_service_api_config WHERE id = #{id}
|
||||||
</select>
|
</select>
|
||||||
|
<select id="getAuthList" resultType="net.srt.entity.ApiConfigEntity">
|
||||||
|
<choose>
|
||||||
|
<when test="ifMarket != null and ifMarket==1">
|
||||||
|
SELECT
|
||||||
|
dsac.*,
|
||||||
|
dsaa.id AS auth_id,
|
||||||
|
dsag.path AS group_path
|
||||||
|
FROM
|
||||||
|
data_service_api_config dsac
|
||||||
|
INNER JOIN data_service_api_group dsag ON dsac.group_id=dsag.id
|
||||||
|
INNER JOIN data_service_api_auth1 dsaa ON dsac.id = dsaa.api_id
|
||||||
|
WHERE
|
||||||
|
dsaa.app_id=#{appId}
|
||||||
|
AND dsac.deleted=0
|
||||||
|
AND dsaa.deleted=0
|
||||||
|
</when>
|
||||||
|
<otherwise>
|
||||||
|
SELECT
|
||||||
|
dsac.*,
|
||||||
|
dsaa.id AS auth_id
|
||||||
|
FROM
|
||||||
|
data_service_api_config dsac
|
||||||
|
LEFT JOIN data_service_api_auth1 dsaa ON dsac.id = dsaa.api_id AND dsaa.app_id=#{appId}
|
||||||
|
AND dsaa.deleted=0
|
||||||
|
WHERE
|
||||||
|
dsac.group_id = #{groupId}
|
||||||
|
AND dsac.previlege=1
|
||||||
|
AND dsac.deleted=0
|
||||||
|
</otherwise>
|
||||||
|
</choose>
|
||||||
|
<if test="name != null and name.trim() != ''">
|
||||||
|
AND dsac.name LIKE "%"#{name}"%"
|
||||||
|
</if>
|
||||||
|
<if test="path != null and path.trim() != ''">
|
||||||
|
AND dsac.path LIKE "%"#{path}"%"
|
||||||
|
</if>
|
||||||
|
<if test="contentType != null and contentType.trim() != ''">
|
||||||
|
AND dsac.content_type = #{contentType}
|
||||||
|
</if>
|
||||||
|
<if test="status != null">
|
||||||
|
AND dsac.status = #{status}
|
||||||
|
</if>
|
||||||
|
<if test="sqlDbType != null">
|
||||||
|
AND dsac.sql_db_type = #{sqlDbType}
|
||||||
|
</if>
|
||||||
|
<if test="databaseId != null">
|
||||||
|
AND dsac.database_id = #{databaseId}
|
||||||
|
</if>
|
||||||
|
<if test="previlege != null">
|
||||||
|
AND dsac.previlege = #{previlege}
|
||||||
|
</if>
|
||||||
|
<if test="openTrans != null">
|
||||||
|
AND dsac.open_trans = #{openTrans}
|
||||||
|
</if>
|
||||||
|
ORDER BY dsac.create_time DESC,dsac.id DESC
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<mapper namespace="net.srt.dao.DataServiceAppDao">
|
<mapper namespace="net.srt.dao.DataServiceAppDao">
|
||||||
|
|
||||||
|
|
||||||
<select id="selectByApplyId" resultType="net.srt.entity.DataServiceAppEntity">
|
<!-- <select id="selectByApplyId" resultType="net.srt.entity.DataServiceAppEntity">-->
|
||||||
SELECT dsa.* FROM data_service_app dsa INNER JOIN data_market_resource_apply dmra ON dsa.id=dmra.app_id WHERE dmra.id=#{applyId}
|
<!-- SELECT dsa.* FROM data_service_app dsa INNER JOIN data_market_resource_apply dmra ON dsa.id=dmra.app_id WHERE dmra.id=#{applyId}-->
|
||||||
</select>
|
<!-- </select>-->
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
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
|
- Path=/srt-cloud-datax-service/** # Adjust the path as needed
|
||||||
filters:
|
filters:
|
||||||
- StripPrefix=1
|
- 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:
|
nacos:
|
||||||
discovery:
|
discovery:
|
||||||
server-addr: 101.34.77.101:8848
|
server-addr: 101.34.77.101:8848
|
||||||
# 命名空间,默认:public
|
# 命名空间,默认:public
|
||||||
namespace: 7e34f104-f333-4828-b36a-02146e521c9a
|
namespace: 9de208a6-cb30-41ae-a880-78196c99c050
|
||||||
service: ${spring.application.name}
|
service: ${spring.application.name}
|
||||||
group: srt2.0
|
group: srt2.0
|
||||||
|
|
||||||
|
|
|
@ -9,11 +9,6 @@
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
|
||||||
<groupId>net.srt</groupId>
|
|
||||||
<artifactId>srt-cloud-api</artifactId>
|
|
||||||
<version>2.0.0</version>
|
|
||||||
</dependency>
|
|
||||||
<!--数据血缘-->
|
<!--数据血缘-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.srt</groupId>
|
<groupId>net.srt</groupId>
|
||||||
|
|
|
@ -9,6 +9,7 @@ import org.mybatis.spring.annotation.MapperScan;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||||
|
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -16,6 +17,8 @@ import static com.alibaba.druid.sql.SQLUtils.toSQLString;
|
||||||
|
|
||||||
@EnableDiscoveryClient
|
@EnableDiscoveryClient
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
|
@EnableFeignClients
|
||||||
|
|
||||||
@MapperScan("net.srt.Fink.mapper")
|
@MapperScan("net.srt.Fink.mapper")
|
||||||
@MapperScan("net.srt.Hadoop.mapper")
|
@MapperScan("net.srt.Hadoop.mapper")
|
||||||
@MapperScan("net.srt.disposition.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;
|
private DataProductionService dataProductionService;
|
||||||
|
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public Result<List<TreeNodeVo>> listResult(){
|
public Result<List<TreeNodeVo>> listResult(@RequestParam String t){
|
||||||
List<TreeNodeVo> dispositionVos=dataProductionService.dataTreeList();
|
List<TreeNodeVo> dispositionVos=dataProductionService.dataTreeList();
|
||||||
return Result.ok(dispositionVos);
|
return Result.ok(dispositionVos);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public Result add(@RequestBody DataProductionTreeDto dataProductionTreeDto){
|
public Result<String> add(@RequestBody DataProductionTreeDto dataProductionTreeDto){
|
||||||
dataProductionService.add(dataProductionTreeDto);
|
dataProductionService.add(dataProductionTreeDto);
|
||||||
return Result.ok();
|
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 com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import net.srt.disposition.entity.DataProductionTreeEntity;
|
import net.srt.disposition.entity.DataProductionTreeEntity;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
public interface DataProductionMapper extends BaseMapper<DataProductionTreeEntity> {
|
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 com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import net.srt.disposition.entity.DispositionEntity;
|
import net.srt.disposition.entity.DispositionEntity;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
public interface DispositionMapper extends BaseMapper<DispositionEntity> {
|
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:
|
auth:
|
||||||
ignore_urls:
|
ignore_urls:
|
||||||
- /auth/captcha
|
- /data-development/**
|
||||||
- /auth/login
|
|
||||||
- /auth/send/code
|
|
||||||
- /auth/mobile
|
|
||||||
- /upload/**
|
|
||||||
|
|
|
@ -2,11 +2,22 @@ server:
|
||||||
port: 8094
|
port: 8094
|
||||||
|
|
||||||
spring:
|
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:
|
mvc:
|
||||||
servlet:
|
servlet:
|
||||||
load-on-startup: 1
|
load-on-startup: 1
|
||||||
application:
|
application:
|
||||||
name: srt-data-development
|
name: srt-cloud-data-development
|
||||||
profiles:
|
profiles:
|
||||||
active: dev
|
active: dev
|
||||||
cloud:
|
cloud:
|
||||||
|
@ -14,9 +25,9 @@ spring:
|
||||||
discovery:
|
discovery:
|
||||||
server-addr: 101.34.77.101:8848
|
server-addr: 101.34.77.101:8848
|
||||||
# 命名空间,默认:public
|
# 命名空间,默认:public
|
||||||
namespace: c5d32e76-b83c-4254-8176-1c6a2cee8e3b
|
namespace: 9de208a6-cb30-41ae-a880-78196c99c050
|
||||||
service: ${spring.application.name}
|
service: ${spring.application.name}
|
||||||
group: srt2.1
|
group: srt2.0
|
||||||
config:
|
config:
|
||||||
server-addr: ${spring.cloud.nacos.discovery.server-addr}
|
server-addr: ${spring.cloud.nacos.discovery.server-addr}
|
||||||
namespace: ${spring.cloud.nacos.discovery.namespace}
|
namespace: ${spring.cloud.nacos.discovery.namespace}
|
||||||
|
@ -25,19 +36,4 @@ spring:
|
||||||
extension-configs:
|
extension-configs:
|
||||||
- data-id: datasource.yaml
|
- data-id: datasource.yaml
|
||||||
refresh: true
|
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