16
16
import org .springframework .http .ResponseEntity ;
17
17
import org .springframework .web .bind .annotation .*;
18
18
19
- @ CrossOrigin ("http://localhost:4040" )
20
19
@ RestController
21
20
@ RequiredArgsConstructor
22
- @ RequestMapping ("/conversation" )
23
21
public class ConversationController {
24
22
25
23
private final ConversationService conversationService ;
@@ -34,7 +32,7 @@ public class ConversationController {
34
32
content = {@ Content (mediaType = "application/json" )})
35
33
})
36
34
@ Operation (summary = "Get all conversations" )
37
- @ GetMapping
35
+ @ GetMapping ( value = "/api/v1/paid/conversation" )
38
36
public ResponseEntity <List <ConversationResponseCompact >> getAllConversations () throws UnAuthorizedException {
39
37
return ResponseEntity .ok (conversationService .getAll ().stream ()
40
38
.map (conversationApiMapper ::mapCompact )
@@ -49,7 +47,7 @@ public ResponseEntity<List<ConversationResponseCompact>> getAllConversations() t
49
47
content = {@ Content (mediaType = "application/json" )})
50
48
})
51
49
@ Operation (summary = "Get conversation by ID" )
52
- @ GetMapping ("/{id}" )
50
+ @ GetMapping ("/api/v1/conversation/ {id}" )
53
51
public ResponseEntity <ConversationResponse > getConversationById (@ PathVariable UUID id )
54
52
throws ConversationNotFoundException , UnAuthorizedException {
55
53
Conversation conversation =
@@ -66,7 +64,7 @@ public ResponseEntity<ConversationResponse> getConversationById(@PathVariable UU
66
64
content = {@ Content (mediaType = "application/json" )})
67
65
})
68
66
@ Operation (summary = "Create new conversation" )
69
- @ PostMapping
67
+ @ PostMapping ( "/api/v1/conversation" )
70
68
public ResponseEntity <ConversationResponse > createConversation () throws Exception {
71
69
Conversation conversation = conversationService .start ();
72
70
@@ -81,7 +79,7 @@ public ResponseEntity<ConversationResponse> createConversation() throws Exceptio
81
79
content = {@ Content (mediaType = "application/json" )})
82
80
})
83
81
@ Operation (summary = "Continue conversation using conversation ID" )
84
- @ PutMapping ("/{id}/continue" )
82
+ @ PutMapping ("/api/v1/conversation/ {id}/continue" )
85
83
public ResponseEntity <List <DiscussionResponse >> continueConversation (
86
84
@ PathVariable UUID id , @ RequestBody ConversationRequest conversationRequest )
87
85
throws ConversationNotFoundException , UnAuthorizedException {
@@ -100,14 +98,19 @@ public ResponseEntity<List<DiscussionResponse>> continueConversation(
100
98
content = {@ Content (mediaType = "application/json" )})
101
99
})
102
100
@ Operation (summary = "update conversation title" )
103
- @ PutMapping ("/{id}" )
101
+ @ PutMapping ("/api/v1/conversation/ {id}" )
104
102
public ResponseEntity <ConversationResponseCompact > editConversation (
105
103
@ PathVariable UUID id , @ RequestBody ConversationTitleRequest conversationTitleRequest ) throws Exception {
106
- Conversation conversation =
104
+ Conversation conversationOld =
107
105
conversationService .getByID (id ).orElseThrow (() -> new ConversationNotFoundException (id ));
108
- conversationService .editTitle (conversation , conversationTitleRequest .getTitle ());
106
+ Conversation conversationNew =
107
+ conversationService .editTitle (conversationOld , conversationTitleRequest .getTitle ());
108
+
109
+ // TODO find why save does not return discussions
110
+ // TEMP Solution
111
+ conversationNew .setDiscussions (conversationOld .getDiscussions ());
109
112
110
- return ResponseEntity .status (HttpStatus .OK ).body (conversationApiMapper .mapCompact (conversation ));
113
+ return ResponseEntity .status (HttpStatus .OK ).body (conversationApiMapper .mapCompact (conversationNew ));
111
114
}
112
115
113
116
@ ApiResponses (
@@ -118,7 +121,7 @@ public ResponseEntity<ConversationResponseCompact> editConversation(
118
121
content = {@ Content (mediaType = "application/json" )})
119
122
})
120
123
@ Operation (summary = "deletes a conversation" )
121
- @ DeleteMapping ("/{id}" )
124
+ @ DeleteMapping ("/api/v1/conversation/ {id}" )
122
125
public ResponseEntity <Void > deleteConversation (@ PathVariable UUID id )
123
126
throws ConversationNotFoundException , UnAuthorizedException {
124
127
conversationService .getByID (id ).orElseThrow (() -> new ConversationNotFoundException (id ));
@@ -134,7 +137,7 @@ public ResponseEntity<Void> deleteConversation(@PathVariable UUID id)
134
137
content = {@ Content (mediaType = "application/json" )})
135
138
})
136
139
@ Operation (summary = "deletes all conversations" )
137
- @ DeleteMapping
140
+ @ DeleteMapping ( "/api/v1/conversation" )
138
141
public ResponseEntity <Void > deleteConversation () {
139
142
conversationService .deleteAll ();
140
143
return ResponseEntity .status (HttpStatus .OK ).body (null );
0 commit comments