Skip to content

Commit

Permalink
[BE/#34] Feat : 이슈 마일스톤 추가/수정 API 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
hanurii committed Jun 24, 2020
1 parent 6d1fd73 commit 5027c43
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package com.codesquad.issuetracker.hamill.controller;

import com.codesquad.issuetracker.hamill.dto.request.NewIssueDto;
import com.codesquad.issuetracker.hamill.dto.request.UpdateAttachedLabelsDto;
import com.codesquad.issuetracker.hamill.dto.request.UpdateStateOfIssueDto;
import com.codesquad.issuetracker.hamill.dto.request.UpdateTitleDto;
import com.codesquad.issuetracker.hamill.dto.request.*;
import com.codesquad.issuetracker.hamill.dto.response.ApiResponse;
import com.codesquad.issuetracker.hamill.dto.response.IssueDto;
import com.codesquad.issuetracker.hamill.dto.response.ListOfIssuesDto;
import com.codesquad.issuetracker.hamill.service.IssueService_Hamill;
import com.codesquad.issuetracker.hamill.service.LabelService_Hamill;
import com.codesquad.issuetracker.hamill.service.MilestoneService_Hamill;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
Expand Down Expand Up @@ -65,10 +63,20 @@ public ResponseEntity<ApiResponse<?>> updateStatusOfIssue(@RequestBody UpdateSta
return new ResponseEntity<>(ApiResponse.OK("SUCCESS"), HttpStatus.OK);
}

// 이슈에 달려있는 label 추가, 삭제
@PutMapping("/{issueId}/labels")
public ResponseEntity<ApiResponse<?>> updateAttachedLabels(@PathVariable Long issueId, @RequestBody UpdateAttachedLabelsDto updateAttachedLabelsDto) {
labelService_hamill.updateAttachedLabels(issueId, updateAttachedLabelsDto);

return new ResponseEntity<>(ApiResponse.OK("SUCCESS"), HttpStatus.OK);
}

// 이슈에 달려있는 milestone 추가, 삭제
@PatchMapping("/{issueId}/milestone")
public ResponseEntity<ApiResponse<?>> updateAllocatedAssignees(@PathVariable Long issueId,
@RequestBody UpdateAllocatedAssigneesDto updateAllocatedAssigneesDto) {
issueService_Hamill.updateAllocatedAssignees(issueId, updateAllocatedAssigneesDto);

return new ResponseEntity<>(ApiResponse.OK("SUCCESS"), HttpStatus.OK);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ public void updateStateOfIssue(boolean isOpened, Long issueId) {
jdbcTemplate.update(sql, isOpened, issueId);
}

public void updateAllocatedAssignees(Long issueId, Integer milestoneId) {
String sql = "UPDATE issue SET milestone_id = ? WHERE id = ?";
jdbcTemplate.update(sql, milestoneId, issueId);
}

public void saveNewIssueHasLabel(Long labelId, Long issueId) {
logger.info("##### labelId: {}", labelId);
logger.info("##### issueId: {}", issueId);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.codesquad.issuetracker.hamill.dto.request;

public class UpdateAllocatedAssigneesDto {

private Long userId;

private Integer milestoneId;

private UpdateAllocatedAssigneesDto(Long userId, Integer milestoneId) {
this.userId = userId;
this.milestoneId = milestoneId;
}

public static UpdateAllocatedAssigneesDto of(Long userId, Integer milestoneId) {
return new UpdateAllocatedAssigneesDto(userId, milestoneId);
}

public Long getUserId() {
return userId;
}

public Integer getMilestoneId() {
return milestoneId;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.codesquad.issuetracker.hamill.domain.Milestone;
import com.codesquad.issuetracker.hamill.domain.User;
import com.codesquad.issuetracker.hamill.dto.request.NewIssueDto;
import com.codesquad.issuetracker.hamill.dto.request.UpdateAllocatedAssigneesDto;
import com.codesquad.issuetracker.hamill.dto.request.UpdateStateOfIssueDto;
import com.codesquad.issuetracker.hamill.dto.request.UpdateTitleDto;
import com.codesquad.issuetracker.hamill.dto.response.IssueDto;
Expand Down Expand Up @@ -111,6 +112,11 @@ public void updateStateOfIssue(UpdateStateOfIssueDto updateStateOfIssueDto) {
}
}

public void updateAllocatedAssignees(Long issueId, UpdateAllocatedAssigneesDto updateAllocatedAssigneesDto) {

issueDao_Hamill.updateAllocatedAssignees(issueId, updateAllocatedAssigneesDto.getMilestoneId());
}



// public IssuesDto findIssueByIssueId(Long issueId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,4 @@ public MilestoneInformation findMilestoneInformation() {
public Milestone findMilestoneByMilestoneId(Integer milestoneId) {
return milestoneDao_hamill.findMilestoneByMilestoneId(milestoneId);
}

}

0 comments on commit 5027c43

Please sign in to comment.