Skip to content
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

fix: 배포 후 발생한 문제 해결 #88

Merged
merged 2 commits into from
Dec 2, 2024
Merged
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 @@ -56,7 +56,8 @@ private List<PlanetThemeResponse> getPlanetThemeResponses(Long galaxyThemeId, Ma
private ThemeStatus determineStatus(Status status) {
return switch (status) {
case CLEAR -> ACQUIRED;
case SOON, FAILED, ACQUIRABLE, ON_PROGRESS -> DISCOVERED;
case FAILED, ACQUIRABLE, ON_PROGRESS -> DISCOVERED;
case SOON -> HIDDEN;
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,9 @@ public ResponseEntity<RatioResponse> acquirePlanet(
) {
return ResponseEntity.ok(planetService.acquirePlanet(userId, planetId));
}

@PutMapping("/test/{planetId}")
public void updatePlanetAndMissions(@PathVariable Long planetId) {
planetService.updatePlanetAndMissions(planetId);
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.spaceme.planet.service;

import com.spaceme.collection.service.DynamicProbabilityGenerator;
import com.spaceme.common.domain.Status;
import com.spaceme.common.exception.BadRequestException;
import com.spaceme.common.exception.ForbiddenException;
import com.spaceme.common.exception.NotFoundException;
import com.spaceme.mission.domain.Mission;
import com.spaceme.mission.repository.MissionRepository;
import com.spaceme.mission.service.MissionService;
import com.spaceme.planet.domain.Planet;
Expand Down Expand Up @@ -101,4 +103,15 @@ public void validatePlanet(Long userId, Long planetId) {
.filter(Boolean::booleanValue)
.orElseThrow(() -> new ForbiddenException("접근 권한이 없습니다."));
}

@Transactional
public void updatePlanetAndMissions(Long planetId) {

Planet planet = planetRepository.findById(planetId)
.orElseThrow(() -> new NotFoundException("행성을 찾을 수 없습니다."));

List<Mission> missions = missionRepository.findAllByPlanetId(planet.getId());
missions.forEach(mission -> mission.updateStatus(Status.CLEAR));
planet.updateStatus(Status.ACQUIRABLE);
}
}