Skip to content

Commit

Permalink
Merge pull request #100 from codesquad-issue-team-05/dev-be/feature/#96
Browse files Browse the repository at this point in the history
[be] 이슈목록 조회 및 필터링
  • Loading branch information
chunghye98 authored Aug 17, 2023
2 parents 25c932a + 5b5514a commit 1d6ffbb
Show file tree
Hide file tree
Showing 19 changed files with 758 additions and 264 deletions.
3 changes: 3 additions & 0 deletions be/issue/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-webflux'
// 파일 업로드
implementation 'org.springframework.cloud:spring-cloud-starter-aws:2.2.6.RELEASE'
// myBatis
implementation 'org.mybatis.spring.boot:mybatis-spring-boot-starter:2.3.1'
testImplementation 'org.mybatis.spring.boot:mybatis-spring-boot-starter-test:2.3.1'

}

Expand Down
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);
}
}
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;
}
}
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;

}
}
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;
}

}
Loading

0 comments on commit 1d6ffbb

Please sign in to comment.