-
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.
YEL-193 [feat] 친구 쪽지 전체 조회하기
- Loading branch information
Showing
21 changed files
with
417 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
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
20 changes: 20 additions & 0 deletions
20
src/main/java/com/yello/server/domain/vote/dto/response/VoteFriendAndUserResponse.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,20 @@ | ||
package com.yello.server.domain.vote.dto.response; | ||
|
||
import java.util.List; | ||
import lombok.Builder; | ||
|
||
@Builder | ||
public record VoteFriendAndUserResponse( | ||
Long totalCount, | ||
List<VoteFriendAndUserVO> friendVotes | ||
|
||
) { | ||
|
||
public static VoteFriendAndUserResponse of(Long totalCount, List<VoteFriendAndUserVO> friendVotes) { | ||
return VoteFriendAndUserResponse.builder() | ||
.totalCount(totalCount) | ||
.friendVotes(friendVotes) | ||
.build(); | ||
} | ||
} | ||
|
46 changes: 46 additions & 0 deletions
46
src/main/java/com/yello/server/domain/vote/dto/response/VoteFriendAndUserVO.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,46 @@ | ||
package com.yello.server.domain.vote.dto.response; | ||
|
||
import static com.yello.server.global.common.factory.TimeFactory.toFormattedString; | ||
|
||
import com.yello.server.domain.vote.entity.Vote; | ||
import lombok.Builder; | ||
|
||
@Builder | ||
public record VoteFriendAndUserVO( | ||
Long id, | ||
Long senderId, | ||
String senderName, | ||
String senderGender, | ||
String senderYelloId, | ||
String senderProfileImage, | ||
Long receiverId, | ||
String receiverName, | ||
String receiverGender, | ||
String receiverYelloId, | ||
String receiverProfileImage, | ||
VoteContentVO vote, | ||
Boolean isHintUsed, | ||
String createdAt, | ||
Boolean isUserSenderVote | ||
) { | ||
|
||
public static VoteFriendAndUserVO of(Vote vote, Boolean isUserSenderVote) { | ||
return VoteFriendAndUserVO.builder() | ||
.id(vote.getId()) | ||
.senderId(vote.getSender().getId()) | ||
.senderName(vote.getSender().getName()) | ||
.senderGender(vote.getSender().getGender().name()) | ||
.senderYelloId(vote.getSender().getYelloId()) | ||
.senderProfileImage(vote.getSender().getProfileImage()) | ||
.receiverId(vote.getReceiver().getId()) | ||
.receiverGender(vote.getReceiver().getGender().name()) | ||
.receiverName(vote.getReceiver().getName()) | ||
.receiverYelloId(vote.getReceiver().getYelloId()) | ||
.receiverProfileImage(vote.getReceiver().getProfileImage()) | ||
.vote(VoteContentVO.of(vote)) | ||
.isHintUsed(vote.getIsAnswerRevealed()) | ||
.createdAt(toFormattedString(vote.getCreatedAt())) | ||
.isUserSenderVote(isUserSenderVote) | ||
.build(); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/main/java/com/yello/server/domain/vote/entity/VoteType.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,27 @@ | ||
package com.yello.server.domain.vote.entity; | ||
|
||
import java.text.MessageFormat; | ||
import java.util.Arrays; | ||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Getter | ||
@RequiredArgsConstructor | ||
public enum VoteType { | ||
SEND("send"); | ||
|
||
private final String intial; | ||
|
||
public static VoteType fromCode(String dbData) { | ||
return Arrays.stream(VoteType.values()) | ||
.filter(v -> v.getIntial().equals(dbData)) | ||
.findAny() | ||
.orElseThrow(() -> new IllegalArgumentException( | ||
MessageFormat.format("존재하지 않는 투표 타입입니다. {0}", dbData))); | ||
} | ||
|
||
public String intial() { | ||
return intial; | ||
} | ||
|
||
} |
32 changes: 32 additions & 0 deletions
32
src/main/java/com/yello/server/domain/vote/entity/VoteTypeConverter.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,32 @@ | ||
package com.yello.server.domain.vote.entity; | ||
|
||
import com.yello.server.domain.user.entity.Social; | ||
import javax.persistence.AttributeConverter; | ||
import javax.persistence.Converter; | ||
import lombok.extern.log4j.Log4j2; | ||
|
||
@Converter | ||
@Log4j2 | ||
public class VoteTypeConverter implements AttributeConverter<VoteType, String> { | ||
|
||
@Override | ||
public String convertToDatabaseColumn(VoteType voteType) { | ||
if (voteType == null) { | ||
return null; | ||
} | ||
return voteType.getIntial(); | ||
} | ||
|
||
@Override | ||
public VoteType convertToEntityAttribute(String dbData) { | ||
if (dbData == null) { | ||
return null; | ||
} | ||
try { | ||
return VoteType.fromCode(dbData); | ||
} catch (IllegalArgumentException exception) { | ||
log.error("failure to convert cause unexpected code" + dbData + exception); | ||
throw exception; | ||
} | ||
} | ||
} |
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.