Skip to content

Commit

Permalink
feature: update schedule type
Browse files Browse the repository at this point in the history
  • Loading branch information
wangqi committed Sep 6, 2024
1 parent 406695f commit 4e28b56
Show file tree
Hide file tree
Showing 21 changed files with 356 additions and 91 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
import cn.sliew.carp.framework.common.dict.k8s.ClusterStatus;
import cn.sliew.carp.framework.common.dict.k8s.ClusterType;
import cn.sliew.carp.framework.common.dict.oam.AppType;
import cn.sliew.carp.framework.common.dict.schedule.ScheduleEngineType;
import cn.sliew.carp.framework.common.dict.schedule.ScheduleJobType;
import cn.sliew.carp.framework.common.dict.schedule.ScheduleStatus;
import cn.sliew.carp.framework.common.dict.schedule.ScheduleType;
import cn.sliew.carp.framework.common.dict.security.*;
import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
Expand Down Expand Up @@ -59,6 +63,11 @@ public enum DictType implements DictDefinition {

DATASOURCE_TYPE("datasource_type", "数据源类型", DataSourceType.class),
DS_REDIS_MODE("datasource_redis_mode", "Redis Mode", RedisMode.class),

SCHEDULE_TYPE("schedule_type", "Schedule Type", ScheduleType.class),
SCHEDULE_STATUS("schedule_status", "Schedule Status", ScheduleStatus.class),
SCHEDULE_JOB_TYPE("schedule_job_type", "Schedule Job Type", ScheduleJobType.class),
SCHEDULE_ENGINE_TYPE("schedule_engine_type", "Schedule Engine Type", ScheduleEngineType.class),
;

@JsonCreator
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* 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 cn.sliew.carp.framework.common.dict.schedule;

import cn.sliew.carp.framework.common.dict.DictInstance;
import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonFormat;

import java.util.Arrays;

@JsonFormat(shape = JsonFormat.Shape.OBJECT)
public enum ScheduleEngineType implements DictInstance {

INTERNAL("internal", "内置"),
TEMPORAL("temporal", "Tempolra"),
DOLPHINSCHEDULER("dolphin-scheduler", "DolphinScheduler"),
;

@JsonCreator
public static ScheduleEngineType of(String value) {
return Arrays.stream(values())
.filter(instance -> instance.getValue().equals(value))
.findAny().orElseThrow(() -> new EnumConstantNotPresentException(ScheduleEngineType.class, value));
}

@EnumValue
private String value;
private String label;

ScheduleEngineType(String value, String label) {
this.value = value;
this.label = label;
}

@Override
public String getValue() {
return value;
}

@Override
public String getLabel() {
return label;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* 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 cn.sliew.carp.framework.common.dict.schedule;

import cn.sliew.carp.framework.common.dict.DictInstance;
import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonFormat;

import java.util.Arrays;

@JsonFormat(shape = JsonFormat.Shape.OBJECT)
public enum ScheduleJobType implements DictInstance {

NORMAL("0", "普通"),
WORKFLOW("1", "WorkFlow"),
;

@JsonCreator
public static ScheduleJobType of(String value) {
return Arrays.stream(values())
.filter(instance -> instance.getValue().equals(value))
.findAny().orElseThrow(() -> new EnumConstantNotPresentException(ScheduleJobType.class, value));
}

@EnumValue
private String value;
private String label;

ScheduleJobType(String value, String label) {
this.value = value;
this.label = label;
}

@Override
public String getValue() {
return value;
}

@Override
public String getLabel() {
return label;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* 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 cn.sliew.carp.framework.common.dict.schedule;

import cn.sliew.carp.framework.common.dict.DictInstance;
import cn.sliew.carp.framework.common.dict.common.YesOrNo;
import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonFormat;

import java.util.Arrays;

@JsonFormat(shape = JsonFormat.Shape.OBJECT)
public enum ScheduleType implements DictInstance {

SYSTEM("0", "系统"),
USER("1", "用户"),
;

@JsonCreator
public static ScheduleType of(String value) {
return Arrays.stream(values())
.filter(instance -> instance.getValue().equals(value))
.findAny().orElseThrow(() -> new EnumConstantNotPresentException(ScheduleType.class, value));
}

@EnumValue
private String value;
private String label;

ScheduleType(String value, String label) {
this.value = value;
this.label = label;
}

@Override
public String getValue() {
return value;
}

@Override
public String getLabel() {
return label;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,36 +18,36 @@

package cn.sliew.module.scheduler.repository.entity;

import cn.sliew.carp.framework.common.dict.schedule.ScheduleEngineType;
import cn.sliew.carp.framework.common.dict.schedule.ScheduleJobType;
import cn.sliew.carp.framework.common.dict.schedule.ScheduleType;
import cn.sliew.carp.framework.mybatis.entity.BaseAuditDO;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import lombok.Data;

@Getter
@Setter
@Data
@TableName("schedule_job_config")
@Schema(name = "ScheduleJobConfig", description = "schedule job config")
public class ScheduleJobConfig extends BaseAuditDO {

@Schema(description = "任务分组 id")
@TableField("job_group_id")
private Long jobGroupId;

@Schema(description = "任务类型")
@TableField("`type`")
private String type;
private ScheduleType type;

@TableField("`engine_type`")
private ScheduleEngineType engineType;

@TableField("`job_type`")
private ScheduleJobType jobType;

@Schema(description = "任务名称")
@TableField("`name`")
private String name;

@Schema(description = "任务处理器")
@TableField("`handler`")
private String handler;

@Schema(description = "remark")
@TableField("remark")
private String remark;
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,18 @@
import cn.sliew.carp.framework.mybatis.entity.BaseAuditDO;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import lombok.Data;

@Getter
@Setter
@Data
@TableName("schedule_job_group")
@Schema(name = "ScheduleJobGroup", description = "schedule job group")
public class ScheduleJobGroup extends BaseAuditDO {

@Schema(description = "命名空间")
@TableField("namespace")
private String namespace;

@Schema(description = "分组名称")
@TableField("`name`")
private String name;

@Schema(description = "remark")
@TableField("remark")
private String remark;
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,41 +21,33 @@
import cn.sliew.carp.framework.mybatis.entity.BaseAuditDO;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import lombok.Data;

@Getter
@Setter
@Data
@TableName("schedule_job_instance")
@Schema(name = "ScheduleJobInstance", description = "schedule job instance")
public class ScheduleJobInstance extends BaseAuditDO {

@Schema(description = "任务配置id")
@TableField("job_config_id")
private Long jobConfigId;

@Schema(description = "实例名称")
@TableField("`name`")
private String name;

@Schema(description = "CRON表达式")
@TableField("cron")
private String cron;

@Schema(description = "参数")
@TableField("props")
private String props;

@TableField("params")
private String params;

@Schema(description = "超时时间(毫秒)")
@TableField("timeout")
private Long timeout;

@Schema(description = "状态")
@TableField("`status`")
private String status;

@Schema(description = "remark")
@TableField("remark")
private String remark;
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@

package cn.sliew.module.scheduler.service.dto;

import cn.sliew.carp.framework.common.dict.schedule.ScheduleEngineType;
import cn.sliew.carp.framework.common.dict.schedule.ScheduleJobType;
import cn.sliew.carp.framework.common.dict.schedule.ScheduleType;
import cn.sliew.carp.framework.common.model.BaseDTO;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

Expand All @@ -29,8 +33,14 @@ public class ScheduleJobConfigDTO extends BaseDTO {
@Schema(description = "任务分组 id")
private Long jobGroupId;

@Schema(description = "类型")
private ScheduleType type;

@Schema(description = "引擎类型")
private ScheduleEngineType engineType;

@Schema(description = "任务类型")
private String type;
private ScheduleJobType jobType;

@Schema(description = "任务名称")
private String name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package cn.sliew.module.scheduler.service.dto;

import cn.sliew.carp.framework.common.model.BaseDTO;
import com.fasterxml.jackson.databind.JsonNode;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

Expand All @@ -35,6 +36,9 @@ public class ScheduleJobInstanceDTO extends BaseDTO {
@Schema(description = "CRON表达式")
private String cron;

@Schema(description = "属性")
private JsonNode props;

@Schema(description = "参数")
private String params;

Expand Down
Loading

0 comments on commit 4e28b56

Please sign in to comment.