diff --git a/src/main/java/com/SollutionChallenge/HighLight/Page/Page.java b/src/main/java/com/SollutionChallenge/HighLight/Page/Page.java index b8bbf18..6369ab1 100644 --- a/src/main/java/com/SollutionChallenge/HighLight/Page/Page.java +++ b/src/main/java/com/SollutionChallenge/HighLight/Page/Page.java @@ -35,8 +35,8 @@ public class Page { private static Page createPage(Long id, File fileId) { Page page = new Page(); - page.id=id; - page.fileId=fileId; - return new Page(); + page.id = id; + page.fileId = fileId; + return page; } } diff --git a/src/main/java/com/SollutionChallenge/HighLight/Page/PageController.java b/src/main/java/com/SollutionChallenge/HighLight/Page/PageController.java new file mode 100644 index 0000000..9fcd0d2 --- /dev/null +++ b/src/main/java/com/SollutionChallenge/HighLight/Page/PageController.java @@ -0,0 +1,4 @@ +package com.SollutionChallenge.HighLight.Page; + +public class PageController { +} diff --git a/src/main/java/com/SollutionChallenge/HighLight/auth/GoogleController.java b/src/main/java/com/SollutionChallenge/HighLight/auth/GoogleController.java index b8fb125..7414505 100644 --- a/src/main/java/com/SollutionChallenge/HighLight/auth/GoogleController.java +++ b/src/main/java/com/SollutionChallenge/HighLight/auth/GoogleController.java @@ -1,7 +1,5 @@ package com.SollutionChallenge.HighLight.auth; -import com.SollutionChallenge.HighLight.common.ApiResponse; -import com.SollutionChallenge.HighLight.common.Success; import com.SollutionChallenge.HighLight.dto.TokenDto; import com.SollutionChallenge.HighLight.service.AuthService; import lombok.RequiredArgsConstructor; @@ -20,28 +18,16 @@ public class GoogleController { @Autowired AuthService authService; + /* ResponseEntity 사용해서 헤더에 status code 담는 버전 */ @PostMapping(value = "/login") - public ApiResponse googleLogin(@RequestBody GoogleLoginResponse googleLoginResponse) throws IOException { + public ResponseEntity googleLogin(@RequestBody GoogleLoginResponse googleLoginResponse) throws IOException { String accessToken = googleLoginResponse.getAccess_token(); String idToken = googleLoginResponse.getId_token(); - System.out.println(accessToken); + System.out.println("========== user's accessToken: " + accessToken + " =========="); - return ApiResponse.successCode(Success.CREATE_USER_SUCCESS, authService.googleLogin(accessToken)); + return ResponseEntity + .status(HttpStatus.OK) + .body(authService.googleLogin(accessToken)); } - /* ResponseEntity 사용해서 헤더에 status code 담는 버전 */ -// @PostMapping(value = "/login") -// public ResponseEntity googleLogin(@RequestBody GoogleLoginResponse googleLoginResponse) throws IOException { -// HttpHeaders headers = new HttpHeaders(); -// headers.set("Status-Code", String.valueOf(HttpStatus.OK)); -// -// String accessToken = googleLoginResponse.getAccess_token(); -// String idToken = googleLoginResponse.getId_token(); -// System.out.println(accessToken); -// -// return ResponseEntity -// .status(HttpStatus.OK) -// .headers(headers) -// .body(authService.googleLogin(accessToken)); -// } } \ No newline at end of file diff --git a/src/main/java/com/SollutionChallenge/HighLight/controller/GCSController.java b/src/main/java/com/SollutionChallenge/HighLight/controller/GCSController.java index 89aede8..02f5a74 100644 --- a/src/main/java/com/SollutionChallenge/HighLight/controller/GCSController.java +++ b/src/main/java/com/SollutionChallenge/HighLight/controller/GCSController.java @@ -1,6 +1,5 @@ package com.SollutionChallenge.HighLight.controller; -import com.google.auth.oauth2.GoogleCredentials; import com.google.cloud.storage.Storage; import com.SollutionChallenge.HighLight.dto.UploadReqDto; import lombok.RequiredArgsConstructor; @@ -10,7 +9,6 @@ import org.springframework.web.bind.annotation.*; import com.SollutionChallenge.HighLight.service.GCSService; -import java.io.FileInputStream; import java.io.IOException; @RestController @@ -23,11 +21,9 @@ public class GCSController { @PostMapping("/upload") - public ResponseEntity uploadNewImage(UploadReqDto dto) throws IOException { - - gcsService.uploadNewImage(dto); - - return new ResponseEntity(HttpStatus.OK); + public ResponseEntity uploadNewFile(UploadReqDto dto) throws IOException { + gcsService.uploadNewFile(dto); + return new ResponseEntity<>(HttpStatus.OK); } } diff --git a/src/main/java/com/SollutionChallenge/HighLight/dto/UploadReqDto.java b/src/main/java/com/SollutionChallenge/HighLight/dto/UploadReqDto.java index 65ff5b6..d60ccce 100644 --- a/src/main/java/com/SollutionChallenge/HighLight/dto/UploadReqDto.java +++ b/src/main/java/com/SollutionChallenge/HighLight/dto/UploadReqDto.java @@ -10,5 +10,5 @@ @Builder public class UploadReqDto { private String userName; - private MultipartFile image; + private MultipartFile uploadedfile; } \ No newline at end of file diff --git a/src/main/java/com/SollutionChallenge/HighLight/service/GCSService.java b/src/main/java/com/SollutionChallenge/HighLight/service/GCSService.java index aea334d..e4b7c3f 100644 --- a/src/main/java/com/SollutionChallenge/HighLight/service/GCSService.java +++ b/src/main/java/com/SollutionChallenge/HighLight/service/GCSService.java @@ -19,20 +19,17 @@ public class GCSService { @Value("${spring.cloud.gcp.storage.bucket}") private String bucketName; - public void uploadNewImage(UploadReqDto dto) throws IOException { + public void uploadNewFile(UploadReqDto dto) throws IOException { String uuid = UUID.randomUUID().toString(); // Google Cloud Storage에 저장될 파일 이름 - String ext = dto.getImage().getContentType(); // 파일의 형식 ex) JPG + String ext = dto.getUploadedfile().getContentType(); // 파일의 형식 ex) JPG // Cloud에 이미지 업로드 BlobInfo blobInfo = storage.create( BlobInfo.newBuilder(bucketName, uuid) .setContentType(ext) .build(), - dto.getImage().getInputStream() + dto.getUploadedfile().getInputStream() ); - - - } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 2351b98..46230a9 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -5,7 +5,8 @@ spring.servlet.multipart.maxRequestSize=100MB spring.jpa.database-platform=org.hibernate.dialect.H2Dialect spring.jpa.hibernate.ddl-auto=update spring.jpa.properties.hibernate.show_sql=true -spring.jpa.properties.hibernate.format_sql=true +#spring.jpa.properties.hibernate.format_sql=true + logging.level.org.hibernate.SQL=debug logging.level.org.hibernate.type=trace spring.h2.console.enabled=true