update 定时任务时间1

This commit is contained in:
mash 2023-11-02 11:32:55 +08:00
parent 7e942a09ec
commit 0f02e687df
3 changed files with 16 additions and 11 deletions

View File

@ -25,10 +25,10 @@ public class CustomMetaObjectHandler implements MetaObjectHandler {
*/ */
@Override @Override
public void insertFill(MetaObject metaObject) { public void insertFill(MetaObject metaObject) {
String scheduled = getScheduled(); Boolean flag = getScheduled();
this.setFieldValByName("createdId", StrUtil.isNotBlank(scheduled) ? "":StpUtil.getLoginIdAsString(), metaObject); this.setFieldValByName("createdId", flag ? null:StpUtil.getLoginIdAsString(), metaObject);
this.setFieldValByName("createdAt", LocalDateTime.now(), metaObject); this.setFieldValByName("createdAt", LocalDateTime.now(), metaObject);
this.setFieldValByName("updatedId", StrUtil.isNotBlank(scheduled) ? "":StpUtil.getLoginIdAsString(), metaObject); this.setFieldValByName("updatedId", flag ? null:StpUtil.getLoginIdAsString(), metaObject);
this.setFieldValByName("updatedAt", LocalDateTime.now(), metaObject); this.setFieldValByName("updatedAt", LocalDateTime.now(), metaObject);
} }
@ -39,14 +39,18 @@ public class CustomMetaObjectHandler implements MetaObjectHandler {
*/ */
@Override @Override
public void updateFill(MetaObject metaObject) { public void updateFill(MetaObject metaObject) {
String scheduled = getScheduled(); Boolean flag = getScheduled();
this.setFieldValByName("updatedId", StrUtil.isNotBlank(scheduled) ? "":StpUtil.getLoginIdAsString(), metaObject); this.setFieldValByName("updatedId", flag ? null:StpUtil.getLoginIdAsString(), metaObject);
this.setFieldValByName("updatedAt", LocalDateTime.now(), metaObject); this.setFieldValByName("updatedAt", LocalDateTime.now(), metaObject);
} }
public String getScheduled() { public Boolean getScheduled() {
Boolean flag= false;
String scheduled = CacheUtil.get(ConfigCache.SCHEDULED_CODE_PERSONNEL_RETIRE, ConfigCache.SCHEDULED_CODE_PERSONNEL_RETIRE, "scheduled").toString(); String scheduled = CacheUtil.get(ConfigCache.SCHEDULED_CODE_PERSONNEL_RETIRE, ConfigCache.SCHEDULED_CODE_PERSONNEL_RETIRE, "scheduled").toString();
return scheduled; if ("true".equals(scheduled)){
return flag = true;
}
return flag;
} }
} }

View File

@ -12,6 +12,7 @@ import com.ydool.common.base.BaseService;
import com.ydool.common.cache.ConfigCache; import com.ydool.common.cache.ConfigCache;
import com.ydool.common.constant.UrlConstant; import com.ydool.common.constant.UrlConstant;
import com.ydool.common.data.dto.AjaxResult; import com.ydool.common.data.dto.AjaxResult;
import com.ydool.common.utils.CacheUtil;
import com.ydool.common.utils.HttpServletUtil; import com.ydool.common.utils.HttpServletUtil;
import com.ydool.common.utils.PasswordUtil; import com.ydool.common.utils.PasswordUtil;
import com.ydool.common.utils.RsaUtil; import com.ydool.common.utils.RsaUtil;
@ -84,7 +85,7 @@ public class AuthServiceImpl extends BaseService<UserMapper, User> implements IA
// 第1步先登录上 // 第1步先登录上
StpUtil.login(loginUser.getId()); StpUtil.login(loginUser.getId());
CacheUtil.put(ConfigCache.SCHEDULED_CODE_PERSONNEL_RETIRE, ConfigCache.SCHEDULED_CODE_PERSONNEL_RETIRE, "scheduled", false);
boolean flag = updateById(loginUser); boolean flag = updateById(loginUser);
if (flag) { if (flag) {

View File

@ -97,13 +97,13 @@
overflowToDisk="false"> overflowToDisk="false">
</cache> </cache>
<!-- 登录手机验证码,缓存十分钟 --> <!-- 定时任务编码,缓存十分钟 -->
<cache name="scheduled_code_personnel_retire" <cache name="scheduled_code_personnel_retire"
maxElementsInMemory="1" maxElementsInMemory="1"
maxEntriesLocalHeap="0" maxEntriesLocalHeap="0"
eternal="false" eternal="false"
timeToIdleSeconds="600" timeToIdleSeconds="86400"
timeToLiveSeconds="600" timeToLiveSeconds="86400"
overflowToDisk="false"> overflowToDisk="false">
</cache> </cache>