Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement/페이지 조회 api #41 #43

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/main/java/com/SollutionChallenge/HighLight/Page/Page.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.SollutionChallenge.HighLight.Page;

public class PageController {
}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -20,13 +18,16 @@ public class GoogleController {
@Autowired
AuthService authService;

/* ResponseEntity 사용해서 헤더에 status code 담는 버전 */
@PostMapping(value = "/login")
public ApiResponse googleLogin(@RequestBody GoogleLoginResponse googleLoginResponse) throws IOException {
public ResponseEntity<TokenDto> 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")
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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
Expand All @@ -23,11 +21,9 @@ public class GCSController {


@PostMapping("/upload")
public ResponseEntity<Void> uploadNewImage(UploadReqDto dto) throws IOException {

gcsService.uploadNewImage(dto);

return new ResponseEntity(HttpStatus.OK);
public ResponseEntity<Void> uploadNewFile(UploadReqDto dto) throws IOException {
gcsService.uploadNewFile(dto);
return new ResponseEntity<>(HttpStatus.OK);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
@Builder
public class UploadReqDto {
private String userName;
private MultipartFile image;
private MultipartFile uploadedfile;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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()
);



}


Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down