1
0

feat(web): 增加数据授权结构

This commit is contained in:
2024-11-29 10:45:41 +08:00
parent 1740b7bea2
commit 4d1119997e
2 changed files with 98 additions and 0 deletions

View File

@@ -0,0 +1,92 @@
package com.eshore.gringotts.web.domain.authentication.entity;
import com.eshore.gringotts.core.Constants;
import com.eshore.gringotts.web.domain.base.entity.SimpleEntity;
import com.eshore.gringotts.web.domain.resource.entity.DataResource;
import com.eshore.gringotts.web.domain.upload.entity.DataFile;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.ConstraintMode;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.ForeignKey;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToOne;
import javax.persistence.NamedAttributeNode;
import javax.persistence.NamedEntityGraph;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.hibernate.annotations.DynamicUpdate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
/**
* 授权
*
* @author lanyuanxiaoyao
* @date 2024-11-29
*/
@Getter
@Setter
@ToString
@Entity
@DynamicUpdate
@EntityListeners(AuditingEntityListener.class)
@Table(name = Constants.TABLE_PREFIX + "authentication")
@NamedEntityGraph(name = "authentication.list", attributeNodes = {
@NamedAttributeNode(value = "target"),
@NamedAttributeNode(value = "createdUser"),
})
@NamedEntityGraph(name = "authentication.detail", attributeNodes = {
@NamedAttributeNode(value = "target"),
@NamedAttributeNode(value = "evidences"),
@NamedAttributeNode(value = "createdUser"),
@NamedAttributeNode(value = "modifiedUser"),
})
public class Authentication extends SimpleEntity {
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(nullable = false, foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
private DataResource target;
private String description;
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@JoinTable(foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT), inverseForeignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
@ToString.Exclude
private Set<DataFile> evidences;
@Column(nullable = false)
@Enumerated(EnumType.STRING)
private State state = State.DRAFT;
public enum State {
/**
* 无确权
*/
NONE,
/**
* 草稿
*/
DRAFT,
/**
* 属主审查中
*/
OWNER_CHECKING,
/**
* 审查中
*/
CHECKING,
/**
* 正常
*/
NORMAL,
/**
* 驳回
*/
REJECT,
}
}

View File

@@ -1,11 +1,13 @@
package com.eshore.gringotts.web.domain.resource.entity;
import com.eshore.gringotts.core.Constants;
import com.eshore.gringotts.web.domain.authentication.entity.Authentication;
import com.eshore.gringotts.web.domain.base.entity.SimpleEntity;
import com.eshore.gringotts.web.domain.confirmation.entity.Confirmation;
import com.eshore.gringotts.web.domain.resource.entity.format.ResourceFormat;
import com.eshore.gringotts.web.domain.resource.entity.type.ResourceType;
import com.eshore.gringotts.web.domain.upload.entity.DataFile;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.ConstraintMode;
@@ -16,6 +18,7 @@ import javax.persistence.ForeignKey;
import javax.persistence.JoinColumn;
import javax.persistence.NamedAttributeNode;
import javax.persistence.NamedEntityGraph;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import lombok.Getter;
@@ -64,4 +67,7 @@ public class DataResource extends SimpleEntity {
@OneToOne(cascade = CascadeType.REMOVE, fetch = FetchType.EAGER, mappedBy = "target")
@ToString.Exclude
private Confirmation confirmation;
@OneToMany(cascade = CascadeType.REMOVE, fetch = FetchType.EAGER, mappedBy = "target")
@ToString.Exclude
private Set<Authentication> authentications;
}