Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

πŸ”€ :: User Entity #1

Merged
merged 5 commits into from
Jul 30, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/main/java/com/msg/gauth/domain/enums/Gender.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.msg.gauth.domain.enums;

public enum Gender {
MALE, FEMALE
}
12 changes: 12 additions & 0 deletions src/main/java/com/msg/gauth/domain/enums/UserRole.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.msg.gauth.domain.enums;

import org.springframework.security.core.GrantedAuthority;

public enum UserRole implements GrantedAuthority {
ROLE_STUDENT, ROLE_TEACHER, ROLE_ADMIN;

@Override
public String getAuthority() {
return name();
}
}
5 changes: 5 additions & 0 deletions src/main/java/com/msg/gauth/domain/enums/UserState.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.msg.gauth.domain.enums;

public enum UserState {
PENDING, CREATED
}
40 changes: 40 additions & 0 deletions src/main/java/com/msg/gauth/domain/user/User.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.msg.gauth.domain.user;

import com.msg.gauth.domain.enums.Gender;
import com.msg.gauth.domain.enums.UserRole;
import com.msg.gauth.domain.enums.UserState;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import javax.persistence.*;

@Entity
@AllArgsConstructor
@NoArgsConstructor
@Getter
public class User {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

private Integer grade;

private Integer classNum;

private Integer num;

@Column(unique = true)
private String email;

@Enumerated(EnumType.STRING)
@ElementCollection(fetch = FetchType.EAGER)
@CollectionTable(name = "Role", joinColumns = @JoinColumn(name = "id"))
baekteun marked this conversation as resolved.
Show resolved Hide resolved
private List<Role> roles = new ArrayList<>();
baekteun marked this conversation as resolved.
Show resolved Hide resolved

@Enumerated(EnumType.STRING)
private UserState state;

@Enumerated(EnumType.STRING)
private Gender gender;
}