Skip to content

Commit

Permalink
🚑[HOTFIX]: hasApplied dto 추가 및 로직수정
Browse files Browse the repository at this point in the history
  • Loading branch information
jiixon committed Apr 12, 2024
1 parent 4a35c91 commit cd38bff
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.example.weneedbe.domain.application.repository;

import org.example.weneedbe.domain.application.domain.Application;
import org.example.weneedbe.domain.application.domain.Recruit;
import org.example.weneedbe.domain.article.domain.Type;
import org.example.weneedbe.domain.user.domain.User;
import org.example.weneedbe.domain.user.domain.UserArticle;
Expand All @@ -17,4 +18,5 @@ public interface ApplicationRepository extends JpaRepository<Application, Long>
Page<Application> findAllByUser(User user, Pageable pageable);

List<Application> findAllByRecruit_RecruitId(Long recruitId);
boolean existsByRecruitAndUser(Recruit recruit, User user);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.util.Optional;
import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
import org.example.weneedbe.domain.application.repository.ApplicationRepository;
import org.example.weneedbe.domain.application.repository.RecruitRepository;
import org.example.weneedbe.domain.article.domain.Article;
import org.example.weneedbe.domain.article.domain.ArticleLike;
Expand Down Expand Up @@ -51,6 +52,7 @@ public class ArticleService {
private final BookmarkService bookmarkService;
private final BookmarkRepository bookmarkRepository;
private final RecruitRepository recruitRepository;
private final ApplicationRepository applicationRepository;

public void createPortfolio(String authorizationHeader, CreateArticleRequest request) {

Expand Down Expand Up @@ -161,7 +163,9 @@ public DetailRecruitDto getDetailRecruit(String authorizationHeader, Long articl

boolean isRecruiting = recruitRepository.existsByArticle_ArticleId(articleId);

return new DetailRecruitDto(article, user, heartCount, bookmarkCount, isHearted, isBookmarked, commentResponseDtos, isRecruiting);
boolean hasApplied = applicationRepository.existsByRecruitAndUser(article.getRecruit(), user);

return new DetailRecruitDto(article, user, heartCount, bookmarkCount, isHearted, isBookmarked, commentResponseDtos, isRecruiting, hasApplied);
}

public static List<CommentResponseDto> mapToResponseDto(List<Comment> commentList) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static class DetailPortfolioDto {
public DetailPortfolioDto(Article article, User user, int heartCount, int bookmarkCount, List<WorkPortfolioArticleDto> workList,
boolean isHearted, boolean isBookmarked, List<CommentResponseDto> commentList, boolean isRecruiting) {
this.user = new DetailUserDto(user, user.getUserId().equals(article.getUser().getUserId()), isHearted, isBookmarked);
this.portfolio = new DetailArticleDto(article, heartCount, bookmarkCount, isRecruiting);
this.portfolio = new DetailArticleDto(article, heartCount, bookmarkCount, isRecruiting, false);
this.workList = workList;
this.comments = commentList;
}
Expand Down Expand Up @@ -73,8 +73,10 @@ public static class DetailArticleDto {
private List<DetailPortfolioContentDto> contents;
private List<DetailTeamMemberDto> teamMembers;
private boolean isRecruiting;
private boolean hasApplied;

public DetailArticleDto(Article article, int heartCount, int bookmarkCount, boolean isRecruiting) {

public DetailArticleDto(Article article, int heartCount, int bookmarkCount, boolean isRecruiting, boolean hasApplied) {
this.thumbnail = article.getThumbnail();
this.title = article.getTitle();
this.createdAt = article.getCreatedAt();
Expand All @@ -94,6 +96,8 @@ public DetailArticleDto(Article article, int heartCount, int bookmarkCount, bool
.map(userArticle -> new DetailTeamMemberDto(userArticle.getUser()))
.collect(Collectors.toList());
this.isRecruiting = isRecruiting;
this.hasApplied = hasApplied;

}
}

Expand Down Expand Up @@ -159,9 +163,9 @@ public static class DetailRecruitDto {
private DetailArticleDto recruit;
private List<CommentResponseDto> comments;

public DetailRecruitDto(Article article, User user, int heartCount, int bookmarkCount, boolean isHearted, boolean isBookmarked, List<CommentResponseDto> commentList, boolean isRecruiting) {
public DetailRecruitDto(Article article, User user, int heartCount, int bookmarkCount, boolean isHearted, boolean isBookmarked, List<CommentResponseDto> commentList, boolean isRecruiting, boolean hasApplied) {
this.user = new DetailUserDto(user, user.getUserId().equals(article.getUser().getUserId()), isHearted, isBookmarked);
this.recruit = new DetailArticleDto(article, heartCount, bookmarkCount, isRecruiting);
this.recruit = new DetailArticleDto(article, heartCount, bookmarkCount, isRecruiting, hasApplied);
this.comments = commentList;
}

Expand Down

0 comments on commit cd38bff

Please sign in to comment.