Skip to content

Commit

Permalink
refactor: 스케줄러에서 레포를 통해 북토크들 조회하는 로직 리팩토링
Browse files Browse the repository at this point in the history
  • Loading branch information
dong2ast committed Aug 2, 2023
1 parent d9bc043 commit 4433a9c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
18 changes: 12 additions & 6 deletions src/main/java/org/sophy/sophy/controller/AuthController.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.security.SecurityRequirements;
import io.swagger.v3.oas.annotations.tags.Tag;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.sophy.sophy.common.dto.ApiResponseDto;
import org.sophy.sophy.controller.dto.request.DuplCheckDto;
Expand All @@ -19,10 +21,12 @@
import org.springframework.http.HttpStatus;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.security.core.userdetails.User;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
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.RequestParam;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/auth")
Expand Down Expand Up @@ -86,8 +90,10 @@ public ApiResponseDto<String> duplCheck(@RequestBody DuplCheckDto email) {

@PostMapping("/email-confirm")
@Operation(summary = "이메일 인증")
public ApiResponseDto<String> emailConfirm(@Parameter(example = "[email protected]") @RequestParam String email) throws Exception {
return ApiResponseDto.success(SuccessStatus.CREATE_AUTHCODE_SUCCESS, emailService.sendEmail(email));
public ApiResponseDto<String> emailConfirm(
@Parameter(example = "[email protected]") @RequestParam String email) throws Exception {
return ApiResponseDto.success(SuccessStatus.CREATE_AUTHCODE_SUCCESS,
emailService.sendEmail(email));
}

@PostMapping("/withdrawal")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public interface BooktalkRepository extends JpaRepository<Booktalk, Long> {

Integer countAllByCityAndCreateAtBetween(City city, LocalDateTime before, LocalDateTime now);

List<Booktalk> findAllByBooktalkStatus(BooktalkStatus booktalkStatus);
List<Booktalk> findAllByBooktalkStatusOrBooktalkStatus(BooktalkStatus recruting, BooktalkStatus recrutingClosed);

default Booktalk getBooktalkById(Long booktalkId) {
return this.findById(booktalkId)
Expand Down
10 changes: 2 additions & 8 deletions src/main/java/org/sophy/sophy/service/SchedulerService.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,12 @@ public class SchedulerService {
@Scheduled(fixedDelay = 60000)
@Transactional
public void updateBooktalkStatus() { //1분마다 북토크 상태 측정
List<Booktalk> recrutingBooktalks = booktalkRepository.findAllByBooktalkStatus(
BooktalkStatus.RECRUITING);
List<Booktalk> closedBooktalks = booktalkRepository.findAllByBooktalkStatus(
BooktalkStatus.RECRUITING_CLOSED);
List<Booktalk> recrutingBooktalks = booktalkRepository.findAllByBooktalkStatusOrBooktalkStatus(
BooktalkStatus.RECRUITING, BooktalkStatus.RECRUITING_CLOSED);

recrutingBooktalks.forEach(booktalk -> {
booktalkToCompletedBooktalk(booktalk);
});

closedBooktalks.forEach(booktalk -> {
booktalkToCompletedBooktalk(booktalk);
});
}

private void booktalkToCompletedBooktalk(
Expand Down

0 comments on commit 4433a9c

Please sign in to comment.