From 31414e651f3cbdb7ea09d39285a623e2be958890 Mon Sep 17 00:00:00 2001 From: mash Date: Wed, 1 Nov 2023 13:50:24 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ydool/common/cache/ConfigCache.java | 5 +++++ .../handler/CustomMetaObjectHandler.java | 17 +++++++++++++---- .../service/impl/PersonnelServiceImpl.java | 3 +++ src/main/resources/ehcache.xml | 10 ++++++++++ 4 files changed, 31 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/ydool/common/cache/ConfigCache.java b/src/main/java/com/ydool/common/cache/ConfigCache.java index ca994a0..07f4712 100644 --- a/src/main/java/com/ydool/common/cache/ConfigCache.java +++ b/src/main/java/com/ydool/common/cache/ConfigCache.java @@ -38,6 +38,11 @@ public class ConfigCache { */ public static final String LOGIN_CAPTCHA_CODE = "login_captcha_code"; + /** + * 定时任务参数 + */ + public static final String SCHEDULED_CODE_PERSONNEL_RETIRE = "scheduled_code_personnel_retire"; + /** * 用户TOKEN密钥 */ diff --git a/src/main/java/com/ydool/platform/mybatis/handler/CustomMetaObjectHandler.java b/src/main/java/com/ydool/platform/mybatis/handler/CustomMetaObjectHandler.java index d4c3e35..16d6a2f 100644 --- a/src/main/java/com/ydool/platform/mybatis/handler/CustomMetaObjectHandler.java +++ b/src/main/java/com/ydool/platform/mybatis/handler/CustomMetaObjectHandler.java @@ -1,8 +1,11 @@ package com.ydool.platform.mybatis.handler; import cn.dev33.satoken.stp.StpUtil; +import cn.hutool.core.util.StrUtil; import cn.hutool.extra.spring.SpringUtil; import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler; +import com.ydool.common.cache.ConfigCache; +import com.ydool.common.utils.CacheUtil; import lombok.extern.slf4j.Slf4j; import org.apache.ibatis.reflection.MetaObject; import org.springframework.beans.factory.annotation.Autowired; @@ -22,10 +25,10 @@ public class CustomMetaObjectHandler implements MetaObjectHandler { */ @Override public void insertFill(MetaObject metaObject) { - -// this.setFieldValByName("createdId", StpUtil.getLoginIdAsString(), metaObject); + String scheduled = getScheduled(); + this.setFieldValByName("createdId", StrUtil.isNotBlank(scheduled) ? "":StpUtil.getLoginIdAsString(), metaObject); this.setFieldValByName("createdAt", LocalDateTime.now(), metaObject); -// this.setFieldValByName("updatedId", StpUtil.getLoginIdAsString(), metaObject); + this.setFieldValByName("updatedId", StrUtil.isNotBlank(scheduled) ? "":StpUtil.getLoginIdAsString(), metaObject); this.setFieldValByName("updatedAt", LocalDateTime.now(), metaObject); } @@ -36,8 +39,14 @@ public class CustomMetaObjectHandler implements MetaObjectHandler { */ @Override public void updateFill(MetaObject metaObject) { -// this.setFieldValByName("updatedId", StpUtil.getLoginIdAsString(), metaObject); + String scheduled = getScheduled(); + this.setFieldValByName("updatedId", StrUtil.isNotBlank(scheduled) ? "":StpUtil.getLoginIdAsString(), metaObject); this.setFieldValByName("updatedAt", LocalDateTime.now(), metaObject); } + public String getScheduled() { + String scheduled = CacheUtil.get(ConfigCache.SCHEDULED_CODE_PERSONNEL_RETIRE, ConfigCache.SCHEDULED_CODE_PERSONNEL_RETIRE, "scheduled").toString(); + return scheduled; + } + } diff --git a/src/main/java/com/ydool/staff/service/impl/PersonnelServiceImpl.java b/src/main/java/com/ydool/staff/service/impl/PersonnelServiceImpl.java index 21b6cd6..f22193c 100644 --- a/src/main/java/com/ydool/staff/service/impl/PersonnelServiceImpl.java +++ b/src/main/java/com/ydool/staff/service/impl/PersonnelServiceImpl.java @@ -16,6 +16,7 @@ import com.ydool.common.base.BaseService; import com.ydool.common.cache.ConfigCache; import com.ydool.common.constant.ArgsConst; import com.ydool.common.data.dto.AjaxResult; +import com.ydool.common.utils.CacheUtil; import com.ydool.common.utils.ColumnUtil; import com.ydool.common.utils.EasyExcelAlibabaUtil; import com.ydool.oa.workFlow.data.entity.WorkFlowNotice; @@ -804,6 +805,7 @@ public class PersonnelServiceImpl extends BaseService().eq(Config::getParamKey, ConfigCache.SYS_USER_LEADERSHIP)); User user = userMapper.selectOne(new LambdaQueryWrapper().eq(User::getLoginName, config.getParamValue())); for (Personnel personnel : list) { @@ -821,6 +823,7 @@ public class PersonnelServiceImpl extends BaseService + + + +