From b3b37f5a9ae23e9dbda44d99174f77b4f8b54155 Mon Sep 17 00:00:00 2001 From: zhouhao Date: Sat, 12 Oct 2024 18:22:42 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/crud/entity/RecordModifierEntity.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/hsweb-commons/hsweb-commons-api/src/main/java/org/hswebframework/web/api/crud/entity/RecordModifierEntity.java b/hsweb-commons/hsweb-commons-api/src/main/java/org/hswebframework/web/api/crud/entity/RecordModifierEntity.java index 4811967a5..685758856 100644 --- a/hsweb-commons/hsweb-commons-api/src/main/java/org/hswebframework/web/api/crud/entity/RecordModifierEntity.java +++ b/hsweb-commons/hsweb-commons-api/src/main/java/org/hswebframework/web/api/crud/entity/RecordModifierEntity.java @@ -1,6 +1,8 @@ package org.hswebframework.web.api.crud.entity; import com.fasterxml.jackson.annotation.JsonIgnore; +import reactor.util.context.Context; +import reactor.util.context.ContextView; /** * 记录修改信息的实体类,包括修改人和修改时间。 @@ -63,4 +65,26 @@ public interface RecordModifierEntity extends Entity { default String getModifierIdProperty() { return modifierId; } + + /** + * 标记不自动更新修改人相关内容 + * + * @param ctx 上下文 + * @return 上下文 + */ + static Context markDoNotUpdate(Context ctx) { + return ctx.put(RecordModifierEntity.class, true); + } + + /** + * 判断上下文是否不更新修改人相关内容 + * + * @param ctx 上下文 + * @return 上下文 + */ + static boolean isDoNotUpdate(ContextView ctx) { + return Boolean.TRUE.equals( + ctx.getOrDefault(RecordModifierEntity.class, false) + ); + } }