-
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.
Merge pull request #69 from Team-FAB/015-Apply
015 apply
- Loading branch information
Showing
9 changed files
with
408 additions
and
2 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
56 changes: 56 additions & 0 deletions
56
src/main/java/com/fab/banggabgo/dto/apply/ApplyListResultDto.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,56 @@ | ||
package com.fab.banggabgo.dto.apply; | ||
|
||
import com.fab.banggabgo.entity.Apply; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
@Getter | ||
@Setter | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class ApplyListResultDto { | ||
|
||
Integer applyId; | ||
Integer articleId; | ||
String articleTitle; | ||
Integer otherUserId; | ||
String otherUserName; | ||
String matchStatus; | ||
|
||
public static List<ApplyListResultDto> toFromApplicantDtoList(List<Apply> applyPage) { | ||
return applyPage.stream().map(ApplyListResultDto::toFromApplicantDto) | ||
.collect(Collectors.toList()); | ||
} | ||
|
||
public static ApplyListResultDto toFromApplicantDto(Apply apply) { | ||
return ApplyListResultDto.builder() | ||
.applyId(apply.getId()) | ||
.articleId(apply.getArticle().getId()) | ||
.articleTitle(apply.getArticle().getTitle()) | ||
.otherUserId(apply.getApplicantUser().getId()) | ||
.otherUserName(apply.getApplicantUser().getNickname()) | ||
.matchStatus(apply.getApproveStatus().getValue()) | ||
.build(); | ||
} | ||
public static List<ApplyListResultDto> toToApplicantDtoList(List<Apply> applyPage) { | ||
return applyPage.stream().map(ApplyListResultDto::toToApplicantDto) | ||
.collect(Collectors.toList()); | ||
} | ||
|
||
public static ApplyListResultDto toToApplicantDto(Apply apply) { | ||
return ApplyListResultDto.builder() | ||
.applyId(apply.getId()) | ||
.articleId(apply.getArticle().getId()) | ||
.articleTitle(apply.getArticle().getTitle()) | ||
.otherUserId(apply.getArticle().getUser().getId()) | ||
.otherUserName(apply.getArticle().getUser().getNickname()) | ||
.matchStatus(apply.getApproveStatus().getValue()) | ||
.build(); | ||
} | ||
} |
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
11 changes: 11 additions & 0 deletions
11
src/main/java/com/fab/banggabgo/repository/ApplyRepositoryCustom.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,11 @@ | ||
package com.fab.banggabgo.repository; | ||
|
||
import com.fab.banggabgo.entity.Apply; | ||
import java.util.List; | ||
import org.springframework.data.domain.Pageable; | ||
|
||
public interface ApplyRepositoryCustom { | ||
|
||
List<Apply> getMyApplicant(Pageable pageable, Integer userId); | ||
List<Apply> getMyToApplicant(Pageable pageable, Integer userId); | ||
} |
45 changes: 45 additions & 0 deletions
45
src/main/java/com/fab/banggabgo/repository/impl/ApplyRepositoryImpl.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,45 @@ | ||
package com.fab.banggabgo.repository.impl; | ||
|
||
import com.fab.banggabgo.entity.Apply; | ||
import com.fab.banggabgo.entity.QApply; | ||
import com.fab.banggabgo.repository.ApplyRepositoryCustom; | ||
import com.querydsl.jpa.impl.JPAQueryFactory; | ||
import java.util.List; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.data.domain.Pageable; | ||
|
||
@RequiredArgsConstructor | ||
public class ApplyRepositoryImpl implements ApplyRepositoryCustom { | ||
|
||
private final JPAQueryFactory jpaQueryFactory; | ||
|
||
QApply qApply = QApply.apply; | ||
|
||
@Override | ||
public List<Apply> getMyApplicant(Pageable pageable, Integer userId) { | ||
var pageQuery = jpaQueryFactory.selectFrom(qApply) | ||
.leftJoin(qApply.applicantUser) | ||
.fetchJoin() | ||
.leftJoin(qApply.article) | ||
.fetchJoin() | ||
.where(qApply.article.user.id.eq(userId)) | ||
.orderBy(qApply.lastModifiedDate.desc()) | ||
.offset(pageable.getOffset()) | ||
.limit(pageable.getPageSize()); | ||
|
||
return pageQuery.fetch(); | ||
} | ||
@Override | ||
public List<Apply> getMyToApplicant(Pageable pageable, Integer userId) { | ||
var pageQuery = jpaQueryFactory.selectFrom(qApply) | ||
.leftJoin(qApply.article) | ||
.fetchJoin() | ||
.leftJoin(qApply.article.user) | ||
.where(qApply.applicantUser.id.eq(userId)) | ||
.orderBy(qApply.lastModifiedDate.desc()) | ||
.offset(pageable.getOffset()) | ||
.limit(pageable.getPageSize()); | ||
|
||
return pageQuery.fetch(); | ||
} | ||
} |
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
Oops, something went wrong.