Skip to content

Commit

Permalink
feat: Member 엔티티 작성
Browse files Browse the repository at this point in the history
- UserDetails 인터페이스를 구현
- MemberRole Enum 클래스 추가
  • Loading branch information
SJ70 committed Jun 29, 2024
1 parent 34152ec commit 53302d0
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 0 deletions.
80 changes: 80 additions & 0 deletions src/main/java/com/j9/bestmoments/member/Member.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package com.j9.bestmoments.member;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import java.util.Collection;
import java.util.UUID;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.GenericGenerator;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

@Entity
@Getter
@EqualsAndHashCode
@NoArgsConstructor
public class Member implements UserDetails {

@Id
@GeneratedValue(strategy = GenerationType.UUID)
@GenericGenerator(name="uuid2", strategy = "uuid2")
@Column(columnDefinition = "BINARY(16)")
private UUID id;
private String oauthProvider;
private String oauthId;
private String name;
private String email;
private MemberRole role;
private String profileImageUrl;

@Builder
private Member(String name, String email, MemberRole role, String profileImageUrl, String oauthProvider, String oauthId) {
this.name = name;
this.email = email;
this.role = role;
this.profileImageUrl = profileImageUrl;
this.oauthProvider = oauthProvider;
this.oauthId = oauthId;
}

@Override
public Collection<? extends GrantedAuthority> getAuthorities() {
return null;
}

@Override
public String getPassword() {
return null;
}

@Override
public String getUsername() {
return id.toString();
}

@Override
public boolean isAccountNonExpired() {
return true;
}

@Override
public boolean isAccountNonLocked() {
return true;
}

@Override
public boolean isCredentialsNonExpired() {
return true;
}

@Override
public boolean isEnabled() {
return true;
}
}
16 changes: 16 additions & 0 deletions src/main/java/com/j9/bestmoments/member/MemberRole.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.j9.bestmoments.member;

import lombok.Getter;
import lombok.RequiredArgsConstructor;

@RequiredArgsConstructor
@Getter
public enum MemberRole {

USER("user"),
ADMIN("admin"),
;

private final String key;

}

0 comments on commit 53302d0

Please sign in to comment.