Skip to content

Commit

Permalink
#273 [feat] 컨트롤러 로직 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
parkheeddong committed Mar 27, 2024
1 parent 35a7e0a commit f3d177c
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import com.mile.moim.service.dto.BestMoimListResponse;
import com.mile.moim.service.dto.ContentListResponse;
import com.mile.moim.service.dto.MoimAuthenticateResponse;
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.MoimInfoResponse;
import com.mile.moim.service.dto.MoimNameConflictCheckResponse;
Expand Down Expand Up @@ -47,7 +49,8 @@ public SuccessResponse<ContentListResponse> getTopicsFromMoim(
@MoimIdPathVariable final Long moimId,
@PathVariable("moimId") final String moimUrl
) {
return SuccessResponse.of(SuccessMessage.TOPIC_SEARCH_SUCCESS, moimService.getContentsFromMoim(moimId, principalHandler.getUserIdFromPrincipal()));
return SuccessResponse.of(SuccessMessage.TOPIC_SEARCH_SUCCESS,
moimService.getContentsFromMoim(moimId, principalHandler.getUserIdFromPrincipal()));
}


Expand All @@ -58,17 +61,20 @@ public ResponseEntity<SuccessResponse<WriterNameConflictCheckResponse>> checkCon
@RequestParam final String writerName,
@PathVariable("moimId") final String moimUrl
) {
return ResponseEntity.ok(SuccessResponse.of(SuccessMessage.IS_CONFLICT_WRITER_NAME_GET_SUCCESS, moimService.checkConflictOfWriterName(moimId, writerName)));
return ResponseEntity.ok(SuccessResponse.of(SuccessMessage.IS_CONFLICT_WRITER_NAME_GET_SUCCESS,
moimService.checkConflictOfWriterName(moimId, writerName)));
}

@Override
@PostMapping("{moimId}/user")
public ResponseEntity<SuccessResponse> joinMoim(
@MoimIdPathVariable final Long moimId,
@RequestBody final WriterMemberJoinRequest joinRequest,
@PathVariable("moimId") final String moimUrl
) {
return ResponseEntity.created(URI.create(moimService.joinMoim(moimId, principalHandler.getUserIdFromPrincipal(), joinRequest).toString())).body(SuccessResponse.of(SuccessMessage.WRITER_JOIN_SUCCESS));
return ResponseEntity.created(URI.create(
moimService.joinMoim(moimId, principalHandler.getUserIdFromPrincipal(), joinRequest).toString()))
.body(SuccessResponse.of(SuccessMessage.WRITER_JOIN_SUCCESS));
}

@Override
Expand All @@ -77,7 +83,8 @@ public ResponseEntity<SuccessResponse<MoimInvitationInfoResponse>> getInvitation
@MoimIdPathVariable final Long moimId,
@PathVariable("moimId") final String moimUrl
) {
return ResponseEntity.ok(SuccessResponse.of(SuccessMessage.MOIM_INVITE_INFO_GET_SUCCESS, moimService.getMoimInvitationInfo(moimId)));
return ResponseEntity.ok(SuccessResponse.of(SuccessMessage.MOIM_INVITE_INFO_GET_SUCCESS,
moimService.getMoimInvitationInfo(moimId)));
}

@Override
Expand All @@ -86,7 +93,8 @@ public SuccessResponse<MoimAuthenticateResponse> getAuthenticationOfMoim(
@MoimIdPathVariable final Long moimId,
@PathVariable("moimId") final String moimUrl
) {
return SuccessResponse.of(SuccessMessage.MOIM_AUTHENTICATE_SUCCESS, moimService.getAuthenticateUserOfMoim(moimId, principalHandler.getUserIdFromPrincipal()));
return SuccessResponse.of(SuccessMessage.MOIM_AUTHENTICATE_SUCCESS,
moimService.getAuthenticateUserOfMoim(moimId, principalHandler.getUserIdFromPrincipal()));
}

@Override
Expand All @@ -95,7 +103,9 @@ public ResponseEntity<SuccessResponse<PopularWriterListResponse>> getMostCurious
@MoimIdPathVariable final Long moimId,
@PathVariable("moimId") final String moimUrl
) {
return ResponseEntity.status(HttpStatus.OK).body(SuccessResponse.of(SuccessMessage.MOIM_POPULAR_WRITER_SEARCH_SUCCESS, moimService.getMostCuriousWritersOfMoim(moimId)));
return ResponseEntity.status(HttpStatus.OK)
.body(SuccessResponse.of(SuccessMessage.MOIM_POPULAR_WRITER_SEARCH_SUCCESS,
moimService.getMostCuriousWritersOfMoim(moimId)));
}

@Override
Expand Down Expand Up @@ -124,7 +134,8 @@ public ResponseEntity<SuccessResponse<TopicListResponse>> getTopicList(
@MoimIdPathVariable final Long moimId,
@PathVariable("moimId") final String moimUrl
) {
return ResponseEntity.status(HttpStatus.OK).body(SuccessResponse.of(SuccessMessage.TOPIC_LIST_SEARCH_SUCCESS, moimService.getTopicList(moimId)));
return ResponseEntity.status(HttpStatus.OK)
.body(SuccessResponse.of(SuccessMessage.TOPIC_LIST_SEARCH_SUCCESS, moimService.getTopicList(moimId)));
}

@Override
Expand All @@ -133,12 +144,14 @@ public SuccessResponse<MoimCuriousPostListResponse> getMostCuriousPostByMoim(
@MoimIdPathVariable final Long moimId,
@PathVariable("moimId") final String moimUrl
) {
return SuccessResponse.of(SuccessMessage.MOIM_TOP_2_POST_GET_SUCCESS, moimService.getMostCuriousPostFromMoim(moimId));
return SuccessResponse.of(SuccessMessage.MOIM_TOP_2_POST_GET_SUCCESS,
moimService.getMostCuriousPostFromMoim(moimId));
}

@GetMapping("/best")
public ResponseEntity<SuccessResponse<BestMoimListResponse>> getBestMoimAndPostList() {
return ResponseEntity.status(HttpStatus.OK).body(SuccessResponse.of(SuccessMessage.BEST_MOIM_POSTS_GET_SUCCESS, moimService.getBestMoimAndPostList()));
return ResponseEntity.status(HttpStatus.OK).body(SuccessResponse.of(SuccessMessage.BEST_MOIM_POSTS_GET_SUCCESS,
moimService.getBestMoimAndPostList()));
}

@Override
Expand All @@ -147,8 +160,10 @@ public SuccessResponse<TemporaryPostExistResponse> getTemporaryPost(
@MoimIdPathVariable final Long moimId,
@PathVariable("moimId") final String moimUrl
) {
return SuccessResponse.of(SuccessMessage.IS_TEMPORARY_POST_EXIST_GET_SUCCESS, moimService.getTemporaryPost(moimId, principalHandler.getUserIdFromPrincipal()));
return SuccessResponse.of(SuccessMessage.IS_TEMPORARY_POST_EXIST_GET_SUCCESS,
moimService.getTemporaryPost(moimId, principalHandler.getUserIdFromPrincipal()));
}

@Override
@PutMapping("/{moimId}/info")
public ResponseEntity<SuccessResponse> modifyMoimInformation(
Expand All @@ -159,11 +174,21 @@ public ResponseEntity<SuccessResponse> modifyMoimInformation(
moimService.modifyMoimInforation(moimId, principalHandler.getUserIdFromPrincipal(), request);
return ResponseEntity.ok(SuccessResponse.of(SuccessMessage.MOIM_INFORMATION_PUT_SUCCESS));
}

@GetMapping("/name/validation")
@Override
public ResponseEntity<SuccessResponse<MoimNameConflictCheckResponse>> validateMoimName(
@RequestParam final String moimName
) {
return ResponseEntity.ok(SuccessResponse.of(SuccessMessage.IS_CONFLICT_MOIM_NAME_GET_SUCCESS, moimService.validateMoimName(moimName)));
return ResponseEntity.ok(SuccessResponse.of(SuccessMessage.IS_CONFLICT_MOIM_NAME_GET_SUCCESS,
moimService.validateMoimName(moimName)));
}

@PostMapping
@Override
public ResponseEntity<SuccessResponse<MoimCreateResponse>> createMoim(
@RequestBody final MoimCreateRequest creatRequest
) {
return ResponseEntity.ok(SuccessResponse.of(SuccessMessage.MOIM_CREATE_SUCCESS, moimService.createMoim(principalHandler.getUserIdFromPrincipal(), creatRequest)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import com.mile.dto.SuccessResponse;
import com.mile.moim.service.dto.BestMoimListResponse;
import com.mile.moim.service.dto.ContentListResponse;
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.MoimInfoResponse;
import com.mile.moim.service.dto.MoimNameConflictCheckResponse;
Expand Down Expand Up @@ -239,4 +241,20 @@ ResponseEntity<SuccessResponse> modifyMoimInformation(
ResponseEntity<SuccessResponse<MoimNameConflictCheckResponse>> validateMoimName(
@RequestParam final String moimName
);

@Operation(summary = "글모임 생성")
@ApiResponses(
value = {
@ApiResponse(responseCode = "201", description = "글감 리스트 조회가 완료되었습니다."),
@ApiResponse(responseCode = "400" ,description = "1. 글모임명은 최대 10글자 이내로 작성해주세요.\n" +
"2. 필명은 최대 8글자 이내로 작성해주세요.\n" +
"3. 글모임장 소개글은 최대 100자 이내로 작성해주세요." +
"4. 글감 소개글은 최대 90자 이내로 작성해주세요."),
@ApiResponse(responseCode = "500", description = "서버 내부 오류입니다.",
content = @Content(schema = @Schema(implementation = ErrorResponse.class)))
}
)
ResponseEntity<SuccessResponse<MoimCreateResponse>> createMoim(
@RequestBody final MoimCreateRequest creatRequest
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public enum SuccessMessage {
CURIOUS_CREATE_SUCCESS(HttpStatus.CREATED.value(), "궁금해요 생성이 완료되었습니다."),
POST_CREATE_SUCCESS(HttpStatus.OK.value(), "글 생성이 완료되었습니다."),
TEMPORARY_POST_CREATE_SUCCESS(HttpStatus.OK.value(), "임시저장 글 생성이 완료되었습니다."),
MOIM_CREATE_SUCCESS(HttpStatus.OK.value(), "글모임 생성이 완료되었습니다."),
;

final int status;
Expand Down

0 comments on commit f3d177c

Please sign in to comment.