Skip to content

Commit

Permalink
#283 [fix] conflict 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
parkheeddong committed Apr 16, 2024
2 parents f506a96 + 6d13c21 commit b1fd52b
Show file tree
Hide file tree
Showing 37 changed files with 756 additions and 100 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,27 @@

import com.mile.authentication.PrincipalHandler;
import com.mile.comment.service.CommentService;
import com.mile.commentreply.service.dto.ReplyCreateRequest;
import com.mile.dto.SuccessResponse;
import com.mile.exception.message.SuccessMessage;
import com.mile.resolver.comment.CommentIdPathVariable;
import com.mile.resolver.reply.ReplyIdPathVariable;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
@RequestMapping("/api/comment")
@RequiredArgsConstructor
public class CommentController implements CommentControllerSwagger{
public class CommentController implements CommentControllerSwagger {

private final CommentService commentService;
private final PrincipalHandler principalHandler;
Expand All @@ -30,4 +36,26 @@ public ResponseEntity<SuccessResponse> deleteComment(
commentService.deleteComment(commentId, principalHandler.getUserIdFromPrincipal());
return ResponseEntity.status(HttpStatus.OK).body(SuccessResponse.of(SuccessMessage.COMMENT_DELETE_SUCCESS));
}

@PostMapping("/{commentId}")
public ResponseEntity<SuccessResponse> createCommentReply(
@CommentIdPathVariable final Long commentId,
@RequestBody final ReplyCreateRequest createRequest,
@PathVariable("commentId") final String commentUrl
) {
return ResponseEntity.status(HttpStatus.CREATED).header("Location",
commentService.createCommentReply(
principalHandler.getUserIdFromPrincipal(),
commentId, createRequest
)).body(SuccessResponse.of(SuccessMessage.REPLY_CREATE_SUCCESS));
}

@DeleteMapping("/reply/{replyId}")
public ResponseEntity<SuccessResponse> deleteCommentReply(
@ReplyIdPathVariable final Long replyId,
@PathVariable("replyId") final String replyUrl
) {
commentService.deleteReply(principalHandler.getUserIdFromPrincipal(), replyId);
return ResponseEntity.ok(SuccessResponse.of(SuccessMessage.REPLY_DELETE_SUCCESS));
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.mile.controller.comment;

import com.mile.commentreply.service.dto.ReplyCreateRequest;
import com.mile.dto.ErrorResponse;
import com.mile.dto.SuccessResponse;
import io.swagger.v3.oas.annotations.Operation;
Expand All @@ -13,9 +14,7 @@
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;

import java.security.Principal;

@Tag(name = "Comment", description = "댓글 관련 API - 현재는 댓글 삭제만 API 해당")
@Tag(name = "Comment", description = "댓글 관련 API")
public interface CommentControllerSwagger {

@Operation(description = "댓글 삭제 API")
Expand All @@ -34,4 +33,40 @@ ResponseEntity<SuccessResponse> deleteComment(
@Parameter(schema = @Schema(implementation = String.class), in = ParameterIn.PATH) final Long commentId,
@PathVariable("commentId") final String commentUrl
);


@Operation(description = "대댓글 등록 API")
@ApiResponses(
value = {
@ApiResponse(responseCode = "200", description = "댓글 등록이 완료되었습니다."),
@ApiResponse(responseCode = "403", description = "해당 사용자는 댓글에 접근 권한이 없습니다.",
content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
@ApiResponse(responseCode = "404", description = "해당 댓글이 존재하지 않습니다.",
content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
@ApiResponse(responseCode = "500", description = "서버 내부 오류입니다.",
content = @Content(schema = @Schema(implementation = ErrorResponse.class)))
}
)
ResponseEntity<SuccessResponse> createCommentReply(
@Parameter(schema = @Schema(implementation = String.class), in = ParameterIn.PATH) final Long commentId,
final ReplyCreateRequest createRequest,
@PathVariable("commentId") final String commentUrl
);

@Operation(description = "대댓글 삭제 API")
@ApiResponses(
value = {
@ApiResponse(responseCode = "200", description = "대댓글 삭제가 완료되었습니다."),
@ApiResponse(responseCode = "403", description = "해당 사용자는 댓글에 접근 권한이 없습니다.",
content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
@ApiResponse(responseCode = "404", description = "해당 댓글이 존재하지 않습니다.",
content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
@ApiResponse(responseCode = "500", description = "서버 내부 오류입니다.",
content = @Content(schema = @Schema(implementation = ErrorResponse.class)))
}
)
ResponseEntity<SuccessResponse> deleteCommentReply(
@Parameter(schema = @Schema(implementation = String.class), in = ParameterIn.PATH) final Long replyId,
@PathVariable("replyId") final String replyUrl
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,21 @@
import com.mile.moim.service.dto.MoimCreateRequest;
import com.mile.moim.service.dto.MoimCreateResponse;
import com.mile.moim.service.dto.MoimCuriousPostListResponse;
import com.mile.moim.service.dto.MoimInfoModifyRequest;
import com.mile.moim.service.dto.MoimInfoOwnerResponse;
import com.mile.moim.service.dto.MoimInfoResponse;
import com.mile.moim.service.dto.MoimTopicInfoListResponse;
import com.mile.moim.service.dto.MoimNameConflictCheckResponse;
import com.mile.moim.service.dto.MoimInvitationInfoResponse;
import com.mile.moim.service.dto.MoimInfoModifyRequest;
import com.mile.moim.service.dto.MoimListOfUserResponse;
import com.mile.moim.service.dto.MoimNameConflictCheckResponse;
import com.mile.moim.service.dto.MoimTopicInfoListResponse;
import com.mile.moim.service.dto.MoimTopicResponse;
import com.mile.moim.service.dto.MoimWriterNameListGetResponse;
import com.mile.moim.service.dto.PopularWriterListResponse;
import com.mile.moim.service.dto.TemporaryPostExistResponse;
import com.mile.moim.service.dto.TopicCreateRequest;
import com.mile.moim.service.dto.TopicListResponse;
import com.mile.moim.service.dto.WriterNameConflictCheckResponse;
import com.mile.moim.service.dto.WriterMemberJoinRequest;
import com.mile.moim.service.dto.WriterNameConflictCheckResponse;
import com.mile.resolver.moim.MoimIdPathVariable;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
Expand Down Expand Up @@ -60,7 +61,7 @@ public SuccessResponse<ContentListResponse> getTopicsFromMoim(


@Override
@GetMapping("/{moimId}/")
@GetMapping("/{moimId}/name/validation")
public ResponseEntity<SuccessResponse<WriterNameConflictCheckResponse>> checkConflictOfWriterName(
@MoimIdPathVariable final Long moimId,
@RequestParam final String writerName,
Expand Down Expand Up @@ -89,7 +90,7 @@ public ResponseEntity<SuccessResponse<MoimInvitationInfoResponse>> getInvitation
@PathVariable("moimId") final String moimUrl
) {
return ResponseEntity.ok(SuccessResponse.of(SuccessMessage.MOIM_INVITE_INFO_GET_SUCCESS,
moimService.getMoimInvitationInfo(moimId)));
moimService.getMoimInvitationInfo(principalHandler.getUserIdFromPrincipal(), moimId)));
}

@Override
Expand Down Expand Up @@ -161,14 +162,15 @@ public ResponseEntity<SuccessResponse<MoimInfoOwnerResponse>> getMoimInfoForOwne
) {
return ResponseEntity.ok(SuccessResponse.of(SuccessMessage.MOIM_INFO_FOR_OWNER_GET_SUCCESS, moimService.getMoimInfoForOwner(moimId, principalHandler.getUserIdFromPrincipal())));
}

@Override
@PostMapping("/{moimId}/topic")
public ResponseEntity<SuccessResponse> createTopicOfMoim(
@MoimIdPathVariable final Long moimId,
@RequestBody final TopicCreateRequest createRequest,
@PathVariable("moimId") final String moimUrl
) {
return ResponseEntity.created(URI.create(moimService.createTopic(moimId,principalHandler.getUserIdFromPrincipal(), createRequest))).body(SuccessResponse.of(SuccessMessage.TOPIC_CREATE_SUCCESS));
return ResponseEntity.created(URI.create(moimService.createTopic(moimId, principalHandler.getUserIdFromPrincipal(), createRequest))).body(SuccessResponse.of(SuccessMessage.TOPIC_CREATE_SUCCESS));
}

@GetMapping("/best")
Expand Down Expand Up @@ -243,5 +245,14 @@ public ResponseEntity<SuccessResponse<MoimWriterNameListGetResponse>> getWriterN
@PathVariable("moimId") final String moimUrl
) {
return ResponseEntity.ok(SuccessResponse.of(SuccessMessage.MOIM_WRITERNAME_LIST_GET_SUCCESS, moimService.getWriterNameListOfMoim(moimId, principalHandler.getUserIdFromPrincipal(), page)));
};
}

;

@Override
@GetMapping("/moimList")
public ResponseEntity<SuccessResponse<MoimListOfUserResponse>> getMoimListOfUser() {
return ResponseEntity.ok(SuccessResponse.of(SuccessMessage.MOIM_LIST_OF_USER_GET_SUCCESS, moimService.getMoimOfUserList(principalHandler.getUserIdFromPrincipal())));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@
import com.mile.moim.service.dto.MoimCreateRequest;
import com.mile.moim.service.dto.MoimCreateResponse;
import com.mile.moim.service.dto.MoimCuriousPostListResponse;
import com.mile.moim.service.dto.MoimInfoModifyRequest;
import com.mile.moim.service.dto.MoimInfoOwnerResponse;
import com.mile.moim.service.dto.MoimInfoResponse;
import com.mile.moim.service.dto.MoimTopicInfoListResponse;
import com.mile.moim.service.dto.MoimNameConflictCheckResponse;
import com.mile.moim.service.dto.MoimInvitationInfoResponse;
import com.mile.moim.service.dto.MoimListOfUserResponse;
import com.mile.moim.service.dto.MoimNameConflictCheckResponse;
import com.mile.moim.service.dto.MoimInfoModifyRequest;
import com.mile.moim.service.dto.MoimTopicInfoListResponse;
import com.mile.moim.service.dto.MoimTopicResponse;
import com.mile.moim.service.dto.MoimWriterNameListGetResponse;
import com.mile.moim.service.dto.PopularWriterListResponse;
import com.mile.moim.service.dto.TemporaryPostExistResponse;
import com.mile.moim.service.dto.TopicCreateRequest;
import com.mile.moim.service.dto.TopicListResponse;
import com.mile.moim.service.dto.PopularWriterListResponse;
import com.mile.moim.service.dto.WriterNameConflictCheckResponse;
import com.mile.moim.service.dto.WriterMemberJoinRequest;
import com.mile.moim.service.dto.WriterNameConflictCheckResponse;
import com.mile.resolver.moim.MoimIdPathVariable;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
Expand Down Expand Up @@ -176,22 +176,26 @@ SuccessResponse<TemporaryPostExistResponse> getTemporaryPost(
@Operation(summary = "초대 링크에서 모임 정보 조회")
@ApiResponses(
value = {
@ApiResponse(responseCode = "200", description = "댓글 조회가 완료되었습니다."),
@ApiResponse(responseCode = "404", description = "해당 글모임이 존재하지 않습니다.\n",
@ApiResponse(responseCode = "200", description = "댓글 조회가 완료되었습니다."),
@ApiResponse(responseCode = "404", description = "해당 글모임이 존재하지 않습니다.\n",
content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
@ApiResponse(responseCode = "500", description = "서버 내부 오류입니다.",
@ApiResponse(responseCode = "500", description = "서버 내부 오류입니다.",
content = @Content(schema = @Schema(implementation = ErrorResponse.class)))
}
)
ResponseEntity<SuccessResponse<MoimInvitationInfoResponse>> getInvitationInfo(
@Parameter(schema = @Schema(implementation = String.class), in = ParameterIn.PATH) final Long moimId,
@PathVariable("moimId") final String moimUrl
);

@Operation(summary = "필명 중복 확인")
@ApiResponses(
value = {
@ApiResponse(responseCode = "200", description = "댓글 중복 여부가 조회되었습니다."),
@ApiResponse(responseCode = "404" , description = "1. 해당 모임은 존재하지 않습니다.\n"),
@ApiResponse(responseCode = "400", description = "사용 불가능한 필명입니다.",
content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
@ApiResponse(responseCode = "404", description = "1. 해당 모임은 존재하지 않습니다.\n",
content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
@ApiResponse(responseCode = "500", description = "서버 내부 오류입니다.",
content = @Content(schema = @Schema(implementation = ErrorResponse.class)))
}
Expand All @@ -201,14 +205,14 @@ ResponseEntity<SuccessResponse<WriterNameConflictCheckResponse>> checkConflictOf
final String writerName,
@PathVariable("moimId") final String moimUrl
);

@Operation(summary = "글모임 링크 접속 후 모임원 가입")
@ApiResponses(
value = {
@ApiResponse(responseCode = "201", description = "모임 가입에 완료되었습니다"),
@ApiResponse(responseCode = "400" ,description = "1. 소개 글은 최대 110자 이내로 작성해주세요.\n" +
"2. 필명이 입력되지 않았습니다.\n" +
"3. 필명은 최대 8자 이내로 작성해주세요.\n"),
@ApiResponse(responseCode = "201", description = "모임 가입에 완료되었습니다"),
@ApiResponse(responseCode = "400", description = "1. 소개 글은 최대 110자 이내로 작성해주세요.\n" +
"2. 필명이 입력되지 않았습니다.\n" +
"3. 필명은 최대 8자 이내로 작성해주세요.\n"),
@ApiResponse(responseCode = "404", description = "해당 모임은 존재하지 않습니다."),
@ApiResponse(responseCode = "500", description = "서버 내부 오류입니다.",
content = @Content(schema = @Schema(implementation = ErrorResponse.class)))
Expand Down Expand Up @@ -240,8 +244,8 @@ ResponseEntity<SuccessResponse<MoimTopicInfoListResponse>> getMoimTopicList(
@Operation(summary = "관리자 페이지 모임 정보 수정")
@ApiResponses(
value = {
@ApiResponse(responseCode = "204", description = "모임 정보 수정이 완료되었습니다."),
@ApiResponse(responseCode = "400" ,description = "1. 소개 글은 최대 100자 이내로 작성해주세요.\n" +
@ApiResponse(responseCode = "204", description = "모임 정보 수정이 완료되었습니다."),
@ApiResponse(responseCode = "400", description = "1. 소개 글은 최대 100자 이내로 작성해주세요.\n" +
"2. 글모임 이름은 최대 10 글자 이내로 작성해주세요.\n"),
@ApiResponse(responseCode = "401", description = "로그인 후 진행해주세요."),
@ApiResponse(responseCode = "403", description = "사용자는 해당 모임의 모임장이 아닙니다."),
Expand All @@ -253,13 +257,14 @@ ResponseEntity<SuccessResponse> modifyMoimInformation(
@RequestBody final MoimInfoModifyRequest request,
@PathVariable("moimId") final String moimUrl
);


@Operation(summary = "글모임 이름 중복확인")
@ApiResponses(
value = {
@ApiResponse(responseCode = "200", description = "글모임 이름 중복 확인이 완료되었습니다."),

@ApiResponse(responseCode = "400", description = "사용 불가능한 모임명입니다.",
content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
@ApiResponse(responseCode = "500", description = "서버 내부 오류입니다.",
content = @Content(schema = @Schema(implementation = ErrorResponse.class)))
}
Expand Down Expand Up @@ -287,7 +292,7 @@ ResponseEntity<SuccessResponse<InvitationCodeGetResponse>> getInvitationCode(
@ApiResponses(
value = {
@ApiResponse(responseCode = "201", description = "글감 리스트 조회가 완료되었습니다."),
@ApiResponse(responseCode = "400" ,description = "1. 글모임명은 최대 10글자 이내로 작성해주세요.\n" +
@ApiResponse(responseCode = "400", description = "1. 글모임명은 최대 10글자 이내로 작성해주세요.\n" +
"2. 필명은 최대 8글자 이내로 작성해주세요.\n" +
"3. 글모임장 소개글은 최대 100자 이내로 작성해주세요." +
"4. 글감 소개글은 최대 90자 이내로 작성해주세요."),
Expand All @@ -304,9 +309,9 @@ ResponseEntity<SuccessResponse<MoimCreateResponse>> createMoim(
@ApiResponses(
value = {
@ApiResponse(responseCode = "201", description = "글감 생성이 완료되었습니다."),
@ApiResponse(responseCode = "400",description = "1. 글감은 최대 15자 이내로 작성해주세요.\n"
@ApiResponse(responseCode = "400", description = "1. 글감은 최대 15자 이내로 작성해주세요.\n"
+ "2. 글감 제목이 비어있습니다.\n" + "3. 글감 태그는 최대 5자 이내로 작성해주세요.\n"
+ "4. 글감 태그가 비어있습니다.\n" + "5. 글감 설명은 최대 90자 이내로 작성해주세요."
+ "4. 글감 태그가 비어있습니다.\n" + "5. 글감 설명은 최대 90자 이내로 작성해주세요."
),
@ApiResponse(responseCode = "401", description = "로그인 후 이용해주세요.",
content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
Expand Down Expand Up @@ -364,4 +369,18 @@ ResponseEntity<SuccessResponse<MoimWriterNameListGetResponse>> getWriterNameList
@RequestParam final int page,
@PathVariable("moimId") final String moimUrl
);

@Operation(summary = "유저 글모임 리스트 조회")
@ApiResponses(
value = {
@ApiResponse(responseCode = "200", description = "글모임 리스트 조회가 조회되었습니다.",
content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
@ApiResponse(responseCode = "401", description = "로그인 후 이용해주세요.",
content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
@ApiResponse(responseCode = "500", description = "서버 내부 오류입니다.",
content = @Content(schema = @Schema(implementation = ErrorResponse.class)))
}
)
ResponseEntity<SuccessResponse<MoimListOfUserResponse>> getMoimListOfUser();

}
Loading

0 comments on commit b1fd52b

Please sign in to comment.