-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from aengzu/refactor
DB 서버 API 수정
- Loading branch information
Showing
162 changed files
with
2,706 additions
and
959 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,16 @@ | ||
// lib/utils/message_utils.dart | ||
|
||
import 'package:palink_v2/data/models/ai_response.dart'; | ||
import 'package:palink_v2/data/models/message_request.dart'; | ||
import 'package:palink_v2/domain/models/chat/message.dart'; | ||
import 'package:uuid/uuid.dart'; | ||
|
||
class MessageUtils { | ||
// 서버에 메시지 저장할 때 MessageDto 로 보내야함 | ||
// 서버에서 받은 메시지를 Message로 변환해서 사용해야함 | ||
|
||
// text 와 conversationId 를 주면 알아서 MessageDto 만드는 것. | ||
static MessageRequest createUserMessageDto(String text, int conversationId) { | ||
return MessageRequest( | ||
sender: true, | ||
messageText: text, | ||
timestamp: DateTime.now().toIso8601String(), | ||
conversationId: conversationId, | ||
); | ||
} | ||
import 'package:palink_v2/data/models/ai_response/ai_response.dart'; | ||
import 'package:palink_v2/data/models/chat/message_request.dart'; | ||
|
||
|
||
class MessageUtils { | ||
// AIResponse 객체를 MessageDto 로 변환 | ||
static MessageRequest convertAIMessageToMessageDto( | ||
AIResponse aiResponse, int conversationId) { | ||
static MessageRequest convertAIMessageToMessageRequest(AIResponse aiResponse) { | ||
return MessageRequest( | ||
sender: false, | ||
messageText: aiResponse.text, | ||
timestamp: DateTime.now().toIso8601String(), | ||
conversationId: conversationId, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import 'package:dio/dio.dart'; | ||
import 'package:palink_v2/data/models/user/user_create_request.dart'; | ||
import 'package:palink_v2/data/models/user/user_login_request.dart'; | ||
import 'package:palink_v2/data/models/user/user_response.dart'; | ||
import 'package:retrofit/http.dart'; | ||
part 'auth_api.g.dart'; | ||
|
||
|
||
@RestApi() | ||
abstract class AuthApi { | ||
factory AuthApi(Dio dio, {String baseUrl}) = _AuthApi; | ||
|
||
|
||
@POST("/login") | ||
Future<UserResponse?> login(@Body() UserLoginRequest body); | ||
|
||
@POST("/users") | ||
Future<UserResponse> signUp(@Body() UserCreateRequest body); | ||
|
||
} |
25 changes: 13 additions & 12 deletions
25
lib/data/api/auth_api.g.dart → lib/data/api/auth/auth_api.g.dart
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import 'package:dio/dio.dart'; | ||
import 'package:palink_v2/data/models/character/character_response.dart'; | ||
import 'package:palink_v2/data/models/character/characters_response.dart'; | ||
import 'package:palink_v2/data/models/tip/tip_request.dart'; | ||
import 'package:palink_v2/data/models/tip/tip_response.dart'; | ||
import 'package:retrofit/http.dart'; | ||
|
||
part 'character_api.g.dart'; | ||
|
||
|
||
@RestApi() | ||
abstract class CharacterApi { | ||
factory CharacterApi(Dio dio, {String baseUrl}) = _CharacterApi; | ||
|
||
@GET("/characters") | ||
Future<CharactersResponse> getAllCharacters(); | ||
|
||
@GET("/characters/{character_id}") | ||
Future<CharacterResponse> getCharacterById(@Path("character_id") int characterId); | ||
|
||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// data/api/chat_api.dart | ||
import 'package:dio/dio.dart'; | ||
import 'package:palink_v2/data/models/chat/conversation_request.dart'; | ||
import 'package:palink_v2/data/models/chat/conversation_response.dart'; | ||
import 'package:palink_v2/data/models/chat/conversations_response.dart'; | ||
import 'package:palink_v2/data/models/chat/message_request.dart'; | ||
import 'package:palink_v2/data/models/chat/message_response.dart'; | ||
import 'package:palink_v2/data/models/chat/messages_response.dart'; | ||
import 'package:retrofit/retrofit.dart'; | ||
|
||
part 'chat_api.g.dart'; | ||
|
||
@RestApi() | ||
abstract class ChatApi { | ||
factory ChatApi(Dio dio, {String baseUrl}) = _ChatApi; | ||
|
||
@POST("/conversations") | ||
Future<ConversationResponse> createConversation(@Body() ConversationRequest conversationRequest); | ||
|
||
@GET("/conversations/{conversation_id}") | ||
Future<ConversationResponse> getConversationById(@Path("conversation_id") int conversationId); | ||
|
||
@GET("/conversations/users/{user_id}") | ||
Future<ConversationsResponse> getConversationsByUserId(@Path("user_id") int userId); | ||
|
||
@POST("/conversations/{conversation_id}/messages") | ||
Future<MessageResponse?> saveMessage(@Path("conversation_id") int conversationId, @Body() MessageRequest messageRequest); | ||
|
||
@GET("/conversations/{conversation_id}/messages") | ||
Future<MessagesResponse?> getMessagesByChatRoomId(@Path("conversation_id") int conversationId); | ||
|
||
@GET("/conversations/{conversation_id}/messages/{message_id}") | ||
Future<MessageResponse> getMessageById(@Path("conversation_id") int conversationId, @Path("message_id") int messageId); | ||
|
||
} |
Oops, something went wrong.