-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from BokDoong/member_feature
Member feature
- Loading branch information
Showing
29 changed files
with
408 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 2 additions & 4 deletions
6
...e/tale/application/dto/TaleImageInfo.java → ...lishfairytale/common/files/ImageInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 72 additions & 11 deletions
83
src/main/java/hanium/englishfairytale/member/application/MemberCommandService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 35 additions & 17 deletions
52
src/main/java/hanium/englishfairytale/member/application/MemberQueryService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,53 @@ | ||
package hanium.englishfairytale.member.application; | ||
|
||
import hanium.englishfairytale.tale.application.dto.TalesInfo; | ||
import hanium.englishfairytale.tale.domain.Keyword; | ||
import hanium.englishfairytale.tale.domain.TaleKeyword; | ||
import hanium.englishfairytale.tale.domain.TaleRepository; | ||
import hanium.englishfairytale.exception.BusinessException; | ||
import hanium.englishfairytale.exception.NotFoundException; | ||
import hanium.englishfairytale.exception.code.ErrorCode; | ||
import hanium.englishfairytale.member.application.dto.MemberDetailInfo; | ||
import hanium.englishfairytale.member.application.dto.MemberInfo; | ||
import hanium.englishfairytale.member.domain.Member; | ||
import hanium.englishfairytale.member.domain.MemberRepository; | ||
import hanium.englishfairytale.member.infra.MemberQueryDao; | ||
import hanium.englishfairytale.tale.infra.TaleQueryDao; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class MemberQueryService { | ||
|
||
private final TaleRepository taleRepository; | ||
private final MemberRepository memberRepository; | ||
private final MemberQueryDao memberQueryDao; | ||
private final TaleQueryDao taleQueryDao; | ||
|
||
@Transactional | ||
public void verifyNickname(String nickname) { | ||
verifyNicknameDuplicated(nickname); | ||
} | ||
|
||
@Transactional(readOnly = true) | ||
public List<TalesInfo> findMainTalesInfo(Long memberId) { | ||
@Transactional | ||
public MemberInfo findMemberInfo(Long memberId) { | ||
return new MemberInfo(findMember(memberId), countTales(memberId)); | ||
} | ||
|
||
// memberId -> Tale 조회 -> 최신순, Tale+Member+Image+TaleKeywords 나옴. | ||
// 각 TaleKeyword 의 id값 -> Keywords 조회 -> 위에서 찾은 TaleKeyword 의 id 값을 넣는다. -> | ||
@Transactional | ||
public MemberDetailInfo findMemberDetailInfo(Long memberId) { | ||
return new MemberDetailInfo(findMember(memberId)); | ||
} | ||
|
||
private Member findMember(Long memberId) { | ||
return memberQueryDao.findMemberAndImage(memberId) | ||
.orElseThrow(() -> new NotFoundException(ErrorCode.MEMBER_NOT_FOUND)); | ||
} | ||
|
||
return null; | ||
private Long countTales(Long memberId) { | ||
return taleQueryDao.countTales(memberId); | ||
} | ||
|
||
private List<Keyword> getKeywordsFromTaleKeyword(List<TaleKeyword> taleKeywords) { | ||
return taleKeywords.stream() | ||
.map(TaleKeyword::getKeyword) | ||
.collect(Collectors.toList()); | ||
private void verifyNicknameDuplicated(String nickName) { | ||
if (memberRepository.findByMemberNickname(nickName).isPresent()) { | ||
throw new BusinessException(ErrorCode.DUPLICATED_NICKNAME); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/main/java/hanium/englishfairytale/member/application/dto/MemberDetailInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package hanium.englishfairytale.member.application.dto; | ||
|
||
import hanium.englishfairytale.member.domain.Member; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
public class MemberDetailInfo { | ||
String nickname; | ||
String email; | ||
String phoneNumber; | ||
String imageUrl; | ||
|
||
public MemberDetailInfo(Member member) { | ||
this.nickname = member.getNickname(); | ||
this.email = member.getEmail(); | ||
this.phoneNumber = member.getPhoneNumber(); | ||
this.imageUrl = member.getImage() == null ? null : member.getImage().getUrl(); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/main/java/hanium/englishfairytale/member/application/dto/MemberImageUpdateCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package hanium.englishfairytale.member.application.dto; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
import org.springframework.web.multipart.MultipartFile; | ||
|
||
@Builder | ||
@Getter | ||
public class MemberImageUpdateCommand { | ||
private Long memberId; | ||
private MultipartFile image; | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/hanium/englishfairytale/member/application/dto/MemberInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package hanium.englishfairytale.member.application.dto; | ||
|
||
import hanium.englishfairytale.member.domain.Member; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
public class MemberInfo { | ||
String nickname; | ||
String imageUrl; | ||
Long taleCounts; | ||
|
||
public MemberInfo(Member member, Long taleCounts) { | ||
this.nickname = member.getNickname(); | ||
this.imageUrl = member.getImage() == null ? null : member.getImage().getUrl(); | ||
this.taleCounts = taleCounts; | ||
} | ||
} |
9 changes: 6 additions & 3 deletions
9
...application/dto/CreateMemberResponse.java → ...tion/dto/MemberUpdatePasswordCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,15 @@ | ||
package hanium.englishfairytale.member.application.dto; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class CreateMemberResponse { | ||
private Long memberId; | ||
@AllArgsConstructor | ||
@Builder | ||
public class MemberUpdatePasswordCommand { | ||
Long memberId; | ||
String password; | ||
} |
6 changes: 6 additions & 0 deletions
6
src/main/java/hanium/englishfairytale/member/domain/ImageRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package hanium.englishfairytale.member.domain; | ||
|
||
public interface ImageRepository { | ||
|
||
void delete(Long memberImageId); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.