diff --git a/backend/gradle/properties.java b/backend/gradle/properties.java deleted file mode 100644 index 58c0462..0000000 --- a/backend/gradle/properties.java +++ /dev/null @@ -1,2 +0,0 @@ -package gradle;public class properties { -} diff --git a/backend/gradle/wrapper/gradle-wrapper.jar b/backend/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 249e583..0000000 Binary files a/backend/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/backend/gradle/wrapper/gradle-wrapper.properties b/backend/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index 070cb70..0000000 --- a/backend/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,5 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/backend/src/main/java/com/rising/backend/domain/post/controller/PostController.java b/backend/src/main/java/com/rising/backend/domain/post/controller/PostController.java index 8663edd..2f489c9 100644 --- a/backend/src/main/java/com/rising/backend/domain/post/controller/PostController.java +++ b/backend/src/main/java/com/rising/backend/domain/post/controller/PostController.java @@ -2,6 +2,7 @@ import com.rising.backend.domain.post.domain.PostType; import com.rising.backend.domain.post.dto.PostDto; +import com.rising.backend.domain.post.dto.PostDto.PostUpdateRequest; import com.rising.backend.domain.post.service.PostService; import com.rising.backend.domain.user.domain.User; import com.rising.backend.global.annotation.LoginRequired; @@ -84,5 +85,25 @@ public ResponseEntity getPostListByUserId(@PathVariable Long use return ResponseEntity.ok(ResultResponse.of(ResultCode.POSTLIST_FIND_BY_USERID_SUCCESS, postList)); } + @PutMapping("/{postId}") + public ResponseEntity update( + @PathVariable Long postId, + @RequestBody PostUpdateRequest updateRequest) { + postService.updatePost(postId, updateRequest); + return ResponseEntity.ok(ResultResponse.of(ResultCode.POST_UPDATE_SUCCESS)); + + } + + //멘토링 종료 + @PutMapping("/{postId}/solve") + public ResponseEntity solve( + @PathVariable Long postId, + @RequestBody String solvedCode) { + postService.solve(postId, solvedCode); + return ResponseEntity.ok(ResultResponse.of(ResultCode.POST_SOLVED)); + + } + + } diff --git a/backend/src/main/java/com/rising/backend/domain/post/domain/Post.java b/backend/src/main/java/com/rising/backend/domain/post/domain/Post.java index 8d2eb7a..982810e 100644 --- a/backend/src/main/java/com/rising/backend/domain/post/domain/Post.java +++ b/backend/src/main/java/com/rising/backend/domain/post/domain/Post.java @@ -1,8 +1,10 @@ package com.rising.backend.domain.post.domain; +import com.rising.backend.domain.post.dto.PostDto.PostUpdateRequest; import com.rising.backend.domain.user.domain.User; import com.rising.backend.global.domain.BaseEntity; import lombok.*; +import org.hibernate.annotations.ColumnDefault; import org.hibernate.annotations.SQLDelete; import org.hibernate.annotations.Where; @@ -31,18 +33,28 @@ public class Post extends BaseEntity { @NotBlank @Column(length = 100) + @Setter private String title; @NotBlank @Column(columnDefinition = "TEXT") + @Setter private String content; + @Column(length = 255) private String videoUrl; @Column(length = 255) private String sessionUrl; + @ColumnDefault("false") + private boolean isSolved; + + @Column(length = 1000) + @Setter + private String solvedCode; + @NotNull @Enumerated(EnumType.STRING) private PostType postType; @@ -52,10 +64,17 @@ public class Post extends BaseEntity { joinColumns = @JoinColumn(name = "POST_ID"), inverseJoinColumns = @JoinColumn(name = "TAG_ID") ) + + @Setter private List tag = new ArrayList<>(); public void setTags(List tags) { this.tag = tags; } + + public void setSolved() { + this.isSolved = true; + } + } diff --git a/backend/src/main/java/com/rising/backend/domain/post/dto/PostDto.java b/backend/src/main/java/com/rising/backend/domain/post/dto/PostDto.java index be61c54..6dc94d1 100644 --- a/backend/src/main/java/com/rising/backend/domain/post/dto/PostDto.java +++ b/backend/src/main/java/com/rising/backend/domain/post/dto/PostDto.java @@ -30,6 +30,15 @@ public static class PostCreateRequest { private List tags = new ArrayList<>(); } + @AllArgsConstructor(access = AccessLevel.PRIVATE) + @NoArgsConstructor(access = AccessLevel.PRIVATE) + @Getter + public static class PostUpdateRequest { + private String title; + private String content; + private List tags = new ArrayList<>(); + } + @Builder @AllArgsConstructor(access = AccessLevel.PRIVATE) @NoArgsConstructor(access = AccessLevel.PRIVATE) @@ -76,6 +85,10 @@ public static class PostDetailResponse { private LocalDate created_at; + private boolean isSolved; + + private String solvedCode; + private List tags; } diff --git a/backend/src/main/java/com/rising/backend/domain/post/mapper/PostMapper.java b/backend/src/main/java/com/rising/backend/domain/post/mapper/PostMapper.java index 08b4830..9006ff2 100644 --- a/backend/src/main/java/com/rising/backend/domain/post/mapper/PostMapper.java +++ b/backend/src/main/java/com/rising/backend/domain/post/mapper/PostMapper.java @@ -39,7 +39,9 @@ public PostDto.PostDetailResponse toPostDto(Post post, List tags) { .title(post.getTitle()) .content(post.getContent()) .videoUrl(post.getVideoUrl()) - .type(post.getPostType()) + .type(post.getType()) + .isSolved(post.isSolved()) + .solvedCode(post.getSolvedCode()) .tags(tags) .created_at(post.getCreatedAt().toLocalDate()) .build(); diff --git a/backend/src/main/java/com/rising/backend/domain/post/service/PostService.java b/backend/src/main/java/com/rising/backend/domain/post/service/PostService.java index 66c89af..134e198 100644 --- a/backend/src/main/java/com/rising/backend/domain/post/service/PostService.java +++ b/backend/src/main/java/com/rising/backend/domain/post/service/PostService.java @@ -91,4 +91,21 @@ public Tag getTagByContent(String content) { public void deletePostById(Long postId) { postRepository.deleteById(postId); } + + public void updatePost(Long postId, PostDto.PostUpdateRequest updateRequest) { + Post post = findPostById(postId); + + List tags = updateRequest.getTags().stream().map(t -> getTagByContent(t)) + .collect(Collectors.toList()); + + post.setTitle(updateRequest.getTitle()); + post.setContent(updateRequest.getContent()); + post.setTags(tags); + } + + public void solve(Long postId, String solvedCode) { + Post post = findPostById(postId); + post.setSolved(); //멘토링 완료 + post.setSolvedCode(solvedCode); + } } \ No newline at end of file diff --git a/backend/src/main/java/com/rising/backend/global/result/ResultCode.java b/backend/src/main/java/com/rising/backend/global/result/ResultCode.java index 868fc56..41f0f15 100644 --- a/backend/src/main/java/com/rising/backend/global/result/ResultCode.java +++ b/backend/src/main/java/com/rising/backend/global/result/ResultCode.java @@ -16,11 +16,12 @@ public enum ResultCode { //POST POST_CREATE_SUCCESS(201, "게시글 등록 성공"), - + POST_UPDATE_SUCCESS(200, "게시글 수정 성공"), POST_DELETE_SUCCESS(200, "게시글 삭제 성공"), POST_PAGINATION_SUCCESS(200, "게시글 리스트 조회 성공"), POST_FIND_SUCCESS(200, "게시글 id로 단일 게시글 조회 성공"), POSTLIST_FIND_BY_USERID_SUCCESS(200, "유저 id로 게시글 리스트 조회 성공"), + POST_SOLVED(200, "질문 해결"), //SESSION SESSION_GET_SUCCESS(201, "세션 반환 성공"),