user entity
This commit is contained in:
23
src/main/java/com/example/oneul/model/Post.java
Normal file
23
src/main/java/com/example/oneul/model/Post.java
Normal file
@@ -0,0 +1,23 @@
|
||||
package com.example.oneul.model;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
|
||||
import org.springframework.data.annotation.CreatedDate;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Getter
|
||||
@NoArgsConstructor
|
||||
@Entity
|
||||
public class Post {
|
||||
@Id @GeneratedValue
|
||||
private Long id;
|
||||
@CreatedDate
|
||||
private LocalDateTime createdAt;
|
||||
private String content;
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
package com.example.oneul.model;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
|
||||
@Entity
|
||||
public class User {
|
||||
@Id @GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private Long id;
|
||||
private String username;
|
||||
private String password;
|
||||
private LocalDate createdAt;
|
||||
|
||||
public Long getId(){
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public String getUsername(){
|
||||
return this.username;
|
||||
}
|
||||
|
||||
public String getPassword(){
|
||||
return this.password;
|
||||
}
|
||||
|
||||
public LocalDate getCreatedAt(){
|
||||
return this.createdAt;
|
||||
}
|
||||
}
|
||||
88
src/main/java/com/example/oneul/model/UserEntity.java
Normal file
88
src/main/java/com/example/oneul/model/UserEntity.java
Normal file
@@ -0,0 +1,88 @@
|
||||
package com.example.oneul.model;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
|
||||
import org.springframework.data.annotation.CreatedDate;
|
||||
|
||||
@Entity
|
||||
public class UserEntity {
|
||||
@Id @GeneratedValue
|
||||
private Long id;
|
||||
@Column(nullable = false)
|
||||
private String username;
|
||||
@Column(nullable = false)
|
||||
private String password;
|
||||
@CreatedDate
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
public Long getId(){
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public String getUsername(){
|
||||
return this.username;
|
||||
}
|
||||
|
||||
public String getPassword(){
|
||||
return this.password;
|
||||
}
|
||||
|
||||
public LocalDateTime getCreatedAt(){
|
||||
return this.createdAt;
|
||||
}
|
||||
|
||||
public UserEntity(Long id, String username, String password, LocalDateTime createdAt){
|
||||
this.id = id;
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
return "userEntity["
|
||||
+ "id: " + this.id
|
||||
+ ", username: " + this.username
|
||||
+ ", createdAt: " + this.createdAt
|
||||
+ "]";
|
||||
}
|
||||
public static class Builder {
|
||||
private Long id;
|
||||
private String username;
|
||||
private String password;
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
public UserEntity build() {
|
||||
return new UserEntity(
|
||||
id,
|
||||
username,
|
||||
password,
|
||||
createdAt);
|
||||
}
|
||||
|
||||
public Builder id(Long id){
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder username(String username){
|
||||
this.username = username;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder password(String password){
|
||||
this.password = password;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder createdAt(LocalDateTime createdAt){
|
||||
this.createdAt = createdAt;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user