Skip to content

Commit

Permalink
codesquad-issue-team-05#80 feat : 이슈 milestone 수정 api 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
DOEKYONG committed Aug 14, 2023
1 parent eae871b commit b7076e3
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
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;
Expand Down Expand Up @@ -80,8 +81,14 @@ public ApiResponse<String> patchAssignees(@PathVariable Long id, @RequestBody Mo
}

@PatchMapping("/issues/{id}/labels")
public ApiResponse<String> patchLabel(@PathVariable Long id, @RequestBody ModifyLabelRequestDto request) {
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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
@Getter
@AllArgsConstructor
public class ModifyIssueContentResponseDto {
String modifiedContent;
private String modifiedContent;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package codesquad.issueTracker.issue.dto;

import lombok.Getter;

@Getter
public class ModifyIssueMilestoneDto {
private Long milestone;
}
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,13 @@ public Long resetAssignees(Long issueId) {
jdbcTemplate.update(sql, parameterSource);
return issueId;
}

public Long updateMilestone(Long issueId, Long milestoneId) {
String sql = "UPDATE issues SET milestone_id = :milestoneId WHERE id = :issueId ";
SqlParameterSource parameterSource = new MapSqlParameterSource()
.addValue("issueId", issueId)
.addValue("milestoneId", milestoneId);
jdbcTemplate.update(sql, parameterSource);
return issueId;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
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;
Expand Down Expand Up @@ -166,4 +167,14 @@ public Long modifyLabels(Long id, ModifyLabelRequestDto request) {
labelService.resetLabels(id);
return id;
}

@Transactional
public Long modifyMilestone(Long id, ModifyIssueMilestoneDto request) {
validateExistIssue(id);
Long milestoneId = request.getMilestone();
if (milestoneId != null) {
milestoneService.isExistMilestone(milestoneId);
}
return issueRepository.updateMilestone(id, milestoneId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,5 @@ public Long insertIssuesLabels(Long issueId, Long labelId) {
jdbcTemplate.update(sql, parameters, keyHolder);
return keyHolder.getKey().longValue();
}

}

0 comments on commit b7076e3

Please sign in to comment.