From 702bb83b80a10da741c2b47467e1acaa739a3940 Mon Sep 17 00:00:00 2001 From: crusader Date: Wed, 7 Mar 2018 21:04:44 +0900 Subject: [PATCH] ing --- .../overflow/module/domain/dao/DomainMemberDAO.java | 8 ++++++++ .../module/domain/service/DomainMemberService.java | 13 +++++++++++++ .../module/member/service/MemberService.java | 6 ++++-- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/loafle/overflow/module/domain/dao/DomainMemberDAO.java b/src/main/java/com/loafle/overflow/module/domain/dao/DomainMemberDAO.java index a5fe331..6a04f52 100644 --- a/src/main/java/com/loafle/overflow/module/domain/dao/DomainMemberDAO.java +++ b/src/main/java/com/loafle/overflow/module/domain/dao/DomainMemberDAO.java @@ -16,6 +16,14 @@ import java.util.List; @Repository public interface DomainMemberDAO extends JpaRepository { + @Query("SELECT dm from DomainMember dm where dm.member.id = (:id)") + DomainMember findByMemberID(@Param("id") long id); + + @Query("SELECT dm.domain from DomainMember dm where dm.member = (:member)") + Domain findDomainByMember(@Param("member") Member member); + @Query("SELECT dm.member from DomainMember dm where dm.domain = (:domain)") List findAllMemberByDomain(@Param("domain") Domain domain); + + } diff --git a/src/main/java/com/loafle/overflow/module/domain/service/DomainMemberService.java b/src/main/java/com/loafle/overflow/module/domain/service/DomainMemberService.java index 08d19e7..589de7d 100644 --- a/src/main/java/com/loafle/overflow/module/domain/service/DomainMemberService.java +++ b/src/main/java/com/loafle/overflow/module/domain/service/DomainMemberService.java @@ -3,6 +3,7 @@ package com.loafle.overflow.module.domain.service; import com.loafle.overflow.module.domain.dao.DomainMemberDAO; import com.loafle.overflow.module.domain.model.Domain; import com.loafle.overflow.module.domain.model.DomainMember; +import com.loafle.overflow.module.member.dao.MemberDAO; import com.loafle.overflow.module.member.model.Member; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -18,10 +19,22 @@ public class DomainMemberService { @Autowired private DomainMemberDAO domainMemberDAO; + @Autowired + private MemberDAO memberDAO; + public void regist(DomainMember domainMember) { this.domainMemberDAO.save(domainMember); } + public Domain readDomainByMemberID(long id) { + Member member = this.memberDAO.findOne(id); + return this.domainMemberDAO.findDomainByMember(member); + } + + public DomainMember readByMemberID(long id) { + return this.domainMemberDAO.findByMemberID(id); + } + public List readAllMemberByDomain(Domain domain) { return this.domainMemberDAO.findAllMemberByDomain(domain); } diff --git a/src/main/java/com/loafle/overflow/module/member/service/MemberService.java b/src/main/java/com/loafle/overflow/module/member/service/MemberService.java index e592b6b..de98588 100644 --- a/src/main/java/com/loafle/overflow/module/member/service/MemberService.java +++ b/src/main/java/com/loafle/overflow/module/member/service/MemberService.java @@ -52,7 +52,7 @@ public class MemberService { private BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder(); - public Member signin(String signinId, String signinPw) { + public DomainMember signin(String signinId, String signinPw) { Member m = this.memberDAO.findByEmail(signinId); if ( null == m ) { @@ -76,8 +76,10 @@ public class MemberService { m.setSigninFailCount(0); this.modify(m); + DomainMember dm = domainMemberService.readByMemberID(m.getId()); + // Todo Signin History - return m; + return dm; } public Member signup(Member member, String pw) throws UnsupportedEncodingException {