Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ ResponseEntity<AdminVersionResponse> getVersion(
@PutMapping("/{type}")
@AdminActivityLogging(domain = VERSION)
ResponseEntity<Void> updateVersion(
@Parameter(description = "android, ios, android_owner") @PathVariable("type") String type,
@Parameter(description = "android, ios, android_owner, timetable, shuttle_bus_timetable, city_bus_timetable, express_bus_timetable") @PathVariable("type") String type,
@RequestBody @Valid AdminVersionUpdateRequest adminVersionUpdateRequest,
@Auth(permit = {ADMIN}) Integer adminId
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@
import in.koreatech.koin.admin.version.dto.AdminVersionResponse;
import in.koreatech.koin.admin.version.dto.AdminVersionUpdateRequest;
import in.koreatech.koin.admin.version.dto.AdminVersionsResponse;
import in.koreatech.koin.admin.version.exception.VersionNotSupportedException;
import in.koreatech.koin.admin.version.repository.AdminVersionRepository;
import in.koreatech.koin.common.model.Criteria;
import in.koreatech.koin.domain.version.model.Version;
import in.koreatech.koin.domain.version.model.VersionType;
import in.koreatech.koin.common.model.Criteria;
import lombok.RequiredArgsConstructor;

@Service
Expand Down Expand Up @@ -44,15 +43,19 @@ public AdminVersionResponse getVersion(String type) {
@Transactional
public void updateVersion(String type, AdminVersionUpdateRequest request) {
VersionType versionType = VersionType.from(type);
if (!versionType.isPlatform()) {
throw VersionNotSupportedException.withDetail("type: " + versionType);
}

Version currentVersion = adminVersionRepository.getByTypeAndIsPrevious(versionType, false);
currentVersion.toPreviousVersion();

Version newVersion = Version.of(versionType, request);
adminVersionRepository.save(newVersion);
if (versionType.isPlatform()) {
currentVersion.toPreviousVersion();

Version newVersion = Version.of(versionType, request);
adminVersionRepository.save(newVersion);
} else {
currentVersion.update(
request.version(),
request.title(),
request.content()
);
}
}

public AdminVersionHistoryResponse getHistory(String type, Integer page, Integer limit) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ public void update(Clock clock) {
version = generateVersionName(clock);
}

public void update(String version, String title, String content) {
this.version = version;
this.title = title;
this.content = content;
}

private String generateVersionName(Clock clock) {
String year = Integer.toString(LocalDate.now().getYear());
String padding = "0_";
Expand Down
Loading