diff --git a/src/main/java/io/oeid/mogakgo/domain/project/application/ProjectService.java b/src/main/java/io/oeid/mogakgo/domain/project/application/ProjectService.java index 856811c0..8aae55d5 100644 --- a/src/main/java/io/oeid/mogakgo/domain/project/application/ProjectService.java +++ b/src/main/java/io/oeid/mogakgo/domain/project/application/ProjectService.java @@ -22,6 +22,7 @@ import io.oeid.mogakgo.domain.project.presentation.dto.req.ProjectCreateReq; import io.oeid.mogakgo.domain.project.presentation.dto.res.ProjectDensityRankRes; import io.oeid.mogakgo.domain.project.presentation.dto.res.ProjectDetailAPIRes; +import io.oeid.mogakgo.domain.project.presentation.dto.res.ProjectDetailInfoAPIRes; import io.oeid.mogakgo.domain.project.presentation.dto.res.ProjectInfoAPIRes; import io.oeid.mogakgo.domain.project_join_req.exception.ProjectJoinRequestException; import io.oeid.mogakgo.domain.project_join_req.infrastructure.ProjectJoinRequestJpaRepository; @@ -179,7 +180,7 @@ public ProjectDensityRankRes getDensityRankProjects() { return new ProjectDensityRankRes(regionRankList); } - public List getLastedProjectByUserId(Long userId, Long id) { + public ProjectDetailInfoAPIRes getLastedProjectByUserId(Long userId, Long id) { User user = getUser(userId); validateProjectCardCreator(user, id); diff --git a/src/main/java/io/oeid/mogakgo/domain/project/infrastructure/ProjectRepositoryCustom.java b/src/main/java/io/oeid/mogakgo/domain/project/infrastructure/ProjectRepositoryCustom.java index 0efc0095..e82be64d 100644 --- a/src/main/java/io/oeid/mogakgo/domain/project/infrastructure/ProjectRepositoryCustom.java +++ b/src/main/java/io/oeid/mogakgo/domain/project/infrastructure/ProjectRepositoryCustom.java @@ -5,6 +5,7 @@ import io.oeid.mogakgo.domain.geo.domain.enums.Region; import io.oeid.mogakgo.domain.project.domain.entity.enums.ProjectStatus; import io.oeid.mogakgo.domain.project.presentation.dto.res.ProjectDetailAPIRes; +import io.oeid.mogakgo.domain.project.presentation.dto.res.ProjectDetailInfoAPIRes; import io.oeid.mogakgo.domain.project.presentation.dto.res.ProjectInfoAPIRes; import java.util.List; @@ -20,5 +21,5 @@ CursorPaginationResult findByCreatorIdWithPagination( List getDensityRankProjectsByRegion(int limit); - List findLatestProjectByUserId(Long userId); + ProjectDetailInfoAPIRes findLatestProjectByUserId(Long userId); } diff --git a/src/main/java/io/oeid/mogakgo/domain/project/infrastructure/ProjectRepositoryCustomImpl.java b/src/main/java/io/oeid/mogakgo/domain/project/infrastructure/ProjectRepositoryCustomImpl.java index e59ae5eb..7df3e5c7 100644 --- a/src/main/java/io/oeid/mogakgo/domain/project/infrastructure/ProjectRepositoryCustomImpl.java +++ b/src/main/java/io/oeid/mogakgo/domain/project/infrastructure/ProjectRepositoryCustomImpl.java @@ -2,6 +2,7 @@ import static io.oeid.mogakgo.domain.project.domain.entity.QProject.project; import static io.oeid.mogakgo.domain.user.domain.QUser.user; +import static io.oeid.mogakgo.domain.matching.domain.entity.QMatching.matching; import com.querydsl.core.types.dsl.BooleanExpression; import com.querydsl.jpa.impl.JPAQueryFactory; @@ -13,6 +14,7 @@ import io.oeid.mogakgo.domain.project.domain.entity.enums.ProjectStatus; import io.oeid.mogakgo.domain.project.presentation.dto.res.MeetingInfoResponse; import io.oeid.mogakgo.domain.project.presentation.dto.res.ProjectDetailAPIRes; +import io.oeid.mogakgo.domain.project.presentation.dto.res.ProjectDetailInfoAPIRes; import io.oeid.mogakgo.domain.project.presentation.dto.res.ProjectInfoAPIRes; import io.oeid.mogakgo.domain.user.domain.UserDevelopLanguageTag; import io.oeid.mogakgo.domain.user.domain.UserWantedJobTag; @@ -126,7 +128,7 @@ public List getDensityRankProjectsByRegion(int limit) { } @Override - public List findLatestProjectByUserId(Long userId) { + public ProjectDetailInfoAPIRes findLatestProjectByUserId(Long userId) { List entity = jpaQueryFactory.selectFrom(project) .innerJoin(project.creator, user) @@ -134,10 +136,17 @@ public List findLatestProjectByUserId(Long userId) { .where( userIdEq(userId), projectStatusEq(ProjectStatus.PENDING) + .or(projectStatusEq(ProjectStatus.MATCHED)), + createdAtEq(LocalDate.now()) ) .fetch(); - return entity.stream().map( + Long matchingId = entity.isEmpty() ? null : jpaQueryFactory.select(matching.id) + .from(matching) + .where(matching.project.id.eq(entity.get(0).getId())) + .fetchOne(); + + List result = entity.stream().map( project -> new ProjectDetailAPIRes( project.getId(), new UserPublicApiResponse( @@ -165,6 +174,8 @@ public List findLatestProjectByUserId(Long userId) { ) ) ).toList(); + + return ProjectDetailInfoAPIRes.of(matchingId, result); } private BooleanExpression cursorIdCondition(Long cursorId) { @@ -180,7 +191,7 @@ private BooleanExpression regionEq(Region region) { } private BooleanExpression projectStatusEq(ProjectStatus projectStatus) { - return projectStatus != null ? project.projectStatus.eq(projectStatus) : null; + return project.projectStatus.eq(projectStatus); } private BooleanExpression createdAtEq(LocalDate today) { diff --git a/src/main/java/io/oeid/mogakgo/domain/project/presentation/ProjectController.java b/src/main/java/io/oeid/mogakgo/domain/project/presentation/ProjectController.java index d8cb453e..89cd4f78 100644 --- a/src/main/java/io/oeid/mogakgo/domain/project/presentation/ProjectController.java +++ b/src/main/java/io/oeid/mogakgo/domain/project/presentation/ProjectController.java @@ -99,7 +99,7 @@ public ResponseEntity getById( @GetMapping("/{id}/info") public ResponseEntity getByUserId( @UserId Long userId, @PathVariable Long id) { - return ResponseEntity.ok().body(ProjectDetailInfoAPIRes.of(projectService.getLastedProjectByUserId(userId, id))); + return ResponseEntity.ok().body(projectService.getLastedProjectByUserId(userId, id)); } } diff --git a/src/main/java/io/oeid/mogakgo/domain/project/presentation/dto/res/ProjectDetailInfoAPIRes.java b/src/main/java/io/oeid/mogakgo/domain/project/presentation/dto/res/ProjectDetailInfoAPIRes.java index 10598626..038ea15f 100644 --- a/src/main/java/io/oeid/mogakgo/domain/project/presentation/dto/res/ProjectDetailInfoAPIRes.java +++ b/src/main/java/io/oeid/mogakgo/domain/project/presentation/dto/res/ProjectDetailInfoAPIRes.java @@ -11,9 +11,10 @@ @AllArgsConstructor(access = AccessLevel.PRIVATE) public class ProjectDetailInfoAPIRes { + private final Long matchingId; private final List response; - public static ProjectDetailInfoAPIRes of(List response) { - return new ProjectDetailInfoAPIRes(response); + public static ProjectDetailInfoAPIRes of(Long matchingId, List response) { + return new ProjectDetailInfoAPIRes(matchingId, response); } }