v3.12【新增】标签页Chome模式;【优化】优化很多细节

This commit is contained in:
zhuoda
2025-01-08 20:14:53 +08:00
parent 56517b650a
commit 96d498fbbf
77 changed files with 2721 additions and 918 deletions

View File

@@ -53,6 +53,15 @@ public class AdminSmartJobController extends SupportBaseController {
return jobService.queryJob(queryForm);
}
@Operation(summary = "定时任务-添加任务 @huke")
@PostMapping("/job/add")
@RepeatSubmit
public ResponseDTO<String> addJob(@RequestBody @Valid SmartJobAddForm addForm) {
RequestUser requestUser = SmartRequestUtil.getRequestUser();
addForm.setUpdateName(requestUser.getUserName());
return jobService.addJob(addForm);
}
@Operation(summary = "定时任务-更新-任务信息 @huke")
@PostMapping("/job/update")
@RepeatSubmit
@@ -71,6 +80,13 @@ public class AdminSmartJobController extends SupportBaseController {
return jobService.updateJobEnabled(updateForm);
}
@Operation(summary = "定时任务-删除 @zhuoda")
@GetMapping("/job/delete")
@RepeatSubmit
public ResponseDTO<String> deleteJob(@RequestParam Integer jobId) {
return jobService.deleteJob(jobId, SmartRequestUtil.getRequestUser());
}
@Operation(summary = "定时任务-执行记录-分页查询 @huke")
@PostMapping("/job/log/query")
public ResponseDTO<PageResult<SmartJobLogVO>> queryJobLog(@RequestBody @Valid SmartJobLogQueryForm queryForm) {

View File

@@ -0,0 +1,34 @@
package net.lab1024.sa.base.config;
import cn.dev33.satoken.config.SaTokenConfig;
import net.lab1024.sa.base.module.support.securityprotect.service.Level3ProtectConfigService;
import org.springframework.context.annotation.Configuration;
import javax.annotation.Resource;
/**
*
* 三级等保配置初始化后最低活跃频率全局配置
*
* @Author 1024创新实验室-创始人兼主任:卓大
* @Date 2024/11/24
* @Wechat zhuoda1024
* @Email lab1024@163.com
* @Copyright <a href="https://1024lab.net">1024创新实验室</a> Since 2012
*/
@Configuration
public class TokenConfig {
@Resource
private Level3ProtectConfigService level3ProtectConfigService;
// 此配置会覆盖 sa-base.yaml 中的配置
@Resource
public void configSaToken(SaTokenConfig config) {
config.setActiveTimeout(level3ProtectConfigService.getLoginActiveTimeoutSeconds());
}
}

View File

@@ -9,10 +9,10 @@ import lombok.extern.slf4j.Slf4j;
import net.lab1024.sa.base.common.annoation.NoNeedLogin;
import net.lab1024.sa.base.common.domain.RequestUrlVO;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.mvc.condition.PathPatternsRequestCondition;
import org.springframework.web.servlet.mvc.method.RequestMappingInfo;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
@@ -21,7 +21,6 @@ import java.lang.reflect.Method;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
/**
* url配置
@@ -49,11 +48,12 @@ public class UrlConfig {
Map<RequestMappingInfo, HandlerMethod> map = requestMappingHandlerMapping.getHandlerMethods();
for (Map.Entry<RequestMappingInfo, HandlerMethod> entry : map.entrySet()) {
RequestMappingInfo requestMappingInfo = entry.getKey();
if(requestMappingInfo.getPatternsCondition() == null){
PathPatternsRequestCondition pathPatternsCondition = requestMappingInfo.getPathPatternsCondition();
if(pathPatternsCondition == null){
continue;
}
Set<String> urls = requestMappingInfo.getPatternsCondition().getPatterns();
Set<String> urls = pathPatternsCondition.getPatternValues();
if (CollectionUtils.isEmpty(urls)) {
continue;
}

View File

@@ -1,8 +1,6 @@
package net.lab1024.sa.base.module.support.dict.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.collect.Interner;
import com.google.common.collect.Interners;
import net.lab1024.sa.base.common.code.UserErrorCode;
import net.lab1024.sa.base.common.domain.PageResult;
import net.lab1024.sa.base.common.domain.ResponseDTO;
@@ -28,7 +26,7 @@ import java.util.List;
* @Date 2022/5/26 19:40:55
* @Wechat zhuoda1024
* @Email lab1024@163.com
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
*/
@Service
public class DictService {
@@ -39,10 +37,6 @@ public class DictService {
private DictValueDao dictValueDao;
@Resource
private DictCacheService dictCacheService;
/**
* CODE锁
*/
private static final Interner<String> CODE_POOL = Interners.newWeakInterner();
/**
@@ -51,15 +45,15 @@ public class DictService {
* @param keyAddForm
* @return
*/
public ResponseDTO<String> keyAdd(DictKeyAddForm keyAddForm) {
synchronized (CODE_POOL.intern(keyAddForm.getKeyCode())) {
DictKeyEntity dictKeyEntity = dictKeyDao.selectByCode(keyAddForm.getKeyCode(), false);
if (dictKeyEntity != null) {
return ResponseDTO.error(UserErrorCode.ALREADY_EXIST);
}
dictKeyEntity = SmartBeanUtil.copy(keyAddForm, DictKeyEntity.class);
dictKeyDao.insert(dictKeyEntity);
public synchronized ResponseDTO<String> keyAdd(DictKeyAddForm keyAddForm) {
DictKeyEntity dictKeyEntity = dictKeyDao.selectByCode(keyAddForm.getKeyCode(), false);
if (dictKeyEntity != null) {
return ResponseDTO.error(UserErrorCode.ALREADY_EXIST);
}
dictKeyEntity = SmartBeanUtil.copy(keyAddForm, DictKeyEntity.class);
dictKeyDao.insert(dictKeyEntity);
//刷新缓存
dictCacheService.cacheRefresh();
return ResponseDTO.ok();
}
@@ -69,15 +63,15 @@ public class DictService {
* @param valueAddForm
* @return
*/
public ResponseDTO<String> valueAdd(DictValueAddForm valueAddForm) {
synchronized (CODE_POOL.intern(valueAddForm.getValueCode())) {
DictValueEntity dictValueEntity = dictValueDao.selectByCode(valueAddForm.getValueCode(), false);
if (dictValueEntity != null) {
return ResponseDTO.error(UserErrorCode.ALREADY_EXIST);
}
dictValueEntity = SmartBeanUtil.copy(valueAddForm, DictValueEntity.class);
dictValueDao.insert(dictValueEntity);
public synchronized ResponseDTO<String> valueAdd(DictValueAddForm valueAddForm) {
DictValueEntity dictValueEntity = dictValueDao.selectByCode(valueAddForm.getValueCode(), false);
if (dictValueEntity != null) {
return ResponseDTO.error(UserErrorCode.ALREADY_EXIST);
}
dictValueEntity = SmartBeanUtil.copy(valueAddForm, DictValueEntity.class);
dictValueDao.insert(dictValueEntity);
//刷新缓存
dictCacheService.cacheRefresh();
return ResponseDTO.ok();
}
@@ -87,15 +81,15 @@ public class DictService {
* @param keyUpdateForm
* @return
*/
public ResponseDTO<String> keyEdit(DictKeyUpdateForm keyUpdateForm) {
synchronized (CODE_POOL.intern(keyUpdateForm.getKeyCode())) {
DictKeyEntity dictKeyEntity = dictKeyDao.selectByCode(keyUpdateForm.getKeyCode(), false);
if (dictKeyEntity != null && !dictKeyEntity.getDictKeyId().equals(keyUpdateForm.getDictKeyId())) {
return ResponseDTO.error(UserErrorCode.ALREADY_EXIST);
}
DictKeyEntity dictKeyUpdateEntity = SmartBeanUtil.copy(keyUpdateForm, DictKeyEntity.class);
dictKeyDao.updateById(dictKeyUpdateEntity);
public synchronized ResponseDTO<String> keyEdit(DictKeyUpdateForm keyUpdateForm) {
DictKeyEntity dictKeyEntity = dictKeyDao.selectByCode(keyUpdateForm.getKeyCode(), false);
if (dictKeyEntity != null && !dictKeyEntity.getDictKeyId().equals(keyUpdateForm.getDictKeyId())) {
return ResponseDTO.error(UserErrorCode.ALREADY_EXIST);
}
DictKeyEntity dictKeyUpdateEntity = SmartBeanUtil.copy(keyUpdateForm, DictKeyEntity.class);
dictKeyDao.updateById(dictKeyUpdateEntity);
//刷新缓存
dictCacheService.cacheRefresh();
return ResponseDTO.ok();
}
@@ -105,19 +99,19 @@ public class DictService {
* @param valueUpdateForm
* @return
*/
public ResponseDTO<String> valueEdit(DictValueUpdateForm valueUpdateForm) {
public synchronized ResponseDTO<String> valueEdit(DictValueUpdateForm valueUpdateForm) {
DictKeyEntity dictKeyEntity = dictKeyDao.selectById(valueUpdateForm.getDictKeyId());
if (dictKeyEntity == null || dictKeyEntity.getDeletedFlag()) {
return ResponseDTO.userErrorParam("key不能存在");
}
synchronized (CODE_POOL.intern(valueUpdateForm.getValueCode())) {
DictValueEntity dictValueEntity = dictValueDao.selectByCode(valueUpdateForm.getValueCode(), false);
if (dictValueEntity != null && !dictValueEntity.getDictValueId().equals(valueUpdateForm.getDictValueId())) {
return ResponseDTO.error(UserErrorCode.ALREADY_EXIST);
}
DictValueEntity dictValueUpdateEntity = SmartBeanUtil.copy(valueUpdateForm, DictValueEntity.class);
dictValueDao.updateById(dictValueUpdateEntity);
DictValueEntity dictValueEntity = dictValueDao.selectByCode(valueUpdateForm.getValueCode(), false);
if (dictValueEntity != null && !dictValueEntity.getDictValueId().equals(valueUpdateForm.getDictValueId())) {
return ResponseDTO.error(UserErrorCode.ALREADY_EXIST);
}
DictValueEntity dictValueUpdateEntity = SmartBeanUtil.copy(valueUpdateForm, DictValueEntity.class);
dictValueDao.updateById(dictValueUpdateEntity);
//刷新缓存
dictCacheService.cacheRefresh();
return ResponseDTO.ok();
}
@@ -127,11 +121,13 @@ public class DictService {
* @param keyIdList
* @return
*/
public ResponseDTO<String> keyDelete(List<Long> keyIdList) {
public synchronized ResponseDTO<String> keyDelete(List<Long> keyIdList) {
if (CollectionUtils.isEmpty(keyIdList)) {
return ResponseDTO.ok();
}
dictKeyDao.updateDeletedFlagByIdList(keyIdList, true);
//刷新缓存
dictCacheService.cacheRefresh();
return ResponseDTO.ok();
}
@@ -141,11 +137,13 @@ public class DictService {
* @param valueIdList
* @return
*/
public ResponseDTO<String> valueDelete(List<Long> valueIdList) {
public synchronized ResponseDTO<String> valueDelete(List<Long> valueIdList) {
if (CollectionUtils.isEmpty(valueIdList)) {
return ResponseDTO.ok();
}
dictValueDao.updateDeletedFlagByIdList(valueIdList, true);
//刷新缓存
dictCacheService.cacheRefresh();
return ResponseDTO.ok();
}

View File

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.collect.Lists;
import net.lab1024.sa.base.common.code.UserErrorCode;
import net.lab1024.sa.base.common.domain.PageResult;
import net.lab1024.sa.base.common.domain.RequestUser;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.util.SmartBeanUtil;
import net.lab1024.sa.base.common.util.SmartPageUtil;
@@ -16,7 +17,6 @@ import net.lab1024.sa.base.module.support.job.repository.SmartJobLogDao;
import net.lab1024.sa.base.module.support.job.repository.domain.SmartJobEntity;
import net.lab1024.sa.base.module.support.job.repository.domain.SmartJobLogEntity;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.stereotype.Service;
@@ -126,27 +126,61 @@ public class SmartJobService {
return ResponseDTO.ok(pageResult);
}
/**
* 添加定时任务
*
* @param addForm
* @return
*/
public synchronized ResponseDTO<String> addJob(SmartJobAddForm addForm) {
// 校验参数
ResponseDTO<String> checkRes = this.checkParam(addForm);
if (!checkRes.getOk()) {
return checkRes;
}
// 校验重复的执行类
SmartJobEntity existJobClass = jobDao.selectByJobClass(addForm.getJobClass());
if (null != existJobClass && !existJobClass.getDeletedFlag()) {
return ResponseDTO.userErrorParam("已经存在相同的执行类");
}
// 添加数据
SmartJobEntity jobEntity = SmartBeanUtil.copy(addForm, SmartJobEntity.class);
jobDao.insert(jobEntity);
// 更新执行端
SmartJobMsg jobMsg = new SmartJobMsg();
jobMsg.setJobId(jobEntity.getJobId());
jobMsg.setMsgType(SmartJobMsg.MsgTypeEnum.UPDATE_JOB);
jobMsg.setUpdateName(addForm.getUpdateName());
jobClientManager.publishToClient(jobMsg);
return ResponseDTO.ok();
}
/**
* 更新定时任务
*
* @param updateForm
* @return
*/
public ResponseDTO<String> updateJob(SmartJobUpdateForm updateForm) {
public synchronized ResponseDTO<String> updateJob(SmartJobUpdateForm updateForm) {
// 校验参数
Integer jobId = updateForm.getJobId();
SmartJobEntity jobEntity = jobDao.selectById(jobId);
if (null == jobEntity) {
return ResponseDTO.error(UserErrorCode.DATA_NOT_EXIST);
}
// 校验触发时间配置
String triggerType = updateForm.getTriggerType();
String triggerValue = updateForm.getTriggerValue();
if (SmartJobTriggerTypeEnum.CRON.equalsValue(triggerType) && !SmartJobUtil.checkCron(triggerValue)) {
return ResponseDTO.userErrorParam("cron表达式错误");
ResponseDTO<String> checkRes = this.checkParam(updateForm);
if (!checkRes.getOk()) {
return checkRes;
}
if (SmartJobTriggerTypeEnum.FIXED_DELAY.equalsValue(triggerType) && !SmartJobUtil.checkFixedDelay(triggerValue)) {
return ResponseDTO.userErrorParam("固定间隔错误整数且大于0");
// 校验重复的执行类
SmartJobEntity existJobClass = jobDao.selectByJobClass(updateForm.getJobClass());
if (null != existJobClass && !existJobClass.getDeletedFlag() && !existJobClass.getJobId().equals(jobId)) {
return ResponseDTO.userErrorParam("已经存在相同的执行类");
}
// 更新数据
@@ -162,6 +196,27 @@ public class SmartJobService {
return ResponseDTO.ok();
}
/**
* 校验参数
* 如需其他校验,请自行添加校验逻辑
*
* @param addForm
* @return
*/
private ResponseDTO<String> checkParam(SmartJobAddForm addForm) {
// 校验触发时间配置
String triggerType = addForm.getTriggerType();
String triggerValue = addForm.getTriggerValue();
if (SmartJobTriggerTypeEnum.CRON.equalsValue(triggerType) && !SmartJobUtil.checkCron(triggerValue)) {
return ResponseDTO.userErrorParam("cron表达式错误");
}
if (SmartJobTriggerTypeEnum.FIXED_DELAY.equalsValue(triggerType) && !SmartJobUtil.checkFixedDelay(triggerValue)) {
return ResponseDTO.userErrorParam("固定间隔配置错误必须是大于0的整数");
}
// 校验job class
return SmartJobUtil.checkJobClass(addForm.getJobClass());
}
/**
* 更新定时任务-是否开启
*
@@ -219,28 +274,23 @@ public class SmartJobService {
}
/**
* 新增定时任务
* ps:目前没有业务场景需要通过接口 添加任务
* 因为新增定时任务无论如何都需要 手动编码
* 需要时手动给数据库增加一条就行
* 移除定时任务
* 物理删除
*
* @return
* @author huke
*/
public ResponseDTO<String> addJob() {
return ResponseDTO.userErrorParam("暂未支持");
public synchronized ResponseDTO<String> deleteJob(Integer jobId, RequestUser requestUser) {
// 删除任务
jobDao.updateDeletedFlag(jobId, Boolean.TRUE);
// 更新执行端
SmartJobMsg jobMsg = new SmartJobMsg();
jobMsg.setJobId(jobId);
jobMsg.setMsgType(SmartJobMsg.MsgTypeEnum.UPDATE_JOB);
jobMsg.setUpdateName(requestUser.getUserName());
jobClientManager.publishToClient(jobMsg);
return ResponseDTO.ok();
}
/**
* 移除定时任务
* ps目前没有业务场景需要通过接口移除理由同 {@link SmartJobService#addJob}
* 彻底移除始终都需要手动删除代码
* 如果只是想暂停任务执行,可以调用 {@link SmartJobService#updateJobEnabled}
*
* @return
* @author huke
*/
public ResponseDTO<String> delJob() {
return ResponseDTO.userErrorParam("暂未支持");
}
}

View File

@@ -0,0 +1,59 @@
package net.lab1024.sa.base.module.support.job.api.domain;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import net.lab1024.sa.base.common.swagger.SchemaEnum;
import net.lab1024.sa.base.common.validator.enumeration.CheckEnum;
import net.lab1024.sa.base.module.support.job.constant.SmartJobTriggerTypeEnum;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
/**
* 定时任务 添加
*
* @author huke
* @date 2024/12/19 19:30
*/
@Data
public class SmartJobAddForm {
@Schema(description = "任务名称")
@NotBlank(message = "任务名称不能为空")
@Length(max = 100, message = "任务名称最多100字符")
private String jobName;
@Schema(description = "任务执行类")
@NotBlank(message = "任务执行类不能为空")
@Length(max = 200, message = "任务执行类最多200字符")
private String jobClass;
@SchemaEnum(desc = "触发类型", value = SmartJobTriggerTypeEnum.class)
@CheckEnum(value = SmartJobTriggerTypeEnum.class, required = true, message = "触发类型错误")
private String triggerType;
@Schema(description = "触发配置")
@NotBlank(message = "触发配置不能为空")
@Length(max = 100, message = "触发配置最多100字符")
private String triggerValue;
@Schema(description = "定时任务参数|可选")
@Length(max = 1000, message = "定时任务参数最多1000字符")
private String param;
@Schema(description = "是否开启")
@NotNull(message = "是否开启不能为空")
private Boolean enabledFlag;
@Schema(description = "备注")
@Length(max = 250, message = "任务备注最多250字符")
private String remark;
@NotNull(message = "排序不能为空")
@Schema(description = "排序")
private Integer sort;
@Schema(hidden = true)
private String updateName;
}

View File

@@ -27,4 +27,7 @@ public class SmartJobQueryForm extends PageParam {
@Schema(description = "是否启用|可选")
private Boolean enabledFlag;
@Schema(description = "是否删除|可选")
private Boolean deletedFlag;
}

View File

@@ -2,12 +2,7 @@ package net.lab1024.sa.base.module.support.job.api.domain;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import net.lab1024.sa.base.common.swagger.SchemaEnum;
import net.lab1024.sa.base.common.validator.enumeration.CheckEnum;
import net.lab1024.sa.base.module.support.job.constant.SmartJobTriggerTypeEnum;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
/**
@@ -17,47 +12,9 @@ import javax.validation.constraints.NotNull;
* @date 2024/6/17 21:30
*/
@Data
public class SmartJobUpdateForm {
public class SmartJobUpdateForm extends SmartJobAddForm {
@Schema(description = "任务id")
@NotNull(message = "任务id不能为空")
private Integer jobId;
@Schema(description = "任务名称")
@NotBlank(message = "任务名称不能为空")
@Length(max = 100, message = "任务名称最多100字符")
private String jobName;
@Schema(description = "任务执行类")
@NotBlank(message = "任务执行类不能为空")
@Length(max = 200, message = "任务执行类最多200字符")
private String jobClass;
@SchemaEnum(desc = "触发类型", value = SmartJobTriggerTypeEnum.class)
@CheckEnum(value = SmartJobTriggerTypeEnum.class, required = true, message = "触发类型错误")
private String triggerType;
@Schema(description = "触发配置")
@NotBlank(message = "触发配置不能为空")
@Length(max = 100, message = "触发配置最多100字符")
private String triggerValue;
@Schema(description = "定时任务参数|可选")
@Length(max = 1000, message = "定时任务参数最多1000字符")
private String param;
@Schema(description = "是否开启")
@NotNull(message = "是否开启不能为空")
private Boolean enabledFlag;
@Schema(description = "备注")
@Length(max = 250, message = "任务备注最多250字符")
private String remark;
@NotNull(message = "排序不能为空")
@Schema(description = "排序")
private Integer sort;
@Schema(hidden = true)
private String updateName;
}

View File

@@ -1,5 +1,7 @@
package net.lab1024.sa.base.module.support.job.constant;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.module.support.job.core.SmartJob;
import org.springframework.scheduling.support.CronExpression;
import java.lang.management.ManagementFactory;
@@ -98,7 +100,7 @@ public class SmartJobUtil {
} else if (SmartJobTriggerTypeEnum.FIXED_DELAY.equalsValue(triggerType)) {
Integer fixedDelay = getFixedDelayVal(triggerVal);
LocalDateTime startTime = null == lastExecuteTime || lastExecuteTime.plusSeconds(fixedDelay).isBefore(nowTime)
? nowTime : lastExecuteTime;
? nowTime : lastExecuteTime;
nextTimeList = SmartJobUtil.queryNextTime(fixedDelay, startTime, num);
}
return nextTimeList;
@@ -174,6 +176,24 @@ public class SmartJobUtil {
return runtime.getName().split("@")[0];
}
/**
* 根据className 判断job class
*/
public static ResponseDTO<String> checkJobClass(String className) {
try {
Class<?> aClass = Class.forName(className);
// 判断是否实现了 SmartJob
if (!SmartJob.class.isAssignableFrom(aClass)) {
return ResponseDTO.userErrorParam(className + " 执行类没有实现 SmartJob 接口");
}
} catch (ClassNotFoundException e) {
return ResponseDTO.userErrorParam("没有在代码中发现执行类:" + className);
}
return ResponseDTO.ok();
}
public static void main(String[] args) {
LocalDateTime startTime = LocalDateTime.now();
List<LocalDateTime> timeList = SmartJobUtil.queryNextTime("5 * * * * *", startTime, 3);
@@ -184,5 +204,7 @@ public class SmartJobUtil {
System.out.println("project path ->" + getProgramPath());
System.out.println("project process id ->" + getProcessId());
ResponseDTO<String> res = checkJobClass("net.lab1024.sa.base.module.support.job.sample.SmartJobSample1");
System.out.println(res.getMsg());
}
}

View File

@@ -103,6 +103,10 @@ public class SmartJobLauncher {
if (!jobEntity.getEnabledFlag()) {
continue;
}
// 任务删除
if (jobEntity.getDeletedFlag()) {
continue;
}
// 查找任务实现类
SmartJob jobImpl = jobImplMap.get(jobEntity.getJobClass());
if (null == jobImpl) {
@@ -135,6 +139,7 @@ public class SmartJobLauncher {
private static boolean isNeedUpdate(SmartJobEntity oldJob, SmartJobEntity newJob) {
// cron为空时 fixedDelay 才有意义
return !Objects.equals(oldJob.getEnabledFlag(), newJob.getEnabledFlag())
|| !Objects.equals(oldJob.getDeletedFlag(), newJob.getDeletedFlag())
|| !Objects.equals(oldJob.getTriggerType(), newJob.getTriggerType())
|| !Objects.equals(oldJob.getTriggerValue(), newJob.getTriggerValue())
|| !Objects.equals(oldJob.getJobClass(), newJob.getJobClass());

View File

@@ -29,4 +29,20 @@ public interface SmartJobDao extends BaseMapper<SmartJobEntity> {
* @return
*/
List<SmartJobVO> query(Page<?> page, @Param("query") SmartJobQueryForm queryForm);
/**
* 假删除
*
* @param jobId
* @return
*/
void updateDeletedFlag(@Param("jobId") Integer jobId, @Param("deletedFlag") Boolean deletedFlag);
/**
* 根据 任务class 查找
*
* @param jobClass
* @return
*/
SmartJobEntity selectByJobClass(@Param("jobClass") String jobClass);
}

View File

@@ -76,6 +76,11 @@ public class SmartJobEntity {
*/
private Integer sort;
/**
* 是否删除
*/
private Boolean deletedFlag;
private String updateName;
private LocalDateTime updateTime;

View File

@@ -45,7 +45,7 @@ public class Level3ProtectConfigService {
/**
* 最低活跃时间(单位:秒),超过此时间没有操作系统就会被冻结,默认-1 代表不限制,永不冻结; 默认 30分钟
*/
private int loginActiveTimeoutSeconds = 1800;
private int loginActiveTimeoutSeconds = -1;
/**
* 密码复杂度 是否开启,默认:开启

View File

@@ -2,6 +2,12 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="net.lab1024.sa.base.module.support.job.repository.SmartJobDao">
<update id="updateDeletedFlag">
update t_smart_job
set deleted_flag = #{deletedFlag}
where job_id = #{jobId}
</update>
<!-- 定时任务-分页查询 -->
<select id="query" resultType="net.lab1024.sa.base.module.support.job.api.domain.SmartJobVO">
SELECT *
@@ -19,10 +25,19 @@
<if test="query.enabledFlag != null">
AND enabled_flag = #{query.enabledFlag}
</if>
<if test="query.deletedFlag != null">
AND deleted_flag = #{query.deletedFlag}
</if>
</where>
<if test="query.sortItemList == null or query.sortItemList.size == 0">
ORDER BY sort ASC,job_id DESC
</if>
</select>
<select id="selectByJobClass" resultType="net.lab1024.sa.base.module.support.job.repository.domain.SmartJobEntity">
SELECT *
FROM t_smart_job
WHERE job_class = #{jobClass}
</select>
</mapper>