-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…tities feat(#166): auditted entities
- Loading branch information
Showing
16 changed files
with
395 additions
and
280 deletions.
There are no files selected for viewing
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
57 changes: 57 additions & 0 deletions
57
...tor-starter/src/main/java/org/citrusframework/simulator/model/AbstractAuditingEntity.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package org.citrusframework.simulator.model; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import jakarta.persistence.Column; | ||
import jakarta.persistence.EntityListeners; | ||
import jakarta.persistence.MappedSuperclass; | ||
import org.springframework.data.annotation.CreatedDate; | ||
import org.springframework.data.annotation.LastModifiedDate; | ||
import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ||
|
||
import java.io.Serializable; | ||
import java.time.Instant; | ||
|
||
/** | ||
* Base abstract class for entities which will hold definitions for created and last modified by attributes. | ||
*/ | ||
@MappedSuperclass | ||
@EntityListeners({ AuditingEntityListener.class }) | ||
@JsonIgnoreProperties(value = { "createdDate", "lastModifiedDate" }, allowGetters = true) | ||
public abstract class AbstractAuditingEntity<T, I> implements Serializable { | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
@CreatedDate | ||
@Column(name = "created_date", nullable = false, updatable = false) | ||
private Instant createdDate = Instant.now(); | ||
|
||
@LastModifiedDate | ||
@Column(name = "last_modified_date") | ||
private Instant lastModifiedDate = Instant.now(); | ||
|
||
public Instant getCreatedDate() { | ||
return createdDate; | ||
} | ||
|
||
public void setCreatedDate(Instant createdDate) { | ||
this.createdDate = createdDate; | ||
} | ||
|
||
public T createdDate(Instant createdDate) { | ||
setCreatedDate(createdDate); | ||
return (T) this; | ||
} | ||
|
||
public Instant getLastModifiedDate() { | ||
return lastModifiedDate; | ||
} | ||
|
||
public void setLastModifiedDate(Instant lastModifiedDate) { | ||
this.lastModifiedDate = lastModifiedDate; | ||
} | ||
|
||
public T lastModifiedDate(Instant lastModifiedDate) { | ||
setLastModifiedDate(lastModifiedDate); | ||
return (T) this; | ||
} | ||
} |
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
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
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
Oops, something went wrong.