Skip to content

Commit

Permalink
refactor: 불필요한 개행 삭제 및 컨벤션 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
yongbin97 committed Sep 27, 2024
1 parent 0226e2b commit 8541a07
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ public String getSummary(CreatePostServiceRequest createPostServiceRequest) {
Prompt prompt = getPrompt(createPostServiceRequest);
ChatResponse response = chatModel.call(prompt);

return response.getResult().getOutput().getContent();
return response.getResult()
.getOutput()
.getContent();
}

private Prompt getPrompt(CreatePostServiceRequest createPostServiceRequest) {
Expand All @@ -34,8 +36,8 @@ private Prompt getPrompt(CreatePostServiceRequest createPostServiceRequest) {
+ "Summary conditions: \n"
+ "Summary length: " + options.getLevel().getLines() + "\n"
+ "Summary tone:" + options.getTone().getValue() + "\n"
+ "Summary language: " + options.getLanguage().getValue() +
"\n" + "Summary keywords: " + options.getKeywords();
+ "Summary language: " + options.getLanguage().getValue() + "\n"
+ "Summary keywords: " + options.getKeywords();

return new Prompt(requestMessage,
VertexAiGeminiChatOptions.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
@Getter
@Builder
public class PostDetailServiceRequest {

private Long postId;
private PostStatus status;

Expand All @@ -20,5 +21,4 @@ public static PostDetailServiceRequest of(Long postId, String status) {
.status(postStatus)
.build();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ public enum SummaryLevel {
BASE("moderate summary", 20),
DETAIL("detail summary", 30);


private final String value;
private final int lines;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,12 @@ public class SummaryOption {
private SummaryLanguage language;
private String keywords;


public static SummaryOption of(String level, String tone, String language, String keywords) {
try {
return SummaryOption.builder()
.level(SummaryLevel.stringToEnum(level.toUpperCase()))
.tone(SummaryTone.stringToEnum(tone.toUpperCase()))
.language(
SummaryLanguage.stringToEnum(language.toUpperCase()))
.language(SummaryLanguage.stringToEnum(language.toUpperCase()))
.keywords(keywords)
.build();
} catch (IllegalArgumentException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
@Getter
@Builder
public class PostListDto {

private final Long id;
private final String title;
private final String createdAt;
private final List<String> tagList;

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import java.util.List;
import lombok.Builder;
import lombok.Getter;
import project.backend.business.post.request.PostListServiceRequest;

@Getter
public class PostListResponse {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,27 @@
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import project.backend.business.post.PostService;
import project.backend.business.post.request.PostDetailServiceRequest;
import project.backend.business.post.request.PostListServiceRequest;
import project.backend.business.post.response.CreateUpdatePostResponse;
import project.backend.business.post.response.PostListResponse;
import project.backend.business.post.response.PostDetailResponse;
import project.backend.business.post.response.PostListResponse;
import project.backend.presentation.post.request.SummaryUrlRequest;
import project.backend.presentation.post.request.UpdatePostRequest;
import project.backend.security.aop.AssignCurrentUserInfo;
import project.backend.security.aop.AssignOrNullCurrentUserInfo;
import project.backend.security.aop.CurrentUserInfo;


@Slf4j
@RestController
@RequiredArgsConstructor
Expand Down Expand Up @@ -46,16 +53,14 @@ public ResponseEntity<PostListResponse> getPosts(CurrentUserInfo userInfo,
public ResponseEntity<CreateUpdatePostResponse> createNewPost(CurrentUserInfo userInfo,
@RequestBody SummaryUrlRequest summaryUrlRequest) {
CreateUpdatePostResponse createUpdatePostResponse = postService.createNewPostDetail(
userInfo.getUserId(),
summaryUrlRequest.toServiceRequest());
userInfo.getUserId(), summaryUrlRequest.toServiceRequest());
return new ResponseEntity<>(createUpdatePostResponse, HttpStatus.CREATED);
}

@AssignOrNullCurrentUserInfo
@GetMapping("/{id}")
public ResponseEntity<PostDetailResponse> getPostDetail(CurrentUserInfo userInfo,
@PathVariable("id") Long id,
@RequestParam String status) {
@PathVariable("id") Long id, @RequestParam String status) {
PostDetailServiceRequest request = PostDetailServiceRequest.of(id, status);
PostDetailResponse response = postService.getPostDetail(userInfo.getUserId(), request);
return new ResponseEntity<>(response, HttpStatus.OK);
Expand All @@ -64,8 +69,7 @@ public ResponseEntity<PostDetailResponse> getPostDetail(CurrentUserInfo userInfo
@AssignCurrentUserInfo
@PatchMapping("/{id}")
public ResponseEntity<CreateUpdatePostResponse> updatePost(CurrentUserInfo userInfo,
@PathVariable("id") Long postId,
@RequestBody UpdatePostRequest updatePostRequest) {
@PathVariable("id") Long postId, @RequestBody UpdatePostRequest updatePostRequest) {
CreateUpdatePostResponse response = postService.updatePostDetail(userInfo.getUserId(), postId,
updatePostRequest.toServiceRequest());

Expand All @@ -80,12 +84,10 @@ public ResponseEntity<Void> deletePost(CurrentUserInfo userInfo,
return new ResponseEntity<>(HttpStatus.OK);
}


@AssignOrNullCurrentUserInfo
@PatchMapping("/{id}/summary")
public ResponseEntity<CreateUpdatePostResponse> updateSummaryPost(CurrentUserInfo userInfo,
@PathVariable("id") Long postId,
@RequestBody SummaryUrlRequest summaryUrlRequest) {
@PathVariable("id") Long postId, @RequestBody SummaryUrlRequest summaryUrlRequest) {
CreateUpdatePostResponse response = postService.updateSummaryPost(userInfo.getUserId(), postId,
summaryUrlRequest.toServiceRequest());
return new ResponseEntity<>(response, HttpStatus.OK);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import project.backend.entity.post.Post;
import project.backend.entity.post.PostStatus;


@Repository
public interface PostRepository extends JpaRepository<Post, Long>, JpaSpecificationExecutor {

Expand Down

0 comments on commit 8541a07

Please sign in to comment.