IdEntityWithCreateTime.java 894 B

1234567891011121314151617181920212223242526272829303132
  1. package com.yihu.jw.entity;
  2. import com.fasterxml.jackson.annotation.JsonFormat;
  3. import org.springframework.data.annotation.CreatedDate;
  4. import org.springframework.data.jpa.domain.support.AuditingEntityListener;
  5. import javax.persistence.Column;
  6. import javax.persistence.EntityListeners;
  7. import javax.persistence.MappedSuperclass;
  8. import java.util.Date;
  9. /**
  10. * Created by lith on 2019/3/13.
  11. */
  12. @MappedSuperclass
  13. @EntityListeners(AuditingEntityListener.class)
  14. public abstract class IdEntityWithCreateTime extends IdEntity {
  15. protected Date createTime;
  16. @CreatedDate
  17. @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
  18. @Column(name = "create_time", nullable = false, length = 0,updatable = false)
  19. public Date getCreateTime() {
  20. return createTime;
  21. }
  22. public void setCreateTime(Date createTime) {
  23. this.createTime = createTime;
  24. }
  25. }