refactor(web): 优化单表调度提交

This commit is contained in:
2023-07-11 18:50:40 +08:00
parent 5abfe2d017
commit 2cfc009c51
4 changed files with 29 additions and 22 deletions

View File

@@ -1,21 +1,18 @@
package com.lanyuanxiaoyao.service.web.controller;
import cn.hutool.core.util.ReUtil;
import com.dtflys.forest.annotation.Get;
import com.lanyuanxiaoyao.service.configuration.entity.info.JobIdAndAlias;
import com.lanyuanxiaoyao.service.configuration.exception.TableNotFoundException;
import com.lanyuanxiaoyao.service.forest.service.InfoService;
import com.lanyuanxiaoyao.service.forest.service.ScheduleService;
import com.lanyuanxiaoyao.service.web.controller.base.AmisResponse;
import com.lanyuanxiaoyao.service.web.controller.base.BaseController;
import java.util.regex.Pattern;
import org.eclipse.collections.api.factory.Lists;
import org.eclipse.collections.api.list.ImmutableList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
/**
* 调度
@@ -38,7 +35,7 @@ public class ScheduleController extends BaseController {
}
@PostMapping("table_batch")
public void tableBatch(@RequestParam("lines") String lines) throws TableNotFoundException {
public AmisResponse<Object> tableBatch(@RequestParam("lines") String lines) throws TableNotFoundException {
Pattern p = Pattern.compile("^(\\d+)\\s*(\\S+)$");
ImmutableList<JobIdAndAlias> jobIdAndAliases = Lists.immutable.of(lines.trim().split("\n"))
.collect(line -> {
@@ -50,14 +47,18 @@ public class ScheduleController extends BaseController {
checkTableExists(infoService, jobIdAndAlias.getId(), jobIdAndAlias.getAlias());
}
jobIdAndAliases.forEach(item -> scheduleService.scheduleTable(item.getId(), item.getAlias()));
return AmisResponse.responseSuccess();
}
@Get("table")
public void table(
@GetMapping("table")
public AmisResponse<Object> table(
@RequestParam("flink_job_id") Long flinkJobId,
@RequestParam("alias") String alias
@RequestParam("alias") String alias,
@RequestParam(value = "force", required = false) String forceCluster,
@RequestParam(value = "recommend", required = false) String recommendCluster
) throws TableNotFoundException {
checkTableExists(infoService, flinkJobId, alias);
scheduleService.scheduleTable(flinkJobId, alias);
// checkTableExists(infoService, flinkJobId, alias);
// scheduleService.scheduleTable(flinkJobId, alias);
return AmisResponse.responseSuccess();
}
}

View File

@@ -1926,24 +1926,26 @@ function filterableField(mapping, multiple = false) {
}
}
function flinkJobIdTextInput() {
function flinkJobIdTextInput(require = false) {
return {
type: 'input-text',
name: 'flinkJobId',
label: 'Flink job id',
placeholder: '通过 ID 搜索',
clearable: true,
required: require,
autoComplete: '${base}/table/all_flink_job_id?key=$term',
}
}
function aliasTextInput() {
function aliasTextInput(require = false) {
return {
type: 'input-text',
name: 'alias',
label: '别名',
placeholder: '通过别名搜索',
clearable: true,
required: require,
autoComplete: '${base}/table/all_alias?key=$term',
}
}

View File

@@ -88,23 +88,28 @@ function toolTab() {
type: 'form',
title: '提交压缩任务',
api: {
method: 'post',
// url: '${base}/schedule/table_batch',
dataType: 'form',
method: 'get',
url: '${base}/schedule/table',
data: {
flink_job_id: '${flinkJobId|default:undefined}',
alias: '${alias|default:undefined}',
recommend: "${recommend === 'undefined' ? undefined : recommend|default:undefined}",
force: "${force === 'undefined' ? undefined : force|default:undefined}",
}
},
body: [
{
type: 'group',
body: [
flinkJobIdTextInput(),
aliasTextInput(),
flinkJobIdTextInput(true),
aliasTextInput(true),
]
},
{
type: 'group',
body: [
{
name: 'xxxx',
name: 'recommend',
type: 'radios',
label: '优先指定集群',
selectFirst: true,
@@ -116,14 +121,13 @@ function toolTab() {
]
},
{
name: 'xxx',
name: 'force',
type: 'radios',
label: '强制指定集群',
selectFirst: true,
options: [
{label: '无', value: 'undefined'},
{label: 'b1', value: 'b1'},
{label: 'b1', value: 'b1'},
{label: 'b5', value: 'b5'},
{label: 'a4', value: 'a4'},
]

View File

@@ -91,8 +91,8 @@
enableAMISDebug: debug,
},
);
console.log('Source', amisJSON)
if (debug) {
console.log('Source', amisJSON)
}
})()
</script>