From 635c115b923c39979b305a7150c0ea6c3de6d73b Mon Sep 17 00:00:00 2001 From: su080915 Date: Tue, 27 Aug 2024 04:40:06 +0900 Subject: [PATCH] fixed todo --- .../domain/ai/controller/AiController.java | 3 ++- .../domain/todo/repository/TodoRepository.java | 2 ++ .../domain/todo/service/TodoServiceImpl.java | 2 +- .../crescendoserver/domain/user/domain/UserRole.java | 3 +-- .../global/config/security/SecurityConfig.java | 12 ++++++------ 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/crescendo-server/src/main/java/com/example/crescendoserver/domain/ai/controller/AiController.java b/crescendo-server/src/main/java/com/example/crescendoserver/domain/ai/controller/AiController.java index a53abc6..16584a9 100644 --- a/crescendo-server/src/main/java/com/example/crescendoserver/domain/ai/controller/AiController.java +++ b/crescendo-server/src/main/java/com/example/crescendoserver/domain/ai/controller/AiController.java @@ -3,6 +3,7 @@ import lombok.RequiredArgsConstructor; import org.springframework.ai.openai.OpenAiChatModel; import org.springframework.web.bind.annotation.GetMapping; +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; @@ -14,7 +15,7 @@ public class AiController { private final OpenAiChatModel openAiChatModel; @GetMapping("/chat") - public String chat(@RequestParam String message) { + public String chat(@RequestBody String message) { return openAiChatModel.call(String.valueOf(message)); } diff --git a/crescendo-server/src/main/java/com/example/crescendoserver/domain/todo/repository/TodoRepository.java b/crescendo-server/src/main/java/com/example/crescendoserver/domain/todo/repository/TodoRepository.java index c0528c4..49a7613 100644 --- a/crescendo-server/src/main/java/com/example/crescendoserver/domain/todo/repository/TodoRepository.java +++ b/crescendo-server/src/main/java/com/example/crescendoserver/domain/todo/repository/TodoRepository.java @@ -3,9 +3,11 @@ import com.example.crescendoserver.domain.todo.domain.Todo; import com.example.crescendoserver.domain.user.domain.User; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; import java.util.List; +@Repository public interface TodoRepository extends JpaRepository { List findAllByAuthorOrderByIdDesc(User author); } diff --git a/crescendo-server/src/main/java/com/example/crescendoserver/domain/todo/service/TodoServiceImpl.java b/crescendo-server/src/main/java/com/example/crescendoserver/domain/todo/service/TodoServiceImpl.java index da36073..b77f072 100644 --- a/crescendo-server/src/main/java/com/example/crescendoserver/domain/todo/service/TodoServiceImpl.java +++ b/crescendo-server/src/main/java/com/example/crescendoserver/domain/todo/service/TodoServiceImpl.java @@ -15,7 +15,7 @@ @Service @RequiredArgsConstructor public class TodoServiceImpl implements TodoService { - private TodoRepository todoRepository; + private final TodoRepository todoRepository; private final AuthService authService; @Override diff --git a/crescendo-server/src/main/java/com/example/crescendoserver/domain/user/domain/UserRole.java b/crescendo-server/src/main/java/com/example/crescendoserver/domain/user/domain/UserRole.java index 3ceec6b..1a40f00 100644 --- a/crescendo-server/src/main/java/com/example/crescendoserver/domain/user/domain/UserRole.java +++ b/crescendo-server/src/main/java/com/example/crescendoserver/domain/user/domain/UserRole.java @@ -1,6 +1,5 @@ package com.example.crescendoserver.domain.user.domain; public enum UserRole { - USER, - ADMIN + USER } diff --git a/crescendo-server/src/main/java/com/example/crescendoserver/global/config/security/SecurityConfig.java b/crescendo-server/src/main/java/com/example/crescendoserver/global/config/security/SecurityConfig.java index 0637d08..2190de5 100644 --- a/crescendo-server/src/main/java/com/example/crescendoserver/global/config/security/SecurityConfig.java +++ b/crescendo-server/src/main/java/com/example/crescendoserver/global/config/security/SecurityConfig.java @@ -54,12 +54,12 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { .requestMatchers(HttpMethod.GET, "/ws/chat").permitAll() .requestMatchers(HttpMethod.POST, "/chat").permitAll() .requestMatchers(HttpMethod.GET, "/chat").permitAll() - .requestMatchers(HttpMethod.GET, "/todos/{todoId}").authenticated() - .requestMatchers(HttpMethod.GET, "/todos").authenticated() - .requestMatchers(HttpMethod.POST, "/todos").authenticated() - .requestMatchers(HttpMethod.PATCH, "/todos/{todoId}/check").authenticated() - .requestMatchers(HttpMethod.PATCH, "/todos/{todoId}").authenticated() - .requestMatchers(HttpMethod.DELETE, "/todos/{todoId}").authenticated() + .requestMatchers(HttpMethod.GET, "/todos/{todoId}").permitAll() + .requestMatchers(HttpMethod.GET, "/todos").permitAll() + .requestMatchers(HttpMethod.POST, "/todos").permitAll() + .requestMatchers(HttpMethod.PATCH, "/todos/{todoId}/check").permitAll() + .requestMatchers(HttpMethod.PATCH, "/todos/{todoId}").permitAll() + .requestMatchers(HttpMethod.DELETE, "/todos/{todoId}").permitAll() ) .addFilterBefore(jwtAuthenticationFilter, UsernamePasswordAuthenticationFilter.class)