Skip to content

Commit

Permalink
Merge pull request #45 from 24-1-CapstoneDesign/develop
Browse files Browse the repository at this point in the history
[DEPLOY]
  • Loading branch information
jisujeong0 authored Jun 5, 2024
2 parents 1290828 + 923e3ac commit 1deac64
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ jobs:
echo "${{ secrets.APPLICATION_S3_YML }}" | base64 --decode > src/main/resources/s3/application-s3.yml
mkdir -p src/main/resources/chatgpt
echo "${{ secrets.APPLICATION_CHATGPT_YML }}" | base64 --decode > src/main/resources/chatgpt/application-chatgpt.yml
mkdir -p src/main/resources/webclient
echo "${{ secrets.APPLICATION_WEBCLIENT_YML }}" | base64 --decode > src/main/resources/webclient/application-webclient.yml
# (4) Gradle build (Test 제외)
Expand Down
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ dependencies {
implementation 'com.amazonaws:aws-java-sdk-s3'
implementation 'org.springframework.cloud:spring-cloud-starter-aws:2.2.6.RELEASE'

// fastAPI
implementation 'org.springframework.boot:spring-boot-starter-webflux'
implementation 'io.netty:netty-resolver-dns-native-macos:4.1.68.Final'

compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'

Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/example/ai_tutor/AiTutorApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
@PropertySource(value = { "classpath:oauth2/application-oauth2.yml" }, factory = YamlPropertySourceFactory.class)
@PropertySource(value = { "classpath:database/application-database.yml" }, factory = YamlPropertySourceFactory.class)
@PropertySource(value = { "classpath:s3/application-s3.yml" }, factory = YamlPropertySourceFactory.class)
@PropertySource(value = { "classpath:webclient/application-webclient.yml" }, factory = YamlPropertySourceFactory.class)
@PropertySource(value = { "classpath:chatgpt/application-chatgpt.yml" }, factory = YamlPropertySourceFactory.class)
public class AiTutorApplication {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.example.ai_tutor.domain.Folder.domain.repository.FolderRepository;
import com.example.ai_tutor.domain.note.domain.Note;
import com.example.ai_tutor.domain.note.domain.repository.NoteRepository;
import com.example.ai_tutor.domain.note.dto.request.NoteCreateProcessReq;
import com.example.ai_tutor.domain.note.dto.request.NoteCreateReq;
import com.example.ai_tutor.domain.note.dto.request.NoteDeleteReq;
import com.example.ai_tutor.domain.note.dto.request.NoteStepUpdateReq;
Expand All @@ -24,9 +25,11 @@
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.multipart.MultipartFile;
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.model.PutObjectRequest;
import org.springframework.web.reactive.function.client.WebClient;

import java.io.IOException;
import java.util.Comparator;
Expand All @@ -44,6 +47,7 @@ public class NoteService {
private final TextRepository textRepository;
private final SummaryRepository summaryRepository;
private final AmazonS3 amazonS3;
private final WebClient webClient;

@Transactional
public ResponseEntity<?> createNewNote(UserPrincipal userPrincipal, Long folderId, NoteCreateReq noteCreateReq, MultipartFile recordFile) {
Expand All @@ -66,13 +70,39 @@ public ResponseEntity<?> createNewNote(UserPrincipal userPrincipal, Long folderI
.user(user)
.build();

noteRepository.save(note);
ApiResponse apiResponse = ApiResponse.builder()
.check(true)
.information("노트 생성 성공")
NoteCreateProcessReq noteCreateProcessReq = NoteCreateProcessReq.builder()
.userId(user.getUserId())
.folderId(folderId)
.noteId(note.getNoteId())
.recordUrl(recordUrl)
.build();

return ResponseEntity.ok(apiResponse);
//post요청으로 user_id(Long), folder_id(Long), note_id(Long), 음성 url(String) 보내기
ResponseEntity requestResult = webClient.post()
.uri("/start-process")
.bodyValue(noteCreateProcessReq)
.retrieve()
.bodyToMono(ResponseEntity.class)
.block();

//상태코드로 완료 여부 판단
if(requestResult.getStatusCode().is2xxSuccessful()){
noteRepository.save(note);
ApiResponse apiResponse = ApiResponse.builder()
.check(true)
.information("노트 생성 성공")
.build();

return ResponseEntity.ok(apiResponse);
}
else{
ApiResponse apiResponse = ApiResponse.builder()
.check(false)
.information("노트 생성 실패")
.build();

return ResponseEntity.badRequest().body(apiResponse);
}
}

@Transactional(readOnly = true)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.example.ai_tutor.domain.note.dto.request;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Builder
@AllArgsConstructor
@NoArgsConstructor
@Getter
public class NoteCreateProcessReq {
//post요청으로 user_id(Long), folder_id(Long), note_id(Long), 음성 url(String) 보내기
private Long userId;
private Long folderId;
private Long noteId;
private String recordUrl;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.example.ai_tutor.global.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.ReactorResourceFactory;
import org.springframework.web.reactive.function.client.WebClient;

@Configuration
public class WebClientConfig {

@Value("${webclient.base-url}")
private String baseUrl;

@Bean
public ReactorResourceFactory resourceFactory() {
ReactorResourceFactory factory = new ReactorResourceFactory();
factory.setUseGlobalResources(false);
return factory;
}

@Bean
public WebClient webClient(){
return WebClient.builder()
.baseUrl(baseUrl)
.build();
}

}

0 comments on commit 1deac64

Please sign in to comment.