-
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 #91 from SWM-Flash/integration
Integration
- Loading branch information
Showing
6 changed files
with
98 additions
and
1 deletion.
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
22 changes: 22 additions & 0 deletions
22
src/main/java/com/first/flash/version/application/VersionService.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,22 @@ | ||
package com.first.flash.version.application; | ||
|
||
import java.util.NoSuchElementException; | ||
import com.first.flash.version.infrastructure.VersionJpaRepository; | ||
import com.first.flash.version.application.dto.VersionResponseDto; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
@Transactional(readOnly = true) | ||
public class VersionService { | ||
|
||
private final VersionJpaRepository versionJpaRepository; | ||
|
||
public VersionResponseDto getLatestVersions() { | ||
return versionJpaRepository.findTopByOrderByIdDesc() | ||
.map(version -> new VersionResponseDto(version.getAndroid(), version.getIos())) | ||
.orElseThrow(() -> new NoSuchElementException("No version information available")); | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
src/main/java/com/first/flash/version/application/dto/VersionResponseDto.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,4 @@ | ||
package com.first.flash.version.application.dto; | ||
|
||
public record VersionResponseDto(String android, String ios) { | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/com/first/flash/version/domain/AppVersion.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,24 @@ | ||
package com.first.flash.version.domain; | ||
|
||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.ToString; | ||
|
||
@Entity | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Getter | ||
@ToString | ||
public class AppVersion { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
private String android; | ||
private String ios; | ||
|
||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/com/first/flash/version/infrastructure/VersionJpaRepository.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,10 @@ | ||
package com.first.flash.version.infrastructure; | ||
|
||
import com.first.flash.version.domain.AppVersion; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import java.util.Optional; | ||
|
||
public interface VersionJpaRepository extends JpaRepository<AppVersion, Long> { | ||
|
||
Optional<AppVersion> findTopByOrderByIdDesc(); | ||
} |
36 changes: 36 additions & 0 deletions
36
src/main/java/com/first/flash/version/ui/VersionController.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,36 @@ | ||
package com.first.flash.version.ui; | ||
|
||
import com.first.flash.climbing.solution.application.dto.SolutionsPageResponseDto; | ||
import com.first.flash.version.application.VersionService; | ||
import com.first.flash.version.application.dto.VersionResponseDto; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
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.responses.ApiResponses; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import lombok.RequiredArgsConstructor; | ||
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.RestController; | ||
|
||
@Tag(name = "versions", description = "앱 버전 정보 API") | ||
@RestController | ||
@RequestMapping | ||
@RequiredArgsConstructor | ||
public class VersionController { | ||
|
||
private final VersionService versionService; | ||
|
||
@Operation(summary = "버전 정보 조회", description = "앱 최신 버전 정보 조회") | ||
@ApiResponses(value = { | ||
@ApiResponse(responseCode = "200", description = "성공적으로 조회함", | ||
content = @Content(mediaType = "application/json", schema = @Schema(implementation = VersionResponseDto.class))) | ||
}) | ||
@GetMapping("versions") | ||
public ResponseEntity<VersionResponseDto> getLatestVersions() { | ||
VersionResponseDto versionInfo = versionService.getLatestVersions(); | ||
return ResponseEntity.ok(versionInfo); | ||
} | ||
} |