Skip to content

Commit

Permalink
#520 [feat] 관리자페이지 글감 수정 인가체제 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
parkheeddong committed Oct 6, 2024
1 parent 6b35522 commit 0ea0caf
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.mile.controller.topic;

import com.mile.common.auth.annotation.UserAuthAnnotation;
import com.mile.common.auth.annotation.UserAuthenticationType;
import com.mile.common.resolver.user.UserId;
import com.mile.dto.SuccessResponse;
import com.mile.exception.message.SuccessMessage;
Expand Down Expand Up @@ -59,13 +61,14 @@ public ResponseEntity<SuccessResponse> deleteTopic(
}

@PutMapping("/{topicId}")
@UserAuthAnnotation(UserAuthenticationType.OWNER)
public ResponseEntity<SuccessResponse> putTopic(
@RequestBody @Valid final TopicPutRequest topicPutRequest,
@TopicIdPathVariable final Long topicId,
@UserId final Long userId,
@PathVariable("topicId") final String topicUrl
) {
topicService.putTopic(userId, topicId, topicPutRequest);
topicService.putTopic(topicId, topicPutRequest);
return ResponseEntity.ok(SuccessResponse.of(SuccessMessage.TOPIC_PUT_SUCCESS));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ ResponseEntity<SuccessResponse> deleteTopic(
ResponseEntity<SuccessResponse> putTopic(
@RequestBody final TopicPutRequest topicPutRequest,
@Parameter(schema = @Schema(implementation = String.class), in = ParameterIn.PATH) final Long topicId,
@Parameter(schema = @Schema(implementation = String.class), in = ParameterIn.PATH) @UserId final Long userId,
@PathVariable("topicId") final String topicUrl
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ public WriterNameInformationResponse getWriterNameOfUser(
return writerNameRetriever.findWriterNameInfo(writerNameId);
}


public WriterNameConflictCheckResponse checkConflictOfWriterName(Long moimId, String writerName) {
if (writerName.length() > WRITER_NAME_MAX_VALUE) {
throw new BadRequestException(ErrorMessage.WRITER_NAME_LENGTH_WRONG);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,10 @@ public void deleteTopic(
}

public void putTopic(
final Long userId,
final Long topicId,
final TopicPutRequest topicPutRequest
) {
topicUpdator.putTopic(userId, topicId, topicPutRequest);
topicUpdator.putTopic(topicId, topicPutRequest);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,10 @@ public class TopicUpdator {

@Transactional
public void putTopic(
final Long userId,
final Long topicId,
final TopicPutRequest topicPutRequest
) {
Topic topic = topicRetriever.findById(topicId);
User user = userService.findById(userId);
topicRetriever.authenticateTopicWithUser(topic, user);
topic.updateTopic(topicPutRequest);
}

Expand Down

0 comments on commit 0ea0caf

Please sign in to comment.