forked from codesquad-members-2023/issue-tracker-max
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[be] 이슈목록 조회 및 필터링
- Loading branch information
Showing
19 changed files
with
758 additions
and
264 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
251 changes: 123 additions & 128 deletions
251
be/issue/src/main/java/codesquad/issueTracker/issue/controller/IssueController.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 |
---|---|---|
@@ -1,141 +1,136 @@ | ||
package codesquad.issueTracker.issue.controller; | ||
|
||
import static codesquad.issueTracker.global.exception.SuccessCode.*; | ||
|
||
import java.util.List; | ||
import codesquad.issueTracker.global.common.ApiResponse; | ||
import codesquad.issueTracker.issue.dto.*; | ||
import codesquad.issueTracker.issue.dto.filter.IssueFilteredResponseDto; | ||
import codesquad.issueTracker.issue.service.IssueService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.web.bind.annotation.*; | ||
import org.springframework.web.multipart.MultipartFile; | ||
|
||
import javax.servlet.http.HttpServletRequest; | ||
import javax.validation.Valid; | ||
import java.util.List; | ||
|
||
import org.springframework.web.bind.annotation.DeleteMapping; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PatchMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestPart; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import org.springframework.web.multipart.MultipartFile; | ||
|
||
import codesquad.issueTracker.global.common.ApiResponse; | ||
import codesquad.issueTracker.issue.dto.IssueFileResponseDto; | ||
import codesquad.issueTracker.issue.dto.IssueLabelResponseDto; | ||
import codesquad.issueTracker.issue.dto.IssueMilestoneResponseDto; | ||
import codesquad.issueTracker.issue.dto.IssueOptionResponseDto; | ||
import codesquad.issueTracker.issue.dto.IssueResponseDto; | ||
import codesquad.issueTracker.issue.dto.IssueUserResponseDto; | ||
import codesquad.issueTracker.issue.dto.IssueWriteRequestDto; | ||
import codesquad.issueTracker.issue.dto.ModifyAssigneeRequestDto; | ||
import codesquad.issueTracker.issue.dto.ModifyIssueContentRequestDto; | ||
import codesquad.issueTracker.issue.dto.ModifyIssueContentResponseDto; | ||
import codesquad.issueTracker.issue.dto.ModifyIssueMilestoneDto; | ||
import codesquad.issueTracker.issue.dto.ModifyIssueStatusRequestDto; | ||
import codesquad.issueTracker.issue.dto.ModifyIssueTitleRequest; | ||
import codesquad.issueTracker.issue.dto.ModifyIssueTitleResponse; | ||
import codesquad.issueTracker.issue.dto.ModifyLabelRequestDto; | ||
import codesquad.issueTracker.issue.service.IssueService; | ||
import lombok.RequiredArgsConstructor; | ||
import static codesquad.issueTracker.global.exception.SuccessCode.SUCCESS; | ||
|
||
@RequiredArgsConstructor | ||
@RestController | ||
@RequestMapping("/api") | ||
public class IssueController { | ||
|
||
private final IssueService issueService; | ||
|
||
@PostMapping("/issues") | ||
public ApiResponse<String> postIssues(@Valid @RequestBody IssueWriteRequestDto request, | ||
HttpServletRequest httpServletRequest) { | ||
Long id = Long.parseLong(String.valueOf(httpServletRequest.getAttribute("userId"))); | ||
issueService.save(request, id); | ||
return ApiResponse.success(SUCCESS.getStatus(), SUCCESS.getMessage()); | ||
} | ||
|
||
@GetMapping("/issues/labels") | ||
public ApiResponse<IssueLabelResponseDto> getIssueLabels() { | ||
IssueLabelResponseDto labels = issueService.getIssueLabels(); | ||
return ApiResponse.success(SUCCESS.getStatus(), labels); | ||
} | ||
|
||
@GetMapping("/issues/milestones") | ||
public ApiResponse<IssueMilestoneResponseDto> getIssueMilestones() { | ||
IssueMilestoneResponseDto milestones = issueService.getIssueMilestones(); | ||
return ApiResponse.success(SUCCESS.getStatus(), milestones); | ||
} | ||
|
||
@GetMapping("/issues/participants") | ||
public ApiResponse<IssueUserResponseDto> getIssueUsers() { | ||
IssueUserResponseDto participants = issueService.getIssueUsers(); | ||
return ApiResponse.success(SUCCESS.getStatus(), participants); | ||
} | ||
|
||
@GetMapping("/issues/{issueId}") | ||
public ApiResponse<IssueResponseDto> getIssue(@PathVariable Long issueId) { | ||
IssueResponseDto issueResponseDto = issueService.getIssueById(issueId); | ||
return ApiResponse.success(SUCCESS.getStatus(), issueResponseDto); | ||
} | ||
|
||
@GetMapping("/issues/{issueId}/options") | ||
public ApiResponse<IssueOptionResponseDto> getIssueOptions(@PathVariable Long issueId) { | ||
IssueOptionResponseDto issueOptionResponseDto = issueService.getIssueOptions(issueId); | ||
return ApiResponse.success(SUCCESS.getStatus(), issueOptionResponseDto); | ||
} | ||
|
||
@PatchMapping("/issues/status") | ||
public ApiResponse<String> patchStatus(@RequestBody ModifyIssueStatusRequestDto request) { | ||
issueService.modifyIssueStatus(request); | ||
return ApiResponse.success(SUCCESS.getStatus(), SUCCESS.getMessage()); | ||
} | ||
|
||
@PatchMapping("/issues/{id}/status") | ||
public ApiResponse<String> patchInDetailStatus(@PathVariable Long id, | ||
@RequestBody ModifyIssueStatusRequestDto request) { | ||
issueService.modifyIssueStatusInDetail(id, request); | ||
return ApiResponse.success(SUCCESS.getStatus(), SUCCESS.getMessage()); | ||
} | ||
|
||
@PatchMapping("/issues/{id}/content") | ||
public ApiResponse<ModifyIssueContentResponseDto> patchContent(@PathVariable Long id, | ||
@RequestBody ModifyIssueContentRequestDto request) { | ||
ModifyIssueContentResponseDto response = issueService.modifyIssueContent(id, request); | ||
return ApiResponse.success(SUCCESS.getStatus(), response); | ||
} | ||
|
||
@PatchMapping("/issues/{id}/title") | ||
public ApiResponse<ModifyIssueTitleResponse> patchTitle(@PathVariable Long id, | ||
@Valid @RequestBody ModifyIssueTitleRequest request) { | ||
ModifyIssueTitleResponse response = issueService.modifyIssueTitle(id, request); | ||
return ApiResponse.success(SUCCESS.getStatus(), response); | ||
} | ||
|
||
@DeleteMapping("/issues/{id}") | ||
public ApiResponse<String> deleteIssues(@PathVariable Long id) { | ||
issueService.delete(id); | ||
return ApiResponse.success(SUCCESS.getStatus(), SUCCESS.getMessage()); | ||
} | ||
|
||
@PatchMapping("/issues/{id}/assignees") | ||
public ApiResponse<String> patchAssignees(@PathVariable Long id, @RequestBody ModifyAssigneeRequestDto request) { | ||
issueService.modifyAssignees(id, request); | ||
return ApiResponse.success(SUCCESS.getStatus(), SUCCESS.getMessage()); | ||
} | ||
|
||
@PatchMapping("/issues/{id}/labels") | ||
public ApiResponse<String> patchLabels(@PathVariable Long id, @RequestBody ModifyLabelRequestDto request) { | ||
issueService.modifyLabels(id, request); | ||
return ApiResponse.success(SUCCESS.getStatus(), SUCCESS.getMessage()); | ||
} | ||
|
||
@PatchMapping("/issues/{id}/milestones") | ||
public ApiResponse<String> patchMilestone(@PathVariable Long id, @RequestBody ModifyIssueMilestoneDto request) { | ||
issueService.modifyMilestone(id, request); | ||
return ApiResponse.success(SUCCESS.getStatus(), SUCCESS.getMessage()); | ||
} | ||
|
||
@PostMapping("/upload") | ||
public ApiResponse<IssueFileResponseDto> uploadFile(@RequestPart(value = "file") MultipartFile multipartFile) { | ||
IssueFileResponseDto response = issueService.uploadImg(multipartFile); | ||
return ApiResponse.success(SUCCESS.getStatus(), response); | ||
} | ||
private final IssueService issueService; | ||
|
||
@GetMapping("/issues") | ||
public ApiResponse<IssueFilteredResponseDto> getIssues(@RequestParam String status, | ||
@RequestParam(required = false) List<Long> labels, | ||
@RequestParam(required = false) Long milestone, | ||
@RequestParam(required = false) Long writer, | ||
@RequestParam(required = false) List<Long> assignees, | ||
@RequestParam(required = false) Boolean comment, | ||
HttpServletRequest httpServletRequest) { | ||
|
||
Long userId = Long.parseLong(String.valueOf(httpServletRequest.getAttribute("userId"))); | ||
IssueFilterRequestDto issueFilterRequestDto = IssueFilterRequestDto.of(status, labels, milestone, writer, | ||
assignees, comment); | ||
IssueFilteredResponseDto issueFilteredResponseDto = issueService.findByFilter( | ||
issueFilterRequestDto.toIssueSearch(userId)); | ||
|
||
return ApiResponse.success(SUCCESS.getStatus(), issueFilteredResponseDto); | ||
} | ||
|
||
@PostMapping("/issues") | ||
public ApiResponse<String> postIssues(@Valid @RequestBody IssueWriteRequestDto request, | ||
HttpServletRequest httpServletRequest) { | ||
Long id = Long.parseLong(String.valueOf(httpServletRequest.getAttribute("userId"))); | ||
issueService.save(request, id); | ||
return ApiResponse.success(SUCCESS.getStatus(), SUCCESS.getMessage()); | ||
} | ||
|
||
@GetMapping("/issues/labels") | ||
public ApiResponse<IssueLabelResponseDto> getIssueLabels() { | ||
IssueLabelResponseDto labels = issueService.getIssueLabels(); | ||
return ApiResponse.success(SUCCESS.getStatus(), labels); | ||
} | ||
|
||
@GetMapping("/issues/milestones") | ||
public ApiResponse<IssueMilestoneResponseDto> getIssueMilestones() { | ||
IssueMilestoneResponseDto milestones = issueService.getIssueMilestones(); | ||
return ApiResponse.success(SUCCESS.getStatus(), milestones); | ||
} | ||
|
||
@GetMapping("/issues/participants") | ||
public ApiResponse<IssueUserResponseDto> getIssueUsers() { | ||
IssueUserResponseDto participants = issueService.getIssueUsers(); | ||
return ApiResponse.success(SUCCESS.getStatus(), participants); | ||
} | ||
|
||
@GetMapping("/issues/{issueId}") | ||
public ApiResponse<IssueResponseDto> getIssue(@PathVariable Long issueId) { | ||
IssueResponseDto issueResponseDto = issueService.getIssueById(issueId); | ||
return ApiResponse.success(SUCCESS.getStatus(), issueResponseDto); | ||
} | ||
|
||
@GetMapping("/issues/{issueId}/options") | ||
public ApiResponse<IssueOptionResponseDto> getIssueOptions(@PathVariable Long issueId) { | ||
IssueOptionResponseDto issueOptionResponseDto = issueService.getIssueOptions(issueId); | ||
return ApiResponse.success(SUCCESS.getStatus(), issueOptionResponseDto); | ||
} | ||
|
||
@PatchMapping("/issues/status") | ||
public ApiResponse<String> patchStatus(@RequestBody ModifyIssueStatusRequestDto request) { | ||
issueService.modifyIssueStatus(request); | ||
return ApiResponse.success(SUCCESS.getStatus(), SUCCESS.getMessage()); | ||
} | ||
|
||
@PatchMapping("/issues/{id}/status") | ||
public ApiResponse<String> patchInDetailStatus(@PathVariable Long id, | ||
@RequestBody ModifyIssueStatusRequestDto request) { | ||
issueService.modifyIssueStatusInDetail(id, request); | ||
return ApiResponse.success(SUCCESS.getStatus(), SUCCESS.getMessage()); | ||
} | ||
|
||
@PatchMapping("/issues/{id}/content") | ||
public ApiResponse<ModifyIssueContentResponseDto> patchContent(@PathVariable Long id, | ||
@RequestBody ModifyIssueContentRequestDto request) { | ||
ModifyIssueContentResponseDto response = issueService.modifyIssueContent(id, request); | ||
return ApiResponse.success(SUCCESS.getStatus(), response); | ||
} | ||
|
||
@PatchMapping("/issues/{id}/title") | ||
public ApiResponse<ModifyIssueTitleResponse> patchTitle(@PathVariable Long id, | ||
@Valid @RequestBody ModifyIssueTitleRequest request) { | ||
ModifyIssueTitleResponse response = issueService.modifyIssueTitle(id, request); | ||
return ApiResponse.success(SUCCESS.getStatus(), response); | ||
} | ||
|
||
@DeleteMapping("/issues/{id}") | ||
public ApiResponse<String> deleteIssues(@PathVariable Long id) { | ||
issueService.delete(id); | ||
return ApiResponse.success(SUCCESS.getStatus(), SUCCESS.getMessage()); | ||
} | ||
|
||
@PatchMapping("/issues/{id}/assignees") | ||
public ApiResponse<String> patchAssignees(@PathVariable Long id, @RequestBody ModifyAssigneeRequestDto request) { | ||
issueService.modifyAssignees(id, request); | ||
return ApiResponse.success(SUCCESS.getStatus(), SUCCESS.getMessage()); | ||
} | ||
|
||
@PatchMapping("/issues/{id}/labels") | ||
public ApiResponse<String> patchLabels(@PathVariable Long id, @RequestBody ModifyLabelRequestDto request) { | ||
issueService.modifyLabels(id, request); | ||
return ApiResponse.success(SUCCESS.getStatus(), SUCCESS.getMessage()); | ||
} | ||
|
||
@PatchMapping("/issues/{id}/milestones") | ||
public ApiResponse<String> patchMilestone(@PathVariable Long id, @RequestBody ModifyIssueMilestoneDto request) { | ||
issueService.modifyMilestone(id, request); | ||
return ApiResponse.success(SUCCESS.getStatus(), SUCCESS.getMessage()); | ||
} | ||
|
||
@PostMapping("/upload") | ||
public ApiResponse<IssueFileResponseDto> uploadFile(@RequestPart(value = "file") MultipartFile multipartFile) { | ||
IssueFileResponseDto response = issueService.uploadImg(multipartFile); | ||
return ApiResponse.success(SUCCESS.getStatus(), response); | ||
} | ||
} |
42 changes: 22 additions & 20 deletions
42
be/issue/src/main/java/codesquad/issueTracker/issue/domain/Issue.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 |
---|---|---|
@@ -1,29 +1,31 @@ | ||
package codesquad.issueTracker.issue.domain; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
@Getter | ||
@NoArgsConstructor | ||
public class Issue { | ||
private Long id; | ||
private Long milestoneId; | ||
private Long userId; | ||
private String title; | ||
private String content; | ||
private LocalDateTime createdAt; | ||
private Boolean isClosed; | ||
private Long id; | ||
private Long milestoneId; | ||
private Long userId; | ||
private String title; | ||
private String content; | ||
private LocalDateTime createdAt; | ||
private Boolean isClosed; | ||
|
||
@Builder | ||
public Issue(Long id, Long milestoneId, Long userId, String title, String content, LocalDateTime createdAt, | ||
Boolean isClosed) { | ||
this.id = id; | ||
this.milestoneId = milestoneId; | ||
this.userId = userId; | ||
this.title = title; | ||
this.content = content; | ||
this.createdAt = createdAt; | ||
this.isClosed = isClosed; | ||
} | ||
@Builder | ||
public Issue(Long id, Long milestoneId, Long userId, String title, String content, LocalDateTime createdAt, | ||
Boolean isClosed) { | ||
this.id = id; | ||
this.milestoneId = milestoneId; | ||
this.userId = userId; | ||
this.title = title; | ||
this.content = content; | ||
this.createdAt = createdAt; | ||
this.isClosed = isClosed; | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
be/issue/src/main/java/codesquad/issueTracker/issue/domain/IssueRead.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,37 @@ | ||
package codesquad.issueTracker.issue.domain; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
|
||
import codesquad.issueTracker.label.domain.Label; | ||
import codesquad.issueTracker.milestone.domain.Milestone; | ||
import codesquad.issueTracker.user.domain.User; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@NoArgsConstructor | ||
public class IssueRead { | ||
|
||
private Long id; | ||
private String title; | ||
private Boolean isClosed; | ||
private LocalDateTime createdAt; | ||
private User user; | ||
private Milestone milestone; | ||
private List<Label> labels; | ||
|
||
@Builder | ||
public IssueRead(Long id, String title, Boolean isClosed, LocalDateTime createdAt, User user, Milestone milestone, | ||
List<Label> labels) { | ||
this.id = id; | ||
this.title = title; | ||
this.isClosed = isClosed; | ||
this.createdAt = createdAt; | ||
this.user = user; | ||
this.milestone = milestone; | ||
this.labels = labels; | ||
|
||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
be/issue/src/main/java/codesquad/issueTracker/issue/domain/IssueSearch.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,31 @@ | ||
package codesquad.issueTracker.issue.domain; | ||
|
||
import java.util.List; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@NoArgsConstructor | ||
public class IssueSearch { | ||
|
||
private Boolean isClosed; | ||
private List<Long> assigneeIds; | ||
private List<Long> labelIds; | ||
private Long milestoneId; | ||
private Long userId; | ||
private Long commentAuthorId; | ||
|
||
@Builder | ||
public IssueSearch(Boolean isClosed, List<Long> assigneeIds, List<Long> labelIds, Long milestoneId, Long userId, | ||
Long commentAuthorId) { | ||
this.isClosed = isClosed; | ||
this.assigneeIds = assigneeIds; | ||
this.labelIds = labelIds; | ||
this.milestoneId = milestoneId; | ||
this.userId = userId; | ||
this.commentAuthorId = commentAuthorId; | ||
} | ||
|
||
} |
Oops, something went wrong.