forked from github/dataease
Merge pull request #1433 from dataease/pr@dev@variable
Merge branch 'dev' into pr@dev@variable
This commit is contained in:
commit
1f94e7cbda
@ -207,7 +207,7 @@
|
||||
<dependency>
|
||||
<groupId>io.dataease</groupId>
|
||||
<artifactId>dataease-plugin-interface</artifactId>
|
||||
<version>1.5</version>
|
||||
<version>1.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
@ -387,34 +387,34 @@
|
||||
</dependencies>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<?m2e execute onConfiguration?>
|
||||
<id>main-class-placement</id>
|
||||
<phase>generate-resources</phase>
|
||||
<configuration>
|
||||
<target>
|
||||
<move todir="src/main/resources/static">
|
||||
<fileset dir="../frontend/dist">
|
||||
<exclude name="*.html"/>
|
||||
</fileset>
|
||||
</move>
|
||||
<move todir="src/main/resources/templates">
|
||||
<fileset dir="../frontend/dist">
|
||||
<include name="*.html"/>
|
||||
</fileset>
|
||||
</move>
|
||||
</target>
|
||||
</configuration>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<!-- <plugin>-->
|
||||
<!-- <groupId>org.apache.maven.plugins</groupId>-->
|
||||
<!-- <artifactId>maven-antrun-plugin</artifactId>-->
|
||||
<!-- <executions>-->
|
||||
<!-- <execution>-->
|
||||
<!-- <?m2e execute onConfiguration?>-->
|
||||
<!-- <id>main-class-placement</id>-->
|
||||
<!-- <phase>generate-resources</phase>-->
|
||||
<!-- <configuration>-->
|
||||
<!-- <target>-->
|
||||
<!-- <move todir="src/main/resources/static">-->
|
||||
<!-- <fileset dir="../frontend/dist">-->
|
||||
<!-- <exclude name="*.html"/>-->
|
||||
<!-- </fileset>-->
|
||||
<!-- </move>-->
|
||||
<!-- <move todir="src/main/resources/templates">-->
|
||||
<!-- <fileset dir="../frontend/dist">-->
|
||||
<!-- <include name="*.html"/>-->
|
||||
<!-- </fileset>-->
|
||||
<!-- </move>-->
|
||||
<!-- </target>-->
|
||||
<!-- </configuration>-->
|
||||
<!-- <goals>-->
|
||||
<!-- <goal>run</goal>-->
|
||||
<!-- </goals>-->
|
||||
<!-- </execution>-->
|
||||
<!-- </executions>-->
|
||||
<!-- </plugin>-->
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
@ -9,4 +9,5 @@ public interface ExtDataSetTableMapper {
|
||||
List<DataSetTableDTO> search(DataSetTableRequest request);
|
||||
|
||||
DataSetTableDTO searchOne(DataSetTableRequest request);
|
||||
|
||||
}
|
||||
|
@ -7,6 +7,12 @@
|
||||
<result column="privileges" property="privileges"/>
|
||||
</resultMap>
|
||||
|
||||
|
||||
<resultMap id="roleItemMap" type="io.dataease.controller.sys.response.RoleUserItem">
|
||||
<id property="id" column="id"/>
|
||||
<result property="name" column="name"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="searchOne" resultMap="BaseResultMapDTO">
|
||||
select
|
||||
id, `name`, scene_id, data_source_id, `type`, `mode`,`info`, create_by, create_time,
|
||||
@ -93,4 +99,5 @@
|
||||
</where>
|
||||
ORDER BY CONVERT(`name` using gbk)
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
@ -19,7 +19,7 @@ public class DefaultLicenseService {
|
||||
private InnerLicenseService innerLicenseService;
|
||||
|
||||
private static final String LICENSE_ID = "fit2cloud_license";
|
||||
private static final String validatorUtil = "/usr/bin/validator";
|
||||
private static final String validatorUtil = "/usr/local/bin/validator";
|
||||
private static final String product = "DataEase";
|
||||
|
||||
public F2CLicenseResponse validateLicense(String product, String licenseKey) {
|
||||
|
@ -0,0 +1,39 @@
|
||||
package io.dataease.plugins.server;
|
||||
|
||||
import io.dataease.plugins.config.SpringContextUtil;
|
||||
import io.dataease.plugins.xpack.auth.dto.request.DataSetRowPermissionsDTO;
|
||||
import io.dataease.plugins.xpack.auth.dto.request.DatasetRowPermissions;
|
||||
import io.dataease.plugins.xpack.auth.dto.response.XpackSysAuthDetailDTO;
|
||||
import io.dataease.plugins.xpack.auth.service.RowPermissionService;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@RestController
|
||||
@RequestMapping("plugin/dataset/rowPermissions")
|
||||
public class RowPermissionsController {
|
||||
|
||||
@ApiOperation("保存")
|
||||
@PostMapping("save")
|
||||
public void save(@RequestBody DatasetRowPermissions datasetRowPermissions) throws Exception {
|
||||
RowPermissionService rowPermissionService = SpringContextUtil.getBean(RowPermissionService.class);
|
||||
rowPermissionService.save(datasetRowPermissions);
|
||||
}
|
||||
|
||||
@ApiOperation("分页查询")
|
||||
@PostMapping("/list")
|
||||
public List<DataSetRowPermissionsDTO> rowPermissions(@RequestBody XpackSysAuthDetailDTO request) {
|
||||
RowPermissionService rowPermissionService = SpringContextUtil.getBean(RowPermissionService.class);
|
||||
return rowPermissionService.searchRowPermissions(request);
|
||||
}
|
||||
|
||||
@ApiOperation("删除")
|
||||
@GetMapping("/delete/{id}")
|
||||
public void dataSetRowPermissionInfo(@PathVariable String id) {
|
||||
RowPermissionService rowPermissionService = SpringContextUtil.getBean(RowPermissionService.class);
|
||||
rowPermissionService.delete(id);
|
||||
}
|
||||
|
||||
}
|
@ -41,7 +41,15 @@ public class XAuthServer {
|
||||
@I18n
|
||||
public List<XpackSysAuthDetail>authDetailsModel(@PathVariable String authType){
|
||||
AuthXpackService sysAuthService = SpringContextUtil.getBean(AuthXpackService.class);
|
||||
return sysAuthService.searchAuthDetailsModel(authType);
|
||||
List<XpackSysAuthDetail> authDetails = sysAuthService.searchAuthDetailsModel(authType);
|
||||
if(authType.equalsIgnoreCase("dataset")){
|
||||
XpackSysAuthDetail xpackSysAuthDetail = new XpackSysAuthDetail();
|
||||
xpackSysAuthDetail.setPrivilegeName("i18n_auth_row_permission");
|
||||
xpackSysAuthDetail.setPrivilegeType(20);
|
||||
xpackSysAuthDetail.setPrivilegeValue(1);
|
||||
authDetails.add(0,xpackSysAuthDetail);
|
||||
}
|
||||
return authDetails;
|
||||
}
|
||||
|
||||
@PostMapping("/authChange")
|
||||
|
@ -23,17 +23,17 @@ public abstract class QueryProvider {
|
||||
|
||||
public abstract String createSQLPreview(String sql, String orderBy);
|
||||
|
||||
public abstract String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds);
|
||||
public abstract String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds, List<ChartCustomFilterDTO> customFilter);
|
||||
|
||||
public abstract String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup);
|
||||
public abstract String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup, List<ChartCustomFilterDTO> customFilter);
|
||||
|
||||
public abstract String createQueryTableWithPage(String table, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, Datasource ds);
|
||||
public abstract String createQueryTableWithPage(String table, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, Datasource ds, List<ChartCustomFilterDTO> customFilter);
|
||||
|
||||
public abstract String createQuerySQLWithPage(String sql, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup);
|
||||
public abstract String createQuerySQLWithPage(String sql, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, List<ChartCustomFilterDTO> customFilter);
|
||||
|
||||
public abstract String createQueryTableWithLimit(String table, List<DatasetTableField> fields, Integer limit, boolean isGroup, Datasource ds);
|
||||
public abstract String createQueryTableWithLimit(String table, List<DatasetTableField> fields, Integer limit, boolean isGroup, Datasource ds, List<ChartCustomFilterDTO> customFilter);
|
||||
|
||||
public abstract String createQuerySqlWithLimit(String sql, List<DatasetTableField> fields, Integer limit, boolean isGroup);
|
||||
public abstract String createQuerySqlWithLimit(String sql, List<DatasetTableField> fields, Integer limit, boolean isGroup, List<ChartCustomFilterDTO> customFilter);
|
||||
|
||||
public abstract String getSQL(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view);
|
||||
|
||||
|
@ -107,7 +107,7 @@ public class CKQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds) {
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds, List<ChartCustomFilterDTO> customFilter) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(CKConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
@ -170,32 +170,36 @@ public class CKQueryProvider extends QueryProvider {
|
||||
st_sql.add("isGroup", isGroup);
|
||||
if (CollectionUtils.isNotEmpty(xFields)) st_sql.add("groups", xFields);
|
||||
if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj);
|
||||
List<SQLObj> customWheres = transCustomFilterList(tableObj, customFilter);
|
||||
List<SQLObj> wheres = new ArrayList<>();
|
||||
if (customWheres != null) wheres.addAll(customWheres);
|
||||
if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres);
|
||||
return st_sql.render();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup) {
|
||||
return createQuerySQL("(" + sqlFix(sql) + ")", fields, isGroup, null);
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup, List<ChartCustomFilterDTO> customFilter) {
|
||||
return createQuerySQL("(" + sqlFix(sql) + ")", fields, isGroup, null, customFilter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQueryTableWithPage(String table, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, Datasource ds) {
|
||||
return createQuerySQL(table, fields, isGroup, null) + " LIMIT " + (page - 1) * pageSize + "," + realSize;
|
||||
public String createQueryTableWithPage(String table, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, Datasource ds, List<ChartCustomFilterDTO> customFilter) {
|
||||
return createQuerySQL(table, fields, isGroup, null, customFilter) + " LIMIT " + (page - 1) * pageSize + "," + realSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQueryTableWithLimit(String table, List<DatasetTableField> fields, Integer limit, boolean isGroup, Datasource ds) {
|
||||
return createQuerySQL(table, fields, isGroup, null) + " LIMIT 0," + limit;
|
||||
public String createQueryTableWithLimit(String table, List<DatasetTableField> fields, Integer limit, boolean isGroup, Datasource ds, List<ChartCustomFilterDTO> customFilter) {
|
||||
return createQuerySQL(table, fields, isGroup, null, customFilter) + " LIMIT 0," + limit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySqlWithLimit(String sql, List<DatasetTableField> fields, Integer limit, boolean isGroup) {
|
||||
return createQuerySQLAsTmp(sql, fields, isGroup) + " LIMIT 0," + limit;
|
||||
public String createQuerySqlWithLimit(String sql, List<DatasetTableField> fields, Integer limit, boolean isGroup, List<ChartCustomFilterDTO> customFilter) {
|
||||
return createQuerySQLAsTmp(sql, fields, isGroup, customFilter) + " LIMIT 0," + limit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQLWithPage(String sql, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup) {
|
||||
return createQuerySQLAsTmp(sql, fields, isGroup) + " LIMIT " + (page - 1) * pageSize + "," + realSize;
|
||||
public String createQuerySQLWithPage(String sql, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, List<ChartCustomFilterDTO> customFilter) {
|
||||
return createQuerySQLAsTmp(sql, fields, isGroup, customFilter) + " LIMIT " + (page - 1) * pageSize + "," + realSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -76,7 +76,7 @@ public class Db2QueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds) {
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds, List<ChartCustomFilterDTO> customFilter) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(Db2Constants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
@ -139,30 +139,30 @@ public class Db2QueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup) {
|
||||
return createQuerySQL("(" + sqlFix(sql) + ")", fields, isGroup, null);
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup, List<ChartCustomFilterDTO> customFilter) {
|
||||
return createQuerySQL("(" + sqlFix(sql) + ")", fields, isGroup, null, customFilter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQueryTableWithPage(String table, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, Datasource ds) {
|
||||
public String createQueryTableWithPage(String table, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, Datasource ds, List<ChartCustomFilterDTO> customFilter) {
|
||||
Integer size = (page - 1) * pageSize + realSize;
|
||||
return createQuerySQL(table, fields, isGroup, null) + String.format(" fetch first %s rows only; ", size);
|
||||
return createQuerySQL(table, fields, isGroup, null, customFilter) + String.format(" fetch first %s rows only; ", size);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQueryTableWithLimit(String table, List<DatasetTableField> fields, Integer limit, boolean isGroup, Datasource ds) {
|
||||
return createQuerySQL(table, fields, isGroup, null) + String.format(" fetch first %s rows only; ", limit);
|
||||
public String createQueryTableWithLimit(String table, List<DatasetTableField> fields, Integer limit, boolean isGroup, Datasource ds, List<ChartCustomFilterDTO> customFilter) {
|
||||
return createQuerySQL(table, fields, isGroup, null, customFilter) + String.format(" fetch first %s rows only; ", limit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySqlWithLimit(String sql, List<DatasetTableField> fields, Integer limit, boolean isGroup) {
|
||||
return createQuerySQLAsTmp(sql, fields, isGroup) + String.format(" fetch first %s rows only; ", limit);
|
||||
public String createQuerySqlWithLimit(String sql, List<DatasetTableField> fields, Integer limit, boolean isGroup, List<ChartCustomFilterDTO> customFilter) {
|
||||
return createQuerySQLAsTmp(sql, fields, isGroup, customFilter) + String.format(" fetch first %s rows only; ", limit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQLWithPage(String sql, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup) {
|
||||
public String createQuerySQLWithPage(String sql, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, List<ChartCustomFilterDTO> customFilter) {
|
||||
Integer size = (page - 1) * pageSize + realSize;
|
||||
return createQuerySQLAsTmp(sql, fields, isGroup) + String.format(" fetch first %s rows only; ", size);
|
||||
return createQuerySQLAsTmp(sql, fields, isGroup, customFilter) + String.format(" fetch first %s rows only; ", size);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -78,7 +78,7 @@ public class DorisQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds) {
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds, List<ChartCustomFilterDTO> customFilter) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(DorisConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
@ -140,6 +140,11 @@ public class DorisQueryProvider extends QueryProvider {
|
||||
st_sql.add("isGroup", isGroup);
|
||||
if (CollectionUtils.isNotEmpty(xFields)) st_sql.add("groups", xFields);
|
||||
if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj);
|
||||
List<SQLObj> customWheres = transCustomFilterList(tableObj, customFilter);
|
||||
List<SQLObj> wheres = new ArrayList<>();
|
||||
if (customWheres != null) wheres.addAll(customWheres);
|
||||
if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres);
|
||||
|
||||
if ((fields.size() > 0)) {
|
||||
xOrders.add(SQLObj.builder()
|
||||
.orderDirection("asc")
|
||||
@ -152,28 +157,28 @@ public class DorisQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup) {
|
||||
return createQuerySQL("(" + sql + ")", fields, isGroup, null);
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup, List<ChartCustomFilterDTO> customFilter) {
|
||||
return createQuerySQL("(" + sql + ")", fields, isGroup, null, customFilter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQueryTableWithPage(String table, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, Datasource ds) {
|
||||
return createQuerySQL(table, fields, isGroup, null) + " LIMIT " + (page - 1) * pageSize + "," + realSize;
|
||||
public String createQueryTableWithPage(String table, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, Datasource ds, List<ChartCustomFilterDTO> customFilter) {
|
||||
return createQuerySQL(table, fields, isGroup, null, customFilter) + " LIMIT " + (page - 1) * pageSize + "," + realSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQueryTableWithLimit(String table, List<DatasetTableField> fields, Integer limit, boolean isGroup, Datasource ds) {
|
||||
return createQuerySQL(table, fields, isGroup, null) + " LIMIT 0," + limit;
|
||||
public String createQueryTableWithLimit(String table, List<DatasetTableField> fields, Integer limit, boolean isGroup, Datasource ds, List<ChartCustomFilterDTO> customFilter) {
|
||||
return createQuerySQL(table, fields, isGroup, null, customFilter) + " LIMIT 0," + limit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySqlWithLimit(String sql, List<DatasetTableField> fields, Integer limit, boolean isGroup) {
|
||||
return createQuerySQLAsTmp(sql, fields, isGroup) + " LIMIT 0," + limit;
|
||||
public String createQuerySqlWithLimit(String sql, List<DatasetTableField> fields, Integer limit, boolean isGroup, List<ChartCustomFilterDTO> customFilter) {
|
||||
return createQuerySQLAsTmp(sql, fields, isGroup, customFilter) + " LIMIT 0," + limit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQLWithPage(String sql, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup) {
|
||||
return createQuerySQLAsTmp(sql, fields, isGroup) + " LIMIT " + (page - 1) * pageSize + "," + realSize;
|
||||
public String createQuerySQLWithPage(String sql, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, List<ChartCustomFilterDTO> customFilter) {
|
||||
return createQuerySQLAsTmp(sql, fields, isGroup, customFilter) + " LIMIT " + (page - 1) * pageSize + "," + realSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -110,7 +110,7 @@ public class EsQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds) {
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds, List<ChartCustomFilterDTO> customFilter) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(EsSqlLConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
@ -169,32 +169,38 @@ public class EsQueryProvider extends QueryProvider {
|
||||
st_sql.add("isGroup", isGroup);
|
||||
if (CollectionUtils.isNotEmpty(xFields)) st_sql.add("groups", xFields);
|
||||
if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj);
|
||||
|
||||
List<SQLObj> customWheres = transCustomFilterList(tableObj, customFilter);
|
||||
List<SQLObj> wheres = new ArrayList<>();
|
||||
if (customWheres != null) wheres.addAll(customWheres);
|
||||
if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres);
|
||||
|
||||
return st_sql.render();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup) {
|
||||
return createQuerySQL("(" + sqlFix(sql) + ")", fields, isGroup, null);
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup, List<ChartCustomFilterDTO> customFilter) {
|
||||
return createQuerySQL("(" + sqlFix(sql) + ")", fields, isGroup, null, customFilter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQueryTableWithPage(String table, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, Datasource ds) {
|
||||
return createQuerySQL(table, fields, isGroup, null);
|
||||
public String createQueryTableWithPage(String table, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, Datasource ds, List<ChartCustomFilterDTO> customFilter) {
|
||||
return createQuerySQL(table, fields, isGroup, null, customFilter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQueryTableWithLimit(String table, List<DatasetTableField> fields, Integer limit, boolean isGroup, Datasource ds) {
|
||||
return createQuerySQL(table, fields, isGroup, null);
|
||||
public String createQueryTableWithLimit(String table, List<DatasetTableField> fields, Integer limit, boolean isGroup, Datasource ds, List<ChartCustomFilterDTO> customFilter) {
|
||||
return createQuerySQL(table, fields, isGroup, null, customFilter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySqlWithLimit(String sql, List<DatasetTableField> fields, Integer limit, boolean isGroup) {
|
||||
return createQuerySQLAsTmp(sql, fields, isGroup);
|
||||
public String createQuerySqlWithLimit(String sql, List<DatasetTableField> fields, Integer limit, boolean isGroup, List<ChartCustomFilterDTO> customFilter) {
|
||||
return createQuerySQLAsTmp(sql, fields, isGroup, customFilter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQLWithPage(String sql, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup) {
|
||||
return createQuerySQLAsTmp(sql, fields, isGroup);
|
||||
public String createQuerySQLWithPage(String sql, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, List<ChartCustomFilterDTO> customFilter) {
|
||||
return createQuerySQLAsTmp(sql, fields, isGroup, customFilter);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -71,7 +71,7 @@ public class HiveQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds) {
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds, List<ChartCustomFilterDTO> customFilter) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(HiveConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
@ -130,32 +130,36 @@ public class HiveQueryProvider extends QueryProvider {
|
||||
st_sql.add("isGroup", isGroup);
|
||||
if (CollectionUtils.isNotEmpty(xFields)) st_sql.add("groups", xFields);
|
||||
if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj);
|
||||
List<SQLObj> customWheres = transCustomFilterList(tableObj, customFilter);
|
||||
List<SQLObj> wheres = new ArrayList<>();
|
||||
if (customWheres != null) wheres.addAll(customWheres);
|
||||
if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres);
|
||||
return st_sql.render();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup) {
|
||||
return createQuerySQL("(" + sqlFix(sql) + ")", fields, isGroup, null);
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup, List<ChartCustomFilterDTO> customFilter) {
|
||||
return createQuerySQL("(" + sqlFix(sql) + ")", fields, isGroup, null, customFilter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQueryTableWithPage(String table, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, Datasource ds) {
|
||||
return createQuerySQL(table, fields, isGroup, null) + " LIMIT " + (page - 1) * pageSize + "," + realSize;
|
||||
public String createQueryTableWithPage(String table, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, Datasource ds, List<ChartCustomFilterDTO> customFilter) {
|
||||
return createQuerySQL(table, fields, isGroup, null, customFilter) + " LIMIT " + (page - 1) * pageSize + "," + realSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQueryTableWithLimit(String table, List<DatasetTableField> fields, Integer limit, boolean isGroup, Datasource ds) {
|
||||
return createQuerySQL(table, fields, isGroup, null) + " LIMIT 0," + limit;
|
||||
public String createQueryTableWithLimit(String table, List<DatasetTableField> fields, Integer limit, boolean isGroup, Datasource ds, List<ChartCustomFilterDTO> customFilter) {
|
||||
return createQuerySQL(table, fields, isGroup, null, customFilter) + " LIMIT 0," + limit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySqlWithLimit(String sql, List<DatasetTableField> fields, Integer limit, boolean isGroup) {
|
||||
return createQuerySQLAsTmp(sql, fields, isGroup) + " LIMIT 0," + limit;
|
||||
public String createQuerySqlWithLimit(String sql, List<DatasetTableField> fields, Integer limit, boolean isGroup, List<ChartCustomFilterDTO> customFilter) {
|
||||
return createQuerySQLAsTmp(sql, fields, isGroup, customFilter) + " LIMIT 0," + limit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQLWithPage(String sql, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup) {
|
||||
return createQuerySQLAsTmp(sql, fields, isGroup) + " LIMIT " + (page - 1) * pageSize + "," + realSize;
|
||||
public String createQuerySQLWithPage(String sql, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, List<ChartCustomFilterDTO> customFilter) {
|
||||
return createQuerySQLAsTmp(sql, fields, isGroup, customFilter) + " LIMIT " + (page - 1) * pageSize + "," + realSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -81,7 +81,7 @@ public class MongoQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds) {
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds, List<ChartCustomFilterDTO> customFilter) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(MongoConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
@ -114,32 +114,36 @@ public class MongoQueryProvider extends QueryProvider {
|
||||
st_sql.add("isGroup", isGroup);
|
||||
if (CollectionUtils.isNotEmpty(xFields)) st_sql.add("groups", xFields);
|
||||
if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj);
|
||||
List<SQLObj> customWheres = transCustomFilterList(tableObj, customFilter);
|
||||
List<SQLObj> wheres = new ArrayList<>();
|
||||
if (customWheres != null) wheres.addAll(customWheres);
|
||||
if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres);
|
||||
return st_sql.render();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup) {
|
||||
return createQuerySQL("(" + sqlFix(sql) + ")", fields, isGroup, null);
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup, List<ChartCustomFilterDTO> customFilter) {
|
||||
return createQuerySQL("(" + sqlFix(sql) + ")", fields, isGroup, null, customFilter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQueryTableWithPage(String table, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, Datasource ds) {
|
||||
return createQuerySQL(table, fields, isGroup, null) + " LIMIT " + (page - 1) * pageSize + "," + realSize;
|
||||
public String createQueryTableWithPage(String table, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, Datasource ds, List<ChartCustomFilterDTO> customFilter) {
|
||||
return createQuerySQL(table, fields, isGroup, null, customFilter) + " LIMIT " + (page - 1) * pageSize + "," + realSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQueryTableWithLimit(String table, List<DatasetTableField> fields, Integer limit, boolean isGroup, Datasource ds) {
|
||||
return createQuerySQL(table, fields, isGroup, null) + " LIMIT 0," + limit;
|
||||
public String createQueryTableWithLimit(String table, List<DatasetTableField> fields, Integer limit, boolean isGroup, Datasource ds, List<ChartCustomFilterDTO> customFilter) {
|
||||
return createQuerySQL(table, fields, isGroup, null, customFilter) + " LIMIT 0," + limit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySqlWithLimit(String sql, List<DatasetTableField> fields, Integer limit, boolean isGroup) {
|
||||
return createQuerySQLAsTmp(sql, fields, isGroup) + " LIMIT 0," + limit;
|
||||
public String createQuerySqlWithLimit(String sql, List<DatasetTableField> fields, Integer limit, boolean isGroup, List<ChartCustomFilterDTO> customFilter) {
|
||||
return createQuerySQLAsTmp(sql, fields, isGroup, customFilter) + " LIMIT 0," + limit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQLWithPage(String sql, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup) {
|
||||
return createQuerySQLAsTmp(sql, fields, isGroup) + " LIMIT " + (page - 1) * pageSize + "," + realSize;
|
||||
public String createQuerySQLWithPage(String sql, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, List<ChartCustomFilterDTO> customFilter) {
|
||||
return createQuerySQLAsTmp(sql, fields, isGroup, customFilter) + " LIMIT " + (page - 1) * pageSize + "," + realSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -78,7 +78,7 @@ public class MysqlQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds) {
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds, List<ChartCustomFilterDTO> customFilter) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(MySQLConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
@ -137,32 +137,38 @@ public class MysqlQueryProvider extends QueryProvider {
|
||||
st_sql.add("isGroup", isGroup);
|
||||
if (CollectionUtils.isNotEmpty(xFields)) st_sql.add("groups", xFields);
|
||||
if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj);
|
||||
|
||||
List<SQLObj> customWheres = transCustomFilterList(tableObj, customFilter);
|
||||
List<SQLObj> wheres = new ArrayList<>();
|
||||
if (customWheres != null) wheres.addAll(customWheres);
|
||||
if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres);
|
||||
|
||||
return st_sql.render();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup) {
|
||||
return createQuerySQL("(" + sqlFix(sql) + ")", fields, isGroup, null);
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup, List<ChartCustomFilterDTO> customFilter) {
|
||||
return createQuerySQL("(" + sqlFix(sql) + ")", fields, isGroup, null, customFilter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQueryTableWithPage(String table, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, Datasource ds) {
|
||||
return createQuerySQL(table, fields, isGroup, null) + " LIMIT " + (page - 1) * pageSize + "," + realSize;
|
||||
public String createQueryTableWithPage(String table, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, Datasource ds, List<ChartCustomFilterDTO> customFilter) {
|
||||
return createQuerySQL(table, fields, isGroup, null, customFilter) + " LIMIT " + (page - 1) * pageSize + "," + realSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQueryTableWithLimit(String table, List<DatasetTableField> fields, Integer limit, boolean isGroup, Datasource ds) {
|
||||
return createQuerySQL(table, fields, isGroup, null) + " LIMIT 0," + limit;
|
||||
public String createQueryTableWithLimit(String table, List<DatasetTableField> fields, Integer limit, boolean isGroup, Datasource ds, List<ChartCustomFilterDTO> customFilter) {
|
||||
return createQuerySQL(table, fields, isGroup, null, customFilter) + " LIMIT 0," + limit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySqlWithLimit(String sql, List<DatasetTableField> fields, Integer limit, boolean isGroup) {
|
||||
return createQuerySQLAsTmp(sql, fields, isGroup) + " LIMIT 0," + limit;
|
||||
public String createQuerySqlWithLimit(String sql, List<DatasetTableField> fields, Integer limit, boolean isGroup, List<ChartCustomFilterDTO> customFilter) {
|
||||
return createQuerySQLAsTmp(sql, fields, isGroup, customFilter) + " LIMIT 0," + limit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQLWithPage(String sql, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup) {
|
||||
return createQuerySQLAsTmp(sql, fields, isGroup) + " LIMIT " + (page - 1) * pageSize + "," + realSize;
|
||||
public String createQuerySQLWithPage(String sql, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, List<ChartCustomFilterDTO> customFilter) {
|
||||
return createQuerySQLAsTmp(sql, fields, isGroup, customFilter) + " LIMIT " + (page - 1) * pageSize + "," + realSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -93,7 +93,7 @@ public class OracleQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds) {
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds, List<ChartCustomFilterDTO> customFilter) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(OracleConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(OracleConstants.ALIAS_FIX, String.format(TABLE_ALIAS_PREFIX, 0)))
|
||||
@ -107,6 +107,10 @@ public class OracleQueryProvider extends QueryProvider {
|
||||
st_sql.add("isGroup", isGroup);
|
||||
if (CollectionUtils.isNotEmpty(xFields)) st_sql.add("groups", xFields);
|
||||
if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj);
|
||||
List<SQLObj> customWheres = transCustomFilterList(tableObj, customFilter);
|
||||
List<SQLObj> wheres = new ArrayList<>();
|
||||
if (customWheres != null) wheres.addAll(customWheres);
|
||||
if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres);
|
||||
return st_sql.render();
|
||||
}
|
||||
|
||||
@ -182,33 +186,33 @@ public class OracleQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup) {
|
||||
return createQuerySQL("(" + sqlFix(sql) + ")", fields, isGroup, null);
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup, List<ChartCustomFilterDTO> customFilter) {
|
||||
return createQuerySQL("(" + sqlFix(sql) + ")", fields, isGroup, null, customFilter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQueryTableWithPage(String table, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, Datasource ds) {
|
||||
public String createQueryTableWithPage(String table, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, Datasource ds, List<ChartCustomFilterDTO> customFilter) {
|
||||
List<SQLObj> xFields = xFields(table, fields);
|
||||
|
||||
return MessageFormat.format("SELECT {0} FROM ( SELECT DE_TMP.*, rownum r FROM ( {1} ) DE_TMP WHERE rownum <= {2} ) WHERE r > {3} ",
|
||||
sqlColumn(xFields), createQuerySQL(table, fields, isGroup, ds), Integer.valueOf(page * realSize).toString(), Integer.valueOf((page - 1) * pageSize).toString());
|
||||
sqlColumn(xFields), createQuerySQL(table, fields, isGroup, ds, customFilter), Integer.valueOf(page * realSize).toString(), Integer.valueOf((page - 1) * pageSize).toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQLWithPage(String sql, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup) {
|
||||
public String createQuerySQLWithPage(String sql, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, List<ChartCustomFilterDTO> customFilter) {
|
||||
List<SQLObj> xFields = xFields("(" + sqlFix(sql) + ")", fields);
|
||||
return MessageFormat.format("SELECT {0} FROM ( SELECT DE_TMP.*, rownum r FROM ( {1} ) DE_TMP WHERE rownum <= {2} ) WHERE r > {3} ",
|
||||
sqlColumn(xFields), createQuerySQLAsTmp(sql, fields, isGroup), Integer.valueOf(page * realSize).toString(), Integer.valueOf((page - 1) * pageSize).toString());
|
||||
sqlColumn(xFields), createQuerySQLAsTmp(sql, fields, isGroup, customFilter), Integer.valueOf(page * realSize).toString(), Integer.valueOf((page - 1) * pageSize).toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQueryTableWithLimit(String table, List<DatasetTableField> fields, Integer limit, boolean isGroup, Datasource ds) {
|
||||
public String createQueryTableWithLimit(String table, List<DatasetTableField> fields, Integer limit, boolean isGroup, Datasource ds, List<ChartCustomFilterDTO> customFilter) {
|
||||
String schema = new Gson().fromJson(ds.getConfiguration(), JdbcConfiguration.class).getSchema();
|
||||
return String.format("SELECT * from %s WHERE rownum <= %s ", schema + "." + String.format(OracleConstants.KEYWORD_TABLE, table), limit.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySqlWithLimit(String sql, List<DatasetTableField> fields, Integer limit, boolean isGroup) {
|
||||
public String createQuerySqlWithLimit(String sql, List<DatasetTableField> fields, Integer limit, boolean isGroup, List<ChartCustomFilterDTO> customFilter) {
|
||||
return String.format("SELECT * from %s WHERE rownum <= %s ", "(" + sqlFix(sql) + ")", limit.toString());
|
||||
}
|
||||
|
||||
|
@ -97,7 +97,7 @@ public class PgQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds) {
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds, List<ChartCustomFilterDTO> customFilter) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(PgConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
@ -158,32 +158,36 @@ public class PgQueryProvider extends QueryProvider {
|
||||
st_sql.add("isGroup", isGroup);
|
||||
if (CollectionUtils.isNotEmpty(xFields)) st_sql.add("groups", xFields);
|
||||
if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj);
|
||||
List<SQLObj> customWheres = transCustomFilterList(tableObj, customFilter);
|
||||
List<SQLObj> wheres = new ArrayList<>();
|
||||
if (customWheres != null) wheres.addAll(customWheres);
|
||||
if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres);
|
||||
return st_sql.render();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup) {
|
||||
return createQuerySQL("(" + sqlFix(sql) + ")", fields, isGroup, null);
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup, List<ChartCustomFilterDTO> customFilter) {
|
||||
return createQuerySQL("(" + sqlFix(sql) + ")", fields, isGroup, null, customFilter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQueryTableWithPage(String table, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, Datasource ds) {
|
||||
return createQuerySQL(table, fields, isGroup, ds) + " LIMIT " + realSize + " offset " + (page - 1) * pageSize;
|
||||
public String createQueryTableWithPage(String table, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, Datasource ds, List<ChartCustomFilterDTO> customFilter) {
|
||||
return createQuerySQL(table, fields, isGroup, ds, customFilter) + " LIMIT " + realSize + " offset " + (page - 1) * pageSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQLWithPage(String sql, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup) {
|
||||
return createQuerySQLAsTmp(sql, fields, isGroup) + " LIMIT " + realSize + " offset " + (page - 1) * pageSize;
|
||||
public String createQuerySQLWithPage(String sql, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, List<ChartCustomFilterDTO> customFilter) {
|
||||
return createQuerySQLAsTmp(sql, fields, isGroup, customFilter) + " LIMIT " + realSize + " offset " + (page - 1) * pageSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQueryTableWithLimit(String table, List<DatasetTableField> fields, Integer limit, boolean isGroup, Datasource ds) {
|
||||
return createQuerySQL(table, fields, isGroup, ds) + " LIMIT " + limit + " offset 0";
|
||||
public String createQueryTableWithLimit(String table, List<DatasetTableField> fields, Integer limit, boolean isGroup, Datasource ds, List<ChartCustomFilterDTO> customFilter) {
|
||||
return createQuerySQL(table, fields, isGroup, ds, customFilter) + " LIMIT " + limit + " offset 0";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySqlWithLimit(String sql, List<DatasetTableField> fields, Integer limit, boolean isGroup) {
|
||||
return createQuerySQLAsTmp(sql, fields, isGroup) + " LIMIT " + limit + " offset 0";
|
||||
public String createQuerySqlWithLimit(String sql, List<DatasetTableField> fields, Integer limit, boolean isGroup, List<ChartCustomFilterDTO> customFilter) {
|
||||
return createQuerySQLAsTmp(sql, fields, isGroup, customFilter) + " LIMIT " + limit + " offset 0";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -106,7 +106,7 @@ public class RedshiftQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds) {
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds, List<ChartCustomFilterDTO> customFilter) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(PgConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
@ -167,32 +167,36 @@ public class RedshiftQueryProvider extends QueryProvider {
|
||||
st_sql.add("isGroup", isGroup);
|
||||
if (CollectionUtils.isNotEmpty(xFields)) st_sql.add("groups", xFields);
|
||||
if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj);
|
||||
List<SQLObj> customWheres = transCustomFilterList(tableObj, customFilter);
|
||||
List<SQLObj> wheres = new ArrayList<>();
|
||||
if (customWheres != null) wheres.addAll(customWheres);
|
||||
if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres);
|
||||
return st_sql.render();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup) {
|
||||
return createQuerySQL("(" + sqlFix(sql) + ")", fields, isGroup, null);
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup, List<ChartCustomFilterDTO> customFilter) {
|
||||
return createQuerySQL("(" + sqlFix(sql) + ")", fields, isGroup, null, customFilter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQueryTableWithPage(String table, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, Datasource ds) {
|
||||
return createQuerySQL(table, fields, isGroup, ds) + " LIMIT " + realSize + " offset " + (page - 1) * pageSize;
|
||||
public String createQueryTableWithPage(String table, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, Datasource ds, List<ChartCustomFilterDTO> customFilter) {
|
||||
return createQuerySQL(table, fields, isGroup, ds, customFilter) + " LIMIT " + realSize + " offset " + (page - 1) * pageSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQLWithPage(String sql, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup) {
|
||||
return createQuerySQLAsTmp(sql, fields, isGroup) + " LIMIT " + realSize + " offset " + (page - 1) * pageSize;
|
||||
public String createQuerySQLWithPage(String sql, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, List<ChartCustomFilterDTO> customFilter) {
|
||||
return createQuerySQLAsTmp(sql, fields, isGroup, customFilter) + " LIMIT " + realSize + " offset " + (page - 1) * pageSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQueryTableWithLimit(String table, List<DatasetTableField> fields, Integer limit, boolean isGroup, Datasource ds) {
|
||||
return createQuerySQL(table, fields, isGroup, null) + " LIMIT " + limit + " offset 0";
|
||||
public String createQueryTableWithLimit(String table, List<DatasetTableField> fields, Integer limit, boolean isGroup, Datasource ds, List<ChartCustomFilterDTO> customFilter) {
|
||||
return createQuerySQL(table, fields, isGroup, null, customFilter) + " LIMIT " + limit + " offset 0";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySqlWithLimit(String sql, List<DatasetTableField> fields, Integer limit, boolean isGroup) {
|
||||
return createQuerySQLAsTmp(sql, fields, isGroup) + " LIMIT " + limit + " offset 0";
|
||||
public String createQuerySqlWithLimit(String sql, List<DatasetTableField> fields, Integer limit, boolean isGroup, List<ChartCustomFilterDTO> customFilter) {
|
||||
return createQuerySQLAsTmp(sql, fields, isGroup, customFilter) + " LIMIT " + limit + " offset 0";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -86,7 +86,7 @@ public class SqlserverQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds) {
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds, List<ChartCustomFilterDTO> customFilter) {
|
||||
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(SqlServerSQLConstants.KEYWORD_TABLE, table))
|
||||
@ -148,35 +148,39 @@ public class SqlserverQueryProvider extends QueryProvider {
|
||||
st_sql.add("isGroup", isGroup);
|
||||
if (CollectionUtils.isNotEmpty(xFields)) st_sql.add("groups", xFields);
|
||||
if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj);
|
||||
List<SQLObj> customWheres = transCustomFilterList(tableObj, customFilter);
|
||||
List<SQLObj> wheres = new ArrayList<>();
|
||||
if (customWheres != null) wheres.addAll(customWheres);
|
||||
if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres);
|
||||
return st_sql.render();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup) {
|
||||
return createQuerySQL("(" + sqlFix(sql) + ")", fields, isGroup, null);
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup, List<ChartCustomFilterDTO> customFilter) {
|
||||
return createQuerySQL("(" + sqlFix(sql) + ")", fields, isGroup, null, customFilter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQueryTableWithPage(String table, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, Datasource ds) {
|
||||
public String createQueryTableWithPage(String table, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, Datasource ds, List<ChartCustomFilterDTO> customFilter) {
|
||||
Integer size = (page - 1) * pageSize + realSize;
|
||||
return String.format("SELECT top %s * from ( %s ) AS DE_SQLSERVER_TMP ", size.toString(), createQuerySQL(table, fields, isGroup, ds));
|
||||
return String.format("SELECT top %s * from ( %s ) AS DE_SQLSERVER_TMP ", size.toString(), createQuerySQL(table, fields, isGroup, ds, customFilter));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQueryTableWithLimit(String table, List<DatasetTableField> fields, Integer limit, boolean isGroup, Datasource ds) {
|
||||
public String createQueryTableWithLimit(String table, List<DatasetTableField> fields, Integer limit, boolean isGroup, Datasource ds, List<ChartCustomFilterDTO> customFilter) {
|
||||
String schema = new Gson().fromJson(ds.getConfiguration(), JdbcConfiguration.class).getSchema();
|
||||
return String.format("SELECT top %s * from %s ", limit.toString(), schema + "." + table);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQLWithPage(String sql, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup) {
|
||||
public String createQuerySQLWithPage(String sql, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, List<ChartCustomFilterDTO> customFilter) {
|
||||
Integer size = (page - 1) * pageSize + realSize;
|
||||
return String.format("SELECT top %s * from ( %s ) AS DE_SQLSERVER_TMP ", size.toString(), createQuerySQLAsTmp(sql, fields, isGroup));
|
||||
return String.format("SELECT top %s * from ( %s ) AS DE_SQLSERVER_TMP ", size.toString(), createQuerySQLAsTmp(sql, fields, isGroup, customFilter));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySqlWithLimit(String sql, List<DatasetTableField> fields, Integer limit, boolean isGroup) {
|
||||
public String createQuerySqlWithLimit(String sql, List<DatasetTableField> fields, Integer limit, boolean isGroup, List<ChartCustomFilterDTO> customFilter) {
|
||||
return String.format("SELECT top %s * from ( %s ) as DE_SQLSERVER_TMP ", limit.toString(), sqlFix(sql));
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,9 @@
|
||||
package io.dataease.service.dataset;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.gson.Gson;
|
||||
import io.dataease.auth.api.dto.CurrentRoleDto;
|
||||
import io.dataease.base.domain.*;
|
||||
import io.dataease.base.mapper.*;
|
||||
import io.dataease.base.mapper.ext.ExtDataSetGroupMapper;
|
||||
@ -16,19 +18,24 @@ import io.dataease.commons.utils.*;
|
||||
import io.dataease.controller.request.dataset.DataSetGroupRequest;
|
||||
import io.dataease.controller.request.dataset.DataSetTableRequest;
|
||||
import io.dataease.controller.request.dataset.DataSetTaskRequest;
|
||||
import io.dataease.controller.request.datasource.DatasourceRequest;
|
||||
import io.dataease.controller.response.DataSetDetail;
|
||||
import io.dataease.dto.chart.ChartCustomFilterDTO;
|
||||
import io.dataease.dto.datasource.TableFiled;
|
||||
import io.dataease.plugins.config.SpringContextUtil;
|
||||
import io.dataease.plugins.xpack.auth.dto.request.DatasetRowPermissions;
|
||||
import io.dataease.plugins.xpack.auth.service.RowPermissionService;
|
||||
import io.dataease.plugins.xpack.oidc.service.OidcXpackService;
|
||||
import io.dataease.provider.datasource.DatasourceProvider;
|
||||
import io.dataease.provider.datasource.JdbcProvider;
|
||||
import io.dataease.provider.ProviderFactory;
|
||||
import io.dataease.controller.request.datasource.DatasourceRequest;
|
||||
import io.dataease.dto.dataset.*;
|
||||
import io.dataease.dto.dataset.union.UnionDTO;
|
||||
import io.dataease.dto.dataset.union.UnionItemDTO;
|
||||
import io.dataease.dto.dataset.union.UnionParamDTO;
|
||||
import io.dataease.dto.datasource.TableFiled;
|
||||
import io.dataease.dto.dataset.union.UnionParamDTO;;
|
||||
import io.dataease.exception.DataEaseException;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.plugins.loader.ClassloaderResponsity;
|
||||
import io.dataease.provider.ProviderFactory;
|
||||
import io.dataease.provider.datasource.DatasourceProvider;
|
||||
import io.dataease.provider.datasource.JdbcProvider;
|
||||
import io.dataease.provider.query.DDLProvider;
|
||||
import io.dataease.provider.query.QueryProvider;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
@ -93,6 +100,7 @@ public class DataSetTableService {
|
||||
private ExtDataSetGroupMapper extDataSetGroupMapper;
|
||||
@Resource
|
||||
private DatasetTableFieldMapper datasetTableFieldMapper;
|
||||
|
||||
private static final String lastUpdateTime = "${__last_update_time__}";
|
||||
private static final String currentUpdateTime = "${__current_update_time__}";
|
||||
|
||||
@ -431,11 +439,49 @@ public class DataSetTableService {
|
||||
return map;
|
||||
}
|
||||
|
||||
private List<DatasetRowPermissions> rowPermissions(String datasetId){
|
||||
List<DatasetRowPermissions> datasetRowPermissions = new ArrayList<>();
|
||||
Map<String, RowPermissionService> beansOfType = SpringContextUtil.getApplicationContext().getBeansOfType((RowPermissionService.class));
|
||||
if(beansOfType.keySet().size() == 0) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
RowPermissionService rowPermissionService = SpringContextUtil.getBean(RowPermissionService.class);
|
||||
datasetRowPermissions.addAll(rowPermissionService.listDatasetRowPermissions(datasetId, Collections.singletonList(AuthUtils.getUser().getUserId()), "user"));
|
||||
datasetRowPermissions.addAll(rowPermissionService.listDatasetRowPermissions(datasetId, AuthUtils.getUser().getRoles().stream().map(CurrentRoleDto::getId).collect(Collectors.toList()) , "role"));
|
||||
datasetRowPermissions.addAll(rowPermissionService.listDatasetRowPermissions(datasetId, Collections.singletonList(AuthUtils.getUser().getDeptId()), "dept"));
|
||||
return datasetRowPermissions;
|
||||
}
|
||||
|
||||
private DatasetTableField getFieldById(List<DatasetTableField> fields, String fieldId){
|
||||
DatasetTableField field = null;
|
||||
for (DatasetTableField datasetTableField : fields) {
|
||||
if(fieldId.equalsIgnoreCase(datasetTableField.getId())){
|
||||
field = datasetTableField;
|
||||
}
|
||||
}
|
||||
return field;
|
||||
}
|
||||
|
||||
|
||||
public List<ChartCustomFilterDTO> getCustomFilters(List<DatasetTableField> fields, DatasetTable datasetTable) {
|
||||
List<ChartCustomFilterDTO> customFilter = new ArrayList<>();
|
||||
rowPermissions(datasetTable.getId()).forEach(datasetRowPermissions -> {
|
||||
List<ChartCustomFilterDTO> lists = JSONObject.parseArray(datasetRowPermissions.getFilter(), ChartCustomFilterDTO.class);
|
||||
lists.forEach(chartCustomFilterDTO -> {
|
||||
DatasetTableField field = getFieldById(fields, datasetRowPermissions.getDatasetFieldId());
|
||||
if(field != null){
|
||||
chartCustomFilterDTO.setFieldId(datasetRowPermissions.getDatasetFieldId());
|
||||
chartCustomFilterDTO.setField(field);
|
||||
}
|
||||
});
|
||||
customFilter.addAll(lists);
|
||||
});
|
||||
return customFilter;
|
||||
}
|
||||
|
||||
public Map<String, Object> getPreviewData(DataSetTableRequest dataSetTableRequest, Integer page, Integer pageSize) throws Exception {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
DatasetTableField datasetTableField = DatasetTableField.builder().build();
|
||||
datasetTableField.setTableId(dataSetTableRequest.getId());
|
||||
datasetTableField.setChecked(Boolean.TRUE);
|
||||
DatasetTableField datasetTableField = DatasetTableField.builder().tableId(dataSetTableRequest.getId()).checked(Boolean.TRUE).build();
|
||||
List<DatasetTableField> fields = dataSetTableFieldsService.list(datasetTableField);
|
||||
if (CollectionUtils.isEmpty(fields)) {
|
||||
map.put("fields", fields);
|
||||
@ -443,10 +489,12 @@ public class DataSetTableService {
|
||||
map.put("page", new DataSetPreviewPage());
|
||||
return map;
|
||||
}
|
||||
DatasetTable datasetTable = datasetTableMapper.selectByPrimaryKey(dataSetTableRequest.getId());
|
||||
List<ChartCustomFilterDTO> customFilter = getCustomFilters(fields, datasetTable);
|
||||
String[] fieldArray = fields.stream().map(DatasetTableField::getDataeaseName).toArray(String[]::new);
|
||||
|
||||
DataTableInfoDTO dataTableInfoDTO = new Gson().fromJson(dataSetTableRequest.getInfo(), DataTableInfoDTO.class);
|
||||
DatasetTable datasetTable = datasetTableMapper.selectByPrimaryKey(dataSetTableRequest.getId());
|
||||
|
||||
|
||||
List<String[]> data = new ArrayList<>();
|
||||
DataSetPreviewPage dataSetPreviewPage = new DataSetPreviewPage();
|
||||
@ -468,7 +516,10 @@ public class DataSetTableService {
|
||||
datasourceRequest.setDatasource(ds);
|
||||
String table = dataTableInfoDTO.getTable();
|
||||
QueryProvider qp = ProviderFactory.getQueryProvider(ds.getType());
|
||||
datasourceRequest.setQuery(qp.createQueryTableWithPage(table, fields, page, pageSize, realSize, false, ds));
|
||||
|
||||
|
||||
datasourceRequest.setQuery(qp.createQueryTableWithPage(table, fields, page, pageSize, realSize, false, ds, customFilter));
|
||||
|
||||
map.put("sql", datasourceRequest.getQuery());
|
||||
datasourceRequest.setPage(page);
|
||||
datasourceRequest.setFetchSize(Integer.parseInt(dataSetTableRequest.getRow()));
|
||||
@ -484,7 +535,7 @@ public class DataSetTableService {
|
||||
}
|
||||
|
||||
try {
|
||||
datasourceRequest.setQuery(qp.createQueryTableWithLimit(table, fields, Integer.valueOf(dataSetTableRequest.getRow()), false, ds));
|
||||
datasourceRequest.setQuery(qp.createQueryTableWithLimit(table, fields, Integer.valueOf(dataSetTableRequest.getRow()), false, ds, customFilter));
|
||||
datasourceRequest.setPageable(false);
|
||||
dataSetPreviewPage.setTotal(datasourceProvider.getData(datasourceRequest).size());
|
||||
} catch (Exception e) {
|
||||
@ -502,7 +553,7 @@ public class DataSetTableService {
|
||||
datasourceRequest.setDatasource(ds);
|
||||
String table = DorisTableUtils.dorisName(dataSetTableRequest.getId());
|
||||
QueryProvider qp = ProviderFactory.getQueryProvider(ds.getType());
|
||||
datasourceRequest.setQuery(qp.createQueryTableWithPage(table, fields, page, pageSize, realSize, false, ds));
|
||||
datasourceRequest.setQuery(qp.createQueryTableWithPage(table, fields, page, pageSize, realSize, false, ds, customFilter));
|
||||
map.put("sql", datasourceRequest.getQuery());
|
||||
try {
|
||||
data.addAll(jdbcProvider.getData(datasourceRequest));
|
||||
@ -511,7 +562,7 @@ public class DataSetTableService {
|
||||
DEException.throwException(Translator.get("i18n_ds_error"));
|
||||
}
|
||||
try {
|
||||
datasourceRequest.setQuery(qp.createQueryTableWithLimit(table, fields, Integer.valueOf(dataSetTableRequest.getRow()), false, ds));
|
||||
datasourceRequest.setQuery(qp.createQueryTableWithLimit(table, fields, Integer.valueOf(dataSetTableRequest.getRow()), false, ds, customFilter));
|
||||
dataSetPreviewPage.setTotal(jdbcProvider.getData(datasourceRequest).size());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
@ -531,7 +582,7 @@ public class DataSetTableService {
|
||||
|
||||
String sql = dataTableInfoDTO.getSql();
|
||||
QueryProvider qp = ProviderFactory.getQueryProvider(ds.getType());
|
||||
datasourceRequest.setQuery(qp.createQuerySQLWithPage(sql, fields, page, pageSize, realSize, false));
|
||||
datasourceRequest.setQuery(qp.createQuerySQLWithPage(sql, fields, page, pageSize, realSize, false, customFilter));
|
||||
map.put("sql", datasourceRequest.getQuery());
|
||||
datasourceRequest.setPage(page);
|
||||
datasourceRequest.setFetchSize(Integer.parseInt(dataSetTableRequest.getRow()));
|
||||
@ -547,7 +598,7 @@ public class DataSetTableService {
|
||||
}
|
||||
try {
|
||||
datasourceRequest.setPageable(false);
|
||||
datasourceRequest.setQuery(qp.createQuerySqlWithLimit(sql, fields, Integer.valueOf(dataSetTableRequest.getRow()), false));
|
||||
datasourceRequest.setQuery(qp.createQuerySqlWithLimit(sql, fields, Integer.valueOf(dataSetTableRequest.getRow()), false, customFilter));
|
||||
dataSetPreviewPage.setTotal(datasourceProvider.getData(datasourceRequest).size());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
@ -564,7 +615,7 @@ public class DataSetTableService {
|
||||
datasourceRequest.setDatasource(ds);
|
||||
String table = DorisTableUtils.dorisName(dataSetTableRequest.getId());
|
||||
QueryProvider qp = ProviderFactory.getQueryProvider(ds.getType());
|
||||
datasourceRequest.setQuery(qp.createQueryTableWithPage(table, fields, page, pageSize, realSize, false, ds));
|
||||
datasourceRequest.setQuery(qp.createQueryTableWithPage(table, fields, page, pageSize, realSize, false, ds, customFilter));
|
||||
map.put("sql", datasourceRequest.getQuery());
|
||||
try {
|
||||
data.addAll(jdbcProvider.getData(datasourceRequest));
|
||||
@ -573,7 +624,7 @@ public class DataSetTableService {
|
||||
DEException.throwException(Translator.get("i18n_ds_error"));
|
||||
}
|
||||
try {
|
||||
datasourceRequest.setQuery(qp.createQueryTableWithLimit(table, fields, Integer.valueOf(dataSetTableRequest.getRow()), false, ds));
|
||||
datasourceRequest.setQuery(qp.createQueryTableWithLimit(table, fields, Integer.valueOf(dataSetTableRequest.getRow()), false, ds, customFilter));
|
||||
dataSetPreviewPage.setTotal(jdbcProvider.getData(datasourceRequest).size());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
@ -591,7 +642,7 @@ public class DataSetTableService {
|
||||
datasourceRequest.setDatasource(ds);
|
||||
String table = DorisTableUtils.dorisName(dataSetTableRequest.getId());
|
||||
QueryProvider qp = ProviderFactory.getQueryProvider(ds.getType());
|
||||
datasourceRequest.setQuery(qp.createQueryTableWithPage(table, fields, page, pageSize, realSize, false, ds));
|
||||
datasourceRequest.setQuery(qp.createQueryTableWithPage(table, fields, page, pageSize, realSize, false, ds, customFilter));
|
||||
map.put("sql", datasourceRequest.getQuery());
|
||||
try {
|
||||
data.addAll(jdbcProvider.getData(datasourceRequest));
|
||||
@ -600,7 +651,7 @@ public class DataSetTableService {
|
||||
DEException.throwException(Translator.get("i18n_ds_error"));
|
||||
}
|
||||
try {
|
||||
datasourceRequest.setQuery(qp.createQueryTableWithLimit(table, fields, Integer.valueOf(dataSetTableRequest.getRow()), false, ds));
|
||||
datasourceRequest.setQuery(qp.createQueryTableWithLimit(table, fields, Integer.valueOf(dataSetTableRequest.getRow()), false, ds, customFilter));
|
||||
dataSetPreviewPage.setTotal(jdbcProvider.getData(datasourceRequest).size());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
@ -627,7 +678,7 @@ public class DataSetTableService {
|
||||
DEException.throwException(Translator.get("i18n_ds_error"));
|
||||
}
|
||||
QueryProvider qp = ProviderFactory.getQueryProvider(ds.getType());
|
||||
datasourceRequest.setQuery(qp.createQuerySQLWithPage(sql, fields, page, pageSize, realSize, false));
|
||||
datasourceRequest.setQuery(qp.createQuerySQLWithPage(sql, fields, page, pageSize, realSize, false, customFilter));
|
||||
map.put("sql", datasourceRequest.getQuery());
|
||||
datasourceRequest.setPage(page);
|
||||
datasourceRequest.setFetchSize(Integer.parseInt(dataSetTableRequest.getRow()));
|
||||
@ -643,7 +694,7 @@ public class DataSetTableService {
|
||||
}
|
||||
try {
|
||||
datasourceRequest.setPageable(false);
|
||||
datasourceRequest.setQuery(qp.createQuerySqlWithLimit(sql, fields, Integer.valueOf(dataSetTableRequest.getRow()), false));
|
||||
datasourceRequest.setQuery(qp.createQuerySqlWithLimit(sql, fields, Integer.valueOf(dataSetTableRequest.getRow()), false, customFilter));
|
||||
dataSetPreviewPage.setTotal(datasourceProvider.getData(datasourceRequest).size());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
@ -656,7 +707,7 @@ public class DataSetTableService {
|
||||
datasourceRequest.setDatasource(ds);
|
||||
String table = DorisTableUtils.dorisName(dataSetTableRequest.getId());
|
||||
QueryProvider qp = ProviderFactory.getQueryProvider(ds.getType());
|
||||
datasourceRequest.setQuery(qp.createQueryTableWithPage(table, fields, page, pageSize, realSize, false, ds));
|
||||
datasourceRequest.setQuery(qp.createQueryTableWithPage(table, fields, page, pageSize, realSize, false, ds, customFilter));
|
||||
map.put("sql", datasourceRequest.getQuery());
|
||||
try {
|
||||
data.addAll(jdbcProvider.getData(datasourceRequest));
|
||||
@ -666,7 +717,7 @@ public class DataSetTableService {
|
||||
}
|
||||
|
||||
try {
|
||||
datasourceRequest.setQuery(qp.createQueryTableWithLimit(table, fields, Integer.valueOf(dataSetTableRequest.getRow()), false, ds));
|
||||
datasourceRequest.setQuery(qp.createQueryTableWithLimit(table, fields, Integer.valueOf(dataSetTableRequest.getRow()), false, ds, customFilter));
|
||||
dataSetPreviewPage.setTotal(jdbcProvider.getData(datasourceRequest).size());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
@ -693,7 +744,7 @@ public class DataSetTableService {
|
||||
DEException.throwException(Translator.get("i18n_ds_error"));
|
||||
}
|
||||
QueryProvider qp = ProviderFactory.getQueryProvider(ds.getType());
|
||||
datasourceRequest.setQuery(qp.createQuerySQLWithPage(sql, fields, page, pageSize, realSize, false));
|
||||
datasourceRequest.setQuery(qp.createQuerySQLWithPage(sql, fields, page, pageSize, realSize, false, customFilter));
|
||||
map.put("sql", datasourceRequest.getQuery());
|
||||
datasourceRequest.setPage(page);
|
||||
datasourceRequest.setFetchSize(Integer.parseInt(dataSetTableRequest.getRow()));
|
||||
@ -709,7 +760,7 @@ public class DataSetTableService {
|
||||
}
|
||||
try {
|
||||
datasourceRequest.setPageable(false);
|
||||
datasourceRequest.setQuery(qp.createQuerySqlWithLimit(sql, fields, Integer.valueOf(dataSetTableRequest.getRow()), false));
|
||||
datasourceRequest.setQuery(qp.createQuerySqlWithLimit(sql, fields, Integer.valueOf(dataSetTableRequest.getRow()), false, customFilter));
|
||||
dataSetPreviewPage.setTotal(datasourceProvider.getData(datasourceRequest).size());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
@ -722,7 +773,7 @@ public class DataSetTableService {
|
||||
datasourceRequest.setDatasource(ds);
|
||||
String table = DorisTableUtils.dorisName(dataSetTableRequest.getId());
|
||||
QueryProvider qp = ProviderFactory.getQueryProvider(ds.getType());
|
||||
datasourceRequest.setQuery(qp.createQueryTableWithPage(table, fields, page, pageSize, realSize, false, ds));
|
||||
datasourceRequest.setQuery(qp.createQueryTableWithPage(table, fields, page, pageSize, realSize, false, ds, customFilter));
|
||||
map.put("sql", datasourceRequest.getQuery());
|
||||
try {
|
||||
data.addAll(jdbcProvider.getData(datasourceRequest));
|
||||
@ -732,7 +783,7 @@ public class DataSetTableService {
|
||||
}
|
||||
|
||||
try {
|
||||
datasourceRequest.setQuery(qp.createQueryTableWithLimit(table, fields, Integer.valueOf(dataSetTableRequest.getRow()), false, ds));
|
||||
datasourceRequest.setQuery(qp.createQueryTableWithLimit(table, fields, Integer.valueOf(dataSetTableRequest.getRow()), false, ds, customFilter));
|
||||
dataSetPreviewPage.setTotal(jdbcProvider.getData(datasourceRequest).size());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
@ -1636,6 +1687,7 @@ public class DataSetTableService {
|
||||
dataSetDetail.setTable(table);
|
||||
if (ObjectUtils.isNotEmpty(table)) {
|
||||
Datasource datasource = datasourceMapper.selectByPrimaryKey(table.getDataSourceId());
|
||||
Optional.ofNullable(datasource).orElse(new Datasource()).setConfiguration(null);
|
||||
dataSetDetail.setDatasource(datasource);
|
||||
}
|
||||
return dataSetDetail;
|
||||
|
@ -5,6 +5,7 @@ import io.dataease.base.domain.DatasetTable;
|
||||
import io.dataease.base.domain.DatasetTableField;
|
||||
import io.dataease.base.domain.Datasource;
|
||||
import io.dataease.commons.utils.CommonBeanFactory;
|
||||
import io.dataease.dto.chart.ChartCustomFilterDTO;
|
||||
import io.dataease.provider.datasource.DatasourceProvider;
|
||||
import io.dataease.provider.ProviderFactory;
|
||||
import io.dataease.controller.request.datasource.DatasourceRequest;
|
||||
@ -41,8 +42,6 @@ public class DirectFieldService implements DataSetFieldService {
|
||||
|
||||
@Override
|
||||
public List<Object> fieldValues(String fieldId) {
|
||||
|
||||
|
||||
List<DatasetTableField> list = dataSetTableFieldsService.getListByIds(new ArrayList<String>() {{
|
||||
add(fieldId);
|
||||
}});
|
||||
@ -51,9 +50,14 @@ public class DirectFieldService implements DataSetFieldService {
|
||||
DatasetTableField field = list.get(0);
|
||||
String tableId = field.getTableId();
|
||||
if (StringUtils.isEmpty(tableId)) return null;
|
||||
|
||||
DatasetTable datasetTable = dataSetTableService.get(tableId);
|
||||
if (ObjectUtils.isEmpty(datasetTable) || StringUtils.isEmpty(datasetTable.getName())) return null;
|
||||
String tableName = datasetTable.getName();
|
||||
String tableName;
|
||||
|
||||
DatasetTableField datasetTableField = DatasetTableField.builder().tableId(tableId).checked(Boolean.TRUE).build();
|
||||
List<DatasetTableField> fields = dataSetTableFieldsService.list(datasetTableField);
|
||||
List<ChartCustomFilterDTO> customFilter = dataSetTableService.getCustomFilters(fields, datasetTable);
|
||||
|
||||
DatasourceRequest datasourceRequest = new DatasourceRequest();
|
||||
DatasourceProvider datasourceProvider = null;
|
||||
@ -67,18 +71,18 @@ public class DirectFieldService implements DataSetFieldService {
|
||||
QueryProvider qp = ProviderFactory.getQueryProvider(ds.getType());
|
||||
if (StringUtils.equalsIgnoreCase(datasetTable.getType(), "db")) {
|
||||
datasourceRequest.setTable(dataTableInfoDTO.getTable());
|
||||
datasourceRequest.setQuery(qp.createQuerySQL(dataTableInfoDTO.getTable(), Collections.singletonList(field), true, ds));
|
||||
datasourceRequest.setQuery(qp.createQuerySQL(dataTableInfoDTO.getTable(), Collections.singletonList(field), true, ds, customFilter));
|
||||
} else if (StringUtils.equalsIgnoreCase(datasetTable.getType(), "sql")) {
|
||||
datasourceRequest.setQuery(qp.createQuerySQLAsTmp(dataTableInfoDTO.getSql(), Collections.singletonList(field), true));
|
||||
datasourceRequest.setQuery(qp.createQuerySQLAsTmp(dataTableInfoDTO.getSql(), Collections.singletonList(field), true, customFilter));
|
||||
} else if (StringUtils.equalsIgnoreCase(datasetTable.getType(), "custom")) {
|
||||
DataTableInfoDTO dt = new Gson().fromJson(datasetTable.getInfo(), DataTableInfoDTO.class);
|
||||
List<DataSetTableUnionDTO> listUnion = dataSetTableUnionService.listByTableId(dt.getList().get(0).getTableId());
|
||||
String sql = dataSetTableService.getCustomSQLDatasource(dt, listUnion, ds);
|
||||
datasourceRequest.setQuery(qp.createQuerySQLAsTmp(sql, Collections.singletonList(field), true));
|
||||
datasourceRequest.setQuery(qp.createQuerySQLAsTmp(sql, Collections.singletonList(field), true, customFilter));
|
||||
} else if (StringUtils.equalsIgnoreCase(datasetTable.getType(), "union")) {
|
||||
DataTableInfoDTO dt = new Gson().fromJson(datasetTable.getInfo(), DataTableInfoDTO.class);
|
||||
String sql = (String) dataSetTableService.getUnionSQLDatasource(dt, ds).get("sql");
|
||||
datasourceRequest.setQuery(qp.createQuerySQLAsTmp(sql, Collections.singletonList(field), true));
|
||||
datasourceRequest.setQuery(qp.createQuerySQLAsTmp(sql, Collections.singletonList(field), true, customFilter));
|
||||
}
|
||||
} else if (datasetTable.getMode() == 1) {// 抽取
|
||||
// 连接doris,构建doris数据源查询
|
||||
@ -89,7 +93,7 @@ public class DirectFieldService implements DataSetFieldService {
|
||||
tableName = "ds_" + datasetTable.getId().replaceAll("-", "_");
|
||||
datasourceRequest.setTable(tableName);
|
||||
QueryProvider qp = ProviderFactory.getQueryProvider(ds.getType());
|
||||
datasourceRequest.setQuery(qp.createQuerySQL(tableName, Collections.singletonList(field), true, null));
|
||||
datasourceRequest.setQuery(qp.createQuerySQL(tableName, Collections.singletonList(field), true, null, customFilter));
|
||||
}
|
||||
|
||||
try {
|
||||
|
File diff suppressed because one or more lines are too long
10
backend/src/main/resources/db/migration/V29__de1.6.sql
Normal file
10
backend/src/main/resources/db/migration/V29__de1.6.sql
Normal file
@ -0,0 +1,10 @@
|
||||
CREATE TABLE `dataset_row_permissions` (
|
||||
`id` varchar(64) NOT NULL COMMENT 'File ID',
|
||||
`auth_target_type` varchar(255) DEFAULT NULL COMMENT '权限类型:组织/角色/用户',
|
||||
`auth_target_id` bigint(20) DEFAULT NULL COMMENT '权限对象ID',
|
||||
`dataset_id` varchar(64) DEFAULT NULL COMMENT '数据集ID',
|
||||
`dataset_field_id` varchar(64) DEFAULT NULL COMMENT '数据集字段ID',
|
||||
`filter` longtext DEFAULT NULL COMMENT '数值',
|
||||
`update_time` bigint(13) NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
)ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_general_ci;
|
@ -5,7 +5,6 @@
|
||||
<!--配置数据库连接的位置-->
|
||||
<properties url="file:///opt/dataease/conf/dataease.properties"/>
|
||||
<!-- 设置mysql驱动路径 -->
|
||||
<!--<classPathEntry location="/Users/liuruibin/.m2/repository/mysql/mysql-connector-java/5.1.34/mysql-connector-java-5.1.34.jar"/>-->
|
||||
<!-- 此处指定生成针对MyBatis3的DAO -->
|
||||
<context id="mysql" targetRuntime="MyBatis3">
|
||||
<!-- 字段带`,解决列表跟关键字冲突问题 -->
|
||||
@ -37,8 +36,6 @@
|
||||
</commentGenerator>
|
||||
|
||||
<!-- jdbc连接信息 --> <!-- EduLoanManage EduTestDataBase -->
|
||||
<!--<jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://192.168.20.180:3306/fit2cloud"-->
|
||||
<!--userId="root" password="Fit2cloud2015!" />-->
|
||||
<jdbcConnection driverClass="com.mysql.cj.jdbc.Driver"
|
||||
connectionURL="${spring.datasource.url}&nullCatalogMeansCurrent=true"
|
||||
userId="${spring.datasource.username}" password="${spring.datasource.password}"/>
|
||||
@ -63,9 +60,9 @@
|
||||
</javaClientGenerator>
|
||||
|
||||
<!--要生成的数据库表 -->
|
||||
|
||||
|
||||
<table tableName="v_auth_model"/>
|
||||
<table tableName="dataset_row_permissions">
|
||||
<columnOverride column="filter" javaType="java.lang.String" jdbcType="VARCHAR" />
|
||||
</table>
|
||||
|
||||
|
||||
</context>
|
||||
|
@ -290,3 +290,4 @@ i18n_dataset_field_delete=该自定义数据集有关联字段被删除,请重
|
||||
i18n_es_limit=Elasticsearch 版本不能小于6.3
|
||||
i18n_ds_error=预览数据错误:执行SQL失败。可能因相关字段、表、数据集等元素发生变更,请检查
|
||||
i18n_union_ds_no_checked=当前关联数据集,无选中字段,请重新编辑
|
||||
i18n_auth_row_permission=行权限
|
@ -164,4 +164,13 @@ export function datasetTaskList(page, size, data, loading) {
|
||||
})
|
||||
}
|
||||
|
||||
export function datasetRowPermissionsList(datasetId, page, size, data, loading) {
|
||||
return request({
|
||||
url: '/dataset/rowpermissions/pageList/' + datasetId + '/' + page + '/' + size,
|
||||
method: 'post',
|
||||
data,
|
||||
loading: loading
|
||||
})
|
||||
}
|
||||
|
||||
export default { loadTable, getScene, addGroup, delGroup, addTable, delTable, groupTree }
|
||||
|
@ -1173,6 +1173,16 @@ export default {
|
||||
confirm_sync_field_tips: 'Sync field maybe change edit field,please confirm',
|
||||
sync_success: 'Success',
|
||||
sync_success_1: 'Success,please sync data again',
|
||||
row_permission: {
|
||||
type: 'Type',
|
||||
name: 'Name',
|
||||
condition: 'Conditions',
|
||||
value: 'Value',
|
||||
add: 'Add row permissions',
|
||||
edit: 'Edit row permissions',
|
||||
please_select_field: 'Please select a field'
|
||||
},
|
||||
row_permissions: 'Row Permissions',
|
||||
union_data: 'Union Dataset',
|
||||
add_union_table: 'Add Union Dataset',
|
||||
edit_union: 'Edit Union Dataset',
|
||||
|
@ -1173,6 +1173,16 @@ export default {
|
||||
confirm_sync_field_tips: '同步字段可能會導致已編輯字段發生變更,請確認',
|
||||
sync_success: '同步成功',
|
||||
sync_success_1: '同步成功,請對當前數據集重新執行數據同步操作',
|
||||
row_permission: {
|
||||
type: '類型',
|
||||
name: '名稱',
|
||||
condition: '條件',
|
||||
value: '值',
|
||||
add: '添加行權限',
|
||||
edit: '編輯行權限',
|
||||
please_select_field: '請選擇字段'
|
||||
},
|
||||
row_permissions: '行權限',
|
||||
union_data: '關聯數據集',
|
||||
add_union_table: '添加關聯數據集',
|
||||
edit_union: '編輯關聯數據集',
|
||||
|
@ -1176,6 +1176,16 @@ export default {
|
||||
confirm_sync_field_tips: '同步字段可能会导致已编辑字段发生变更,请确认',
|
||||
sync_success: '同步成功',
|
||||
sync_success_1: '同步成功,请对当前数据集重新执行数据同步操作',
|
||||
row_permission: {
|
||||
type: '类型',
|
||||
name: '名称',
|
||||
condition: '条件',
|
||||
value: '值',
|
||||
add: '添加行权限',
|
||||
edit: '编辑行权限',
|
||||
please_select_field: '请选择字段'
|
||||
},
|
||||
row_permissions: '行权限',
|
||||
union_data: '关联数据集',
|
||||
add_union_table: '添加关联数据集',
|
||||
edit_union: '编辑关联数据集',
|
||||
|
@ -54,16 +54,6 @@ export default {
|
||||
label: this.$t('chart.filter_not_eq')
|
||||
}]
|
||||
},
|
||||
// {
|
||||
// label: '',
|
||||
// options: [{
|
||||
// value: 'like',
|
||||
// label: this.$t('chart.filter_like')
|
||||
// }, {
|
||||
// value: 'not like',
|
||||
// label: this.$t('chart.filter_not_like')
|
||||
// }]
|
||||
// },
|
||||
{
|
||||
label: '',
|
||||
options: [{
|
||||
|
@ -76,7 +76,7 @@ import FieldEdit from './FieldEdit'
|
||||
|
||||
export default {
|
||||
name: 'ViewTable',
|
||||
components: { FieldEdit, UnionView, DatasetChartDetail, UpdateInfo, TabDataPreview },
|
||||
components: {FieldEdit, UnionView, DatasetChartDetail, UpdateInfo, TabDataPreview },
|
||||
props: {
|
||||
param: {
|
||||
type: Object,
|
||||
|
226
frontend/src/views/dataset/data/authConfig.vue
Normal file
226
frontend/src/views/dataset/data/authConfig.vue
Normal file
@ -0,0 +1,226 @@
|
||||
<template>
|
||||
<de-container style="height: auto">
|
||||
<de-aside-container style="height: auto">
|
||||
<el-button v-show="!showTargetSearchInput" class="de-icon" icon="el-icon-search" circle size="mini" @click="showTargetSearchWidget" />
|
||||
<div v-show="showTargetSearchInput" class="de-input">
|
||||
<el-input v-model="targetFilterText" class="main-area-input">
|
||||
<el-button slot="append" icon="el-icon-close" @click="closeTargetSearchWidget" />
|
||||
</el-input>
|
||||
</div>
|
||||
<el-tabs v-model="targetActiveName" :class="{'de-search-header': showTargetSearchInput}" @tab-click="handleClick">
|
||||
<el-tab-pane v-for="(targetInfo, index) in targetInfoArray" :key="index" :lazy="true" :label="targetInfo.tabName" :name="targetInfo.authType">
|
||||
<lazy-tree
|
||||
v-if="targetActiveName===targetInfo.authType"
|
||||
:active-name="targetActiveName"
|
||||
:filter-text="targetFilterText"
|
||||
:data-info="targetInfo"
|
||||
highlight-current
|
||||
@nodeClick="authNodeClick"
|
||||
@execute-axios="executeAxios"
|
||||
/>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</de-aside-container>
|
||||
<de-main-container class="de-main-container-auth">
|
||||
<el-button v-show="!showSourceSearchInput" class="de-icon" icon="el-icon-search" circle size="mini" @click="showSourceSearchWidget" />
|
||||
<div v-show="showSourceSearchInput" class="de-input">
|
||||
<el-input v-model="sourceFilterText" class="main-area-input">
|
||||
<el-button slot="append" icon="el-icon-close" @click="closeSourceSearchWidget" />
|
||||
</el-input>
|
||||
</div>
|
||||
<el-tabs v-model="sourceActiveName" :class="{'de-search-header': showSourceSearchInput}" @tab-click="handleClick">
|
||||
<el-tab-pane v-for="(sourceInfo, index) in sourceInfoTabs" :key="index" :lazy="true" :label="sourceInfo.tabName" :name="sourceInfo.authType">
|
||||
<lazy-tree
|
||||
v-if="authCondition"
|
||||
:active-name="sourceActiveName"
|
||||
:filter-text="sourceFilterText"
|
||||
:data-info="sourceInfo"
|
||||
show-extent
|
||||
:auth-condition="authCondition"
|
||||
@execute-axios="executeAxios"
|
||||
:attach-active-name="targetActiveName"
|
||||
/>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</de-main-container>
|
||||
</de-container>
|
||||
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import DeContainer from '@/components/dataease/DeContainer'
|
||||
import DeAsideContainer from '@/components/dataease/DeAsideContainer'
|
||||
import DeMainContainer from '@/components/dataease/DeMainContainer'
|
||||
import LazyTree from './components/LazyTree'
|
||||
|
||||
export default {
|
||||
name: 'Authority',
|
||||
components: { LazyTree, DeMainContainer, DeAsideContainer, DeContainer },
|
||||
props: {
|
||||
resourceId: {
|
||||
type: String,
|
||||
default: null
|
||||
}
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
targetInfoArray:
|
||||
[
|
||||
{
|
||||
tabName: this.$t('auth.dept'),
|
||||
head: this.$t('auth.deptHead'),
|
||||
direction: 'target',
|
||||
authType: 'dept'
|
||||
},
|
||||
{
|
||||
tabName: this.$t('auth.role'),
|
||||
head: this.$t('auth.roleHead'),
|
||||
direction: 'target',
|
||||
authType: 'role'
|
||||
},
|
||||
{
|
||||
tabName: this.$t('auth.user'),
|
||||
head: this.$t('auth.userHead'),
|
||||
direction: 'target',
|
||||
authType: 'user'
|
||||
}],
|
||||
sourceInfoArray:
|
||||
[
|
||||
{
|
||||
tabName: this.$t('auth.linkAuth'),
|
||||
head: this.$t('auth.linkAuthHead'),
|
||||
direction: 'source',
|
||||
authType: 'link',
|
||||
authTargets: 'dept,role,user'
|
||||
},
|
||||
{
|
||||
tabName: this.$t('auth.datasetAuth'),
|
||||
head: this.$t('auth.datasetAuthHead'),
|
||||
direction: 'source',
|
||||
authType: 'dataset',
|
||||
authTargets: 'dept,role,user'
|
||||
},
|
||||
{
|
||||
tabName: this.$t('auth.chartAuth'),
|
||||
head: this.$t('auth.chartAuthHead'),
|
||||
direction: 'source',
|
||||
authType: 'chart',
|
||||
authTargets: 'dept,role,user'
|
||||
},
|
||||
{
|
||||
tabName: this.$t('auth.panelAuth'),
|
||||
head: this.$t('auth.panelAuthHead'),
|
||||
direction: 'source',
|
||||
authType: 'panel',
|
||||
authTargets: 'dept,role,user'
|
||||
},
|
||||
{
|
||||
tabName: this.$t('auth.menuAuth'),
|
||||
head: this.$t('auth.menuAuthHead'),
|
||||
direction: 'source',
|
||||
authType: 'menu',
|
||||
authTargets: 'dept,role,user'
|
||||
}
|
||||
],
|
||||
targetActiveName: null,
|
||||
sourceActiveName: null,
|
||||
showSourceSearchInput: false,
|
||||
showTargetSearchInput: false,
|
||||
sourceFilterText: '',
|
||||
targetFilterText: '',
|
||||
timeMachine: null,
|
||||
authCondition: null
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
sourceInfoTabs () {
|
||||
const tabs = []
|
||||
this.sourceInfoArray.forEach(item => {
|
||||
if (item.authTargets.indexOf(this.targetActiveName) > -1) {
|
||||
tabs.push(item)
|
||||
}
|
||||
})
|
||||
return tabs
|
||||
}
|
||||
},
|
||||
created () {
|
||||
this.targetActiveName = this.targetInfoArray[0].authType
|
||||
this.sourceActiveName = this.sourceInfoArray[0].authType
|
||||
},
|
||||
|
||||
methods: {
|
||||
executeAxios (param) {
|
||||
this.$emit('execute-axios', param)
|
||||
},
|
||||
handleClick (tab, event) {
|
||||
},
|
||||
showSourceSearchWidget () {
|
||||
this.showSourceSearchInput = true
|
||||
},
|
||||
closeSourceSearchWidget () {
|
||||
this.sourceFilterText = ''
|
||||
this.showSourceSearchInput = false
|
||||
},
|
||||
showTargetSearchWidget () {
|
||||
this.showTargetSearchInput = true
|
||||
},
|
||||
closeTargetSearchWidget () {
|
||||
this.targetFilterText = ''
|
||||
this.showTargetSearchInput = false
|
||||
},
|
||||
save () {
|
||||
this.$refs[this.activeName].save()
|
||||
this.$emit('close-grant', 0)
|
||||
},
|
||||
cancel () {
|
||||
this.$refs[this.activeName].cancel()
|
||||
this.$emit('close-grant', 0)
|
||||
},
|
||||
authNodeClick (val) {
|
||||
console.log('authNodeClick')
|
||||
this.authCondition = val
|
||||
},
|
||||
clickAuth (auth) {
|
||||
console.log('clickAuth')
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.de-tab {
|
||||
border:1px solid #E6E6E6;
|
||||
min-height:200px !important;
|
||||
max-height:300px !important;
|
||||
overflow:auto;
|
||||
}
|
||||
.de-icon {
|
||||
position: absolute;
|
||||
right: 10px;
|
||||
top: 15px;
|
||||
z-index: 99;
|
||||
}
|
||||
.el-input-group__append{
|
||||
background-color: #ffffff;
|
||||
}
|
||||
.el-input__inner{
|
||||
border-right: none;
|
||||
}
|
||||
|
||||
.auth-root-class {
|
||||
margin: 15px 0px 5px;
|
||||
text-align: right;
|
||||
}
|
||||
.de-main-container-auth{
|
||||
border: 1px solid #E6E6E6;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
.blackTheme .de-main-container-auth {
|
||||
border-color: #495865;
|
||||
}
|
||||
|
||||
// ::-webkit-scrollbar {
|
||||
|
||||
// }
|
||||
</style>
|
373
frontend/src/views/dataset/data/components/LazyTree.vue
Normal file
373
frontend/src/views/dataset/data/components/LazyTree.vue
Normal file
@ -0,0 +1,373 @@
|
||||
<template xmlns:el-col="http://www.w3.org/1999/html">
|
||||
<el-col v-loading="loading" class="tree-main">
|
||||
<el-row v-if="showExtent" class="tree-head">
|
||||
<span style="float: left;padding-left: 10px">{{ dataInfo.head }}</span>
|
||||
<span v-for="auth in defaultAuthDetails" :key="auth.privilegeName" class="auth-span">
|
||||
{{ auth.privilegeName }}
|
||||
</span>
|
||||
</el-row>
|
||||
<el-row style="margin-top: 5px">
|
||||
<el-tree
|
||||
:props="defaultProps"
|
||||
:load="loadNodes"
|
||||
:data="treeData"
|
||||
:node-key="defaultProps.id"
|
||||
:highlight-current="highlightCurrent"
|
||||
:default-expanded-keys="expandedKey"
|
||||
lazy
|
||||
@node-click="nodeClick"
|
||||
>
|
||||
<span slot-scope="{ node, data }" class="custom-tree-node">
|
||||
<span>
|
||||
<span style="margin-left: 6px" v-html="data.name" />
|
||||
</span>
|
||||
<span v-if="showExtent" @click.stop>
|
||||
<div v-if="authDetails[data.id]">
|
||||
<span v-for="auth in authDetails[data.id]" :key="auth.privilegeType" class="auth-span">
|
||||
<!-- 1-{{ auth.privilegeType }}-{{ auth.privilegeValue }}-->
|
||||
<a href="javascript:;" @click="clickAuth(data.id,auth)">
|
||||
<svg-icon style="width: 25px;height: 25px" :icon-class="auth.privilegeValue===1?'lock_open':'lock_closed'" />
|
||||
</a>
|
||||
</span>
|
||||
</div>
|
||||
<div v-else>
|
||||
<span v-for="auth in defaultAuthDetails" :key="auth.privilegeType" class="auth-span">
|
||||
<!--2-{{ auth.privilegeType }}-{{ auth.privilegeValue }}-->
|
||||
<a href="javascript:;" @click="clickAuth(data.id,auth)">
|
||||
<svg-icon style="width: 25px;height: 25px" :icon-class="auth.privilegeValue===1?'lock_open':'lock_closed'" />
|
||||
</a>
|
||||
</span>
|
||||
</div></span>
|
||||
</span>
|
||||
</el-tree>
|
||||
</el-row>
|
||||
</el-col>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
// import { authChange, authDetails, authDetailsModel, authModel } from '@/api/system/sysAuth'
|
||||
// import { execute } from '@/de-base/api/de-api'
|
||||
export default {
|
||||
name: 'LazyTree',
|
||||
components: { },
|
||||
props: {
|
||||
filterText: {
|
||||
type: String,
|
||||
required: false,
|
||||
default: ''
|
||||
},
|
||||
authCondition: {
|
||||
type: Object,
|
||||
required: false
|
||||
},
|
||||
dataInfo: {
|
||||
type: Object,
|
||||
required: true
|
||||
},
|
||||
activeName: {
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
attachActiveName: String,
|
||||
defaultProps: {
|
||||
type: Object,
|
||||
required: false,
|
||||
default: function () {
|
||||
return {
|
||||
children: 'children',
|
||||
label: 'name',
|
||||
id: 'id',
|
||||
parentId: 'pid',
|
||||
isLeaf: 'leaf'
|
||||
}
|
||||
}
|
||||
},
|
||||
showExtent: Boolean,
|
||||
highlightCurrent: Boolean
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
loading: false,
|
||||
treeData: [],
|
||||
changeIndex: 0,
|
||||
timeMachine: null,
|
||||
expandedKey: [], // 展开节点 搜索时默认展开父级节点
|
||||
defaultCondition: { // pid 是0的时候 查询的是顶级的节点
|
||||
pid: '0'
|
||||
},
|
||||
authDetails: {},
|
||||
defaultAuthDetails: [],
|
||||
searchStatus: false, // 当前是否在搜索状态 (搜索状态 展开不加载子节点)
|
||||
// 当前已经加载的节点ID 备用(当前把当前authTarget的所有授权加载进来)
|
||||
loadedNodeIds: new Set()
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
},
|
||||
watch: {
|
||||
filterText (val) {
|
||||
this.expandedKey = []
|
||||
if (val && val.length > 0) {
|
||||
this.searchStatus = true
|
||||
}
|
||||
// 当组件名和 activeName 相等时 才进行查询
|
||||
if (this.dataInfo.authType === this.activeName) {
|
||||
this.destroyTimeMachine()
|
||||
this.changeIndex++
|
||||
this.filterNode(this.changeIndex)
|
||||
}
|
||||
},
|
||||
authCondition: {
|
||||
handler (newVal, oldVla) {
|
||||
this.loadAuth()
|
||||
},
|
||||
deep: true
|
||||
},
|
||||
activeName: {
|
||||
handler (newVal, oldVla) {
|
||||
this.loadAuth()
|
||||
},
|
||||
deep: true
|
||||
},
|
||||
attachActiveName: {
|
||||
handler (newVal, oldVla) {
|
||||
this.authDetails = {}
|
||||
},
|
||||
deep: true
|
||||
}
|
||||
},
|
||||
created () {
|
||||
// 初始化授权模板
|
||||
if (this.showExtent) {
|
||||
this.executeAxios('/plugin/auth/authDetailsModel/' + this.dataInfo.authType, 'get', {}, res => {
|
||||
this.defaultAuthDetails = res.data
|
||||
})
|
||||
// authDetailsModel(this.dataInfo.authType).then(res => {
|
||||
// this.defaultAuthDetails = res.data
|
||||
// })
|
||||
this.loadAuth()
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
executeAxios (url, type, data, callBack) {
|
||||
const param = {
|
||||
url: url,
|
||||
type: type,
|
||||
data: data,
|
||||
callBack: callBack
|
||||
}
|
||||
this.$emit('execute-axios', param)
|
||||
// if (process.env.NODE_ENV === 'development') {
|
||||
// execute(param).then(res => {
|
||||
// if (param.callBack) {
|
||||
// param.callBack(res)
|
||||
// }
|
||||
// }).catch(e => {
|
||||
// if (param.error) {
|
||||
// param.error(e)
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
},
|
||||
loadAuth () {
|
||||
if (this.authCondition && this.showExtent) {
|
||||
let authQueryCondition = {}
|
||||
if (this.dataInfo.direction === 'source') {
|
||||
// 当前为授权数据 获取当前authTarget 的授权信息 authSource
|
||||
authQueryCondition = {
|
||||
authTarget: this.authCondition.id,
|
||||
authTargetType: this.authCondition.type,
|
||||
authSourceType: this.dataInfo.authType
|
||||
}
|
||||
} else {
|
||||
authQueryCondition = {
|
||||
authSource: this.authCondition.id,
|
||||
authSourceType: this.authCondition.type
|
||||
}
|
||||
}
|
||||
this.executeAxios('/plugin/auth/authDetails', 'post', authQueryCondition, res => {
|
||||
this.authDetails = res.data
|
||||
})
|
||||
// authDetails(authQueryCondition).then(res => {
|
||||
// this.authDetails = res.data
|
||||
// })
|
||||
}
|
||||
},
|
||||
loadNodes (node, resolve) {
|
||||
if (!this.searchStatus) {
|
||||
if (node.level === 0) {
|
||||
const queryCondition = {
|
||||
modelType: this.dataInfo.authType,
|
||||
...this.defaultCondition
|
||||
}
|
||||
this.executeAxios('/plugin/auth/authModels', 'post', queryCondition, res => {
|
||||
const data = res.data
|
||||
resolve(data)
|
||||
})
|
||||
// authModel(queryCondition).then(res => {
|
||||
// const data = res.data
|
||||
// resolve(data)
|
||||
// })
|
||||
} else {
|
||||
const queryCondition = {
|
||||
modelType: this.dataInfo.authType
|
||||
}
|
||||
queryCondition[this.defaultProps.parentId] = node.data[this.defaultProps.id]
|
||||
this.executeAxios('/plugin/auth/authModels', 'post', queryCondition, res => {
|
||||
const data = res.data
|
||||
resolve(data)
|
||||
})
|
||||
// authModel(queryCondition).then(res => {
|
||||
// const data = res.data
|
||||
// resolve(data)
|
||||
// })
|
||||
}
|
||||
} else {
|
||||
resolve(node.data.children)
|
||||
}
|
||||
},
|
||||
filterNode (index) {
|
||||
this.timeMachine = setTimeout(() => {
|
||||
if (index === this.changeIndex) {
|
||||
const queryCondition = {
|
||||
withExtend: 'parent',
|
||||
modelType: this.dataInfo.authType
|
||||
}
|
||||
queryCondition[this.defaultProps.label] = this.filterText
|
||||
this.executeAxios('/plugin/auth/authModels', 'post', queryCondition, res => {
|
||||
// 高亮显示
|
||||
this.highlights(res.data)
|
||||
this.treeData = this.buildTree(res.data)
|
||||
// 恢复searchStatus 状态 可以允许继续展开父级
|
||||
this.$nextTick(() => (this.searchStatus = false))
|
||||
})
|
||||
// authModel(queryCondition).then(res => {
|
||||
// // 高亮显示
|
||||
// this.highlights(res.data)
|
||||
// this.treeData = this.buildTree(res.data)
|
||||
// // 恢复searchStatus 状态 可以允许继续展开父级
|
||||
// this.$nextTick(() => (this.searchStatus = false))
|
||||
// })
|
||||
}
|
||||
this.destroyTimeMachine()
|
||||
}, 1500)
|
||||
},
|
||||
nodeClick (data, node) {
|
||||
this.$emit('nodeClick', { id: data.id, type: this.dataInfo.authType })
|
||||
},
|
||||
destroyTimeMachine () {
|
||||
this.timeMachine && clearTimeout(this.timeMachine)
|
||||
this.timeMachine = null
|
||||
},
|
||||
buildTree (arrs) {
|
||||
const idMapping = arrs.reduce((acc, el, i) => {
|
||||
acc[el[this.defaultProps.id]] = i
|
||||
return acc
|
||||
}, {})
|
||||
const roots = []
|
||||
arrs.forEach(el => {
|
||||
// 判断根节点 ###
|
||||
if (el[this.defaultProps.parentId] === null || el[this.defaultProps.parentId] === 0 || el[this.defaultProps.parentId] === '0') {
|
||||
roots.push(el)
|
||||
return
|
||||
}
|
||||
// 用映射表找到父元素
|
||||
const parentEl = arrs[idMapping[el[this.defaultProps.parentId]]]
|
||||
// 把当前元素添加到父元素的`children`数组中
|
||||
parentEl.children = [...(parentEl.children || []), el]
|
||||
|
||||
// 设置展开节点 如果没有子节点则不进行展开
|
||||
if (parentEl.children.length > 0) {
|
||||
this.expandedKey.push(parentEl[this.defaultProps.id])
|
||||
}
|
||||
})
|
||||
return roots
|
||||
},
|
||||
// 权限修改
|
||||
clickAuth (dataId, auth) {
|
||||
let authChangeCondition = {}
|
||||
if (this.dataInfo.direction === 'source') { // 当前为授权数据
|
||||
authChangeCondition = {
|
||||
authSource: dataId,
|
||||
authSourceType: this.dataInfo.authType,
|
||||
authTarget: this.authCondition.id,
|
||||
authTargetType: this.authCondition.type,
|
||||
authDetail: auth
|
||||
|
||||
}
|
||||
} else {
|
||||
authChangeCondition = {
|
||||
authTarget: dataId,
|
||||
authTargetType: this.dataInfo.authType,
|
||||
authSource: this.authCondition.id,
|
||||
authSourceType: this.authCondition.type,
|
||||
authDetail: auth
|
||||
}
|
||||
}
|
||||
this.loading = true
|
||||
this.executeAxios('/plugin/auth/authChange', 'post', authChangeCondition, res => {
|
||||
// 重新加载权限
|
||||
this.loadAuth()
|
||||
this.loading = false
|
||||
})
|
||||
},
|
||||
// 高亮显示搜索内容
|
||||
highlights (data) {
|
||||
if (data && this.filterText && this.filterText.length > 0) {
|
||||
const replaceReg = new RegExp(this.filterText, 'g')// 匹配关键字正则
|
||||
const replaceString = '<span style="color: #faaa39">' + this.filterText + '</span>' // 高亮替换v-html值
|
||||
data.forEach(item => {
|
||||
item.name = item.name.replace(replaceReg, replaceString) // 开始替换
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.custom-tree-node {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
font-size: 14px;
|
||||
padding-left: 8px;
|
||||
}
|
||||
.tree-main{
|
||||
height: calc(100vh - 210px);
|
||||
border: 1px solid #e6e6e6;
|
||||
overflow-y: auto;
|
||||
}
|
||||
.blackTheme .tree-main {
|
||||
border-color: var(--TableBorderColor) !important;
|
||||
}
|
||||
/* .tree-head{
|
||||
height: 30px;
|
||||
line-height: 30px;
|
||||
border-bottom: 1px solid #e6e6e6;
|
||||
background-color: #f7f8fa;
|
||||
font-size: 12px;
|
||||
color: #3d4d66 ;
|
||||
} */
|
||||
|
||||
.tree-head{
|
||||
height: 30px;
|
||||
line-height: 30px;
|
||||
border-bottom: 1px solid var(--TableBorderColor, #e6e6e6);
|
||||
background-color: var(--SiderBG, #f7f8fa);
|
||||
font-size: 12px;
|
||||
color: var(--TableColor, #3d4d66) ;
|
||||
}
|
||||
|
||||
.auth-span{
|
||||
float: right;
|
||||
width:50px;
|
||||
margin-right: 30px
|
||||
}
|
||||
.highlights-text {
|
||||
color: #faaa39 !important;
|
||||
}
|
||||
|
||||
</style>
|
Loading…
Reference in New Issue
Block a user