diff --git a/src/main/java/com/loafle/overflow/models/TblEmailAuth.java b/src/main/java/com/loafle/overflow/models/TblEmailAuth.java deleted file mode 100644 index bf5ef88..0000000 --- a/src/main/java/com/loafle/overflow/models/TblEmailAuth.java +++ /dev/null @@ -1,94 +0,0 @@ -package com.loafle.overflow.models; - -import javax.persistence.*; -import java.sql.Timestamp; - -/** - * Created by root on 17. 6. 22. - */ -@Entity -@Table(name = "TBL_EMAIL_AUTH", schema = "public", catalog = "postgres") -public class TblEmailAuth { - private long id; - private String emailAuthKey; - private Timestamp createDate; - private Timestamp authConfirmDate; - private long memberId; - - @Id - @Column(name = "ID", nullable = false) - public long getId() { - return id; - } - - public void setId(long id) { - this.id = id; - } - - @Basic - @Column(name = "EMAIL_AUTH_KEY", nullable = true, length = 50) - public String getEmailAuthKey() { - return emailAuthKey; - } - - public void setEmailAuthKey(String emailAuthKey) { - this.emailAuthKey = emailAuthKey; - } - - @Basic - @Column(name = "CREATE_DATE", nullable = false) - public Timestamp getCreateDate() { - return createDate; - } - - public void setCreateDate(Timestamp createDate) { - this.createDate = createDate; - } - - @Basic - @Column(name = "AUTH_CONFIRM_DATE", nullable = true) - public Timestamp getAuthConfirmDate() { - return authConfirmDate; - } - - public void setAuthConfirmDate(Timestamp authConfirmDate) { - this.authConfirmDate = authConfirmDate; - } - - @Basic - @Column(name = "MEMBER_ID", nullable = false) - public long getMemberId() { - return memberId; - } - - public void setMemberId(long memberId) { - this.memberId = memberId; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - TblEmailAuth that = (TblEmailAuth) o; - - if (id != that.id) return false; - if (memberId != that.memberId) return false; - if (emailAuthKey != null ? !emailAuthKey.equals(that.emailAuthKey) : that.emailAuthKey != null) return false; - if (createDate != null ? !createDate.equals(that.createDate) : that.createDate != null) return false; - if (authConfirmDate != null ? !authConfirmDate.equals(that.authConfirmDate) : that.authConfirmDate != null) - return false; - - return true; - } - - @Override - public int hashCode() { - int result = (int) (id ^ (id >>> 32)); - result = 31 * result + (emailAuthKey != null ? emailAuthKey.hashCode() : 0); - result = 31 * result + (createDate != null ? createDate.hashCode() : 0); - result = 31 * result + (authConfirmDate != null ? authConfirmDate.hashCode() : 0); - result = 31 * result + (int) (memberId ^ (memberId >>> 32)); - return result; - } -} diff --git a/src/main/java/com/loafle/overflow/module/domain/Domain.java b/src/main/java/com/loafle/overflow/module/domain/Domain.java index f43be5e..703ef33 100644 --- a/src/main/java/com/loafle/overflow/module/domain/Domain.java +++ b/src/main/java/com/loafle/overflow/module/domain/Domain.java @@ -43,17 +43,4 @@ public class Domain { this.createDate = createDate; } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Domain tblDomain = (Domain) o; - - if (id != tblDomain.id) return false; - if (name != null ? !name.equals(tblDomain.name) : tblDomain.name != null) return false; - if (createDate != null ? !createDate.equals(tblDomain.createDate) : tblDomain.createDate != null) return false; - - return true; - } } diff --git a/src/main/java/com/loafle/overflow/module/email/dao/EmailAuthDAO.java b/src/main/java/com/loafle/overflow/module/email/dao/EmailAuthDAO.java index ba8127e..8379210 100644 --- a/src/main/java/com/loafle/overflow/module/email/dao/EmailAuthDAO.java +++ b/src/main/java/com/loafle/overflow/module/email/dao/EmailAuthDAO.java @@ -1,11 +1,8 @@ package com.loafle.overflow.module.email.dao; -import com.loafle.overflow.module.email.model.EmailAuth; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; -import java.util.List; - /** * Created by geek@loafle.com on 17. 6. 6. */ diff --git a/src/main/java/com/loafle/overflow/module/email/model/EmailAuth.java b/src/main/java/com/loafle/overflow/module/email/model/EmailAuth.java index 2c92d51..cfdb0c6 100644 --- a/src/main/java/com/loafle/overflow/module/email/model/EmailAuth.java +++ b/src/main/java/com/loafle/overflow/module/email/model/EmailAuth.java @@ -1,111 +1,69 @@ package com.loafle.overflow.module.email.model; +import com.loafle.overflow.module.member.model.Member; + import javax.persistence.*; -import java.io.Serializable; -import java.util.Date; +import java.sql.Timestamp; /** - * Created by geek@loafle.com on 17. 6. 6. + * Created by root on 17. 6. 22. */ -@SuppressWarnings("serial") -@Entity(name="EMAIL_AUTH") -public class EmailAuth implements Serializable { +@Entity +@Table(name = "TBL_EMAIL_AUTH", schema = "public", catalog = "postgres") +public class EmailAuth { + private long id; + private String emailAuthKey; + private Timestamp createDate; + private Timestamp authConfirmDate; + private Member member; @Id @GeneratedValue(strategy= GenerationType.IDENTITY) - private Long id; - - @ManyToOne - @JoinColumn(name = "MEMBER_ID", nullable=false) - private Member member; - - @Column(name="AUTH_TOKEN", unique=true, nullable=false) - private String authToken; - - @Column(name = "IS_INVALID") - private Boolean isInvalid; - - @Column(name = "IS_CONFIRM") - private Boolean isConfirm; - - @Column(name = "CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false) - private Date createDate; - - @Column(name = "UPDATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = true) - private Date updateDate; - - @Column(name = "CONFIRM_DATE") - private Date confirmDate; - - public EmailAuth() { - - } - - public EmailAuth(Long id) { - this.id = id; - } - - public Long getId() { + public long getId() { return id; } - public void setId(Long id) { + public void setId(long id) { this.id = id; } + @Basic + @Column(name = "EMAIL_AUTH_KEY", nullable = true, length = 50) + public String getEmailAuthKey() { + return emailAuthKey; + } + + public void setEmailAuthKey(String emailAuthKey) { + this.emailAuthKey = emailAuthKey; + } + + @Basic + @Column(name = "CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false) + public Timestamp getCreateDate() { + return createDate; + } + + public void setCreateDate(Timestamp createDate) { + this.createDate = createDate; + } + + @Basic + @Column(name = "AUTH_CONFIRM_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false) + public Timestamp getAuthConfirmDate() { + return authConfirmDate; + } + + public void setAuthConfirmDate(Timestamp authConfirmDate) { + this.authConfirmDate = authConfirmDate; + } + + @Basic + @Column(name = "MEMBER_ID", nullable = false) public Member getMember() { return member; } - public void setMember(Member member) { + public void setMember(Member memberId) { this.member = member; } - - public String getAuthToken() { - return authToken; - } - - public void setAuthToken(String authToken) { - this.authToken = authToken; - } - - public Boolean getIsInvalid() { - return isInvalid; - } - - public void setIsInvalid(Boolean invalid) { - isInvalid = invalid; - } - - public Boolean getIsConfirm() { - return isConfirm; - } - - public void setIsConfirm(Boolean confirm) { - isConfirm = confirm; - } - - public Date getCreateDate() { - return createDate; - } - - public void setCreateDate(Date createDate) { - this.createDate = createDate; - } - - public Date getUpdateDate() { - return updateDate; - } - - public void setUpdateDate(Date updateDate) { - this.updateDate = updateDate; - } - - public Date getConfirmDate() { - return confirmDate; - } - - public void setConfirmDate(Date confirmDate) { - this.confirmDate = confirmDate; - } } diff --git a/src/main/java/com/loafle/overflow/module/member/dao/JPAMemberDAO.java b/src/main/java/com/loafle/overflow/module/member/dao/JPAMemberDAO.java deleted file mode 100644 index 4187217..0000000 --- a/src/main/java/com/loafle/overflow/module/member/dao/JPAMemberDAO.java +++ /dev/null @@ -1,26 +0,0 @@ -//package com.loafle.overflow.module.member.dao; -// -//import com.loafle.overflow.commons.dao.JPABaseDAO; -//import com.loafle.overflow.module.member.model.Member; -// -//import javax.persistence.Query; -// -///** -// * Created by insanity on 17. 5. 25. -// */ -//public class JPAMemberDAO extends JPABaseDAO implements MemberDAO{ -// public Member findByEmail(Member member) { -// -// Query query = getEntityManager().createNativeQuery("SELECT m.* FROM MEMBER m WHERE m.email = :email", Member.class); -// query.setParameter("email", member.getEmail()); -// -// Member retMember = null; -// try { -// retMember = (Member)query.getSingleResult(); -// }catch(Exception e) { -// e.printStackTrace(); -// }finally { -// return retMember; -// } -// } -//} diff --git a/src/main/java/com/loafle/overflow/module/member/dao/MemberDAO.java b/src/main/java/com/loafle/overflow/module/member/dao/MemberDAO.java index 7269864..7284b65 100644 --- a/src/main/java/com/loafle/overflow/module/member/dao/MemberDAO.java +++ b/src/main/java/com/loafle/overflow/module/member/dao/MemberDAO.java @@ -1,6 +1,8 @@ package com.loafle.overflow.module.member.dao; +import com.loafle.overflow.module.member.model.Member; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; import org.springframework.stereotype.Repository; /** @@ -8,5 +10,6 @@ import org.springframework.stereotype.Repository; */ @Repository public interface MemberDAO extends JpaRepository { -// public Member findByEmail(Member member); + @Query("SELECT m FROM MEMBER m WHERE m.email = :email") + Member findByEmail(Member member); }