Unverified Commit 96ce0252 authored by gaoyan's avatar gaoyan Committed by GitHub

Remove statements (#2377)

* fix dag npe * refactor task submit * merge dev * merge dev and formate code * fix some problem * merge dev * remove useSession * formate code * formate code * fix task vesion time * change task version create * formate code * remove statement * refactor ddl, merge statement * formate code * optimizeTheCode * formate code
parent 0ba9d2c3
...@@ -22,7 +22,6 @@ package org.dinky.assertion; ...@@ -22,7 +22,6 @@ package org.dinky.assertion;
import org.dinky.data.exception.BusException; import org.dinky.data.exception.BusException;
import org.dinky.data.model.Cluster; import org.dinky.data.model.Cluster;
import org.dinky.data.model.Jar; import org.dinky.data.model.Jar;
import org.dinky.data.model.Statement;
import org.dinky.data.model.Task; import org.dinky.data.model.Task;
/** /**
...@@ -44,12 +43,6 @@ public interface Assert { ...@@ -44,12 +43,6 @@ public interface Assert {
} }
} }
static void check(Statement statement) {
if (statement == null) {
throw new BusException("FlinkSql语句不存在");
}
}
static void checkHost(String host) { static void checkHost(String host) {
if (host == null || "".equals(host)) { if (host == null || "".equals(host)) {
throw new BusException("集群地址暂不可用"); throw new BusException("集群地址暂不可用");
......
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.dinky.controller;
import org.dinky.data.annotation.Log;
import org.dinky.data.enums.BusinessType;
import org.dinky.data.enums.Status;
import org.dinky.data.model.Statement;
import org.dinky.data.result.ProTableResult;
import org.dinky.data.result.Result;
import org.dinky.service.StatementService;
import java.util.List;
import java.util.Map;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
/**
* StatementController
*
* @since 2021/5/28 13:48
*/
@Slf4j
@RestController
@Api(tags = "Statement Controller")
@RequestMapping("/api/statement")
@RequiredArgsConstructor
public class StatementController {
private final StatementService statementService;
private final ObjectMapper objectMapper = new ObjectMapper();
/**
* Insert or update statement
*
* @param statement {@link Statement}
* @return {@link Result}<{@link Void}>
*/
@PutMapping
@ApiOperation("Insert Or Update Statement")
@Log(title = "Insert Or Update Statement", businessType = BusinessType.INSERT_OR_UPDATE)
@ApiImplicitParam(
name = "statement",
value = "Statement",
dataType = "Statement",
paramType = "body",
required = true,
dataTypeClass = Statement.class)
public Result<Void> saveOrUpdateStatement(@RequestBody Statement statement) {
if (statementService.saveOrUpdate(statement)) {
return Result.succeed(Status.SAVE_SUCCESS);
} else {
return Result.failed(Status.SAVE_FAILED);
}
}
/**
* query statement list
*
* @param para {@link JsonNode} params
* @return {@link ProTableResult}<{@link Statement}>
*/
@PostMapping
@ApiOperation("Query Statement List")
@ApiImplicitParam(name = "para", value = "Query Params", dataType = "JsonNode", paramType = "body", required = true)
public ProTableResult<Statement> listStatements(@RequestBody JsonNode para) {
return statementService.selectForProTable(para);
}
@PostMapping("/getPrintTables")
@ApiOperation("Get Print Tables")
@SuppressWarnings("unchecked")
@ApiImplicitParam(name = "statement", value = "Statement", dataType = "String", paramType = "body", required = true)
public Result<List<String>> getPrintTables(@RequestBody String statement) {
try {
Map<String, String> data = objectMapper.readValue(statement, Map.class);
String ss = data.get("statement");
return Result.succeed(statementService.getPrintTables(ss));
} catch (Exception e) {
return Result.failed(e.getMessage());
}
}
}
...@@ -34,8 +34,10 @@ import org.dinky.gateway.result.SavePointResult; ...@@ -34,8 +34,10 @@ import org.dinky.gateway.result.SavePointResult;
import org.dinky.job.JobResult; import org.dinky.job.JobResult;
import org.dinky.process.exception.ExcuteException; import org.dinky.process.exception.ExcuteException;
import org.dinky.service.TaskService; import org.dinky.service.TaskService;
import org.dinky.utils.JsonUtils;
import java.util.List; import java.util.List;
import java.util.Map;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
...@@ -172,6 +174,20 @@ public class TaskController { ...@@ -172,6 +174,20 @@ public class TaskController {
return Result.succeed(taskService.getTaskInfoById(id)); return Result.succeed(taskService.getTaskInfoById(id));
} }
@PostMapping("/getPrintTables")
@ApiOperation("Get Print Tables")
@SuppressWarnings("unchecked")
@ApiImplicitParam(name = "statement", value = "Statement", dataType = "String", paramType = "body", required = true)
public Result<List<String>> getPrintTables(@RequestBody String statement) {
try {
Map<String, String> data = JsonUtils.toMap(statement);
String ss = data.get("statement");
return Result.succeed(taskService.getPrintTables(ss));
} catch (Exception e) {
return Result.failed(e.getMessage());
}
}
@GetMapping(value = "/listFlinkSQLEnv") @GetMapping(value = "/listFlinkSQLEnv")
@ApiOperation("Get All FlinkSQLEnv") @ApiOperation("Get All FlinkSQLEnv")
public Result<List<Task>> listFlinkSQLEnv() { public Result<List<Task>> listFlinkSQLEnv() {
......
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.dinky.data.model;
import java.io.Serializable;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* Statement
*
* @since 2021/5/28 13:39
*/
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("dinky_task_statement")
@ApiModel(value = "Statement", description = "Statement Information")
public class Statement implements Serializable {
private static final long serialVersionUID = 1646348574144815792L;
@ApiModelProperty(value = "ID", dataType = "Integer", example = "1", notes = "Unique identifier for the statement")
private Integer id;
@ApiModelProperty(
value = "Tenant ID",
dataType = "Integer",
example = "1001",
notes = "ID of the tenant associated with the statement")
private Integer tenantId;
@ApiModelProperty(value = "SQL Statement", dataType = "String", notes = "SQL statement")
private String statement;
}
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.dinky.mapper;
import org.dinky.data.model.Statement;
import org.dinky.mybatis.mapper.SuperMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* StatementMapper
*
* @since 2021/5/28 13:41
*/
@Mapper
public interface StatementMapper extends SuperMapper<Statement> {}
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.dinky.service;
import org.dinky.data.model.Statement;
import org.dinky.mybatis.service.ISuperService;
import java.util.List;
/**
* StatementService
*
* @since 2021/5/28 13:45
*/
public interface StatementService extends ISuperService<Statement> {
boolean insert(Statement statement);
List<String> getPrintTables(String statement);
}
...@@ -101,4 +101,6 @@ public interface TaskService extends ISuperService<Task> { ...@@ -101,4 +101,6 @@ public interface TaskService extends ISuperService<Task> {
List<JobTypeOverView> getTaskOnlineRate(); List<JobTypeOverView> getTaskOnlineRate();
JobModelOverview getJobStreamingOrBatchModelOverview(); JobModelOverview getJobStreamingOrBatchModelOverview();
List<String> getPrintTables(String statement);
} }
...@@ -29,7 +29,6 @@ import org.dinky.data.model.Catalogue; ...@@ -29,7 +29,6 @@ import org.dinky.data.model.Catalogue;
import org.dinky.data.model.History; import org.dinky.data.model.History;
import org.dinky.data.model.JobHistory; import org.dinky.data.model.JobHistory;
import org.dinky.data.model.JobInstance; import org.dinky.data.model.JobInstance;
import org.dinky.data.model.Statement;
import org.dinky.data.model.Task; import org.dinky.data.model.Task;
import org.dinky.data.result.Result; import org.dinky.data.result.Result;
import org.dinky.mapper.CatalogueMapper; import org.dinky.mapper.CatalogueMapper;
...@@ -38,7 +37,6 @@ import org.dinky.service.CatalogueService; ...@@ -38,7 +37,6 @@ import org.dinky.service.CatalogueService;
import org.dinky.service.HistoryService; import org.dinky.service.HistoryService;
import org.dinky.service.JobHistoryService; import org.dinky.service.JobHistoryService;
import org.dinky.service.JobInstanceService; import org.dinky.service.JobInstanceService;
import org.dinky.service.StatementService;
import org.dinky.service.TaskService; import org.dinky.service.TaskService;
import java.io.BufferedReader; import java.io.BufferedReader;
...@@ -80,8 +78,6 @@ public class CatalogueServiceImpl extends SuperServiceImpl<CatalogueMapper, Cata ...@@ -80,8 +78,6 @@ public class CatalogueServiceImpl extends SuperServiceImpl<CatalogueMapper, Cata
private final JobHistoryService jobHistoryService; private final JobHistoryService jobHistoryService;
private final StatementService statementService;
/** /**
* @return * @return
*/ */
...@@ -304,13 +300,6 @@ public class CatalogueServiceImpl extends SuperServiceImpl<CatalogueMapper, Cata ...@@ -304,13 +300,6 @@ public class CatalogueServiceImpl extends SuperServiceImpl<CatalogueMapper, Cata
newTask.setStep(JobLifeCycle.DEVELOP.getValue()); newTask.setStep(JobLifeCycle.DEVELOP.getValue());
taskService.save(newTask); taskService.save(newTask);
Statement statementServiceById = statementService.getById(catalogue.getTaskId());
// 新建作业的sql语句
Statement statement = new Statement();
statement.setStatement(statementServiceById.getStatement());
statement.setId(newTask.getId());
statementService.save(statement);
Catalogue singleCatalogue = Catalogue singleCatalogue =
this.getOne(new LambdaQueryWrapper<Catalogue>().eq(Catalogue::getTaskId, catalogue.getTaskId())); this.getOne(new LambdaQueryWrapper<Catalogue>().eq(Catalogue::getTaskId, catalogue.getTaskId()));
...@@ -420,8 +409,6 @@ public class CatalogueServiceImpl extends SuperServiceImpl<CatalogueMapper, Cata ...@@ -420,8 +409,6 @@ public class CatalogueServiceImpl extends SuperServiceImpl<CatalogueMapper, Cata
// doing: cascade delete jobInstance && jobHistory && history && statement // doing: cascade delete jobInstance && jobHistory && history && statement
// 获取 task 表中的作业 // 获取 task 表中的作业
Task task = taskService.getById(catalogue.getTaskId()); Task task = taskService.getById(catalogue.getTaskId());
// 获取 statement 表中的作业
Statement statement = statementService.getById(catalogue.getTaskId());
// 获取 job instance 表中的作业 // 获取 job instance 表中的作业
List<JobInstance> jobInstanceList = jobInstanceService.list( List<JobInstance> jobInstanceList = jobInstanceService.list(
new LambdaQueryWrapper<JobInstance>().eq(JobInstance::getTaskId, catalogue.getTaskId())); new LambdaQueryWrapper<JobInstance>().eq(JobInstance::getTaskId, catalogue.getTaskId()));
...@@ -443,10 +430,6 @@ public class CatalogueServiceImpl extends SuperServiceImpl<CatalogueMapper, Cata ...@@ -443,10 +430,6 @@ public class CatalogueServiceImpl extends SuperServiceImpl<CatalogueMapper, Cata
if (task != null) { if (task != null) {
taskService.removeById(task.getId()); taskService.removeById(task.getId());
} }
// 删除 statement 表中的作业
if (statement != null) {
statementService.removeById(statement.getId());
}
} }
// 如果是文件夹 , 且下边没有子文件夹 , 则删除 // 如果是文件夹 , 且下边没有子文件夹 , 则删除
......
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.dinky.service.impl;
import org.dinky.data.model.Statement;
import org.dinky.explainer.printTable.PrintStatementExplainer;
import org.dinky.mapper.StatementMapper;
import org.dinky.mybatis.service.impl.SuperServiceImpl;
import org.dinky.parser.SqlType;
import org.dinky.service.StatementService;
import org.dinky.trans.Operations;
import org.dinky.utils.SqlUtil;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import org.springframework.stereotype.Service;
/**
* StatementServiceImpl
*
* @since 2021/5/28 13:45
*/
@Service
public class StatementServiceImpl extends SuperServiceImpl<StatementMapper, Statement> implements StatementService {
@Override
public boolean insert(Statement statement) {
return baseMapper.insert(statement) > 0;
}
@Override
public List<String> getPrintTables(String statement) {
// TODO: 2023/4/7 this function not support variable sql, because, JobManager and executor
// couple function
// and status and task execute.
final String[] statements = SqlUtil.getStatements(SqlUtil.removeNote(statement));
return Arrays.stream(statements)
.filter(t -> SqlType.PRINT.equals(Operations.getOperationType(t)))
.flatMap(t -> Arrays.stream(PrintStatementExplainer.splitTableNames(t)))
.collect(Collectors.toList());
}
}
...@@ -53,6 +53,7 @@ import org.dinky.data.model.UDFTemplate; ...@@ -53,6 +53,7 @@ import org.dinky.data.model.UDFTemplate;
import org.dinky.data.result.Result; import org.dinky.data.result.Result;
import org.dinky.data.result.ResultPool; import org.dinky.data.result.ResultPool;
import org.dinky.data.result.SqlExplainResult; import org.dinky.data.result.SqlExplainResult;
import org.dinky.explainer.printTable.PrintStatementExplainer;
import org.dinky.function.compiler.CustomStringJavaCompiler; import org.dinky.function.compiler.CustomStringJavaCompiler;
import org.dinky.function.pool.UdfCodePool; import org.dinky.function.pool.UdfCodePool;
import org.dinky.function.util.UDFUtil; import org.dinky.function.util.UDFUtil;
...@@ -68,6 +69,7 @@ import org.dinky.job.JobResult; ...@@ -68,6 +69,7 @@ import org.dinky.job.JobResult;
import org.dinky.mapper.TaskMapper; import org.dinky.mapper.TaskMapper;
import org.dinky.metadata.result.JdbcSelectResult; import org.dinky.metadata.result.JdbcSelectResult;
import org.dinky.mybatis.service.impl.SuperServiceImpl; import org.dinky.mybatis.service.impl.SuperServiceImpl;
import org.dinky.parser.SqlType;
import org.dinky.process.context.ProcessContextHolder; import org.dinky.process.context.ProcessContextHolder;
import org.dinky.process.enums.ProcessType; import org.dinky.process.enums.ProcessType;
import org.dinky.process.exception.ExcuteException; import org.dinky.process.exception.ExcuteException;
...@@ -81,14 +83,15 @@ import org.dinky.service.FragmentVariableService; ...@@ -81,14 +83,15 @@ import org.dinky.service.FragmentVariableService;
import org.dinky.service.JarService; import org.dinky.service.JarService;
import org.dinky.service.JobInstanceService; import org.dinky.service.JobInstanceService;
import org.dinky.service.SavepointsService; import org.dinky.service.SavepointsService;
import org.dinky.service.StatementService;
import org.dinky.service.TaskService; import org.dinky.service.TaskService;
import org.dinky.service.TaskVersionService; import org.dinky.service.TaskVersionService;
import org.dinky.service.UDFTemplateService; import org.dinky.service.UDFTemplateService;
import org.dinky.service.UserService; import org.dinky.service.UserService;
import org.dinky.trans.Operations;
import org.dinky.utils.FragmentVariableUtils; import org.dinky.utils.FragmentVariableUtils;
import org.dinky.utils.JsonUtils; import org.dinky.utils.JsonUtils;
import org.dinky.utils.RunTimeUtil; import org.dinky.utils.RunTimeUtil;
import org.dinky.utils.SqlUtil;
import org.dinky.utils.UDFUtils; import org.dinky.utils.UDFUtils;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
...@@ -99,6 +102,7 @@ import java.io.InputStreamReader; ...@@ -99,6 +102,7 @@ import java.io.InputStreamReader;
import java.io.Reader; import java.io.Reader;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
...@@ -138,7 +142,6 @@ import lombok.extern.slf4j.Slf4j; ...@@ -138,7 +142,6 @@ import lombok.extern.slf4j.Slf4j;
public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implements TaskService { public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implements TaskService {
private final SavepointsService savepointsService; private final SavepointsService savepointsService;
private final StatementService statementService;
private final ClusterInstanceService clusterInstanceService; private final ClusterInstanceService clusterInstanceService;
private final ClusterConfigurationService clusterCfgService; private final ClusterConfigurationService clusterCfgService;
private final JarService jarService; private final JarService jarService;
...@@ -546,7 +549,6 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen ...@@ -546,7 +549,6 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
return tasks.stream() return tasks.stream()
.peek(task -> { .peek(task -> {
Assert.notNull(task, Status.TASK_NOT_EXIST.getMessage()); Assert.notNull(task, Status.TASK_NOT_EXIST.getMessage());
task.setStatement(statementService.getById(task.getId()).getStatement());
}) })
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
...@@ -812,4 +814,16 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen ...@@ -812,4 +814,16 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
} }
return treeNodes; return treeNodes;
} }
@Override
public List<String> getPrintTables(String statement) {
// TODO: 2023/4/7 this function not support variable sql, because, JobManager and executor
// couple function
// and status and task execute.
final String[] statements = SqlUtil.getStatements(SqlUtil.removeNote(statement));
return Arrays.stream(statements)
.filter(t -> SqlType.PRINT.equals(Operations.getOperationType(t)))
.flatMap(t -> Arrays.stream(PrintStatementExplainer.splitTableNames(t)))
.collect(Collectors.toList());
}
} }
...@@ -1343,14 +1343,10 @@ CREATE TABLE `dinky_task` ( ...@@ -1343,14 +1343,10 @@ CREATE TABLE `dinky_task` (
`enabled` tinyint(1) NOT null DEFAULT 1 COMMENT 'is enable', `enabled` tinyint(1) NOT null DEFAULT 1 COMMENT 'is enable',
`create_time` datetime(0) null DEFAULT null COMMENT 'create time', `create_time` datetime(0) null DEFAULT null COMMENT 'create time',
`update_time` datetime(0) null DEFAULT null COMMENT 'update time', `update_time` datetime(0) null DEFAULT null COMMENT 'update time',
`version_id` int(11) null DEFAULT null COMMENT 'version id' `version_id` int(11) null DEFAULT null COMMENT 'version id',
) ENGINE = InnoDB ROW_FORMAT = Dynamic; `statement` text null DEFAULT null COMMENT 'statement'
DROP TABLE IF EXISTS `dinky_task_statement`;
CREATE TABLE `dinky_task_statement` (
`id` int(11) NOT null COMMENT 'ID',
`tenant_id` int(11) NOT null DEFAULT 1 COMMENT 'tenant id',
`statement` longtext null COMMENT 'statement set'
) ENGINE = InnoDB ROW_FORMAT = Dynamic; ) ENGINE = InnoDB ROW_FORMAT = Dynamic;
DROP TABLE IF EXISTS `dinky_task_version`; DROP TABLE IF EXISTS `dinky_task_version`;
CREATE TABLE `dinky_task_version` ( CREATE TABLE `dinky_task_version` (
`id` int(11) NOT null AUTO_INCREMENT COMMENT 'ID', `id` int(11) NOT null AUTO_INCREMENT COMMENT 'ID',
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.dinky.mapper.StatementMapper">
<resultMap id="BaseResultMap" type="org.dinky.data.model.Statement">
<id column="id" property="id" />
<result column="statement" property="statement" />
</resultMap>
<sql id="Base_Column_List">
id,statement
</sql>
<select id="selectForProTable" resultType="org.dinky.data.model.Task">
select
a.*
from
dinky_task_statement a
<where>
1=1
<if test='param.id!=null and param.id!=""'>
and a.id = #{param.id}
</if>
<if test='param.statement!=null and param.statement!=""'>
and a.statement like "%${param.statement}%"
</if>
<if test='ew.sqlSegment!=null and ew.sqlSegment!="" and !ew.sqlSegment.startsWith(" ORDER BY")'>
and
</if>
<if test='ew.sqlSegment!=null and ew.sqlSegment!=""'>
${ew.sqlSegment}
</if>
</where>
</select>
</mapper>
...@@ -11,7 +11,7 @@ import * as React from 'react'; ...@@ -11,7 +11,7 @@ import * as React from 'react';
import { useEffect, useState } from 'react'; import { useEffect, useState } from 'react';
export async function getPrintTables(statement: string) { export async function getPrintTables(statement: string) {
return postAll('api/statement/getPrintTables', { statement }); return postAll('api/task/getPrintTables', { statement });
} }
/*--- Clear Console ---*/ /*--- Clear Console ---*/
......
...@@ -674,31 +674,12 @@ CREATE TABLE `dinky_task` ( ...@@ -674,31 +674,12 @@ CREATE TABLE `dinky_task` (
`create_time` datetime(0) NULL DEFAULT NULL COMMENT 'create time', `create_time` datetime(0) NULL DEFAULT NULL COMMENT 'create time',
`update_time` datetime(0) NULL DEFAULT NULL COMMENT 'update time', `update_time` datetime(0) NULL DEFAULT NULL COMMENT 'update time',
`version_id` int(11) NULL DEFAULT NULL COMMENT 'version id', `version_id` int(11) NULL DEFAULT NULL COMMENT 'version id',
statement text null,
PRIMARY KEY (`id`) USING BTREE, PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `task_un_idx1`(`name`, `tenant_id`) USING BTREE, UNIQUE INDEX `task_un_idx1`(`name`, `tenant_id`) USING BTREE,
UNIQUE INDEX `task_un_idx2`(`save_point_path`) USING BTREE UNIQUE INDEX `task_un_idx2`(`save_point_path`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = 'Task' ROW_FORMAT = Dynamic; ) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = 'Task' ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of dinky_task
-- ----------------------------
-- ----------------------------
-- Table structure for dinky_task_statement
-- ----------------------------
DROP TABLE IF EXISTS `dinky_task_statement`;
CREATE TABLE `dinky_task_statement` (
`id` int(11) NOT NULL COMMENT 'ID',
`tenant_id` int(11) NOT NULL DEFAULT 1 COMMENT 'tenant id',
`statement` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT 'statement set',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `task_statement_un_idx1`(`tenant_id`, `id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = 'statement' ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of dinky_task_statement
-- ----------------------------
-- ---------------------------- -- ----------------------------
-- Table structure for dinky_task_version -- Table structure for dinky_task_version
-- ---------------------------- -- ----------------------------
......
...@@ -1137,7 +1137,8 @@ CREATE TABLE "public"."dinky_task" ( ...@@ -1137,7 +1137,8 @@ CREATE TABLE "public"."dinky_task" (
"enabled" int2 NOT null, "enabled" int2 NOT null,
"create_time" timestamp(6), "create_time" timestamp(6),
"update_time" timestamp(6), "update_time" timestamp(6),
"version_id" int4 "version_id" int4,
statement text
) )
; ;
COMMENT ON COLUMN "public"."dinky_task"."id" IS 'ID'; COMMENT ON COLUMN "public"."dinky_task"."id" IS 'ID';
...@@ -1166,31 +1167,9 @@ COMMENT ON COLUMN "public"."dinky_task"."enabled" IS 'is enable'; ...@@ -1166,31 +1167,9 @@ COMMENT ON COLUMN "public"."dinky_task"."enabled" IS 'is enable';
COMMENT ON COLUMN "public"."dinky_task"."create_time" IS 'create time'; COMMENT ON COLUMN "public"."dinky_task"."create_time" IS 'create time';
COMMENT ON COLUMN "public"."dinky_task"."update_time" IS 'update time'; COMMENT ON COLUMN "public"."dinky_task"."update_time" IS 'update time';
COMMENT ON COLUMN "public"."dinky_task"."version_id" IS 'version id'; COMMENT ON COLUMN "public"."dinky_task"."version_id" IS 'version id';
COMMENT ON COLUMN "public"."dinky_task"."statement" IS 'statement';
COMMENT ON TABLE "public"."dinky_task" IS 'Task'; COMMENT ON TABLE "public"."dinky_task" IS 'Task';
-- ----------------------------
-- Records of dinky_task
-- ----------------------------
-- ----------------------------
-- Table structure for dinky_task_statement
-- ----------------------------
DROP TABLE IF EXISTS "public"."dinky_task_statement";
CREATE TABLE "public"."dinky_task_statement" (
"id" SERIAL NOT null,
"tenant_id" int4 NOT null,
"statement" text COLLATE "pg_catalog"."default"
)
;
COMMENT ON COLUMN "public"."dinky_task_statement"."id" IS 'ID';
COMMENT ON COLUMN "public"."dinky_task_statement"."tenant_id" IS 'tenant id';
COMMENT ON COLUMN "public"."dinky_task_statement"."statement" IS 'statement set';
COMMENT ON TABLE "public"."dinky_task_statement" IS 'statement';
-- ----------------------------
-- Records of dinky_task_statement
-- ----------------------------
-- ---------------------------- -- ----------------------------
-- Table structure for dinky_task_version -- Table structure for dinky_task_version
-- ---------------------------- -- ----------------------------
......
...@@ -202,6 +202,8 @@ alter table dinky_user ...@@ -202,6 +202,8 @@ alter table dinky_user
alter table dinky_user_tenant add tenant_admin_flag tinyint default 0 comment 'tenant admin flag(0:false,1:true)' after tenant_id; alter table dinky_user_tenant add tenant_admin_flag tinyint default 0 comment 'tenant admin flag(0:false,1:true)' after tenant_id;
alter table dinky_task
add statement text null;
drop table dinky_namespace; drop table dinky_namespace;
drop table dinky_role_namespace; drop table dinky_role_namespace;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment