Skip to content

Commit

Permalink
✨ feat: create getUrlPath #26
Browse files Browse the repository at this point in the history
  • Loading branch information
noparamin committed Nov 2, 2023
1 parent 50a5b02 commit c335487
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions src/main/java/com/smart/watchboard/service/FileService.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.smart.watchboard.domain.Document;
import com.smart.watchboard.domain.File;
import com.smart.watchboard.domain.SttData;
import com.smart.watchboard.dto.FileDto;
import com.smart.watchboard.dto.SttDto;
import com.smart.watchboard.repository.FileRepository;
import jakarta.transaction.Transactional;
import lombok.RequiredArgsConstructor;
Expand All @@ -17,6 +19,7 @@
import org.springframework.web.multipart.MultipartFile;

import java.time.Instant;
import java.util.List;
import java.util.Optional;

@Service
Expand Down Expand Up @@ -81,14 +84,19 @@ public String getPdfUrl(Long documentId) {
return body;
}

public String createResponseBody(ResponseEntity<String> keywordResponseEntity, String text) throws JsonProcessingException {
ObjectMapper objectMapper = new ObjectMapper();
JsonNode jsonNode = objectMapper.readTree(keywordResponseEntity.getBody());
((ObjectNode) jsonNode).put("text", text);
String updatedJsonString = jsonNode.toString();

return updatedJsonString;
// public String createResponseBody2(ResponseEntity<String> keywordResponseEntity, String text) throws JsonProcessingException {
// ObjectMapper objectMapper = new ObjectMapper();
// JsonNode jsonNode = objectMapper.readTree(keywordResponseEntity.getBody());
// ((ObjectNode) jsonNode).put("text", text);
// String updatedJsonString = jsonNode.toString();
//
// return updatedJsonString;
//
// }

public SttDto createResponseBody(String path, List<SttData> data) throws JsonProcessingException {
SttDto sttDto = new SttDto(path, data);
return sttDto;
}

public void deleteAudioFile(Long documentId) {
Expand All @@ -97,4 +105,10 @@ public void deleteAudioFile(Long documentId) {
file.setDelete(true);
fileRepository.save(file);
}

public String getPath(Long documentId) {
Document document = whiteboardService.findDoc(documentId);
File file = fileRepository.findByDocument(document);
return file.getPath();
}
}

0 comments on commit c335487

Please sign in to comment.