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 @@ -58,9 +58,11 @@ public ResponseEntity<ApiResponse<ApplyCollaborationDto.Response>> applyCollabor
+ "<br>sortType : NEWEST, OLDEST, POPULAR")
@PostMapping("/search")
public ResponseEntity<ApiResponse<CommonPageResponse<GetCollaborationHubListDto.CollaborationDetail>>> getCollaborationHubList(
@UserId Long userId,
@RequestBody GetCollaborationHubListDto.Request request,
@PageableDefault(page = 0, size = 6) Pageable pageable) {
GetCollaborationHubListDto.Parameter parameter = GetCollaborationHubListDtoConverter.toParameter(request,
GetCollaborationHubListDto.Parameter parameter = GetCollaborationHubListDtoConverter.toParameter(userId,
request,
pageable);
CommonPageResponse<GetCollaborationHubListDto.CollaborationDetail> response = collaborationHubService.getCollaborationHubList(
parameter);
Expand All @@ -73,8 +75,8 @@ public ResponseEntity<ApiResponse<CommonPageResponse<GetCollaborationHubListDto.
public ResponseEntity<ApiResponse<GetCollaborationHubDetailDto.Response>> getCollaborationHubDetail(
@UserId Long userId,
@PathVariable("collaborationId") Long collaborationId) {
GetCollaborationHubDetailDto.Parameter parameter = GetCollaborationHubDetailDtoConverter.toParameter(
collaborationId, userId);
GetCollaborationHubDetailDto.Parameter parameter = GetCollaborationHubDetailDtoConverter.toParameter(userId,
collaborationId);
GetCollaborationHubDetailDto.Response response = collaborationHubService.getCollaborationHubDetail(parameter);
return ResponseEntity.ok(ApiResponse.success(response));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.brainpix.api.ApiResponse;
Expand Down Expand Up @@ -40,15 +39,16 @@ public class CommentController {

private final CommentService commentService;

@SwaggerPageable
@AllUser
@SwaggerPageable
@Operation(summary = "댓글 목록 조회 API", description = "경로변수로 postId를 입력받아 해당 게시글의 댓글 목록을 조회합니다.<br>페이징을 위한 page와 size는 쿼리 파라미터로 입력받습니다.")
@GetMapping
public ResponseEntity<ApiResponse<CommonPageResponse<GetCommentListDto.Comment>>> getCommentList(
@UserId Long userId,
@PathVariable("postId") Long postId,
@PageableDefault(page = 0, size = 10) Pageable pageable
) {
GetCommentListDto.Parameter parameter = GetCommentListDtoConverter.toParameter(postId, pageable);
GetCommentListDto.Parameter parameter = GetCommentListDtoConverter.toParameter(userId, postId, pageable);
CommonPageResponse<GetCommentListDto.Comment> response = commentService.getCommentList(parameter);
return ResponseEntity.ok(ApiResponse.success(response));
}
Expand All @@ -58,7 +58,7 @@ public ResponseEntity<ApiResponse<CommonPageResponse<GetCommentListDto.Comment>>
@Operation(summary = "댓글 등록 API", description = "경로변수로 postId를 입력받아 해당 게시글에 댓글을 등록합니다.")
@PostMapping
public ResponseEntity<ApiResponse<CreateCommentDto.Response>> createComment(@PathVariable("postId") Long postId,
@RequestParam("userId") Long userId,
@UserId Long userId,
@Valid @RequestBody CreateCommentDto.Request request) {
CreateCommentDto.Parameter parameter = CreateCommentDtoConverter.toParameter(postId, userId, request);
CreateCommentDto.Response response = commentService.createComment(parameter);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,10 @@ public class IdeaMarketQueryController {
+ "<br>sortType : NEWEST, OLDEST, POPULAR, HIGHEST_PRICE, LOWEST_PRICE")
@PostMapping("/search")
public ResponseEntity<ApiResponse<CommonPageResponse<GetIdeaListDto.IdeaDetail>>> getIdeaList(
@UserId Long userId,
@RequestBody @Valid GetIdeaListDto.Request request,
@PageableDefault(page = 0, size = 6) Pageable pageable) {
GetIdeaListDto.Parameter parameter = GetIdeaListDtoConverter.toParameter(request, pageable);
GetIdeaListDto.Parameter parameter = GetIdeaListDtoConverter.toParameter(userId, request, pageable);
CommonPageResponse<GetIdeaListDto.IdeaDetail> response = ideaMarketService.getIdeaList(parameter);
return ResponseEntity.ok(ApiResponse.success(response));
}
Expand All @@ -75,10 +76,12 @@ public ResponseEntity<ApiResponse<GetIdeaDetailDto.Response>> getIdeaDetail(
@Operation(summary = "인기 아이디어 조회 [GET]", description = "쿼리 파라미터로 아이디어 마켓 타입과 페이징을 위한 page, size를 입력받아 인기 아이디어를 조회합니다.<br>type : IDEA_SOLUTION, MARKET_PLACE")
@GetMapping("/search/popular")
public ResponseEntity<ApiResponse<CommonPageResponse<GetPopularIdeaListDto.IdeaDetail>>> getPopularIdeaList(
@UserId Long userId,
@ModelAttribute @ParameterObject @Valid GetPopularIdeaListDto.Request request,
@PageableDefault(page = 0, size = 3) Pageable pageable
) {
GetPopularIdeaListDto.Parameter parameter = GetPopularIdeaListDtoConverter.toParameter(request, pageable);
GetPopularIdeaListDto.Parameter parameter = GetPopularIdeaListDtoConverter.toParameter(userId, request,
pageable);
CommonPageResponse<GetPopularIdeaListDto.IdeaDetail> response = ideaMarketService.getPopularIdeaList(
parameter);
return ResponseEntity.ok(ApiResponse.success(response));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,11 @@ public class RequestTaskQueryController {
+ "<br>sortType : NEWEST, OLDEST, POPULAR")
@PostMapping("/search")
public ResponseEntity<ApiResponse<CommonPageResponse<GetRequestTaskListDto.RequestTaskDetail>>> getRequestTaskList(
@UserId Long userId,
@RequestBody @Valid GetRequestTaskListDto.Request request,
@PageableDefault(page = 0, size = 6) Pageable pageable) {
GetRequestTaskListDto.Parameter parameter = GetRequestTaskListDtoConverter.toParameter(request, pageable);
GetRequestTaskListDto.Parameter parameter = GetRequestTaskListDtoConverter.toParameter(userId, request,
pageable);
CommonPageResponse<GetRequestTaskListDto.RequestTaskDetail> response = requestTaskQueryService.getRequestTaskList(
parameter);
return ResponseEntity.ok(ApiResponse.success(response));
Expand All @@ -60,9 +62,11 @@ public ResponseEntity<ApiResponse<CommonPageResponse<GetRequestTaskListDto.Reque
+ "<br>type : OPEN_IDEA, TECH_ZONE")
@GetMapping("/search/popular")
public ResponseEntity<ApiResponse<CommonPageResponse<GetPopularRequestTaskListDto.RequestTaskDetail>>> getPopularRequestTaskList(
@UserId Long userId,
@ModelAttribute @ParameterObject @Valid GetPopularRequestTaskListDto.Request request,
@PageableDefault(page = 0, size = 3) Pageable pageable) {
GetPopularRequestTaskListDto.Parameter parameter = GetPopularRequestTaskListDtoConverter.toParameter(request,
GetPopularRequestTaskListDto.Parameter parameter = GetPopularRequestTaskListDtoConverter.toParameter(userId,
request,
pageable);
CommonPageResponse<GetPopularRequestTaskListDto.RequestTaskDetail> response = requestTaskQueryService.getPopularRequestTaskList(
parameter);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@

public class GetCollaborationHubDetailDtoConverter {

public static GetCollaborationHubDetailDto.Parameter toParameter(Long collaborationId, Long userId) {
public static GetCollaborationHubDetailDto.Parameter toParameter(Long userId, Long collaborationId) {
return GetCollaborationHubDetailDto.Parameter.builder()
.collaborationId(collaborationId)
.userId(userId)
.collaborationId(collaborationId)
.build();
}

public static GetCollaborationHubDetailDto.Response toResponse(CollaborationHub collaborationHub,
List<CollectionGathering> collectionGathering, User writer,
Long saveCount,
Long totalIdeas, Long totalCollaborations) {
Long totalIdeas, Long totalCollaborations, Boolean isSavedPost, Boolean isMyPost) {

// 작성자
GetCollaborationHubDetailDto.Writer writerDto = toWriter(writer, totalIdeas, totalCollaborations);
Expand Down Expand Up @@ -64,6 +64,8 @@ public static GetCollaborationHubDetailDto.Response toResponse(CollaborationHub
.recruitments(recruitments)
.openMembers(openMembers)
.openMyProfile(collaborationHub.getOpenMyProfile())
.isSavedPost(isSavedPost)
.isMyPost(isMyPost)
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
import com.brainpix.profile.entity.Specialization;

public class GetCollaborationHubListDtoConverter {
public static GetCollaborationHubListDto.Parameter toParameter(GetCollaborationHubListDto.Request request,
public static GetCollaborationHubListDto.Parameter toParameter(Long userId,
GetCollaborationHubListDto.Request request,
Pageable pageable) {

Specialization category = null;
Expand All @@ -31,6 +32,7 @@ public static GetCollaborationHubListDto.Parameter toParameter(GetCollaborationH
}

return GetCollaborationHubListDto.Parameter.builder()
.userId(userId)
.keyword(request.getKeyword())
.category(category)
.onlyCompany(request.getOnlyCompany())
Expand All @@ -40,20 +42,23 @@ public static GetCollaborationHubListDto.Parameter toParameter(GetCollaborationH
}

public static CommonPageResponse<GetCollaborationHubListDto.CollaborationDetail> toResponse(
Page<Object[]> CollaborationHubs) {
Page<Object[]> collaborationHubs) {

Page<GetCollaborationHubListDto.CollaborationDetail> response = CollaborationHubs
.map(CollaborationHub -> {
CollaborationHub collaboration = (CollaborationHub)CollaborationHub[0]; // 실제 엔티티 객체
Long saveCount = (Long)CollaborationHub[1]; // 저장 횟수
Page<GetCollaborationHubListDto.CollaborationDetail> response = collaborationHubs
.map(collaborationHub -> {
CollaborationHub collaboration = (CollaborationHub)collaborationHub[0]; // 실제 엔티티 객체
Long saveCount = (Long)collaborationHub[1]; // 저장 횟수
LocalDateTime deadline = collaboration.getDeadline(); // 마감 기한
LocalDateTime now = LocalDateTime.now(); // 현재 시간
Long days = deadline.isBefore(now) ? 0L : ChronoUnit.DAYS.between(now, deadline); // D-DAY 계산

// 현재 인원 및 모집 인원
Long occupiedQuantity = collaboration.getOccupiedQuantity();
Long totalQuantity = collaboration.getTotalQuantity();
return toCollaborationDetail(collaboration, saveCount, days, occupiedQuantity, totalQuantity);

Boolean isSavedPost = (Boolean)collaborationHub[2];
return toCollaborationDetail(collaboration, saveCount, days, occupiedQuantity, totalQuantity,
isSavedPost);
}
);

Expand All @@ -62,7 +67,7 @@ public static CommonPageResponse<GetCollaborationHubListDto.CollaborationDetail>

public static GetCollaborationHubListDto.CollaborationDetail toCollaborationDetail(
CollaborationHub collaborationHub, Long saveCount,
Long deadline, Long occupiedQuantity, Long totalQuantity) {
Long deadline, Long occupiedQuantity, Long totalQuantity, Boolean isSavedPost) {
return GetCollaborationHubListDto.CollaborationDetail.builder()
.collaborationId(collaborationHub.getId())
.auth(collaborationHub.getPostAuth().toString())
Expand All @@ -77,6 +82,7 @@ public static GetCollaborationHubListDto.CollaborationDetail toCollaborationDeta
.totalQuantity(totalQuantity)
.saveCount(saveCount)
.viewCount(collaborationHub.getViewCount())
.isSavedPost(isSavedPost)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,24 @@

public class GetCommentListDtoConverter {

public static GetCommentListDto.Parameter toParameter(Long postId, Pageable pageable) {
public static GetCommentListDto.Parameter toParameter(Long userId, Long postId, Pageable pageable) {
return GetCommentListDto.Parameter.builder()
.userId(userId)
.postId(postId)
.pageable(pageable)
.build();
}

public static CommonPageResponse<GetCommentListDto.Comment> toResponse(Page<Comment> comments, Pageable pageable) {
public static CommonPageResponse<GetCommentListDto.Comment> toResponse(Page<Comment> comments, Pageable pageable,
List<Boolean> isMyComments) {

List<GetCommentListDto.Comment> commentDtoList = new ArrayList<>();

for (Comment comment : comments) {
GetCommentListDto.Comment commentDto = GetCommentListDtoConverter.toComment(comment);
List<Comment> commentList = comments.getContent();

for (int i = 0; i < commentList.size(); i++) {
GetCommentListDto.Comment commentDto = GetCommentListDtoConverter.toComment(commentList.get(i),
isMyComments.get(i));
// 자식 댓글인 경우 리스트에서 부모를 꺼내 자식 리스트에 추가
if (commentDto.getParentCommentId() != null && !commentDtoList.isEmpty()) {
GetCommentListDto.Comment parent = commentDtoList.get(commentDtoList.size() - 1);
Expand All @@ -42,7 +47,7 @@ public static CommonPageResponse<GetCommentListDto.Comment> toResponse(Page<Comm
return CommonPageResponse.of(response);
}

public static GetCommentListDto.Comment toComment(Comment comment) {
public static GetCommentListDto.Comment toComment(Comment comment, Boolean isMyComment) {

return GetCommentListDto.Comment.builder()
.commentId(comment.getId())
Expand All @@ -52,6 +57,7 @@ public static GetCommentListDto.Comment toComment(Comment comment) {
.parentCommentId(comment.getParentComment() != null ? comment.getParentComment().getId() : null)
.childComments(new ArrayList<>())
.createdDate(comment.getCreatedAt().toLocalDate())
.isMyComment(isMyComment)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static GetIdeaDetailDto.Parameter toParameter(Long ideaId, Long userId) {
}

public static GetIdeaDetailDto.Response toResponse(IdeaMarket ideaMarket, User writer, Long saveCount,
Long totalIdeas, Long totalCollaborations) {
Long totalIdeas, Long totalCollaborations, Boolean isSavedPost, Boolean isMyPost) {

// 작성자
GetIdeaDetailDto.Writer writerDto = toWriter(writer, totalIdeas, totalCollaborations);
Expand All @@ -41,6 +41,8 @@ public static GetIdeaDetailDto.Response toResponse(IdeaMarket ideaMarket, User w
.writer(writerDto)
.attachments(attachments)
.openMyProfile(ideaMarket.getOpenMyProfile())
.isSavedPost(isSavedPost)
.isMyPost(isMyPost)
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

public class GetIdeaListDtoConverter {

public static GetIdeaListDto.Parameter toParameter(GetIdeaListDto.Request request, Pageable pageable) {
public static GetIdeaListDto.Parameter toParameter(Long userId, GetIdeaListDto.Request request, Pageable pageable) {

IdeaMarketType type = null;
Specialization category = null;
Expand All @@ -31,6 +31,7 @@ public static GetIdeaListDto.Parameter toParameter(GetIdeaListDto.Request reques
}

return GetIdeaListDto.Parameter.builder()
.userId(userId)
.type(type)
.keyword(request.getKeyword())
.category(category)
Expand All @@ -43,13 +44,13 @@ public static GetIdeaListDto.Parameter toParameter(GetIdeaListDto.Request reques
public static CommonPageResponse<GetIdeaListDto.IdeaDetail> toResponse(Page<Object[]> ideaMarkets) {

Page<GetIdeaListDto.IdeaDetail> response = ideaMarkets.map(
ideaMarket -> toIdeaDetail((IdeaMarket)ideaMarket[0], (Long)ideaMarket[1])
ideaMarket -> toIdeaDetail((IdeaMarket)ideaMarket[0], (Long)ideaMarket[1], (Boolean)ideaMarket[2])
);

return CommonPageResponse.of(response);
}

public static GetIdeaListDto.IdeaDetail toIdeaDetail(IdeaMarket ideaMarket, Long saveCount) {
public static GetIdeaListDto.IdeaDetail toIdeaDetail(IdeaMarket ideaMarket, Long saveCount, Boolean isSavedPost) {
return GetIdeaListDto.IdeaDetail.builder()
.ideaId(ideaMarket.getId())
.auth(ideaMarket.getPostAuth().toString())
Expand All @@ -61,6 +62,7 @@ public static GetIdeaListDto.IdeaDetail toIdeaDetail(IdeaMarket ideaMarket, Long
.category(ideaMarket.getSpecialization().toString())
.saveCount(saveCount)
.viewCount(ideaMarket.getViewCount())
.isSavedPost(isSavedPost)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

public class GetPopularIdeaListDtoConverter {

public static GetPopularIdeaListDto.Parameter toParameter(GetPopularIdeaListDto.Request request,
public static GetPopularIdeaListDto.Parameter toParameter(Long userId, GetPopularIdeaListDto.Request request,
Pageable pageable) {
IdeaMarketType type = null;

Expand All @@ -23,6 +23,7 @@ public static GetPopularIdeaListDto.Parameter toParameter(GetPopularIdeaListDto.
}

return GetPopularIdeaListDto.Parameter.builder()
.userId(userId)
.type(type)
.pageable(pageable)
.build();
Expand All @@ -31,13 +32,14 @@ public static GetPopularIdeaListDto.Parameter toParameter(GetPopularIdeaListDto.
public static CommonPageResponse<GetPopularIdeaListDto.IdeaDetail> toResponse(Page<Object[]> ideaMarkets) {

Page<GetPopularIdeaListDto.IdeaDetail> response = ideaMarkets.map(
ideaMarket -> toIdeaDetail((IdeaMarket)ideaMarket[0], (Long)ideaMarket[1])
ideaMarket -> toIdeaDetail((IdeaMarket)ideaMarket[0], (Long)ideaMarket[1], (Boolean)ideaMarket[2])
);

return CommonPageResponse.of(response);
}

public static GetPopularIdeaListDto.IdeaDetail toIdeaDetail(IdeaMarket ideaMarket, Long saveCount) {
public static GetPopularIdeaListDto.IdeaDetail toIdeaDetail(IdeaMarket ideaMarket, Long saveCount,
Boolean isSavedPost) {

return GetPopularIdeaListDto.IdeaDetail.builder()
.ideaId(ideaMarket.getId())
Expand All @@ -50,6 +52,7 @@ public static GetPopularIdeaListDto.IdeaDetail toIdeaDetail(IdeaMarket ideaMarke
.category(ideaMarket.getSpecialization().toString())
.saveCount(saveCount)
.viewCount(ideaMarket.getViewCount())
.isSavedPost(isSavedPost)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@

public class GetPopularRequestTaskListDtoConverter {

public static GetPopularRequestTaskListDto.Parameter toParameter(GetPopularRequestTaskListDto.Request request,
public static GetPopularRequestTaskListDto.Parameter toParameter(Long userId,
GetPopularRequestTaskListDto.Request request,
Pageable pageable) {

RequestTaskType type = null;
Expand All @@ -27,14 +28,16 @@ public static GetPopularRequestTaskListDto.Parameter toParameter(GetPopularReque
}

return GetPopularRequestTaskListDto.Parameter.builder()
.userId(userId)
.type(type)
.pageable(pageable)
.build();
}

public static GetPopularRequestTaskListDto.RequestTaskDetail toRequestTaskDetail(RequestTask requestTask,
Long saveCount,
Long deadline) {
Long deadline, Boolean isSavedPost) {

return GetPopularRequestTaskListDto.RequestTaskDetail.builder()
.taskId(requestTask.getId())
.auth(requestTask.getPostAuth().toString())
Expand All @@ -46,6 +49,7 @@ public static GetPopularRequestTaskListDto.RequestTaskDetail toRequestTaskDetail
.category(requestTask.getSpecialization().toString())
.saveCount(saveCount)
.viewCount(requestTask.getViewCount())
.isSavedPost(isSavedPost)
.build();
}

Expand All @@ -58,7 +62,8 @@ public static CommonPageResponse<GetPopularRequestTaskListDto.RequestTaskDetail>
LocalDateTime deadline = task.getDeadline(); // 마감 기한
LocalDateTime now = LocalDateTime.now(); // 현재 시간
Long days = deadline.isBefore(now) ? 0L : ChronoUnit.DAYS.between(now, deadline); // D-DAY 계산
return GetPopularRequestTaskListDtoConverter.toRequestTaskDetail(task, saveCount, days);
Boolean isSavedPost = (Boolean)requestTask[2]; // 게시글 저장 여부
return GetPopularRequestTaskListDtoConverter.toRequestTaskDetail(task, saveCount, days, isSavedPost);
}
);

Expand Down
Loading