Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,20 @@ public record BranchCategoryResponse(
@Schema(description = "분야 이름(세부분야)")
List<BranchResponse> branchResponses
) {

public static BranchCategoryResponse of(
Branch branch,
List<Branch> branches
Branch branch,
List<Branch> branches
) {
return new BranchCategoryResponse(
branch.getId(),
branch.getName(),
branches.stream()
.filter(childBranch -> !childBranch.isParentBranch())
.filter(childBranch -> childBranch.isChildBranch(branch))
.map(BranchResponse::from)
.toList()
);
return new BranchCategoryResponse(
branch.getId(),
branch.getName(),
branches.stream()
.filter(childBranch -> !childBranch.isParentBranch())
.filter(childBranch -> childBranch.isChildBranch(branch))
.map(BranchResponse::from)
.toList()
);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@
import kr.co.conceptbe.member.domain.Member;

public record MemberResponse(
@Schema(description = "멤버 ID", example = "1")
Long id,
@Schema(description = "프로필 이미지 URL", example = "https://conceptbe.png")
String profileImageUrl,
@Schema(description = "닉네임", example = "conceptbe")
String nickname,
@Schema(description = "세부스킬", example = "서버개발")
String mainSkill
@Schema(description = "멤버 ID", example = "1")
Long id,
@Schema(description = "프로필 이미지 URL", example = "https://conceptbe.png")
String profileImageUrl,
@Schema(description = "닉네임", example = "conceptbe")
String nickname,
@Schema(description = "세부스킬", example = "서버개발")
String mainSkill
) {

public static MemberResponse from(Member member) {
return new MemberResponse(
member.getId(),
member.getProfileImageUrl(),
member.getNickname(),
member.getMainSkill().getName()
member.getId(),
member.getProfileImageUrl(),
member.getNickname(),
member.getMainSkill().getName()
);
}

Expand Down
106 changes: 63 additions & 43 deletions src/main/java/kr/co/conceptbe/idea/dto/IdeaDetailResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,57 +2,77 @@

import java.time.LocalDateTime;
import java.util.List;
import kr.co.conceptbe.branch.domain.Branch;
import kr.co.conceptbe.comment.Comment;
import kr.co.conceptbe.idea.application.response.BranchCategoryResponse;
import kr.co.conceptbe.idea.domain.Idea;
import kr.co.conceptbe.idea.domain.IdeaBranch;
import kr.co.conceptbe.image.application.response.ImageResponse;

public record IdeaDetailResponse(
Long memberId,
String imageUrl,
String nickname,
String mainSkill,
String title,
LocalDateTime date,
String introduce,
List<String> branchList,
List<String> purposeList,
String cooperationWay,
String recruitmentPlace,
List<String> skillCategories,
Integer likesCount,
Integer commentsCount,
Integer bookmarksCount,
Integer hits,
Boolean owner,
Boolean ownerLike,
Boolean ownerScrap,
List<ImageResponse> imageResponses
Long memberId,
String imageUrl,
String nickname,
String mainSkill,
String title,
LocalDateTime date,
String introduce,
List<BranchCategoryResponse> branchList,
List<String> purposeList,
String cooperationWay,
String recruitmentPlace,
List<String> skillCategories,
Integer likesCount,
Integer commentsCount,
Integer bookmarksCount,
Integer hits,
Boolean owner,
Boolean ownerLike,
Boolean ownerScrap,
List<ImageResponse> imageResponses
) {

public static IdeaDetailResponse of(Long tokenMemberId, Idea idea,
List<ImageResponse> imageResponses) {
public static IdeaDetailResponse of(
Long tokenMemberId,
Idea idea,
List<ImageResponse> imageResponses
) {
List<Branch> branches = idea.getBranches()
.stream()
.map(IdeaBranch::getBranch)
.toList();
List<Branch> parentBranches = branches
.stream()
.map(Branch::getParentBranch)
.distinct()
.toList();
List<BranchCategoryResponse> branchResponses = parentBranches.stream()
.map(parentBranch -> BranchCategoryResponse.of(parentBranch, branches))
.toList();

return new IdeaDetailResponse(
idea.getCreator().getId(),
idea.getCreator().getProfileImageUrl(),
idea.getCreator().getNickname(),
idea.getCreator().getMainSkill().getName(),
idea.getTitle(),
idea.getCreatedAt(),
idea.getIntroduce(),
idea.getBranches().stream().map(e -> e.getBranch().getName()).toList(),
idea.getPurposes().stream().map(e -> e.getPurpose().getName()).toList(),
idea.getCooperationWay(),
idea.getRecruitmentPlace(),
idea.getSkillCategories().stream().map(e -> e.getSkillCategory().getName()).toList(),
idea.getLikesCount(),
idea.getComments().stream().filter(Comment::isParentComment)
.mapToInt(e -> e.getCommentsCount() + 1).sum(),
idea.getBookmarksCount(),
idea.getHitsCount(),
idea.isOwner(tokenMemberId),
idea.isOwnerLike(tokenMemberId),
idea.isOwnerScrap(tokenMemberId),
imageResponses
idea.getCreator().getId(),
idea.getCreator().getProfileImageUrl(),
idea.getCreator().getNickname(),
idea.getCreator().getMainSkill().getName(),
idea.getTitle(),
idea.getCreatedAt(),
idea.getIntroduce(),
branchResponses,
idea.getPurposes().stream().map(e -> e.getPurpose().getName()).toList(),
idea.getCooperationWay(),
idea.getRecruitmentPlace(),
idea.getSkillCategories().stream().map(e -> e.getSkillCategory().getName()).toList(),
idea.getLikesCount(),
idea.getComments().stream().filter(Comment::isParentComment)
.mapToInt(e -> e.getCommentsCount() + 1).sum(),
idea.getBookmarksCount(),
idea.getHitsCount(),
idea.isOwner(tokenMemberId),
idea.isOwnerLike(tokenMemberId),
idea.isOwnerScrap(tokenMemberId),
imageResponses
);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public ResponseEntity<Void> removeIdea(
return ResponseEntity.noContent().build();
}

@GetMapping("writing")
@GetMapping("/writing")
public ResponseEntity<FindIdeaWriteResponse> getIdeaWriteResponses() {
FindIdeaWriteResponse response = ideaService.getFindIdeaWriteResponse();

Expand Down Expand Up @@ -199,4 +199,5 @@ public ResponseEntity<List<IdeaHitResponse>> getIdeaHitsResponse(
List<IdeaHitResponse> ideaCommentResponse = ideaService.getIdeaHitsResponse(ideaId);
return ResponseEntity.ok(ideaCommentResponse);
}

}
Loading