-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
283 additions
and
39 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
BE/src/main/java/com/issuetracker/config/QueryDSLConfig.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,20 @@ | ||
package com.issuetracker.config; | ||
|
||
import com.querydsl.jpa.impl.JPAQueryFactory; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
import javax.persistence.EntityManager; | ||
import javax.persistence.PersistenceContext; | ||
|
||
@Configuration | ||
public class QueryDSLConfig { | ||
|
||
@PersistenceContext | ||
private EntityManager entityManager; | ||
|
||
@Bean | ||
public JPAQueryFactory jpaQueryFactory() { | ||
return new JPAQueryFactory(entityManager); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
BE/src/main/java/com/issuetracker/domain/issue/CustomizedIssueRepository.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,12 @@ | ||
package com.issuetracker.domain.issue; | ||
|
||
import com.issuetracker.web.dto.reqeust.SearchRequestDTO; | ||
|
||
import java.util.List; | ||
|
||
public interface CustomizedIssueRepository { | ||
|
||
List<Issue> findAllIssuesFilteredBy(SearchRequestDTO searchRequest); | ||
|
||
// List<Issue> findAllIssuesFilteredBy(SearchRequest searchRequest); | ||
} |
96 changes: 96 additions & 0 deletions
96
BE/src/main/java/com/issuetracker/domain/issue/CustomizedIssueRepositoryImpl.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,96 @@ | ||
package com.issuetracker.domain.issue; | ||
|
||
|
||
import com.issuetracker.domain.user.User; | ||
import com.issuetracker.web.dto.reqeust.SearchRequestDTO; | ||
import com.issuetracker.web.dto.vo.Status; | ||
import com.querydsl.core.types.dsl.BooleanExpression; | ||
import com.querydsl.jpa.impl.JPAQueryFactory; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
import java.util.List; | ||
|
||
import static com.issuetracker.domain.issue.QIssue.issue; | ||
import static com.issuetracker.domain.user.QUser.user; | ||
import static com.issuetracker.domain.label.QLabel.label; | ||
import static com.issuetracker.domain.milestone.QMilestone.milestone; | ||
import static com.issuetracker.domain.comment.QComment.comment1; | ||
import static org.springframework.util.StringUtils.hasText; | ||
|
||
@RequiredArgsConstructor | ||
public class CustomizedIssueRepositoryImpl implements CustomizedIssueRepository { | ||
|
||
private final JPAQueryFactory queryFactory; | ||
|
||
public List<Issue> findAllIssuesFilteredBy(SearchRequestDTO searchRequest) { | ||
return queryFactory | ||
.select(issue) | ||
.distinct() | ||
.from(issue) | ||
.leftJoin(issue.author, user) | ||
.leftJoin(issue.labels, label) | ||
.leftJoin(issue.milestone, milestone) | ||
.leftJoin(issue.comments, comment1) | ||
.where(statusEquals(searchRequest.getStatus()), | ||
authorEquals(searchRequest.getAuthor()), | ||
// labelEquals(labelName), | ||
milestoneEquals(searchRequest.getMilestone()), | ||
assigneeEquals(searchRequest.getAssignee()), | ||
commenterEquals(searchRequest.getCommenter())) | ||
.limit(100) | ||
.fetch(); | ||
|
||
// return queryFactory | ||
// .selectFrom(issue) | ||
// .where( | ||
// statusEquals(searchRequest.getStatus()), | ||
// authorEquals(searchRequest.getAuthor()), | ||
// assigneeEquals(searchRequest.getAssignee()) | ||
// ) | ||
// .fetch(); | ||
} | ||
|
||
public BooleanExpression statusEquals(String status) { | ||
return hasText(status) ? issue.isOpen.eq(Status.statusToBoolean(status)) : null; | ||
} | ||
|
||
public BooleanExpression authorEquals(String author) { | ||
return hasText(author) ? user.userName.eq(author) : null; | ||
} | ||
|
||
public BooleanExpression milestoneEquals(String milestoneTitle) { | ||
return hasText(milestoneTitle) ? milestone.title.eq(milestoneTitle) : null; | ||
} | ||
|
||
public BooleanExpression assigneeEquals(String assignee) { | ||
if (!hasText(assignee)) { | ||
return null; | ||
} | ||
User user = findByUserName(assignee); | ||
if (user == null) { | ||
return null; | ||
} | ||
return issue.assignees.contains(user); | ||
} | ||
|
||
private BooleanExpression commenterEquals(String commenter) { | ||
if (commenter == null) { | ||
return null; | ||
} | ||
return comment1.author.userName.eq(commenter); | ||
} | ||
|
||
private User findByUserName(String userName) { | ||
return queryFactory.selectFrom(user) | ||
.where(user.userName.eq(userName)) | ||
.fetchFirst(); | ||
} | ||
|
||
// public BooleanExpression commenterEquals(User commenter) { | ||
// return commenter != null ? issue.comments.contains(commenter) : null; | ||
// } | ||
// | ||
// public BooleanExpression labelEquals(List<String> label) { | ||
// return label!=null? | ||
// } | ||
} |
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
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
15 changes: 15 additions & 0 deletions
15
BE/src/main/java/com/issuetracker/exception/GlobalExceptionHandler.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,15 @@ | ||
package com.issuetracker.exception; | ||
|
||
import com.issuetracker.web.dto.response.IssuesResponseDTO; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.ExceptionHandler; | ||
import org.springframework.web.bind.annotation.RestControllerAdvice; | ||
|
||
@RestControllerAdvice | ||
public class GlobalExceptionHandler { | ||
|
||
// @ExceptionHandler(InvalidSearchRequestException.class) | ||
// public ResponseEntity handleInvalidSearchRequestException(InvalidSearchRequestException e) { | ||
// return ResponseEntity.ok(new IssuesResponseDTO()); | ||
// } | ||
} |
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
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
2 changes: 1 addition & 1 deletion
2
BE/src/main/java/com/issuetracker/web/dto/reqeust/AssigneesToUpdateRequestDTO.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
20 changes: 20 additions & 0 deletions
20
BE/src/main/java/com/issuetracker/web/dto/reqeust/SearchRequestDTO.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,20 @@ | ||
package com.issuetracker.web.dto.reqeust; | ||
|
||
import lombok.Getter; | ||
import lombok.Setter; | ||
import lombok.ToString; | ||
|
||
import java.util.List; | ||
|
||
@Getter | ||
@Setter | ||
@ToString | ||
public class SearchRequestDTO { | ||
|
||
private String status; | ||
private String author; | ||
private String assignee; | ||
private String commenter; | ||
private List<String> label; | ||
private String milestone; | ||
} |
2 changes: 1 addition & 1 deletion
2
BE/src/main/java/com/issuetracker/web/dto/response/AssigneesResponseDTO.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
2 changes: 1 addition & 1 deletion
2
BE/src/main/java/com/issuetracker/web/dto/response/IssueDetailPageResponseDTO.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
Oops, something went wrong.