From 6a68085870e4c01f1640708a056c79720e551c86 Mon Sep 17 00:00:00 2001 From: lanyuanxiaoyao Date: Thu, 5 Dec 2024 17:57:27 +0800 Subject: [PATCH] =?UTF-8?q?feat(authentication):=20=E4=B8=BA=20Authenticat?= =?UTF-8?q?ion=20=E5=AE=9E=E4=BD=93=E6=B7=BB=E5=8A=A0=E8=BD=AF=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 Authentication 类中添加 @SQLDelete 和 @Where 注解,实现软删除 - 移除 target 和 evidences 关联中的 @Where 注解,避免重复应用软删除逻辑 --- .../web/domain/authentication/entity/Authentication.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/authentication/entity/Authentication.java b/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/authentication/entity/Authentication.java index 10de288..7707463 100644 --- a/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/authentication/entity/Authentication.java +++ b/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/authentication/entity/Authentication.java @@ -25,6 +25,7 @@ import lombok.Getter; import lombok.Setter; import lombok.ToString; import org.hibernate.annotations.DynamicUpdate; +import org.hibernate.annotations.SQLDelete; import org.hibernate.annotations.Where; import org.springframework.data.jpa.domain.support.AuditingEntityListener; @@ -51,15 +52,15 @@ import org.springframework.data.jpa.domain.support.AuditingEntityListener; @NamedAttributeNode(value = "createdUser"), @NamedAttributeNode(value = "modifiedUser"), }) +@SQLDelete(sql = "update " + Constants.TABLE_PREFIX + "authentication" + " set deleted = true where id = ?") +@Where(clause = LogicDeleteEntity.LOGIC_DELETE_CLAUSE) public class Authentication extends CheckingNeededEntity { @ManyToOne(fetch = FetchType.EAGER) @JoinColumn(nullable = false, foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT)) - @Where(clause = LogicDeleteEntity.LOGIC_DELETE_CLAUSE) private DataResource target; @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY) @JoinTable(foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT), inverseForeignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT)) @ToString.Exclude - @Where(clause = LogicDeleteEntity.LOGIC_DELETE_CLAUSE) private Set evidences; /** * 生效时间