diff --git a/be/issue/src/main/java/codesquad/issueTracker/issue/controller/IssueController.java b/be/issue/src/main/java/codesquad/issueTracker/issue/controller/IssueController.java index 709f1126c..6a80fc415 100644 --- a/be/issue/src/main/java/codesquad/issueTracker/issue/controller/IssueController.java +++ b/be/issue/src/main/java/codesquad/issueTracker/issue/controller/IssueController.java @@ -14,6 +14,8 @@ import codesquad.issueTracker.global.common.ApiResponse; import codesquad.issueTracker.issue.dto.IssueWriteRequestDto; +import codesquad.issueTracker.issue.dto.ModifyIssueContentRequestDto; +import codesquad.issueTracker.issue.dto.ModifyIssueContentResponseDto; import codesquad.issueTracker.issue.dto.ModifyIssueStatusRequestDto; import codesquad.issueTracker.issue.service.IssueService; import lombok.RequiredArgsConstructor; @@ -46,4 +48,10 @@ public ApiResponse patchInDetailStatus(@PathVariable Long id, return ApiResponse.success(SUCCESS.getStatus(), SUCCESS.getMessage()); } + @PatchMapping("/issues/{id}/content") + public ApiResponse patchContent(@PathVariable Long id, + @RequestBody ModifyIssueContentRequestDto request) { + ModifyIssueContentResponseDto response = issueService.modifyIssueContent(id, request); + return ApiResponse.success(SUCCESS.getStatus(), response); + } } diff --git a/be/issue/src/main/java/codesquad/issueTracker/issue/dto/ModifyIssueContentRequestDto.java b/be/issue/src/main/java/codesquad/issueTracker/issue/dto/ModifyIssueContentRequestDto.java new file mode 100644 index 000000000..13a4c0d1f --- /dev/null +++ b/be/issue/src/main/java/codesquad/issueTracker/issue/dto/ModifyIssueContentRequestDto.java @@ -0,0 +1,12 @@ +package codesquad.issueTracker.issue.dto; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@AllArgsConstructor +@NoArgsConstructor +public class ModifyIssueContentRequestDto { + private String content; +} diff --git a/be/issue/src/main/java/codesquad/issueTracker/issue/dto/ModifyIssueContentResponseDto.java b/be/issue/src/main/java/codesquad/issueTracker/issue/dto/ModifyIssueContentResponseDto.java new file mode 100644 index 000000000..3d30c762a --- /dev/null +++ b/be/issue/src/main/java/codesquad/issueTracker/issue/dto/ModifyIssueContentResponseDto.java @@ -0,0 +1,10 @@ +package codesquad.issueTracker.issue.dto; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public class ModifyIssueContentResponseDto { + String modifiedContent; +} diff --git a/be/issue/src/main/java/codesquad/issueTracker/issue/repository/IssueRepository.java b/be/issue/src/main/java/codesquad/issueTracker/issue/repository/IssueRepository.java index f93feec47..dbf694a44 100644 --- a/be/issue/src/main/java/codesquad/issueTracker/issue/repository/IssueRepository.java +++ b/be/issue/src/main/java/codesquad/issueTracker/issue/repository/IssueRepository.java @@ -82,4 +82,13 @@ public Long modifyStatus(Long issueId, Boolean status) { .isClosed(rs.getBoolean("is_closed")) .build(); + public Long updateContent(Long id, String modifiedContent) { + String sql = "UPDATE issues SET content = :modifiedContent WHERE Id = :id"; + SqlParameterSource parameterSource = new MapSqlParameterSource() + .addValue("id", id) + .addValue("modifiedContent", modifiedContent); + jdbcTemplate.update(sql, parameterSource); + return id; + + } } diff --git a/be/issue/src/main/java/codesquad/issueTracker/issue/service/IssueService.java b/be/issue/src/main/java/codesquad/issueTracker/issue/service/IssueService.java index 9722616e8..27b60d39e 100644 --- a/be/issue/src/main/java/codesquad/issueTracker/issue/service/IssueService.java +++ b/be/issue/src/main/java/codesquad/issueTracker/issue/service/IssueService.java @@ -14,6 +14,8 @@ import codesquad.issueTracker.global.exception.ErrorCode; import codesquad.issueTracker.issue.domain.Issue; import codesquad.issueTracker.issue.dto.IssueWriteRequestDto; +import codesquad.issueTracker.issue.dto.ModifyIssueContentRequestDto; +import codesquad.issueTracker.issue.dto.ModifyIssueContentResponseDto; import codesquad.issueTracker.issue.dto.ModifyIssueStatusRequestDto; import codesquad.issueTracker.issue.repository.IssueRepository; import codesquad.issueTracker.label.service.LabelService; @@ -96,4 +98,11 @@ public Long modifyIssueStatusInDetail(Long id, ModifyIssueStatusRequestDto reque private Issue validateExistIssue(Long issuesIds) { return issueRepository.findById(issuesIds).orElseThrow(() -> new CustomException(ErrorCode.NOT_FOUND_ISSUES)); } + + @Transactional + public ModifyIssueContentResponseDto modifyIssueContent(Long id, ModifyIssueContentRequestDto request) { + String modifiedContent = request.getContent(); + issueRepository.updateContent(id, modifiedContent); + return new ModifyIssueContentResponseDto(modifiedContent); + } }