diff --git a/BE/src/main/java/com/issuetracker/config/QueryDSLConfig.java b/BE/src/main/java/com/issuetracker/config/QueryDSLConfig.java new file mode 100644 index 000000000..7f6a38472 --- /dev/null +++ b/BE/src/main/java/com/issuetracker/config/QueryDSLConfig.java @@ -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); + } +} diff --git a/BE/src/main/java/com/issuetracker/domain/issue/CustomizedIssueRepository.java b/BE/src/main/java/com/issuetracker/domain/issue/CustomizedIssueRepository.java new file mode 100644 index 000000000..fda435f47 --- /dev/null +++ b/BE/src/main/java/com/issuetracker/domain/issue/CustomizedIssueRepository.java @@ -0,0 +1,12 @@ +package com.issuetracker.domain.issue; + +import com.issuetracker.web.dto.reqeust.SearchRequestDTO; + +import java.util.List; + +public interface CustomizedIssueRepository { + + List findAllIssuesFilteredBy(SearchRequestDTO searchRequest); + +// List findAllIssuesFilteredBy(SearchRequest searchRequest); +} diff --git a/BE/src/main/java/com/issuetracker/domain/issue/CustomizedIssueRepositoryImpl.java b/BE/src/main/java/com/issuetracker/domain/issue/CustomizedIssueRepositoryImpl.java new file mode 100644 index 000000000..20c45a3f9 --- /dev/null +++ b/BE/src/main/java/com/issuetracker/domain/issue/CustomizedIssueRepositoryImpl.java @@ -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 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 label) { +// return label!=null? +// } +} diff --git a/BE/src/main/java/com/issuetracker/domain/issue/IssueRepository.java b/BE/src/main/java/com/issuetracker/domain/issue/IssueRepository.java index 48aa0046d..1a61cbfd2 100644 --- a/BE/src/main/java/com/issuetracker/domain/issue/IssueRepository.java +++ b/BE/src/main/java/com/issuetracker/domain/issue/IssueRepository.java @@ -8,7 +8,7 @@ import java.util.List; -public interface IssueRepository extends JpaRepository { +public interface IssueRepository extends JpaRepository, CustomizedIssueRepository { List findAllByIsOpenTrue(); diff --git a/BE/src/main/java/com/issuetracker/domain/milestone/Milestone.java b/BE/src/main/java/com/issuetracker/domain/milestone/Milestone.java index c5ad75f6e..ff07b9723 100644 --- a/BE/src/main/java/com/issuetracker/domain/milestone/Milestone.java +++ b/BE/src/main/java/com/issuetracker/domain/milestone/Milestone.java @@ -14,7 +14,7 @@ @Setter @Builder @AllArgsConstructor -@NoArgsConstructor(access = AccessLevel.PROTECTED) +@NoArgsConstructor public class Milestone extends BaseTimeEntity { @Id diff --git a/BE/src/main/java/com/issuetracker/domain/milestone/MilestoneRepository.java b/BE/src/main/java/com/issuetracker/domain/milestone/MilestoneRepository.java index 80b6766cd..f14ea6ea7 100644 --- a/BE/src/main/java/com/issuetracker/domain/milestone/MilestoneRepository.java +++ b/BE/src/main/java/com/issuetracker/domain/milestone/MilestoneRepository.java @@ -2,5 +2,9 @@ import org.springframework.data.jpa.repository.JpaRepository; +import java.util.Optional; + public interface MilestoneRepository extends JpaRepository { + + Optional findByTitle(String title); } diff --git a/BE/src/main/java/com/issuetracker/domain/user/User.java b/BE/src/main/java/com/issuetracker/domain/user/User.java index 1c7516bc7..5f5735d16 100644 --- a/BE/src/main/java/com/issuetracker/domain/user/User.java +++ b/BE/src/main/java/com/issuetracker/domain/user/User.java @@ -14,7 +14,7 @@ @EqualsAndHashCode(of = "id") @Builder @AllArgsConstructor -@NoArgsConstructor(access = AccessLevel.PROTECTED) +@NoArgsConstructor public class User { @Id diff --git a/BE/src/main/java/com/issuetracker/domain/user/UserRepository.java b/BE/src/main/java/com/issuetracker/domain/user/UserRepository.java index d48bad2fe..469264d85 100644 --- a/BE/src/main/java/com/issuetracker/domain/user/UserRepository.java +++ b/BE/src/main/java/com/issuetracker/domain/user/UserRepository.java @@ -7,5 +7,6 @@ @Repository public interface UserRepository extends JpaRepository { + Optional findByUserName(String userName); } diff --git a/BE/src/main/java/com/issuetracker/exception/GlobalExceptionHandler.java b/BE/src/main/java/com/issuetracker/exception/GlobalExceptionHandler.java new file mode 100644 index 000000000..ccf87571f --- /dev/null +++ b/BE/src/main/java/com/issuetracker/exception/GlobalExceptionHandler.java @@ -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()); +// } +} diff --git a/BE/src/main/java/com/issuetracker/exception/InvalidSearchRequestException.java b/BE/src/main/java/com/issuetracker/exception/InvalidSearchRequestException.java index b6e278ead..05873b401 100644 --- a/BE/src/main/java/com/issuetracker/exception/InvalidSearchRequestException.java +++ b/BE/src/main/java/com/issuetracker/exception/InvalidSearchRequestException.java @@ -3,10 +3,9 @@ import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.ResponseStatus; -@ResponseStatus(HttpStatus.BAD_REQUEST) public class InvalidSearchRequestException extends RuntimeException { public InvalidSearchRequestException() { - super("Invalid status."); + super("Invalid search request."); } } diff --git a/BE/src/main/java/com/issuetracker/service/IssueService.java b/BE/src/main/java/com/issuetracker/service/IssueService.java index 793ea5ca5..ed4bcb44e 100644 --- a/BE/src/main/java/com/issuetracker/service/IssueService.java +++ b/BE/src/main/java/com/issuetracker/service/IssueService.java @@ -8,9 +8,10 @@ import com.issuetracker.domain.milestone.Milestone; import com.issuetracker.domain.user.User; import com.issuetracker.exception.ElementNotFoundException; -import com.issuetracker.exception.InvalidSearchRequestException; -import com.issuetracker.web.dto.response.vo.Assignee; -import com.issuetracker.web.dto.response.vo.Count; +import com.issuetracker.web.dto.vo.Assignee; +import com.issuetracker.web.dto.vo.Count; +import com.issuetracker.web.dto.vo.SearchRequest; +import com.issuetracker.web.dto.vo.Status; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -27,27 +28,38 @@ public class IssueService { private final MilestoneService milestoneService; private final UserService userService; - public IssuesResponseDTO getIssues(String status) { + public IssuesResponseDTO getIssues(SearchRequestDTO searchRequestDTO) { + +// SearchRequest searchRequest = new SearchRequest( +// Status.statusToBoolean(searchRequestDTO.getStatus()), +// searchRequestDTO.getAuthor(), +// userService.findNullableUserByUserName(searchRequestDTO.getAssignee()), +// userService.findNullableUserByUserName(searchRequestDTO.getCommenter()), +// searchRequestDTO.getLabel(), +// milestoneService.findNullableMilestoneByTitle(searchRequestDTO.getMilestone()) +// ); + Count count = Count.builder() .label((int) labelService.count()) .milestone((int) milestoneService.count()) .openedIssue((int) issueRepository.countAllByIsOpenTrue()) .closedIssue((int) issueRepository.countAllByIsOpenFalse()) .build(); - List issues = filterByStatus(status).stream() + + List issues = issueRepository.findAllIssuesFilteredBy(searchRequestDTO).stream() .map(issue -> IssueResponseDTO.of(issue, userService.usersToAssignees(issue), labelService.labelsToLabelDTOs(issue))) .collect(Collectors.toList()); return IssuesResponseDTO.of(count, issues); } private List filterByStatus(String status) { - boolean newStatus = statusToBoolean(status); + boolean newStatus = Status.statusToBoolean(status); return newStatus ? issueRepository.findAllByIsOpenTrue() : issueRepository.findAllByIsOpenFalse(); } @Transactional public void changeIssueStatus(IssueNumbersRequestDTO requestDTO, String status) { - boolean newStatus = !statusToBoolean(status); + boolean newStatus = !Status.statusToBoolean(status); issueRepository.updateStatusBy(newStatus, requestDTO.getIssueNumbers()); } @@ -172,13 +184,4 @@ private List commentsToCommentDTOs(User user, Issue issue) { .collect(Collectors.toList()); } - private boolean statusToBoolean(String status) { - if (status.equals("open")) { - return true; - } - if (status.equals("close")) { - return false; - } - throw new InvalidSearchRequestException(); - } } diff --git a/BE/src/main/java/com/issuetracker/service/MilestoneService.java b/BE/src/main/java/com/issuetracker/service/MilestoneService.java index 123e473c7..656880035 100644 --- a/BE/src/main/java/com/issuetracker/service/MilestoneService.java +++ b/BE/src/main/java/com/issuetracker/service/MilestoneService.java @@ -44,6 +44,13 @@ public Milestone findMilestoneById(Long milestoneId) { return milestoneRepository.findById(milestoneId).orElseThrow(EntityExistsException::new); } + public Milestone findNullableMilestoneByTitle(String title) { + if (title == null) { + return null; + } + return milestoneRepository.findByTitle(title).orElse(new Milestone()); + } + public List findAllMilestoneDTOs() { return milestoneRepository.findAll().stream().map(MilestoneDTO::of).collect(Collectors.toList()); } diff --git a/BE/src/main/java/com/issuetracker/service/UserService.java b/BE/src/main/java/com/issuetracker/service/UserService.java index 672787c91..67ea74016 100644 --- a/BE/src/main/java/com/issuetracker/service/UserService.java +++ b/BE/src/main/java/com/issuetracker/service/UserService.java @@ -7,14 +7,16 @@ import com.issuetracker.auth.service.JwtService; import com.issuetracker.domain.user.User; import com.issuetracker.domain.user.UserRepository; +import com.issuetracker.exception.InvalidSearchRequestException; import com.issuetracker.exception.UserNotFoundException; import com.issuetracker.web.dto.response.UserResponseDTO; -import com.issuetracker.web.dto.response.vo.Assignee; +import com.issuetracker.web.dto.vo.Assignee; import com.issuetracker.domain.issue.Issue; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import java.util.List; +import java.util.Optional; import java.util.stream.Collectors; @Service @@ -31,9 +33,9 @@ public List findAssignees(List assigneeIdList) { public UserResponseDTO login(String code, UserAgentDTO userAgent) { AccessTokenResponseDTO token = oauth.getToken(code, userAgent.getUserAgent()); - UserResponseDTO userInfo = oauth.getUserInfo(token.getAccessToken()); + OAuthUserResponseDTO userInfo = oauth.getUserInfo(token.getAccessToken()); if (verifyUser(userInfo.getLogin())) { - User user = findByUserName(userInfo.getLogin()); + User user = findUserByUserName(userInfo.getLogin()); user.update(userInfo, token.getAccessToken()); return UserResponseDTO.createUserResponseDTO(user, jwtService.createToken(userRepository.save(user))); } @@ -70,12 +72,19 @@ public List usersToAssignees() { .collect(Collectors.toList()); } - private User findByUserName(String userName) { + public User findUserByUserName(String userName) { return userRepository.findByUserName(userName).orElseThrow( () -> new UserNotFoundException("Cannot find user by given username.") ); } + public User findNullableUserByUserName(String userName) { + if (userName == null) { + return null; + } + return userRepository.findByUserName(userName).orElseThrow(InvalidSearchRequestException::new); + } + private boolean verifyUser(String userName) { return userRepository.findByUserName(userName).isPresent(); } diff --git a/BE/src/main/java/com/issuetracker/web/IssueController.java b/BE/src/main/java/com/issuetracker/web/IssueController.java index 4d573458e..8147c94e7 100644 --- a/BE/src/main/java/com/issuetracker/web/IssueController.java +++ b/BE/src/main/java/com/issuetracker/web/IssueController.java @@ -19,9 +19,9 @@ public class IssueController { private final Logger logger = LoggerFactory.getLogger(IssueController.class); @GetMapping - public IssuesResponseDTO view(@RequestParam String status) { + public IssuesResponseDTO view(SearchRequestDTO requestDTO) { logger.debug("모든 이슈 조회"); - return issueService.getIssues(status); + return issueService.getIssues(requestDTO); } @PatchMapping diff --git a/BE/src/main/java/com/issuetracker/web/dto/reqeust/AssigneesToUpdateRequestDTO.java b/BE/src/main/java/com/issuetracker/web/dto/reqeust/AssigneesToUpdateRequestDTO.java index dc2143dbc..b9989f0eb 100644 --- a/BE/src/main/java/com/issuetracker/web/dto/reqeust/AssigneesToUpdateRequestDTO.java +++ b/BE/src/main/java/com/issuetracker/web/dto/reqeust/AssigneesToUpdateRequestDTO.java @@ -1,6 +1,6 @@ package com.issuetracker.web.dto.reqeust; -import com.issuetracker.web.dto.response.vo.Assignee; +import com.issuetracker.web.dto.vo.Assignee; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; diff --git a/BE/src/main/java/com/issuetracker/web/dto/reqeust/SearchRequestDTO.java b/BE/src/main/java/com/issuetracker/web/dto/reqeust/SearchRequestDTO.java new file mode 100644 index 000000000..ea1e1238e --- /dev/null +++ b/BE/src/main/java/com/issuetracker/web/dto/reqeust/SearchRequestDTO.java @@ -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 label; + private String milestone; +} diff --git a/BE/src/main/java/com/issuetracker/web/dto/response/AssigneesResponseDTO.java b/BE/src/main/java/com/issuetracker/web/dto/response/AssigneesResponseDTO.java index 1d38501d1..ac018ee31 100644 --- a/BE/src/main/java/com/issuetracker/web/dto/response/AssigneesResponseDTO.java +++ b/BE/src/main/java/com/issuetracker/web/dto/response/AssigneesResponseDTO.java @@ -1,6 +1,6 @@ package com.issuetracker.web.dto.response; -import com.issuetracker.web.dto.response.vo.Assignee; +import com.issuetracker.web.dto.vo.Assignee; import lombok.Getter; import lombok.RequiredArgsConstructor; diff --git a/BE/src/main/java/com/issuetracker/web/dto/response/IssueDetailPageResponseDTO.java b/BE/src/main/java/com/issuetracker/web/dto/response/IssueDetailPageResponseDTO.java index 5f014aae8..5c9c2814f 100644 --- a/BE/src/main/java/com/issuetracker/web/dto/response/IssueDetailPageResponseDTO.java +++ b/BE/src/main/java/com/issuetracker/web/dto/response/IssueDetailPageResponseDTO.java @@ -1,6 +1,6 @@ package com.issuetracker.web.dto.response; -import com.issuetracker.web.dto.response.vo.Assignee; +import com.issuetracker.web.dto.vo.Assignee; import com.issuetracker.domain.issue.Issue; import lombok.AllArgsConstructor; import lombok.Builder; diff --git a/BE/src/main/java/com/issuetracker/web/dto/response/IssueFormResponseDTO.java b/BE/src/main/java/com/issuetracker/web/dto/response/IssueFormResponseDTO.java index f6cfbaeed..904c14caf 100644 --- a/BE/src/main/java/com/issuetracker/web/dto/response/IssueFormResponseDTO.java +++ b/BE/src/main/java/com/issuetracker/web/dto/response/IssueFormResponseDTO.java @@ -1,6 +1,6 @@ package com.issuetracker.web.dto.response; -import com.issuetracker.web.dto.response.vo.Assignee; +import com.issuetracker.web.dto.vo.Assignee; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; diff --git a/BE/src/main/java/com/issuetracker/web/dto/response/IssueResponseDTO.java b/BE/src/main/java/com/issuetracker/web/dto/response/IssueResponseDTO.java index e336a6405..81bbd2353 100644 --- a/BE/src/main/java/com/issuetracker/web/dto/response/IssueResponseDTO.java +++ b/BE/src/main/java/com/issuetracker/web/dto/response/IssueResponseDTO.java @@ -1,6 +1,6 @@ package com.issuetracker.web.dto.response; -import com.issuetracker.web.dto.response.vo.Assignee; +import com.issuetracker.web.dto.vo.Assignee; import com.issuetracker.domain.issue.Issue; import lombok.AllArgsConstructor; import lombok.Builder; diff --git a/BE/src/main/java/com/issuetracker/web/dto/response/IssuesResponseDTO.java b/BE/src/main/java/com/issuetracker/web/dto/response/IssuesResponseDTO.java index 1ab5b9693..49a0a4260 100644 --- a/BE/src/main/java/com/issuetracker/web/dto/response/IssuesResponseDTO.java +++ b/BE/src/main/java/com/issuetracker/web/dto/response/IssuesResponseDTO.java @@ -1,11 +1,13 @@ package com.issuetracker.web.dto.response; -import com.issuetracker.web.dto.response.vo.Count; +import com.issuetracker.web.dto.vo.Count; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; +import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; @Getter @Builder @@ -21,4 +23,16 @@ public static IssuesResponseDTO of(Count count, List issues) { .issues(issues) .build(); } + +// public static IssuesResponseDTO blankIssuesResponseDTO(int ) { +// return IssuesResponseDTO.builder() +// .count(Count.builder() +// .label(0) +// .milestone(0) +// .openedIssue(0) +// .closedIssue(0) +// .build()) +// .issues(new ArrayList<>()) +// .build(); +// } } diff --git a/BE/src/main/java/com/issuetracker/web/dto/response/MilestoneDTO.java b/BE/src/main/java/com/issuetracker/web/dto/response/MilestoneDTO.java index 995345ede..4ed72c370 100644 --- a/BE/src/main/java/com/issuetracker/web/dto/response/MilestoneDTO.java +++ b/BE/src/main/java/com/issuetracker/web/dto/response/MilestoneDTO.java @@ -20,8 +20,8 @@ public class MilestoneDTO { private final String description; private final LocalDateTime createdDateTime; private final LocalDate dueDate; - private final Long openedIssuesCount; - private final Long closedIssuesCount; + private final Long openedIssueCount; + private final Long closedIssueCount; public static MilestoneDTO of(Milestone milestone) { return MilestoneDTO.builder() @@ -30,8 +30,8 @@ public static MilestoneDTO of(Milestone milestone) { .description(milestone.getDescription()) .createdDateTime(milestone.getCreatedDateTime()) .dueDate(milestone.getDueDate()) - .openedIssuesCount(milestone.countOpenedIssues()) - .closedIssuesCount(milestone.countClosedIssues()) + .openedIssueCount(milestone.countOpenedIssues()) + .closedIssueCount(milestone.countClosedIssues()) .build(); } } diff --git a/BE/src/main/java/com/issuetracker/web/dto/response/vo/Assignee.java b/BE/src/main/java/com/issuetracker/web/dto/vo/Assignee.java similarity index 95% rename from BE/src/main/java/com/issuetracker/web/dto/response/vo/Assignee.java rename to BE/src/main/java/com/issuetracker/web/dto/vo/Assignee.java index a75215e57..836b7b6ee 100644 --- a/BE/src/main/java/com/issuetracker/web/dto/response/vo/Assignee.java +++ b/BE/src/main/java/com/issuetracker/web/dto/vo/Assignee.java @@ -1,4 +1,4 @@ -package com.issuetracker.web.dto.response.vo; +package com.issuetracker.web.dto.vo; import com.issuetracker.domain.issue.Issue; import com.issuetracker.domain.user.User; diff --git a/BE/src/main/java/com/issuetracker/web/dto/response/vo/Count.java b/BE/src/main/java/com/issuetracker/web/dto/vo/Count.java similarity index 85% rename from BE/src/main/java/com/issuetracker/web/dto/response/vo/Count.java rename to BE/src/main/java/com/issuetracker/web/dto/vo/Count.java index 693fb23f0..de4c52e38 100644 --- a/BE/src/main/java/com/issuetracker/web/dto/response/vo/Count.java +++ b/BE/src/main/java/com/issuetracker/web/dto/vo/Count.java @@ -1,4 +1,4 @@ -package com.issuetracker.web.dto.response.vo; +package com.issuetracker.web.dto.vo; import lombok.AllArgsConstructor; import lombok.Builder; diff --git a/BE/src/main/java/com/issuetracker/web/dto/vo/SearchRequest.java b/BE/src/main/java/com/issuetracker/web/dto/vo/SearchRequest.java new file mode 100644 index 000000000..f732f40af --- /dev/null +++ b/BE/src/main/java/com/issuetracker/web/dto/vo/SearchRequest.java @@ -0,0 +1,20 @@ +package com.issuetracker.web.dto.vo; + +import com.issuetracker.domain.milestone.Milestone; +import com.issuetracker.domain.user.User; +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +import java.util.List; + +@Getter +@RequiredArgsConstructor +public class SearchRequest { + + private final Boolean status; + private final String author; + private final User assignee; + private final User commenter; + private final List label; + private final Milestone milestone; +} diff --git a/BE/src/main/java/com/issuetracker/web/dto/vo/Status.java b/BE/src/main/java/com/issuetracker/web/dto/vo/Status.java new file mode 100644 index 000000000..ff1cc52ff --- /dev/null +++ b/BE/src/main/java/com/issuetracker/web/dto/vo/Status.java @@ -0,0 +1,24 @@ +package com.issuetracker.web.dto.vo; + +import com.issuetracker.exception.InvalidSearchRequestException; +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@Getter +@RequiredArgsConstructor +public enum Status { + OPEN("open"), + CLOSE("close"); + + private final String name; + + public static Boolean statusToBoolean(String status) { + if (status.equals(OPEN.name)) { + return true; + } + if (status.equals(CLOSE.name)) { + return false; + } + throw new InvalidSearchRequestException(); + } +}