-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Production
- Loading branch information
Showing
38 changed files
with
919 additions
and
305 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
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
28 changes: 28 additions & 0 deletions
28
noti-service/src/main/java/com/waither/notiservice/api/TokenContoller.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,28 @@ | ||
package com.waither.notiservice.api; | ||
|
||
import com.waither.notiservice.api.request.TokenDto; | ||
import com.waither.notiservice.global.annotation.AuthUser; | ||
import com.waither.notiservice.global.response.ApiResponse; | ||
import com.waither.notiservice.service.AlarmService; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponses; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RequiredArgsConstructor | ||
@RequestMapping("/noti") | ||
@RestController | ||
public class TokenContoller { | ||
|
||
private final AlarmService alarmService; | ||
|
||
@Operation(summary = "Firebase Token 업데이트", description = "Request Body에 발급한 FCM토큰 값을 넣어서 주시면 됩니다.") | ||
@PostMapping("/token") | ||
public ApiResponse<?> updateToken(@AuthUser String email, @RequestBody TokenDto tokenDto) { | ||
alarmService.updateToken(email, tokenDto); | ||
return ApiResponse.onSuccess("토큰 업로드가 완료되었습니다."); | ||
} | ||
} |
26 changes: 11 additions & 15 deletions
26
noti-service/src/main/java/com/waither/notiservice/api/request/LocationDto.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,27 +1,23 @@ | ||
package com.waither.notiservice.api.request; | ||
|
||
import jakarta.validation.Valid; | ||
import jakarta.validation.constraints.DecimalMax; | ||
import jakarta.validation.constraints.DecimalMin; | ||
import jakarta.validation.constraints.NotBlank; | ||
import jakarta.validation.constraints.NotNull; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class LocationDto { | ||
public record LocationDto ( | ||
@NotBlank(message = " 위도(lat) 값은 필수입니다.") | ||
@DecimalMax(value = "132.0", inclusive = true, message = "위도(lat)는 대한민국 내에서만 가능합니다.") | ||
@DecimalMin(value = "124.0", inclusive = true, message = "위도(lat)는 대한민국 내에서만 가능합니다.") | ||
double lat, | ||
|
||
@NotBlank(message = " 경도(y) 값은 필수입니다.") | ||
@DecimalMax(value = "43.0", inclusive = true, message = "경도(lon)는 대한민국 내에서만 가능합니다.") | ||
@DecimalMin(value = "33.0", inclusive = true, message = "경도(lon)는 대한민국 내에서만 가능합니다.") | ||
double lon | ||
) { | ||
|
||
@NotBlank(message = " 위도(x) 값은 필수입니다.") | ||
@DecimalMax(value = "132.0", inclusive = true, message = "위도(x)는 대한민국 내에서만 가능합니다.") | ||
@DecimalMin(value = "124.0", inclusive = true, message = "위도(x)는 대한민국 내에서만 가능합니다.") | ||
public double x; | ||
|
||
@NotBlank(message = " 경도(y) 값은 필수입니다.") | ||
@DecimalMax(value = "43.0", inclusive = true, message = "경도(y)는 대한민국 내에서만 가능합니다.") | ||
@DecimalMin(value = "33.0", inclusive = true, message = "경도(y)는 대한민국 내에서만 가능합니다.") | ||
public double y; | ||
} |
7 changes: 7 additions & 0 deletions
7
noti-service/src/main/java/com/waither/notiservice/api/request/TokenDto.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,7 @@ | ||
package com.waither.notiservice.api.request; | ||
|
||
public record TokenDto( | ||
String token | ||
|
||
) { | ||
} |
32 changes: 32 additions & 0 deletions
32
noti-service/src/main/java/com/waither/notiservice/config/FirebaseConfig.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,32 @@ | ||
package com.waither.notiservice.config; | ||
|
||
import com.google.auth.oauth2.GoogleCredentials; | ||
import com.google.firebase.FirebaseApp; | ||
import com.google.firebase.FirebaseOptions; | ||
import jakarta.annotation.PostConstruct; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
import java.io.FileInputStream; | ||
import java.io.IOException; | ||
|
||
@Configuration | ||
@RequiredArgsConstructor | ||
public class FirebaseConfig { | ||
|
||
@Value("${firebase.key.path}") | ||
private final String keyPath; | ||
|
||
@PostConstruct | ||
public void initializeApp() throws IOException { | ||
FileInputStream serviceAccount = | ||
new FileInputStream(keyPath); | ||
|
||
FirebaseOptions options = FirebaseOptions.builder() | ||
.setCredentials(GoogleCredentials.fromStream(serviceAccount)) | ||
.build(); | ||
|
||
FirebaseApp.initializeApp(options); | ||
} | ||
} |
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
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 |
---|---|---|
|
@@ -11,7 +11,7 @@ | |
public class FireBaseToken { | ||
|
||
@Id | ||
private Long userId; | ||
private String email; | ||
|
||
private String token; | ||
} |
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
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
Oops, something went wrong.