Skip to content

Commit

Permalink
feat: Routine을 사용할 경우 count 증가시키는 로직 추가 (#164) (#166)
Browse files Browse the repository at this point in the history
* feat: Routine에 count 증가하는 메소드 추가 (#164)

* feat: ReservationService에 count 증가하는 로직 추가 (#164)
  • Loading branch information
hoyun06 authored Oct 9, 2023
1 parent 853fd02 commit 43605f6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ public void updateName(String name) {
this.name = name;
}

public void incrementCount() {
this.count++;
}

@Builder(access = AccessLevel.PRIVATE)
private Routine(Authority authority, String name) {
this.authority = authority;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,18 @@
import com.newfit.reservation.domain.reservation.Reservation;
import com.newfit.reservation.domain.reservation.Status;
import com.newfit.reservation.domain.routine.EquipmentRoutine;
import com.newfit.reservation.domain.routine.Routine;
import com.newfit.reservation.dto.request.ReservationRequest;
import com.newfit.reservation.dto.request.ReservationUpdateRequest;
import com.newfit.reservation.dto.response.*;
import com.newfit.reservation.exception.CustomException;
import com.newfit.reservation.exception.ErrorCode;
import com.newfit.reservation.repository.AuthorityRepository;
import com.newfit.reservation.repository.CreditRepository;
import com.newfit.reservation.repository.equipment.EquipmentGymRepository;
import com.newfit.reservation.repository.reservation.ReservationRepository;
import com.newfit.reservation.repository.routine.EquipmentRoutineRepository;
import com.newfit.reservation.repository.routine.RoutineRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
Expand All @@ -40,7 +43,7 @@ public class ReservationService {
private final EquipmentGymRepository equipmentGymRepository;
private final EquipmentRoutineRepository equipmentRoutineRepository;
private final CreditRepository creditRepository;

private final RoutineRepository routineRepository;

public void reserve(Long authorityId,
Long equipmentId,
Expand Down Expand Up @@ -148,6 +151,8 @@ public List<RoutineReservationResponse> reserveByRoutine(Long authorityId, Long
}
}

Routine routine = routineRepository.findById(routineId).orElseThrow(() -> new CustomException(ROUTINE_NOT_FOUND));
routine.incrementCount();
return reservedList;
}

Expand Down

0 comments on commit 43605f6

Please sign in to comment.