Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#522 [feat] MoimController 인가체제 변경 #548

Merged
merged 2 commits into from
Oct 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ public class MoimController implements MoimControllerSwagger {
@UserAuthAnnotation(UserAuthenticationType.WRITER_NAME)
public SuccessResponse<ContentListResponse> getTopicsFromMoim(
@MoimIdPathVariable final Long moimId,
@UserId final Long userId,
@PathVariable("moimId") final String moimUrl
) {
return SuccessResponse.of(SuccessMessage.TOPIC_SEARCH_SUCCESS,
Expand All @@ -85,6 +84,15 @@ public ResponseEntity<SuccessResponse<WriterNameConflictCheckResponse>> checkCon
moimService.checkConflictOfWriterName(moimId, writerName)));
}

/**
* 인가체제 예외 사항 - > user Id를 넘기는게 필요하기 때문에 User Authentication 처리하지 않음
*
* @param moimId
* @param joinRequest
* @param userId
* @param moimUrl
* @return ResponseEntity
*/
@Override
@PostMapping("/{moimId}/user")
public ResponseEntity<SuccessResponse> joinMoim(
Expand All @@ -102,24 +110,24 @@ public ResponseEntity<SuccessResponse> joinMoim(

@Override
@GetMapping("/{moimId}/invite")
@UserAuthAnnotation(UserAuthenticationType.USER)
public ResponseEntity<SuccessResponse<MoimInvitationInfoResponse>> getInvitationInfo(
@MoimIdPathVariable final Long moimId,
@UserId final Long userId,
@PathVariable("moimId") final String moimUrl
) {
return ResponseEntity.ok(SuccessResponse.of(SuccessMessage.MOIM_INVITE_INFO_GET_SUCCESS,
moimService.getMoimInvitationInfo(userId, moimId)));
moimService.getMoimInvitationInfo(moimId, WriterNameContextUtil.getMoimWriterNameMapContext())));
}

@Override
@GetMapping("/{moimId}/authenticate")
@UserAuthAnnotation(UserAuthenticationType.USER)
public SuccessResponse<MoimAuthenticateResponse> getAuthenticationOfMoim(
@MoimIdPathVariable final Long moimId,
@UserId final Long userId,
@PathVariable("moimId") final String moimUrl
) {
return SuccessResponse.of(SuccessMessage.MOIM_AUTHENTICATE_SUCCESS,
moimService.getAuthenticateUserOfMoim(moimId, userId));
moimService.getAuthenticateUserOfMoim(moimId, WriterNameContextUtil.getMoimWriterNameMapContext()));
}


Expand Down Expand Up @@ -187,13 +195,13 @@ public ResponseEntity<SuccessResponse<MoimInfoOwnerResponse>> getMoimInfoForOwne

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

@GetMapping("/best")
Expand All @@ -204,36 +212,36 @@ public ResponseEntity<SuccessResponse<BestMoimListResponse>> getBestMoimAndPostL

@Override
@GetMapping("/{moimId}/temporary")
@UserAuthAnnotation(UserAuthenticationType.WRITER_NAME)
public SuccessResponse<TemporaryPostExistResponse> getTemporaryPost(
@MoimIdPathVariable final Long moimId,
@UserId final Long userId,
@PathVariable("moimId") final String moimUrl
) {
return SuccessResponse.of(SuccessMessage.IS_TEMPORARY_POST_EXIST_GET_SUCCESS,
moimService.getTemporaryPost(moimId, userId));
moimService.getTemporaryPost(moimId, WriterNameContextUtil.getWriterNameContext()));
}


@Override
@GetMapping("/{moimId}/admin/topics")
@UserAuthAnnotation(UserAuthenticationType.OWNER)
public ResponseEntity<SuccessResponse<MoimTopicInfoListResponse>> getMoimTopicList(
@MoimIdPathVariable final Long moimId,
@RequestParam final int page,
@UserId final Long userId,
@PathVariable("moimId") final String moimUrl
) {
return ResponseEntity.ok(SuccessResponse.of(SuccessMessage.MOIM_TOPIC_LIST_GET_SUCCESS, moimService.getMoimTopicList(moimId, userId, page)));
return ResponseEntity.ok(SuccessResponse.of(SuccessMessage.MOIM_TOPIC_LIST_GET_SUCCESS, moimService.getMoimTopicList(moimId, page)));
}

@Override
@PutMapping("/{moimId}/info")
@UserAuthAnnotation(UserAuthenticationType.OWNER)
public ResponseEntity<SuccessResponse> modifyMoimInformation(
@MoimIdPathVariable final Long moimId,
@RequestBody @Valid final MoimInfoModifyRequest request,
@UserId final Long userId,
@PathVariable("moimId") final String moimUrl
) {
moimService.modifyMoimInforation(moimId, userId, request);
moimService.modifyMoimInforation(moimId, request);
return ResponseEntity.ok(SuccessResponse.of(SuccessMessage.MOIM_INFORMATION_PUT_SUCCESS));
}

Expand All @@ -246,6 +254,13 @@ public ResponseEntity<SuccessResponse<MoimNameConflictCheckResponse>> validateMo
moimService.validateMoimName(moimName)));
}

/**
* 모임 생성에는 UserID가 필요하기 때문에 Authentication 적용 X
*
* @param creatRequest
* @param userId
* @return
*/
@PostMapping
@Override
public ResponseEntity<SuccessResponse<AccessTokenDto>> createMoim(
Expand All @@ -265,23 +280,23 @@ public ResponseEntity<SuccessResponse<AccessTokenDto>> createMoim(

@GetMapping("/{moimId}/invitation-code")
@Override
@UserAuthAnnotation(UserAuthenticationType.OWNER)
public ResponseEntity<SuccessResponse<InvitationCodeGetResponse>> getInvitationCode(
@MoimIdPathVariable final Long moimId,
@UserId final Long userId,
@PathVariable("moimId") final String moimUrl
) {
return ResponseEntity.ok(SuccessResponse.of(SuccessMessage.INVITATION_CODE_GET_SUCCESS, moimService.getInvitationCode(moimId, userId)));
return ResponseEntity.ok(SuccessResponse.of(SuccessMessage.INVITATION_CODE_GET_SUCCESS, moimService.getInvitationCode(moimId)));
}

@Override
@GetMapping("/{moimId}/writernames")
@UserAuthAnnotation(UserAuthenticationType.OWNER)
public ResponseEntity<SuccessResponse<MoimWriterNameListGetResponse>> getWriterNameListOfMoim(
@MoimIdPathVariable final Long moimId,
@RequestParam final int page,
@UserId final Long userId,
@PathVariable("moimId") final String moimUrl
) {
return ResponseEntity.ok(SuccessResponse.of(SuccessMessage.MOIM_WRITERNAME_LIST_GET_SUCCESS, moimService.getWriterNameListOfMoim(moimId, userId, page)));
return ResponseEntity.ok(SuccessResponse.of(SuccessMessage.MOIM_WRITERNAME_LIST_GET_SUCCESS, moimService.getWriterNameListOfMoim(moimId, page)));
}

@Override
Expand All @@ -306,12 +321,12 @@ public SuccessResponse<MoimPublicStatusResponse> getPublicStatusOfMoim(

@Override
@DeleteMapping("/{moimId}")
@UserAuthAnnotation(UserAuthenticationType.OWNER)
public ResponseEntity<SuccessResponse> deleteMoim(
@MoimIdPathVariable final Long moimId,
@UserId final Long userId,
@PathVariable("moimId") final String moimUrl
) {
moimService.deleteMoim(moimId, userId);
moimService.deleteMoim(moimId);
return ResponseEntity.ok(SuccessResponse.of(SuccessMessage.MOIM_DELETE_SUCCESS));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ public interface MoimControllerSwagger {
)
SuccessResponse<ContentListResponse> getTopicsFromMoim(
@Parameter(schema = @Schema(implementation = String.class), in = ParameterIn.PATH) final Long moimId,
@Parameter(schema = @Schema(implementation = String.class), in = ParameterIn.PATH) @UserId final Long userId,
@PathVariable("moimId") final String moimUrl
);

Expand All @@ -72,7 +71,6 @@ SuccessResponse<ContentListResponse> getTopicsFromMoim(
)
SuccessResponse getAuthenticationOfMoim(
@Parameter(schema = @Schema(implementation = String.class), in = ParameterIn.PATH) final Long moimId,
@Parameter(schema = @Schema(implementation = String.class), in = ParameterIn.PATH) @UserId final Long userId,
@PathVariable("moimId") final String moimUrl
);

Expand Down Expand Up @@ -173,7 +171,6 @@ ResponseEntity<SuccessResponse<TopicListResponse>> getTopicList(
)
SuccessResponse<TemporaryPostExistResponse> getTemporaryPost(
@Parameter(schema = @Schema(implementation = String.class), in = ParameterIn.PATH) final Long moimId,
@Parameter(schema = @Schema(implementation = String.class), in = ParameterIn.PATH) @UserId final Long userId,
@PathVariable("moimId") final String moimUrl
);

Expand All @@ -189,7 +186,6 @@ SuccessResponse<TemporaryPostExistResponse> getTemporaryPost(
)
ResponseEntity<SuccessResponse<MoimInvitationInfoResponse>> getInvitationInfo(
@Parameter(schema = @Schema(implementation = String.class), in = ParameterIn.PATH) final Long moimId,
@Parameter(schema = @Schema(implementation = String.class), in = ParameterIn.PATH) @UserId final Long userId,
@PathVariable("moimId") final String moimUrl
);

Expand Down Expand Up @@ -243,7 +239,6 @@ ResponseEntity<SuccessResponse> joinMoim(
ResponseEntity<SuccessResponse<MoimTopicInfoListResponse>> getMoimTopicList(
@Parameter(schema = @Schema(implementation = String.class), in = ParameterIn.PATH) final Long moimId,
final int page,
@Parameter(schema = @Schema(implementation = String.class), in = ParameterIn.PATH) final @UserId Long userId,
@PathVariable("moimId") final String moimUrl
);

Expand All @@ -262,7 +257,6 @@ ResponseEntity<SuccessResponse<MoimTopicInfoListResponse>> getMoimTopicList(
ResponseEntity<SuccessResponse> modifyMoimInformation(
@Parameter(schema = @Schema(implementation = String.class), in = ParameterIn.PATH) final Long moimId,
@RequestBody final MoimInfoModifyRequest request,
@Parameter(schema = @Schema(implementation = String.class), in = ParameterIn.PATH) final @UserId Long userId,
@PathVariable("moimId") final String moimUrl
);

Expand Down Expand Up @@ -293,7 +287,6 @@ ResponseEntity<SuccessResponse<MoimNameConflictCheckResponse>> validateMoimName(
)
ResponseEntity<SuccessResponse<InvitationCodeGetResponse>> getInvitationCode(
@MoimIdPathVariable final Long moimId,
@Parameter(schema = @Schema(implementation = String.class), in = ParameterIn.PATH) final @UserId Long userId,
@PathVariable("moimId") final String moimUrl
);

Expand Down Expand Up @@ -336,7 +329,6 @@ ResponseEntity<SuccessResponse<AccessTokenDto>> createMoim(
ResponseEntity<SuccessResponse> createTopicOfMoim(
@Parameter(schema = @Schema(implementation = String.class), in = ParameterIn.PATH) final Long moimId,
@RequestBody final TopicCreateRequest createRequest,
@Parameter(schema = @Schema(implementation = String.class), in = ParameterIn.PATH) final @UserId Long userId,
@PathVariable("moimId") final String moimUrl
);

Expand Down Expand Up @@ -379,7 +371,6 @@ ResponseEntity<SuccessResponse<MoimInfoOwnerResponse>> getMoimInfoForOwner(
ResponseEntity<SuccessResponse<MoimWriterNameListGetResponse>> getWriterNameListOfMoim(
@Parameter(schema = @Schema(implementation = String.class), in = ParameterIn.PATH) final Long moimId,
@RequestParam final int page,
@Parameter(schema = @Schema(implementation = String.class), in = ParameterIn.PATH) final @UserId Long userId,
@PathVariable("moimId") final String moimUrl
);

Expand Down Expand Up @@ -426,7 +417,6 @@ SuccessResponse getPublicStatusOfMoim(
)
ResponseEntity<SuccessResponse> deleteMoim(
@Parameter(schema = @Schema(implementation = String.class), in = ParameterIn.PATH) final Long moimId,
@Parameter(schema = @Schema(implementation = String.class), in = ParameterIn.PATH) @UserId final Long userId,
@PathVariable("moimId") final String moimUrl
);

Expand Down
Loading
Loading