-
Notifications
You must be signed in to change notification settings - Fork 1
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
앱 버전 관리 기능 구현 #72
Merged
Merged
앱 버전 관리 기능 구현 #72
Changes from all commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
b56ce3e
refactor: 패키지명 변경
GIVEN53 57bbebe
refactor: intro interface, test용 controller 제거
GIVEN53 6ff0c40
refactor: 클래스명 변경
GIVEN53 fc81004
refactor: endpoint 변경
GIVEN53 27fda69
refactor: dto 클래스명 변경
GIVEN53 c8b0588
feat: version domain 생성
GIVEN53 f440026
refactor: 사용하지 않는 메서드 제거
GIVEN53 db1c7ea
feat: 생성자 구현
GIVEN53 a383311
feat: 버전 정보를 반환하는 기능 추가
GIVEN53 25b708d
docs: JavaDoc 추가
GIVEN53 e912ae7
refactor: 버전 enum 제거
GIVEN53 a53915a
docs: JavaDoc 추가, 수정
GIVEN53 1f3cd1c
feat: 앱 버전 post 요청시 body에 사용할 dto 추가
GIVEN53 cad1dc9
chore: update submodule
GIVEN53 1a9e10d
feat: 앱 버전을 저장하는 기능 추가
GIVEN53 5641cb8
feat: id auto increment
GIVEN53 f149c20
chore: version schema 추가
GIVEN53 0331aa8
feat: created_at 필드만 존재하는 base entity 추가
GIVEN53 9ca2dd0
chore: schema 포맷 수정, not null 수정
GIVEN53 bd1d8f6
chore: test용 schema symlink로 변경
GIVEN53 72879c2
fix: Version PK createdAt으로 변경
GIVEN53 c6d9aff
chore: data.sql version 추가
GIVEN53 5c3407a
refactor: @Value 생성자 주입으로 변경
GIVEN53 13550f9
chore: test yml에 key 추가
GIVEN53 127432a
feat: version fixture 추가
GIVEN53 bad1ac0
test: version repository unit test
GIVEN53 54b7a60
test: version service unit test
GIVEN53 1b32321
test: version controller unit test
GIVEN53 ee8fccf
refactor: 사용하지 않는 클래스 제거
GIVEN53 8d72644
refactor: fixture 반영
GIVEN53 ed96a1f
feat: 정규식 추가
GIVEN53 7c3f694
test: request body validation test
GIVEN53 a240e71
refactor: public 제거
GIVEN53 b935ece
refactor: 상수 처리
GIVEN53 8283777
refactor: 테스트 메서드 구체적으로 변경
GIVEN53 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
lombok.copyableAnnotations += org.springframework.beans.factory.annotation.Value |
16 changes: 0 additions & 16 deletions
16
src/main/java/com/coniverse/dangjang/domain/intro/controller/IntroController.java
This file was deleted.
Oops, something went wrong.
28 changes: 0 additions & 28 deletions
28
src/main/java/com/coniverse/dangjang/domain/intro/controller/ProdIntroController.java
This file was deleted.
Oops, something went wrong.
29 changes: 0 additions & 29 deletions
29
src/main/java/com/coniverse/dangjang/domain/intro/controller/TestIntroController.java
This file was deleted.
Oops, something went wrong.
14 changes: 0 additions & 14 deletions
14
src/main/java/com/coniverse/dangjang/domain/intro/dto/IntroResponse.java
This file was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
src/main/java/com/coniverse/dangjang/domain/intro/dto/Version.java
This file was deleted.
Oops, something went wrong.
48 changes: 0 additions & 48 deletions
48
src/main/java/com/coniverse/dangjang/domain/intro/service/IntroService.java
This file was deleted.
Oops, something went wrong.
52 changes: 52 additions & 0 deletions
52
src/main/java/com/coniverse/dangjang/domain/version/controller/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,52 @@ | ||
package com.coniverse.dangjang.domain.version.controller; | ||
|
||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
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; | ||
|
||
import com.coniverse.dangjang.domain.version.dto.request.VersionRequest; | ||
import com.coniverse.dangjang.domain.version.dto.response.VersionResponse; | ||
import com.coniverse.dangjang.domain.version.service.VersionService; | ||
import com.coniverse.dangjang.global.dto.SuccessSingleResponse; | ||
|
||
import jakarta.validation.Valid; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
/** | ||
* 앱 버전 관련 controller | ||
* | ||
* @author TEO | ||
* @since 1.3.0 | ||
*/ | ||
@RestController | ||
@RequestMapping("/api/version") | ||
@RequiredArgsConstructor | ||
public class VersionController { | ||
private final VersionService versionService; | ||
|
||
/** | ||
* 버전 정보를 GET 요청한다. | ||
* | ||
* @since 1.3.0 | ||
*/ | ||
@GetMapping("/intro") | ||
public ResponseEntity<SuccessSingleResponse<VersionResponse<?>>> getIntro() { | ||
VersionResponse<?> versionResponse = versionService.getVersionResponse(); | ||
return ResponseEntity.ok().body(new SuccessSingleResponse<>(HttpStatus.OK.getReasonPhrase(), versionResponse)); | ||
} | ||
|
||
/** | ||
* 버전 정보를 POST 요청한다. | ||
* | ||
* @since 1.3.0 | ||
*/ | ||
@PostMapping | ||
public ResponseEntity<SuccessSingleResponse<VersionResponse<?>>> postVersion(@Valid @RequestBody VersionRequest request) { | ||
VersionResponse<?> versionResponse = versionService.saveVersion(request); | ||
return ResponseEntity.ok().body(new SuccessSingleResponse<>(HttpStatus.OK.getReasonPhrase(), versionResponse)); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/com/coniverse/dangjang/domain/version/dto/request/VersionRequest.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,14 @@ | ||
package com.coniverse.dangjang.domain.version.dto.request; | ||
|
||
import jakarta.validation.constraints.NotBlank; | ||
import jakarta.validation.constraints.Pattern; | ||
|
||
/** | ||
* 앱 버전 post dto | ||
* | ||
* @author TEO | ||
* @since 1.3.0 | ||
*/ | ||
public record VersionRequest(@NotBlank @Pattern(regexp = "^\\d\\.\\d\\.\\d$") String minVersion, | ||
@NotBlank @Pattern(regexp = "^\\d\\.\\d\\.\\d$") String latestVersion, @NotBlank String key) { | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/com/coniverse/dangjang/domain/version/dto/response/VersionResponse.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,18 @@ | ||
package com.coniverse.dangjang.domain.version.dto.response; | ||
|
||
import java.util.List; | ||
|
||
import com.coniverse.dangjang.domain.version.entity.Version; | ||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
|
||
/** | ||
* 버전 정보를 반환하는 dto이다. | ||
* | ||
* @author TEO | ||
* @since 1.3.0 | ||
*/ | ||
public record VersionResponse<T>(String minVersion, String latestVersion, @JsonInclude(JsonInclude.Include.NON_NULL) List<T> loadData) { | ||
public VersionResponse(Version version, List<T> loadData) { | ||
this(version.getMinVersion(), version.getLatestVersion(), loadData); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
src/main/java/com/coniverse/dangjang/domain/version/entity/Version.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,38 @@ | ||
package com.coniverse.dangjang.domain.version.entity; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
import org.springframework.data.annotation.CreatedDate; | ||
import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ||
|
||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.EntityListeners; | ||
import jakarta.persistence.Id; | ||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
/** | ||
* app version entity | ||
* | ||
* @author TEO | ||
* @since 1.3.0 | ||
*/ | ||
@Entity | ||
@Getter | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@EntityListeners(AuditingEntityListener.class) | ||
public class Version { | ||
@Id | ||
@CreatedDate | ||
private LocalDateTime createdAt; | ||
private String minVersion; | ||
private String latestVersion; | ||
|
||
@Builder | ||
private Version(String minVersion, String latestVersion) { | ||
this.minVersion = minVersion; | ||
this.latestVersion = latestVersion; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/main/java/com/coniverse/dangjang/domain/version/repository/VersionRepository.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.coniverse.dangjang.domain.version.repository; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import com.coniverse.dangjang.domain.version.entity.Version; | ||
|
||
/** | ||
* app version repository | ||
* | ||
* @author TEO | ||
* @since 1.3.0 | ||
*/ | ||
public interface VersionRepository extends JpaRepository<Version, Long> { | ||
|
||
/** | ||
* 가장 최근의 버전 정보를 반환한다. | ||
* | ||
* @return Version | ||
* @since 1.3.0 | ||
*/ | ||
Version findFirstByOrderByCreatedAtDesc(); | ||
} |
69 changes: 69 additions & 0 deletions
69
src/main/java/com/coniverse/dangjang/domain/version/service/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,69 @@ | ||
package com.coniverse.dangjang.domain.version.service; | ||
|
||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import com.coniverse.dangjang.domain.version.dto.request.VersionRequest; | ||
import com.coniverse.dangjang.domain.version.dto.response.VersionResponse; | ||
import com.coniverse.dangjang.domain.version.entity.Version; | ||
import com.coniverse.dangjang.domain.version.repository.VersionRepository; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
|
||
/** | ||
* 앱 버전 관련 service | ||
* | ||
* @author TEO | ||
* @since 1.3.0 | ||
*/ | ||
@Service | ||
@RequiredArgsConstructor | ||
@Transactional | ||
public class VersionService { | ||
private final VersionRepository versionRepository; | ||
@Value("${version.key}") | ||
private final String serverKey; | ||
|
||
/** | ||
* 가장 최근의 버전 정보를 반환한다. | ||
* | ||
* @return VersionResponse | ||
* @since 1.0.0 | ||
*/ | ||
@Transactional(readOnly = true) | ||
public VersionResponse<?> getVersionResponse() { | ||
Version version = versionRepository.findFirstByOrderByCreatedAtDesc(); | ||
return new VersionResponse<>(version, null); | ||
} | ||
|
||
/** | ||
* 버전 정보를 저장한다. | ||
* | ||
* @param request 버전 정보 | ||
* @return VersionResponse | ||
* @since 1.3.0 | ||
*/ | ||
public VersionResponse<?> saveVersion(VersionRequest request) { | ||
validateKey(request.key()); | ||
Version version = Version.builder() | ||
.minVersion(request.minVersion()) | ||
.latestVersion(request.latestVersion()) | ||
.build(); | ||
versionRepository.save(version); | ||
return new VersionResponse<>(version, null); | ||
} | ||
|
||
/** | ||
* 버전 정보의 키 값을 확인한다. | ||
* | ||
* @param key 버전 키 | ||
* @throws IllegalArgumentException 서버 키가 아닐 경우 | ||
* @since 1.3.0 | ||
*/ | ||
private void validateKey(String key) { | ||
if (!key.equals(serverKey)) { | ||
throw new IllegalArgumentException("올바르지 않은 키 값입니다."); | ||
} | ||
} | ||
} |
Submodule config
updated
from 64b96d to f027d6
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
loadData가 어디서 쓰이는지 궁금해요 !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
intro 때 클라이언트에서 미리 로드할 데이터들을 넘기기 위한 필드에요 1.0.0 버전 때부터 존재했던거 였는데 앞으로도 계속 쓰이지 않을 경우 삭제하도록 하겠습니당