Skip to content

Commit

Permalink
Merge pull request #222 from sharemindteam/revert-221-revert-218-feat…
Browse files Browse the repository at this point in the history
…ure/215-front-shutdown

Revert "Revert "feat: 프론트 셧다운 상태 저장 및 확인 위한 api 구현""
  • Loading branch information
letskuku authored Jul 15, 2024
2 parents 8c73ab1 + 9f7bc6a commit c1f0216
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,8 @@ public interface AdminService {
void deletePostByPostId(Long postId);

InformationGetResponse getInformation();

Boolean updateShutdown(Boolean shutdown);

Boolean getShutdown();
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
import com.example.sharemind.post.exception.PostErrorCode;
import com.example.sharemind.post.exception.PostException;
import lombok.RequiredArgsConstructor;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

Expand All @@ -50,6 +52,7 @@
@Transactional(readOnly = true)
@RequiredArgsConstructor
public class AdminServiceImpl implements AdminService {
private static final String SHUT_DOWN_KEY = "SHUT_DOWN";

private final ConsultService consultService;
private final LetterService letterService;
Expand All @@ -59,6 +62,7 @@ public class AdminServiceImpl implements AdminService {
private final CustomerService customerService;
private final PostService postService;
private final EmailService emailService;
private final RedisTemplate<String, Boolean> redisTemplate;

@Override
public List<ConsultGetUnpaidResponse> getUnpaidConsults() {
Expand Down Expand Up @@ -295,4 +299,18 @@ public InformationGetResponse getInformation() {
publicPosts, completedPublicPosts, secretPosts, secretPostCosts,
completedSecretPosts, completedSecretPostCosts);
}

@Override
public Boolean updateShutdown(Boolean shutdown) {
ValueOperations<String, Boolean> valueOperations = redisTemplate.opsForValue();
valueOperations.set(SHUT_DOWN_KEY, shutdown);

return valueOperations.get(SHUT_DOWN_KEY);
}

@Override
public Boolean getShutdown() {
ValueOperations<String, Boolean> valueOperations = redisTemplate.opsForValue();
return valueOperations.get(SHUT_DOWN_KEY);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -292,4 +292,25 @@ public ResponseEntity<Void> deletePostByPostId(@PathVariable Long postId) {
public ResponseEntity<InformationGetResponse> getInformation() {
return ResponseEntity.ok(adminService.getInformation());
}

@Operation(summary = "서비스 셧다운 여부 수정", description = "서비스 셧다운 여부 수정")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "수정 성공")
})
@Parameters({
@Parameter(name = "shutdown", description = "true: 서비스 셧다운, false: 서비스 정상 동작")
})
@PatchMapping("/managements")
public ResponseEntity<Boolean> updateShutdown(@RequestParam Boolean shutdown) {
return ResponseEntity.ok(adminService.updateShutdown(shutdown));
}

@Operation(summary = "서비스 셧다운 여부 조회", description = "서비스 셧다운 여부 조회")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "수정 성공")
})
@GetMapping("/managements")
public ResponseEntity<Boolean> getShutdown() {
return ResponseEntity.ok(adminService.getShutdown());
}
}

0 comments on commit c1f0216

Please sign in to comment.