Skip to content

Commit

Permalink
improve front end hard code and back end check method
Browse files Browse the repository at this point in the history
  • Loading branch information
zzzk1 committed Jan 7, 2024
1 parent f2cd7f4 commit 5b90bdf
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,19 @@

/* the flink environment status */
public enum FlinkEnvStatus {

/* FLINK_HOME path invalid */
INVALID(-1),

/* this add/update operation are feasible */
FEASIBLE(0),

/* defined flink name repeated */
NAME_REPEATED(1),

/* dist Jar more than one */
FLINK_DIST_REPEATED(2);

private final int code;

FlinkEnvStatus(int code) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ public class FlinkEnvServiceImpl extends ServiceImpl<FlinkEnvMapper, FlinkEnv>
* two places will be checked: <br>
* 1) name repeated <br>
* 2) flink-dist repeated <br>
* -1) invalid path <br>
* 0) ok <br>
*/
@Override
public Integer check(FlinkEnv version) {
Expand All @@ -74,10 +72,8 @@ public Integer check(FlinkEnv version) {
return FlinkEnvStatus.FLINK_DIST_REPEATED.getCode();
}
} else {

return FlinkEnvStatus.INVALID.getCode();
}

return FlinkEnvStatus.FEASIBLE.getCode();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,3 +234,10 @@ export enum AppExistsEnum {
IN_KUBERNETES = 3,
INVALID = 4,
}

export enum FlinkEvnEnum {
INVALID = -1,
FEASIBLE = 0,
NAME_REPEATED = 1,
FLINK_DIST_REPEATED = 2,
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import { BasicModal, useModalInner } from '/@/components/Modal';
import { useMessage } from '/@/hooks/web/useMessage';
import { fetchCheckEnv, fetchFlinkCreate, fetchFlinkUpdate } from '/@/api/flink/flinkEnv';

import { FlinkEvnEnum } from '/@/enums/flinkEnum';
const emit = defineEmits(['reload', 'register']);
const versionId = ref<string | null>(null);
const { t } = useI18n();
Expand Down Expand Up @@ -100,13 +100,13 @@
flinkHome: formValue.flinkHome,
});
const checkResp = parseInt(resp.data);
if (checkResp != 0) {
if (checkResp !== FlinkEvnEnum.FEASIBLE) {
// Environment detection is successful
if (checkResp == -1) {
if (checkResp === FlinkEvnEnum.INVALID) {
Swal.fire('Failed', 'FLINK_HOME invalid path.', 'error');
} else if (checkResp == 1) {
} else if (checkResp === FlinkEvnEnum.NAME_REPEATED) {
Swal.fire('Failed', t('setting.flinkHome.operateMessage.flinkNameIsUnique'), 'error');
} else if (checkResp == 2) {
} else if (checkResp === FlinkEvnEnum.FLINK_DIST_REPEATED) {
Swal.fire(
'Failed',
'can no found flink-dist or found multiple flink-dist, FLINK_HOME error.',
Expand Down

0 comments on commit 5b90bdf

Please sign in to comment.