-
Notifications
You must be signed in to change notification settings - Fork 2
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 #42 from Modagbul/feat/마이페이지
feat: 마이페이지 조회 및 소모임 생성 에러 처리 추가
- Loading branch information
Showing
17 changed files
with
266 additions
and
22 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
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
23 changes: 23 additions & 0 deletions
23
...main/java/com/moing/backend/domain/mypage/application/dto/response/GetMyPageResponse.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,23 @@ | ||
package com.moing.backend.domain.mypage.application.dto.response; | ||
|
||
import com.moing.backend.domain.member.domain.entity.Member; | ||
import com.moing.backend.domain.team.domain.constant.Category; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@Builder | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Getter | ||
public class GetMyPageResponse { | ||
private String profileImage; | ||
private String nickName; | ||
private String introduction; | ||
private List<Category> categories=new ArrayList<>(); | ||
private List<GetMyPageTeamBlock> getMyPageTeamBlocks = new ArrayList<>(); | ||
} |
14 changes: 14 additions & 0 deletions
14
...ain/java/com/moing/backend/domain/mypage/application/dto/response/GetMyPageTeamBlock.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,14 @@ | ||
package com.moing.backend.domain.mypage.application.dto.response; | ||
|
||
import com.moing.backend.domain.team.domain.constant.Category; | ||
import lombok.*; | ||
|
||
@Builder | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Getter | ||
public class GetMyPageTeamBlock { | ||
private Long teamId; | ||
private String teamName; | ||
private Category category; | ||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/com/moing/backend/domain/mypage/application/mapper/MyPageMapper.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,25 @@ | ||
package com.moing.backend.domain.mypage.application.mapper; | ||
|
||
import com.moing.backend.domain.member.domain.entity.Member; | ||
import com.moing.backend.domain.mypage.application.dto.response.GetMyPageResponse; | ||
import com.moing.backend.domain.mypage.application.dto.response.GetMyPageTeamBlock; | ||
import com.moing.backend.domain.team.domain.constant.Category; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.util.List; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class MyPageMapper { | ||
|
||
public GetMyPageResponse toGetMyPageResponse(Member member, List<Category> categories, List<GetMyPageTeamBlock> blocks) { | ||
return GetMyPageResponse.builder() | ||
.profileImage(member.getProfileImage()) | ||
.nickName(member.getNickName()) | ||
.introduction(member.getIntroduction()) | ||
.categories(categories) | ||
.getMyPageTeamBlocks(blocks) | ||
.build(); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
src/main/java/com/moing/backend/domain/mypage/application/service/GetMyPageUserCase.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,40 @@ | ||
package com.moing.backend.domain.mypage.application.service; | ||
|
||
import com.moing.backend.domain.member.domain.entity.Member; | ||
import com.moing.backend.domain.member.domain.service.MemberGetService; | ||
import com.moing.backend.domain.mypage.application.dto.response.GetMyPageResponse; | ||
import com.moing.backend.domain.mypage.application.dto.response.GetMyPageTeamBlock; | ||
import com.moing.backend.domain.mypage.application.mapper.MyPageMapper; | ||
import com.moing.backend.domain.team.domain.constant.Category; | ||
import com.moing.backend.domain.team.domain.service.TeamGetService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
import javax.transaction.Transactional; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
@Service | ||
@Transactional | ||
@RequiredArgsConstructor | ||
public class GetMyPageUserCase { | ||
|
||
private final MemberGetService memberGetService; | ||
private final TeamGetService teamGetService; | ||
private final MyPageMapper myPageMapper; | ||
|
||
public GetMyPageResponse getMyPageResponse(String socialId) { | ||
Member member = memberGetService.getMemberBySocialId(socialId); | ||
List<GetMyPageTeamBlock> getMyPageTeamBlocks = teamGetService.getMyPageTeamBlockByMemberId(member.getMemberId()); | ||
return myPageMapper.toGetMyPageResponse(member, calculateCategory(getMyPageTeamBlocks), getMyPageTeamBlocks); | ||
} | ||
|
||
private List<Category> calculateCategory(List<GetMyPageTeamBlock> getMyPageTeamBlocks) { | ||
return getMyPageTeamBlocks.stream() | ||
.map(GetMyPageTeamBlock::getCategory) | ||
.distinct() | ||
.limit(2) | ||
.collect(Collectors.toList()); | ||
} | ||
|
||
} |
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
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
11 changes: 11 additions & 0 deletions
11
src/main/java/com/moing/backend/domain/team/exception/AlreadyJoinTeamException.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,11 @@ | ||
package com.moing.backend.domain.team.exception; | ||
|
||
import com.moing.backend.global.response.ErrorCode; | ||
import org.springframework.http.HttpStatus; | ||
|
||
public class AlreadyJoinTeamException extends TeamException{ | ||
public AlreadyJoinTeamException(){ | ||
super(ErrorCode.ALREADY_JOIN_ERROR, | ||
HttpStatus.UNAUTHORIZED); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/com/moing/backend/domain/team/exception/AlreadyWithdrawTeamException.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,11 @@ | ||
package com.moing.backend.domain.team.exception; | ||
|
||
import com.moing.backend.global.response.ErrorCode; | ||
import org.springframework.http.HttpStatus; | ||
|
||
public class AlreadyWithdrawTeamException extends TeamException{ | ||
public AlreadyWithdrawTeamException(){ | ||
super(ErrorCode.ALREADY_WITHDRAW_ERROR, | ||
HttpStatus.NOT_FOUND); | ||
} | ||
} |
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
Oops, something went wrong.