Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

프로젝트 전체 조회 시 기술 스택 및 제목과 멤버로 검색 기능 #191

Merged
merged 8 commits into from
Mar 18, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ModelAttribute;
import sixgaezzang.sidepeek.common.exception.ErrorResponse;
import sixgaezzang.sidepeek.projects.dto.request.CursorPaginationInfoRequest;
import sixgaezzang.sidepeek.projects.dto.request.FindProjectRequest;
import sixgaezzang.sidepeek.projects.dto.request.SaveProjectRequest;
import sixgaezzang.sidepeek.projects.dto.request.UpdateProjectRequest;
import sixgaezzang.sidepeek.projects.dto.response.CursorPaginationResponse;
Expand Down Expand Up @@ -47,7 +47,7 @@ ResponseEntity<ProjectResponse> save(@Parameter(hidden = true) Long loginId,
})
ResponseEntity<CursorPaginationResponse<ProjectListResponse>> getByCondition(
@Parameter(hidden = true) Long loginId,
@Valid @ModelAttribute CursorPaginationInfoRequest pageable);
@Valid @ModelAttribute FindProjectRequest pageable);

@Operation(summary = "지난 주 인기 프로젝트 조회", description = "지난 주 좋아요를 많이 받은 순으로 최대 5개 프로젝트 목록 조회, 로그인 선택")
@ApiResponses({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@

@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class ProjectDescription {
// CursorPaginationInfoRequest

// FindProjectRequest
public static final String IS_RELEASED_DESCRIPTION = "출시 서비스만 보기(기본 - false)";
public static final String SORT_DESCRIPTION = "정렬 조건 [ createdAt(default), view, like ]";
public static final String PAGE_SIZE_DESCRIPTION = "한 페이지내 보여질 데이터의 개수";
public static final String LAST_ORDER_COUNT_DESCRIPTION = "더보기 이전 마지막으로 보여진 좋아요수/조회수(첫 페이지면 null)";
public static final String LAST_PROJECT_ID_DESCRIPTION = "더보기 이전 마지막으로 보여진 프로젝트 식별자(첫 페이지면 null)";
public static final String SKILL_DESCRIPTION = "조회할 기술 스택 목록(없으면 null)";
public static final String SEARCH_DESCRIPTION = "검색어 [ 프로젝트 제목, 멤버 ](없으면 null)";
yenzip marked this conversation as resolved.
Show resolved Hide resolved

// SaveProjectRequest, UpdateProjectRequest
public static final String NAME_DESCRIPTION = "제목, " + MAX_PROJECT_NAME_LENGTH + "자 이하";
Expand All @@ -43,6 +46,7 @@ public final class ProjectDescription {

// SaveMemberRequest
public static final String MEMBER_ROLE_DESCRIPTION = "멤버 역할, " + MAX_ROLE_LENGTH + "자 이하";
public static final String MEMBER_NICKNAME_DESCRIPTION = "멤버 닉네임, 회원도 설정 가능, " + MAX_NICKNAME_LENGTH + "자 이하";
public static final String MEMBER_NICKNAME_DESCRIPTION =
"멤버 닉네임, 회원도 설정 가능, " + MAX_NICKNAME_LENGTH + "자 이하";
public static final String MEMBER_USER_ID_DESCRIPTION = "회원 멤버 유저 식별자(비회원 멤버이면 null)";
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import org.springframework.web.servlet.support.ServletUriComponentsBuilder;
import sixgaezzang.sidepeek.common.annotation.Login;
import sixgaezzang.sidepeek.common.doc.ProjectControllerDoc;
import sixgaezzang.sidepeek.projects.dto.request.CursorPaginationInfoRequest;
import sixgaezzang.sidepeek.projects.dto.request.FindProjectRequest;
import sixgaezzang.sidepeek.projects.dto.request.SaveProjectRequest;
import sixgaezzang.sidepeek.projects.dto.request.UpdateProjectRequest;
import sixgaezzang.sidepeek.projects.dto.response.CursorPaginationResponse;
Expand Down Expand Up @@ -63,10 +63,10 @@ public ResponseEntity<ProjectResponse> getById(
@GetMapping
public ResponseEntity<CursorPaginationResponse<ProjectListResponse>> getByCondition(
@Login Long loginId,
@Valid @ModelAttribute CursorPaginationInfoRequest pageable
@Valid @ModelAttribute FindProjectRequest request
) {
CursorPaginationResponse<ProjectListResponse> responses = projectService.findByCondition(
loginId, pageable);
loginId, request);
yenzip marked this conversation as resolved.
Show resolved Hide resolved
return ResponseEntity.ok().body(responses);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,19 @@
import static sixgaezzang.sidepeek.common.doc.description.ProjectDescription.LAST_ORDER_COUNT_DESCRIPTION;
import static sixgaezzang.sidepeek.common.doc.description.ProjectDescription.LAST_PROJECT_ID_DESCRIPTION;
import static sixgaezzang.sidepeek.common.doc.description.ProjectDescription.PAGE_SIZE_DESCRIPTION;
import static sixgaezzang.sidepeek.common.doc.description.ProjectDescription.SEARCH_DESCRIPTION;
import static sixgaezzang.sidepeek.common.doc.description.ProjectDescription.SKILL_DESCRIPTION;
import static sixgaezzang.sidepeek.common.doc.description.ProjectDescription.SORT_DESCRIPTION;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.annotation.Nullable;
import java.util.List;
import lombok.Builder;

@Schema(description = "프로젝트 조회 시 필터 및 페이지네이션 정보")
@Builder
public record CursorPaginationInfoRequest(

public record FindProjectRequest(
// Cursor Based Pagination
yenzip marked this conversation as resolved.
Show resolved Hide resolved
@Schema(description = LAST_PROJECT_ID_DESCRIPTION)
@Nullable
Long lastProjectId,
Expand All @@ -26,22 +29,35 @@ public record CursorPaginationInfoRequest(
@Nullable
Integer pageSize,

// Sort
@Schema(description = SORT_DESCRIPTION)
@Nullable
SortType sort,

// Filter
@Schema(description = IS_RELEASED_DESCRIPTION)
@Nullable
Boolean isReleased
Boolean isReleased,

@Schema(description = SKILL_DESCRIPTION)
@Nullable
List<String> skill,

@Schema(description = SEARCH_DESCRIPTION)
@Nullable
String search
) {
public CursorPaginationInfoRequest(@Nullable Long lastProjectId, Long lastOrderCount,
Integer pageSize, SortType sort,
Boolean isReleased) {

public FindProjectRequest(Long lastProjectId, Long lastOrderCount,
Integer pageSize, SortType sort,
Boolean isReleased, List<String> skill, String search) {
this.lastProjectId = lastProjectId;
this.lastOrderCount = lastOrderCount;
this.pageSize = (pageSize != null) ? pageSize : 24;
this.sort = (sort != null) ? sort : SortType.createdAt;
this.isReleased = (isReleased != null) ? isReleased : false;
this.skill = skill;
this.search = search;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import java.util.List;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import sixgaezzang.sidepeek.projects.dto.request.CursorPaginationInfoRequest;
import sixgaezzang.sidepeek.projects.dto.request.FindProjectRequest;
import sixgaezzang.sidepeek.projects.dto.response.CursorPaginationResponse;
import sixgaezzang.sidepeek.projects.dto.response.ProjectBannerResponse;
import sixgaezzang.sidepeek.projects.dto.response.ProjectListResponse;
Expand All @@ -14,16 +14,17 @@ public interface ProjectRepositoryCustom {

CursorPaginationResponse<ProjectListResponse> findByCondition(
List<Long> likedProjectIds,
CursorPaginationInfoRequest pageable);
FindProjectRequest request);

List<ProjectBannerResponse> findAllPopularOfPeriod(LocalDate startDate, LocalDate endDate, int count);
List<ProjectBannerResponse> findAllPopularOfPeriod(LocalDate startDate, LocalDate endDate,
int count);

Page<ProjectListResponse> findAllByUserJoined(List<Long> likedProjectIds, User user,
Pageable pageable);
Pageable pageable);

Page<ProjectListResponse> findAllByUserLiked(List<Long> likedProjectIds, User user,
Pageable pageable);
Pageable pageable);

Page<ProjectListResponse> findAllByUserCommented(List<Long> likedProjectIds, User user,
Pageable pageable);
Pageable pageable);
}
Loading
Loading