Skip to content

Commit

Permalink
[refactor] : BaseEntity 제거
Browse files Browse the repository at this point in the history
  • Loading branch information
chahyunsoo committed May 8, 2024
1 parent 3d03863 commit 3c87475
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@
import lombok.*;
import org.springframework.security.crypto.password.PasswordEncoder;
import seoul.gonggong.domain.member.domain.Authority;
import seoul.gonggong.global.BaseEntity;

@Entity
@Table(name = "agents")
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor
@Builder
public class AgentEntity extends BaseEntity {
public class AgentEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@
import jakarta.persistence.*;
import lombok.*;
import org.springframework.security.crypto.password.PasswordEncoder;
import seoul.gonggong.global.BaseEntity;

@Entity
@Table(name = "members")
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor
@Builder
public class MemberEntity extends BaseEntity {
public class MemberEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
Expand All @@ -28,11 +27,11 @@ public class MemberEntity extends BaseEntity {
@Enumerated(EnumType.STRING)
private Authority authority;

public static MemberEntity of(Long id, String email, String username, String password,Authority authority) {
public static MemberEntity of(Long id, String email, String username, String password, Authority authority) {
return new MemberEntity(id, email, username, password, authority);
}

public void encodePassword(PasswordEncoder passwordEncoder){
public void encodePassword(PasswordEncoder passwordEncoder) {
this.password = passwordEncoder.encode(password);
}

Expand Down
50 changes: 25 additions & 25 deletions src/main/java/seoul/gonggong/global/BaseEntity.java
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
package seoul.gonggong.global;

import jakarta.persistence.Column;
import jakarta.persistence.EntityListeners;
import jakarta.persistence.MappedSuperclass;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import java.time.LocalDateTime;

@MappedSuperclass
@Getter
@NoArgsConstructor(access = lombok.AccessLevel.PROTECTED)
@EntityListeners(AuditingEntityListener.class)
public abstract class BaseEntity {
@CreatedDate
@Column(updatable = false)
private LocalDateTime createdAt;

@LastModifiedDate
private LocalDateTime updatedAt;
}
//package seoul.gonggong.global;
//
//import jakarta.persistence.Column;
//import jakarta.persistence.EntityListeners;
//import jakarta.persistence.MappedSuperclass;
//import lombok.Getter;
//import lombok.NoArgsConstructor;
//import org.springframework.data.annotation.CreatedDate;
//import org.springframework.data.annotation.LastModifiedDate;
//import org.springframework.data.jpa.domain.support.AuditingEntityListener;
//
//import java.time.LocalDateTime;
//
//@MappedSuperclass
//@Getter
//@NoArgsConstructor(access = lombok.AccessLevel.PROTECTED)
//@EntityListeners(AuditingEntityListener.class)
//public abstract class BaseEntity {
// @CreatedDate
// @Column(updatable = false)
// private LocalDateTime createdAt;
//
// @LastModifiedDate
// private LocalDateTime updatedAt;
//}

0 comments on commit 3c87475

Please sign in to comment.