Skip to content

Commit

Permalink
chore: Optimize code and update ui version
Browse files Browse the repository at this point in the history
  • Loading branch information
itinycheng committed Dec 4, 2024
1 parent e7b6788 commit 3da6354
Show file tree
Hide file tree
Showing 18 changed files with 75 additions and 81 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.flink.platform.dao.service.AlertService;
import com.flink.platform.web.entity.request.AlertInfoRequest;
import com.flink.platform.web.entity.response.ResultInfo;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
Expand All @@ -30,10 +31,10 @@
/** Alert controller. */
@RestController
@RequestMapping("/alert")
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class AlertController {

@Autowired
private AlertService alertService;
private final AlertService alertService;

@PostMapping(value = "/create")
public ResultInfo<Long> create(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
import com.flink.platform.common.enums.ExecutionStatus;
import com.flink.platform.common.enums.JobType;
import com.flink.platform.dao.entity.task.DependentJob;
import com.flink.platform.dao.service.JobInfoService;
import com.flink.platform.dao.service.WorkerService;
import com.flink.platform.web.config.FlinkConfig;
import com.flink.platform.web.entity.response.ResultInfo;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
Expand All @@ -36,23 +36,17 @@
import static com.flink.platform.common.enums.ExecutionStatus.FAILURE;
import static com.flink.platform.common.enums.ExecutionStatus.SUCCESS;
import static com.flink.platform.web.entity.response.ResultInfo.success;
import static java.util.stream.Collectors.toList;

/** Attrs controller. */
@Slf4j
@RestController
@RequestMapping("/attr")
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class AttrsController {

private static final String CLASS_PATH_PREFIX = "com.flink.platform.common.enums";

@Autowired
private JobInfoService jobInfoService;

@Autowired
private WorkerService workerService;

@Autowired
private List<FlinkConfig> flinkConfigs;
private final List<FlinkConfig> flinkConfigs;

@GetMapping(value = "/preconditions")
public ResultInfo<List<ExecutionCondition>> precondition() {
Expand All @@ -74,7 +68,7 @@ public ResultInfo<List<String>> versions(String type) {
versions.addAll(flinkConfigs.stream()
.map(FlinkConfig::getVersion)
.filter(Objects::nonNull)
.collect(toList()));
.toList());
} else {
versions.add(FULL_VERSION);
}
Expand Down Expand Up @@ -109,7 +103,7 @@ public ResultInfo<List<ExecutionStatus>> edgeStates(Long jobId) {
return success(Arrays.asList(SUCCESS, FAILURE));
}

@GetMapping(value = "/list")
@GetMapping(value = "/enums")
public ResultInfo<List<Map<String, Object>>> list(
@RequestParam(name = "className", required = false) String className) {
List<Map<String, Object>> enums = Lists.newArrayList();
Expand All @@ -126,7 +120,7 @@ public ResultInfo<List<Map<String, Object>>> list(
enums.add(map);
}
} catch (Exception e) {
e.printStackTrace();
log.error("Get enum list error", e);
}
return success(enums);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.flink.platform.dao.service.CatalogInfoService;
import com.flink.platform.web.entity.request.CatalogInfoRequest;
import com.flink.platform.web.entity.response.ResultInfo;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
Expand All @@ -32,10 +33,10 @@
/** Catalog info controller. */
@RestController
@RequestMapping("/catalog")
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class CatalogInfoController {

@Autowired
private CatalogInfoService catalogService;
private final CatalogInfoService catalogService;

@PostMapping(value = "/create")
public ResultInfo<Long> create(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.flink.platform.dao.service.JobFlowRunService;
import com.flink.platform.dao.service.JobRunInfoService;
import com.flink.platform.web.entity.response.ResultInfo;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
Expand All @@ -27,13 +28,12 @@
/** Dashboard statistics. */
@RestController
@RequestMapping("/dashboard")
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class DashboardController {

@Autowired
private JobFlowRunService jobFlowRunService;
private final JobFlowRunService jobFlowRunService;

@Autowired
private JobRunInfoService jobRunService;
private final JobRunInfoService jobRunService;

@GetMapping(value = "/jobRunStatusCount")
public ResultInfo<List<Map<String, Object>>> jobRunStatusCount(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.flink.platform.dao.service.DatasourceService;
import com.flink.platform.web.entity.request.DatasourceRequest;
import com.flink.platform.web.entity.response.ResultInfo;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
Expand All @@ -32,10 +33,10 @@
/** datasource controller. */
@RestController
@RequestMapping("/datasource")
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class DatasourceController {

@Autowired
private DatasourceService datasourceService;
private final DatasourceService datasourceService;

@PostMapping(value = "/create")
public ResultInfo<Long> create(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.flink.platform.common.util.JsonUtil;
import com.flink.platform.dao.entity.alert.FeiShuAlert;
import com.flink.platform.web.entity.response.ResultInfo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
Expand All @@ -19,10 +20,10 @@
@Slf4j
@RestController
@RequestMapping("/webhook")
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class GrafanaWebHookController {

@Autowired
private AlertSender alertSender;
private final AlertSender alertSender;

@PostMapping(value = "/forwardToFeiShu")
public ResultInfo<String> forwardToFeiShu(@RequestBody Map<String, Object> grafanaMap) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.flink.platform.common.constants.Constant;
import com.flink.platform.common.enums.JobFlowStatus;
import com.flink.platform.common.enums.JobFlowType;
import com.flink.platform.common.util.UuidGenerator;
import com.flink.platform.dao.entity.ExecutionConfig;
import com.flink.platform.dao.entity.JobFlow;
Expand Down Expand Up @@ -163,7 +164,9 @@ public ResultInfo<IPage<JobFlow>> page(
@RequestAttribute(value = Constant.SESSION_USER) User loginUser,
@RequestParam(name = "page", required = false, defaultValue = "1") Integer page,
@RequestParam(name = "size", required = false, defaultValue = "20") Integer size,
@RequestParam(name = "id", required = false) Long id,
@RequestParam(name = "name", required = false) String name,
@RequestParam(name = "type", required = false) JobFlowType type,
@RequestParam(name = "status", required = false) JobFlowStatus status,
@RequestParam(name = "tag", required = false) String tagCode,
@RequestParam(name = "sort", required = false) String sort) {
Expand All @@ -173,6 +176,8 @@ public ResultInfo<IPage<JobFlow>> page(
.lambda()
.select(JobFlow.class, field -> !"flow".equals(field.getProperty()))
.eq(JobFlow::getUserId, loginUser.getId())
.eq(id != null, JobFlow::getId, id)
.eq(type != null, JobFlow::getType, type)
.like(isNotEmpty(name), JobFlow::getName, name)
.like(isNotEmpty(tagCode), JobFlow::getTags, tagCode);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.flink.platform.web.entity.request.JobInfoRequest;
import com.flink.platform.web.entity.response.ResultInfo;
import com.flink.platform.web.service.QuartzService;
import lombok.RequiredArgsConstructor;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -58,19 +59,16 @@
/** manage job info. */
@RestController
@RequestMapping("/jobInfo")
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class JobInfoController {

@Autowired
private JobInfoService jobInfoService;
private final JobInfoService jobInfoService;

@Autowired
private JobRunInfoService jobRunService;
private final JobRunInfoService jobRunService;

@Autowired
private JobFlowService jobFlowService;
private final JobFlowService jobFlowService;

@Autowired
private QuartzService quartzService;
private final QuartzService quartzService;

@PostMapping(value = "/create")
public ResultInfo<JobInfo> create(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.flink.platform.dao.service.JobParamService;
import com.flink.platform.web.entity.request.JobParamRequest;
import com.flink.platform.web.entity.response.ResultInfo;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
Expand All @@ -38,13 +39,12 @@
/** Alert controller. */
@RestController
@RequestMapping("/jobParam")
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class JobParamController {

@Autowired
private JobParamService jobParamService;
private final JobParamService jobParamService;

@Autowired
private JobInfoService jobService;
private final JobInfoService jobService;

@PostMapping(value = "/create")
public ResultInfo<Long> create(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.flink.platform.web.entity.request.JobRunRequest;
import com.flink.platform.web.entity.response.ResultInfo;
import com.flink.platform.web.service.KillJobService;
import lombok.RequiredArgsConstructor;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
Expand Down Expand Up @@ -43,16 +44,14 @@
/** Job run info controller. */
@RestController
@RequestMapping("/jobRun")
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class JobRunController {

@Autowired
private JobRunInfoService jobRunInfoService;
private final JobRunInfoService jobRunInfoService;

@Autowired
private JobInfoService jobInfoService;
private final JobInfoService jobInfoService;

@Autowired
private KillJobService killJobService;
private final KillJobService killJobService;

@GetMapping(value = "/get/{runId}")
public ResultInfo<JobRunInfo> get(@PathVariable Long runId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.flink.platform.web.entity.response.ResultInfo;
import com.flink.platform.web.util.HttpUtil;
import jakarta.servlet.http.HttpServletRequest;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
Expand All @@ -29,13 +30,12 @@
/** user controller. */
@RestController
@RequestMapping
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class LoginController {

@Autowired
private UserService userService;
private final UserService userService;

@Autowired
private SessionService sessionService;
private final SessionService sessionService;

@PostMapping(value = "/login")
public ResultInfo<Map<String, String>> login(@RequestBody User user, HttpServletRequest request) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.flink.platform.web.service.ReactiveService;
import com.flink.platform.web.service.WorkerApplyService;
import com.flink.platform.web.util.HttpUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
Expand Down Expand Up @@ -48,19 +49,16 @@
@Slf4j
@RestController
@RequestMapping("/reactive")
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class ReactiveController {

@Autowired
private ReactiveService reactiveService;
private final ReactiveService reactiveService;

@Autowired
private DatasourceService datasourceService;
private final DatasourceService datasourceService;

@Autowired
private WorkerApplyService workerApplyService;
private final WorkerApplyService workerApplyService;

@Autowired
private RestTemplate restTemplate;
private final RestTemplate restTemplate;

@GetMapping(value = "/jobToDbTypes")
public ResultInfo<Map<JobType, DbType>> jobToDbTypes() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.flink.platform.web.service.ResourceManageService;
import com.flink.platform.web.service.StorageService;
import com.flink.platform.web.util.ResourceUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.hadoop.fs.Path;
Expand Down Expand Up @@ -45,16 +46,14 @@
@Slf4j
@RestController
@RequestMapping("/resource")
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class ResourceController {

@Autowired
private ResourceManageService resourceManageService;
private final ResourceManageService resourceManageService;

@Autowired
private ResourceService resourceService;
private final ResourceService resourceService;

@Autowired
private StorageService storageService;
private final StorageService storageService;

@PostMapping(value = "/create")
public ResultInfo<Long> create(
Expand Down
Loading

0 comments on commit 3da6354

Please sign in to comment.