Last active
August 4, 2024 18:38
-
-
Save bonniss/173b696aeb596f9ec17cc72d155a626c to your computer and use it in GitHub Desktop.
Entity sample sinh bởi JHipster
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package vn.ric.dragon.domain; | |
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | |
import jakarta.persistence.*; | |
import jakarta.validation.constraints.*; | |
import java.io.Serializable; | |
import java.time.Instant; | |
import org.hibernate.annotations.Cache; | |
import org.hibernate.annotations.CacheConcurrencyStrategy; | |
import org.springframework.data.domain.Persistable; | |
/** | |
* Vai trò nhân viên trong đơn vị | |
* @lang vi Vai trò | |
*/ | |
@Entity | |
@Table(name = "app_agency_role") | |
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE) | |
@JsonIgnoreProperties(value = { "new" }) | |
@SuppressWarnings("common-java:DuplicatedBlocks") | |
public class AppAgencyRole extends AbstractAuditingEntity<Long> implements Serializable, Persistable<Long> { | |
private static final long serialVersionUID = 1L; | |
@Id | |
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator") | |
@SequenceGenerator(name = "sequenceGenerator") | |
@Column(name = "id") | |
private Long id; | |
@NotNull | |
@Size(min = 2, max = 256) | |
@Column(name = "name", length = 256, nullable = false) | |
private String name; | |
@Size(max = 65535) | |
@Column(name = "description", length = 65535) | |
private String description; | |
/** | |
* Cấu hình quyền hạn cho vai trò | |
* | |
* @lang vi Cấu hình quyền JSON | |
*/ | |
@Lob | |
@Column(name = "permission_grid_json") | |
private String permissionGridJson; | |
// Inherited createdBy definition | |
// Inherited createdDate definition | |
// Inherited lastModifiedBy definition | |
// Inherited lastModifiedDate definition | |
@Transient | |
private boolean isPersisted; | |
@ManyToOne(fetch = FetchType.LAZY) | |
@JsonIgnoreProperties(value = { "industry", "appManager", "organization" }, allowSetters = true) | |
private OrgApplication application; | |
// jhipster-needle-entity-add-field - JHipster will add fields here | |
public Long getId() { | |
return this.id; | |
} | |
public AppAgencyRole id(Long id) { | |
this.setId(id); | |
return this; | |
} | |
public void setId(Long id) { | |
this.id = id; | |
} | |
public String getName() { | |
return this.name; | |
} | |
public AppAgencyRole name(String name) { | |
this.setName(name); | |
return this; | |
} | |
public void setName(String name) { | |
this.name = name; | |
} | |
public String getDescription() { | |
return this.description; | |
} | |
public AppAgencyRole description(String description) { | |
this.setDescription(description); | |
return this; | |
} | |
public void setDescription(String description) { | |
this.description = description; | |
} | |
public String getPermissionGridJson() { | |
return this.permissionGridJson; | |
} | |
public AppAgencyRole permissionGridJson(String permissionGridJson) { | |
this.setPermissionGridJson(permissionGridJson); | |
return this; | |
} | |
public void setPermissionGridJson(String permissionGridJson) { | |
this.permissionGridJson = permissionGridJson; | |
} | |
// Inherited createdBy methods | |
public AppAgencyRole createdBy(String createdBy) { | |
this.setCreatedBy(createdBy); | |
return this; | |
} | |
// Inherited createdDate methods | |
public AppAgencyRole createdDate(Instant createdDate) { | |
this.setCreatedDate(createdDate); | |
return this; | |
} | |
// Inherited lastModifiedBy methods | |
public AppAgencyRole lastModifiedBy(String lastModifiedBy) { | |
this.setLastModifiedBy(lastModifiedBy); | |
return this; | |
} | |
// Inherited lastModifiedDate methods | |
public AppAgencyRole lastModifiedDate(Instant lastModifiedDate) { | |
this.setLastModifiedDate(lastModifiedDate); | |
return this; | |
} | |
@PostLoad | |
@PostPersist | |
public void updateEntityState() { | |
this.setIsPersisted(); | |
} | |
@Transient | |
@Override | |
public boolean isNew() { | |
return !this.isPersisted; | |
} | |
public AppAgencyRole setIsPersisted() { | |
this.isPersisted = true; | |
return this; | |
} | |
public OrgApplication getApplication() { | |
return this.application; | |
} | |
public void setApplication(OrgApplication orgApplication) { | |
this.application = orgApplication; | |
} | |
public AppAgencyRole application(OrgApplication orgApplication) { | |
this.setApplication(orgApplication); | |
return this; | |
} | |
// jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here | |
@Override | |
public boolean equals(Object o) { | |
if (this == o) { | |
return true; | |
} | |
if (!(o instanceof AppAgencyRole)) { | |
return false; | |
} | |
return getId() != null && getId().equals(((AppAgencyRole) o).getId()); | |
} | |
@Override | |
public int hashCode() { | |
// see https://vladmihalcea.com/how-to-implement-equals-and-hashcode-using-the-jpa-entity-identifier/ | |
return getClass().hashCode(); | |
} | |
// prettier-ignore | |
@Override | |
public String toString() { | |
return "AppAgencyRole{" + | |
"id=" + getId() + | |
", name='" + getName() + "'" + | |
", description='" + getDescription() + "'" + | |
", permissionGridJson='" + getPermissionGridJson() + "'" + | |
", createdBy='" + getCreatedBy() + "'" + | |
", createdDate='" + getCreatedDate() + "'" + | |
", lastModifiedBy='" + getLastModifiedBy() + "'" + | |
", lastModifiedDate='" + getLastModifiedDate() + "'" + | |
"}"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment