资产授权
parent
1da0924d97
commit
5dabacaf84
|
@ -0,0 +1,30 @@
|
|||
package com.muyu.source.domain.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* @author Lenovo
|
||||
* @ Tool:IntelliJ IDEA
|
||||
* @ Author:CHX
|
||||
* @ Date:2024-09-03-22:14
|
||||
* @ Version:1.0
|
||||
* @ Description:任务表查询时用到
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class DataValueModel {
|
||||
/**
|
||||
* 数据接入的ID
|
||||
*/
|
||||
private Long basicId;
|
||||
/**
|
||||
* 拼写的sql语句
|
||||
*/
|
||||
private String sql;
|
||||
|
||||
}
|
|
@ -2,14 +2,12 @@ package com.muyu.source.controller;
|
|||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.source.core.DataValue;
|
||||
import com.muyu.source.domain.model.DataValueModel;
|
||||
import com.muyu.source.service.DataValueService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -38,8 +36,8 @@ public class DataValueController {
|
|||
*/
|
||||
@PostMapping("/findTableValue")
|
||||
@Operation(summary = "根据基础表ID和SQL语句查询数据", description = "根据基础表ID和SQL语句查询数据")
|
||||
public Result findTableValue(@RequestParam("basicId") Long basicId, @RequestParam("sql") String sql) {
|
||||
List<DataValue> dataValueList = dataValueService.findTableValue(basicId, sql);
|
||||
public Result findTableValue(@RequestBody DataValueModel dataValueModel) {
|
||||
List<DataValue> dataValueList = dataValueService.findTableValue(dataValueModel);
|
||||
return Result.success(dataValueList);
|
||||
}
|
||||
|
||||
|
|
|
@ -155,60 +155,4 @@ public class TableDataController extends BaseController {
|
|||
}
|
||||
|
||||
|
||||
// @GetMapping("/findTableInfo")
|
||||
// @Operation(summary = "查询表结构树", description = "查询表结构树")
|
||||
// public Result<List<TableInfoTreeRep>> findTableInfo() {
|
||||
//// AssetDataSource dataSource = assetDataSourceService.getOne(new LambdaQueryWrapper<>() {{
|
||||
//// eq(AssetDataSource::getType, "dataSource");
|
||||
//// }});
|
||||
// List<TableInfoTreeRep> tableInfoTreeReps = new ArrayList<TableInfoTreeRep>();
|
||||
// List<AssetDataSource> dataSource = assetDataSourceService.list(new LambdaQueryWrapper<>() {{
|
||||
// eq(AssetDataSource::getType, "dataSource");
|
||||
// }});
|
||||
// for (AssetDataSource assetDataSource : dataSource) {
|
||||
// List<Children> childrenList =childrenService.findSourceList(assetDataSource.getId());
|
||||
// for (Children children : childrenList) {
|
||||
// TableInfoTreeRep tableInfoTreeRep = new TableInfoTreeRep();
|
||||
// tableInfoTreeRep.setChildren(children);
|
||||
// List<TableInfoRep> tableInfoRepList =childrenService.findTablesList(children.getAssetId());
|
||||
// tableInfoTreeRep.setTableInfoRepList(tableInfoRepList);
|
||||
// for(TableInfoRep tableInfoRep:tableInfoRepList){
|
||||
// List<TableData> tableDataList =tableDataService.findTableDataList(tableInfoRep.getId());
|
||||
// tableInfoRep.setTableDataList(tableDataList);
|
||||
// }
|
||||
// tableInfoTreeReps.add(tableInfoTreeRep);
|
||||
// }
|
||||
// return Result.success(tableInfoTreeReps);
|
||||
// }
|
||||
// return Result.success(tableInfoTreeReps);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 根据表名查询表结构
|
||||
// * @return
|
||||
// */
|
||||
// @GetMapping("/findTableInfoList")
|
||||
// @Operation(summary = "根据表名查询表结构", description = "根据表名查询表结构")
|
||||
// public Result findByTableName(){
|
||||
// assetDataSourceService.list(new LambdaQueryWrapper<>(){{
|
||||
// eq(AssetDataSource::getType,"dataSource");
|
||||
// }});
|
||||
// //
|
||||
// List<Children> childrenList = childrenService.list();
|
||||
// List<TableInfoResp> list = childrenList.stream().map(children -> {
|
||||
// TableInfoResp tableInfoResp = Children.toTableInfoResp(children);
|
||||
// tableInfoResp.setChildren(getChildren(children, childrenList));
|
||||
// return tableInfoResp;
|
||||
// }).toList();
|
||||
// return Result.success(list);
|
||||
// }
|
||||
//
|
||||
// private List<TableInfoResp> getChildren(Children children, List<Children> childrenList) {
|
||||
// return childrenList.stream().filter(children1 -> children1.getAssetId().equals(children.getId())).map(
|
||||
// children2 -> Children.toTableInfoResp(children2)
|
||||
// ).toList();
|
||||
//
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import com.muyu.common.core.domain.Result;
|
|||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
import com.muyu.common.system.domain.LoginUser;
|
||||
import com.muyu.common.system.domain.SysUser;
|
||||
import com.muyu.source.domain.Structure;
|
||||
import com.muyu.source.domain.TableInfo;
|
||||
import com.muyu.source.domain.rep.AssetAuthorizationRep;
|
||||
import com.muyu.source.domain.rep.TableInfoResp;
|
||||
|
@ -17,6 +18,7 @@ import lombok.extern.log4j.Log4j2;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -215,7 +217,6 @@ public class TableInfoController {
|
|||
TableInfo byId = tableInfoService.getById(id);
|
||||
return Result.success(byId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id查询数据集
|
||||
* @param id id
|
||||
|
@ -228,4 +229,35 @@ public class TableInfoController {
|
|||
List<TableInfo> list =tableInfoService.findTableNameById(id);
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 给规则引擎调用
|
||||
* 根据parentId查询数据接入
|
||||
* @param parentId 父id
|
||||
* @return 查询的结果
|
||||
*/
|
||||
@PostMapping("/selectById")
|
||||
@Operation(summary = "根据parentId查询数据接入" , description = "根据parentId查询数据接入")
|
||||
public Result<List<TableInfo>> selectById(@RequestParam("parentId") Long parentId){
|
||||
List<TableInfo> tableInfo =tableInfoService.selectById(parentId);
|
||||
return Result.success(tableInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据parentId向下查询出子表
|
||||
* @param parentId 父id
|
||||
* @return 返回tableInfo列表
|
||||
*/
|
||||
@PostMapping("/findTableIdByParentId/{parentId}")
|
||||
@Operation(summary = "根据parentId向下查询出子表" , description = "根据parentId向下查询出子表")
|
||||
public Result<List<TableInfo>> findTableIdByParentId(@PathVariable("parentId") Long parentId) {
|
||||
List<TableInfo> tableInfoList = null;
|
||||
List<Long> structureIds = tableInfoService.findTableIdByParentId(parentId);
|
||||
for (Long structureId : structureIds) {
|
||||
tableInfoList = tableInfoService.selectById(structureId);
|
||||
}
|
||||
return Result.success(tableInfoList);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.muyu.source.service;
|
|||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.source.core.DataValue;
|
||||
import com.muyu.source.domain.model.DataValueModel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -14,7 +15,7 @@ import java.util.List;
|
|||
* @ Description:资产展示{KLTV}业务层
|
||||
*/
|
||||
public interface DataValueService extends IService<DataValue> {
|
||||
List<DataValue> findTableValue(Long basicId, String sql);
|
||||
List<DataValue> findTableValue(DataValueModel dataValueModel);
|
||||
|
||||
List<DataValue> findTableValueByTableName(Long basicId, String tableName);
|
||||
}
|
||||
|
|
|
@ -4,12 +4,14 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|||
import com.muyu.source.core.DataType;
|
||||
import com.muyu.source.core.DataValue;
|
||||
import com.muyu.source.domain.DataSource;
|
||||
import com.muyu.source.domain.model.DataValueModel;
|
||||
import com.muyu.source.mapper.DataValueMapper;
|
||||
import com.muyu.source.mysql.MysqlQuery;
|
||||
import com.muyu.source.pool.MysqlPool;
|
||||
import com.muyu.source.service.DataSourceService;
|
||||
import com.muyu.source.service.DataValueService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.actuate.autoconfigure.metrics.MetricsProperties;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.sql.*;
|
||||
|
@ -32,17 +34,17 @@ public class DataValueServiceImpl extends ServiceImpl<DataValueMapper, DataValue
|
|||
@Autowired
|
||||
private DataSourceService dataSourceService;
|
||||
@Override
|
||||
public List<DataValue> findTableValue(Long basicId, String sql) {
|
||||
public List<DataValue> findTableValue(DataValueModel dataValueModel) {
|
||||
List<DataValue> dataValueList = new ArrayList<>();
|
||||
|
||||
MysqlQuery mysqlQuery = new MysqlQuery();
|
||||
mysqlQuery.setDataSourceId(String.valueOf(basicId));
|
||||
DataSource dataSource = dataSourceService.getById(basicId);
|
||||
mysqlQuery.setDataSourceId(String.valueOf(dataValueModel.getBasicId()));
|
||||
DataSource dataSource = dataSourceService.getById(dataValueModel.getBasicId());
|
||||
MysqlPool mysqlPool = new MysqlPool(dataSource);
|
||||
mysqlPool.init();
|
||||
Connection conn = mysqlPool.getConn();
|
||||
try {
|
||||
PreparedStatement preparedStatement = conn.prepareStatement(sql);
|
||||
PreparedStatement preparedStatement = conn.prepareStatement(dataValueModel.getSql());
|
||||
ResultSet resultSet = preparedStatement.executeQuery();
|
||||
ResultSetMetaData metaData = resultSet.getMetaData();
|
||||
int columnCount = metaData.getColumnCount();
|
||||
|
|
|
@ -66,4 +66,12 @@ public class TableServiceImpl extends ServiceImpl<TableInfoMapper, TableInfo> im
|
|||
return tableInfoMapper.findTableIdByParentId(basicId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TableInfo> selectById(Long parentId) {
|
||||
LambdaQueryWrapper<TableInfo> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(TableInfo::getParentId, 0);
|
||||
List<TableInfo> tableInfoList = tableInfoMapper.selectList(queryWrapper);
|
||||
return tableInfoList;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -41,4 +41,6 @@ public interface TableInfoService extends IService<TableInfo> {
|
|||
* @return List<Long>
|
||||
*/
|
||||
List<Long> findTableIdByParentId(Long basicId);
|
||||
|
||||
List<TableInfo> selectById(Long parentId);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue