-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from Team-Walkie/mvc/seungmin
community upload api 수정
- Loading branch information
Showing
10 changed files
with
158 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
25 changes: 25 additions & 0 deletions
25
src/main/java/com/whyranoid/walkie/ApiBaseUrlSingleton.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.whyranoid.walkie; | ||
|
||
public class ApiBaseUrlSingleton { | ||
private static ApiBaseUrlSingleton instance; | ||
private String baseUrl; | ||
|
||
private ApiBaseUrlSingleton() { | ||
// private 생성자로 외부에서 인스턴스를 생성하지 못하도록 함 | ||
} | ||
|
||
public static ApiBaseUrlSingleton getInstance() { | ||
if (instance == null) { | ||
instance = new ApiBaseUrlSingleton(); | ||
} | ||
return instance; | ||
} | ||
|
||
public String getBaseUrl() { | ||
return baseUrl; | ||
} | ||
|
||
public void setBaseUrl(String baseUrl) { | ||
this.baseUrl = baseUrl; | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
src/main/java/com/whyranoid/walkie/FirebaseInitializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.whyranoid.walkie; | ||
|
||
import com.google.auth.oauth2.GoogleCredentials; | ||
import com.google.firebase.FirebaseApp; | ||
import com.google.firebase.FirebaseOptions; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.core.io.ClassPathResource; | ||
import org.springframework.stereotype.Service; | ||
|
||
import javax.annotation.PostConstruct; | ||
import java.io.IOException; | ||
|
||
@Slf4j | ||
@Service | ||
public class FirebaseInitializer { | ||
@Value("${app.firebase-configuration-file}") | ||
private String firebaseConfigPath; | ||
|
||
@PostConstruct | ||
public void initialize() { | ||
try { | ||
ApiBaseUrlSingleton.getInstance().setBaseUrl("https://walkie-5bfb3.appspot.com"); | ||
FirebaseOptions options = new FirebaseOptions.Builder().setCredentials( | ||
GoogleCredentials.fromStream( | ||
new ClassPathResource(firebaseConfigPath).getInputStream())).build(); | ||
if (FirebaseApp.getApps().isEmpty()) { | ||
FirebaseApp.initializeApp(options); | ||
log.info("Firebase application has been initialized"); | ||
} | ||
} catch (IOException e) { | ||
log.error(e.getMessage()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 36 additions & 36 deletions
72
src/main/java/com/whyranoid/walkie/controller/HistoryController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,36 @@ | ||
package com.whyranoid.walkie.controller; | ||
|
||
import com.whyranoid.walkie.dto.response.HistoryResponse; | ||
import com.whyranoid.walkie.service.HistoryService; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.media.ArraySchema; | ||
import io.swagger.v3.oas.annotations.media.Content; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.HttpHeaders; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@Tag(name = "history", description = "운동기록 API") | ||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/api/history") | ||
public class HistoryController { | ||
HttpHeaders httpHeaders = new HttpHeaders(); | ||
private final HistoryService historyService; | ||
|
||
@Operation(summary = "운동기록 가져오기", description = "해당 유저의 운동기록을 가져옵니다.") | ||
@ApiResponse(responseCode = "200", description = "호출 성공", content = @Content(array = @ArraySchema(schema = @Schema(implementation = HistoryResponse.class)))) | ||
@GetMapping("/my-history") | ||
public ResponseEntity getHistory( | ||
@RequestParam Long walkieId | ||
) { | ||
return new ResponseEntity<>(historyService.getHistory(walkieId), httpHeaders, HttpStatus.OK); | ||
} | ||
} | ||
//package com.whyranoid.walkie.controller; | ||
// | ||
//import com.whyranoid.walkie.dto.response.HistoryResponse; | ||
//import com.whyranoid.walkie.service.HistoryService; | ||
//import io.swagger.v3.oas.annotations.Operation; | ||
//import io.swagger.v3.oas.annotations.media.ArraySchema; | ||
//import io.swagger.v3.oas.annotations.media.Content; | ||
//import io.swagger.v3.oas.annotations.media.Schema; | ||
//import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
//import io.swagger.v3.oas.annotations.tags.Tag; | ||
//import lombok.RequiredArgsConstructor; | ||
//import org.springframework.http.HttpHeaders; | ||
//import org.springframework.http.HttpStatus; | ||
//import org.springframework.http.ResponseEntity; | ||
//import org.springframework.web.bind.annotation.GetMapping; | ||
//import org.springframework.web.bind.annotation.RequestMapping; | ||
//import org.springframework.web.bind.annotation.RequestParam; | ||
//import org.springframework.web.bind.annotation.RestController; | ||
// | ||
//@Tag(name = "history", description = "운동기록 API") | ||
//@RestController | ||
//@RequiredArgsConstructor | ||
//@RequestMapping("/api/history") | ||
//public class HistoryController { | ||
// HttpHeaders httpHeaders = new HttpHeaders(); | ||
// private final HistoryService historyService; | ||
// | ||
// @Operation(summary = "운동기록 가져오기", description = "해당 유저의 운동기록을 가져옵니다.") | ||
// @ApiResponse(responseCode = "200", description = "호출 성공", content = @Content(array = @ArraySchema(schema = @Schema(implementation = HistoryResponse.class)))) | ||
// @GetMapping("/my-history") | ||
// public ResponseEntity getHistory( | ||
// @RequestParam Long walkieId | ||
// ) { | ||
// return new ResponseEntity<>(historyService.getHistory(walkieId), httpHeaders, HttpStatus.OK); | ||
// } | ||
//} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 0 additions & 32 deletions
32
src/main/java/com/whyranoid/walkie/dto/request/PostRequest.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters