Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
fixed todo
Browse files Browse the repository at this point in the history
  • Loading branch information
osoohynn committed Aug 26, 2024
1 parent 3a5d77c commit 635c115
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Todo, Long> {
List<Todo> findAllByAuthorOrderByIdDesc(User author);
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
@Service
@RequiredArgsConstructor
public class TodoServiceImpl implements TodoService {
private TodoRepository todoRepository;
private final TodoRepository todoRepository;
private final AuthService authService;

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.example.crescendoserver.domain.user.domain;

public enum UserRole {
USER,
ADMIN
USER
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 635c115

Please sign in to comment.