Skip to content

Commit

Permalink
fix: request string -> dto
Browse files Browse the repository at this point in the history
  • Loading branch information
osoohynn committed Nov 29, 2024
1 parent f344786 commit abfb9e9
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package com.project.oof.gpt.controller;

import com.project.oof.gpt.dto.MessageDto;
import com.project.oof.gpt.dto.request.RefreshRequest;
import com.project.oof.gpt.dto.request.TranslateRequest;
import com.project.oof.gpt.dto.response.MessageDto;
import com.project.oof.gpt.service.ChatGPTService;
import com.project.oof.storage.service.ChatHistoryService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
Expand All @@ -14,6 +15,7 @@
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.UUID;


@Slf4j
Expand All @@ -25,14 +27,14 @@ public class ChatGPTController {
private final ChatGPTService chatGPTService;

@PostMapping("/translate")
public ResponseEntity<MessageDto> selectPrompt(@RequestBody MessageDto request) {
MessageDto result = chatGPTService.translateMessage(request.message());
public ResponseEntity<MessageDto> selectPrompt(@RequestBody TranslateRequest request) {
MessageDto result = chatGPTService.translateMessage(request);
return new ResponseEntity<>(result, HttpStatus.OK);
}

@PostMapping("/refresh")
public ResponseEntity<MessageDto> refresh() {
MessageDto result = chatGPTService.refreshResult();
public ResponseEntity<MessageDto> refresh(@RequestBody RefreshRequest request) {
MessageDto result = chatGPTService.refreshResult(request.userId());
return new ResponseEntity<>(result, HttpStatus.OK);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.project.oof.gpt.dto.request;

import java.util.UUID;

public record RefreshRequest(
UUID userId
) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.project.oof.gpt.dto.request;

import java.util.UUID;

public record TranslateRequest(
String message,
UUID userId
) {
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.project.oof.gpt.dto;
package com.project.oof.gpt.dto.response;

public record MessageDto (
String message
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/com/project/oof/gpt/service/ChatGPTService.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
package com.project.oof.gpt.service;

import com.project.oof.gpt.dto.MessageDto;
import com.project.oof.gpt.dto.request.TranslateRequest;
import com.project.oof.gpt.dto.response.MessageDto;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.UUID;


@Service
public interface ChatGPTService {

MessageDto translateMessage(String userMessage);
MessageDto translateMessage(TranslateRequest request);

MessageDto refreshResult();
MessageDto refreshResult(UUID userId);

List<String> getAnswers();
}

0 comments on commit abfb9e9

Please sign in to comment.