From 5a982538c6abb62390216190df5a410862557130 Mon Sep 17 00:00:00 2001 From: geek Date: Thu, 8 Mar 2018 18:54:54 +0900 Subject: [PATCH] Member TOTP Model Service DAO created --- .../module/member/dao/MemberTotpDAO.java | 16 +++++ .../overflow/module/member/model/Member.java | 20 ++++++ .../module/member/model/MemberTotp.java | 63 +++++++++++++++++++ .../member/service/MemberTotpService.java | 10 +++ 4 files changed, 109 insertions(+) create mode 100644 src/main/java/com/loafle/overflow/module/member/dao/MemberTotpDAO.java create mode 100644 src/main/java/com/loafle/overflow/module/member/model/MemberTotp.java create mode 100644 src/main/java/com/loafle/overflow/module/member/service/MemberTotpService.java diff --git a/src/main/java/com/loafle/overflow/module/member/dao/MemberTotpDAO.java b/src/main/java/com/loafle/overflow/module/member/dao/MemberTotpDAO.java new file mode 100644 index 0000000..eebf3f5 --- /dev/null +++ b/src/main/java/com/loafle/overflow/module/member/dao/MemberTotpDAO.java @@ -0,0 +1,16 @@ +package com.loafle.overflow.module.member.dao; + +import com.loafle.overflow.module.member.model.MemberTotp; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; + +/** + * Created by geek on 18. 3. 8. + */ +@Repository +public interface MemberTotpDAO extends JpaRepository { + @Query("select m from MemberTotp m WHERE m.secretCode = :secretCode") + MemberTotp findBySecretCode(@Param("secretCode") String secretCode); +} diff --git a/src/main/java/com/loafle/overflow/module/member/model/Member.java b/src/main/java/com/loafle/overflow/module/member/model/Member.java index 239d609..a53c194 100644 --- a/src/main/java/com/loafle/overflow/module/member/model/Member.java +++ b/src/main/java/com/loafle/overflow/module/member/model/Member.java @@ -22,6 +22,8 @@ public class Member { private Date createDate; private MetaMemberStatus status; private int signinFailCount; + private MemberTotp totp; + private boolean totpType; public Member() { } @@ -120,4 +122,22 @@ public class Member { this.signinFailCount = failCount; } + @OneToOne + @JsonIgnore + @JoinColumn(name = "MEMBER_TOTP", nullable = true) + public MemberTotp getTotp() { + return totp; + } + + public void setTotp(MemberTotp totp) { + this.totp = totp; + } + + public boolean isTotpType() { + return totpType; + } + + public void setTotpType(boolean totpType) { + this.totpType = totpType; + } } diff --git a/src/main/java/com/loafle/overflow/module/member/model/MemberTotp.java b/src/main/java/com/loafle/overflow/module/member/model/MemberTotp.java new file mode 100644 index 0000000..bb8b046 --- /dev/null +++ b/src/main/java/com/loafle/overflow/module/member/model/MemberTotp.java @@ -0,0 +1,63 @@ +package com.loafle.overflow.module.member.model; + +import javax.persistence.*; +import java.util.Date; + +/** + * Created by geek on 18. 3. 8. + */ +@Entity +@Table(name = "MEMBER", schema = "public") +public class MemberTotp { + private long id; + private String secretCode; + private Date createDate; + private Date updateDate; + + public MemberTotp() { + } + + public MemberTotp(long id) { + this.id = id; + } + + @Id + @GeneratedValue(strategy= GenerationType.IDENTITY) + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @Basic + @Column(name = "SECRET_CODE", nullable = false, length = 20) + public String getSecretCode() { + return secretCode; + } + + public void setSecretCode(String secretCode) { + this.secretCode = secretCode; + } + + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false) + public Date getCreateDate() { + return createDate; + } + + public void setCreateDate(Date createDate) { + this.createDate = createDate; + } + + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = true) + public Date getUpdateDate() { + return updateDate; + } + + public void setUpdateDate(Date updateDate) { + this.updateDate = updateDate; + } +} diff --git a/src/main/java/com/loafle/overflow/module/member/service/MemberTotpService.java b/src/main/java/com/loafle/overflow/module/member/service/MemberTotpService.java new file mode 100644 index 0000000..18d717a --- /dev/null +++ b/src/main/java/com/loafle/overflow/module/member/service/MemberTotpService.java @@ -0,0 +1,10 @@ +package com.loafle.overflow.module.member.service; + +import org.springframework.stereotype.Service; + +/** + * Created by geek on 18. 3. 8. + */ +@Service("MemberTotpService") +public class MemberTotpService { +}