Skip to content

Commit

Permalink
✨ [#148] feature: 커밋
Browse files Browse the repository at this point in the history
  • Loading branch information
strongmhk committed Aug 22, 2024
1 parent d0ce294 commit 34ca10b
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
public interface CommunityPostCommandService {

CommnuityPost uploadPost(Long userId, CommunityPostRequestDTO.UploadPostRequestDTO request);
CommnuityPost editPost(Long userId, Long postId, CommunityPostRequestDTO.EditPostRequestDTO request);
CommunityComment writeCommentOnCommunityPost(Long userId, Long postId, Long parentCommentId, CommunityPostRequestDTO.WriteCommentRequestDTO request);
void hardDeleteComment(Long userId, Long commentId);
void hardDeleteCommunityPost(Long userId, Long postId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import gaji.service.domain.common.service.CategoryService;
import gaji.service.domain.common.service.HashtagService;
import gaji.service.domain.enums.CategoryEnum;
import gaji.service.domain.enums.PostTypeEnum;
import gaji.service.domain.post.converter.CommunityPostConverter;
import gaji.service.domain.post.entity.CommnuityPost;
import gaji.service.domain.post.entity.CommunityComment;
Expand Down Expand Up @@ -53,7 +54,7 @@ public CommnuityPost uploadPost(Long userId, CommunityPostRequestDTO.UploadPostR
List<String> hashtagStringList = request.getHashtagList();
List<Hashtag> hashtagEntityList = hashtagService.createHashtagEntityList(hashtagStringList);

List<SelectHashtag> selectHashtagList = HashtagConverter.toSelectHashtagList(hashtagEntityList, post.getId(), request.getType());
List<SelectHashtag> selectHashtagList = HashtagConverter.toSelectHashtagList(hashtagEntityList, post.getId(), PostTypeEnum.from(request.getType()));
hashtagService.saveAllSelectHashtag(selectHashtagList);
}

Expand All @@ -70,6 +71,19 @@ public CommnuityPost uploadPost(Long userId, CommunityPostRequestDTO.UploadPostR
return newPost;
}

@Override
public CommnuityPost editPost(Long userId, Long postId, CommunityPostRequestDTO.EditPostRequestDTO request) {
// 조회
CommnuityPost findPost = communityPostQueryService.findPostByPostId(postId);

// 작성자 검증
communityPostQueryService.validPostWriter(userId, findPost);



return null;
}

@Override
public CommunityComment writeCommentOnCommunityPost(Long userId, Long postId, Long parentCommentId, CommunityPostRequestDTO.WriteCommentRequestDTO request) {
User findUser = userQueryService.findUserById(userId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,21 @@ public class CommunityPostRestController {

@PostMapping
@Operation(summary = "커뮤니티 게시글 업로드 API", description = "커뮤니티의 게시글을 업로드하는 API입니다. 게시글 유형과 제목, 본문 내용을 검증합니다.")
public BaseResponse<CommunityPostResponseDTO.UploadPostResponseDTO> uploadPost(@RequestHeader("Authorization") String authorizationHeader,
@RequestBody @Valid CommunityPostRequestDTO.UploadPostRequestDTO request) {
public BaseResponse<CommunityPostResponseDTO.PostIdResponseDTO> uploadPost(@RequestHeader("Authorization") String authorizationHeader,
@RequestBody @Valid CommunityPostRequestDTO.UploadPostRequestDTO request) {
Long userId = tokenProviderService.getUserIdFromToken(authorizationHeader);
CommnuityPost newPost = communityPostCommandService.uploadPost(userId, request);
return BaseResponse.onSuccess(CommunityPostConverter.toUploadPostResponseDTO(newPost));
return BaseResponse.onSuccess(CommunityPostConverter.toPostIdResponseDTO(newPost));
}

@PutMapping("/{postId}")
@Operation(summary = "커뮤니티 게시글 수정 API", description = "커뮤니티 게시글을 수정 API입니다.")
public BaseResponse<CommunityPostResponseDTO.PostIdResponseDTO> editPost(@RequestHeader("Authorization") String authorizationHeader,
@RequestBody @Valid CommunityPostRequestDTO.EditPostRequestDTO request,
@Min(value = 1, message = "postId는 1 이상 이어야 합니다.") @PathVariable Long postId) {
Long userId = tokenProviderService.getUserIdFromToken(authorizationHeader);
CommnuityPost editedCommnuityPost = communityPostCommandService.editPost(userId, postId, request);
return BaseResponse.onSuccess(CommunityPostConverter.toPostIdResponseDTO(editedCommnuityPost));
}

@DeleteMapping("/{postId}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static class UploadPostRequestDTO {

@Schema(description = "게시글 유형(프로젝트 모집, 질문, 블로그)")
@ExistPostType
private final PostTypeEnum type;
private final String type;

@Schema(description = "해시태그 리스트")
@CheckHashtagBlank
Expand All @@ -44,6 +44,25 @@ public static class UploadPostRequestDTO {
private final String category;
}

@Schema(description = "커뮤니티 게시글 수정 DTO")
@Getter
public static class EditPostRequestDTO {
@Schema(description = "게시글 제목")
private String title;

@Schema(description = "게시글 본문")
private String body;

@Schema(description = "카테고리")
@ExistsCategory
private String category;

@Schema(description = "해시태그 리스트")
@CheckHashtagBlank
@CheckHashtagLength
private final List<String> hashtagList = new ArrayList<>();
}

@Schema(description = "커뮤니티 게시글 댓글 작성 DTO")
@Getter
@RequiredArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class CommunityPostResponseDTO {
@Getter
@NoArgsConstructor
@AllArgsConstructor
public static class UploadPostResponseDTO {
public static class PostIdResponseDTO {
Long postId;
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/application-dev.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
server:
port: 8000
port: 8080

spring:
application:
Expand Down

0 comments on commit 34ca10b

Please sign in to comment.