55import com .somemore .domains .recruitboard .domain .RecruitStatus ;
66import com .somemore .domains .recruitboard .dto .request .RecruitBoardLocationUpdateRequestDto ;
77import com .somemore .domains .recruitboard .dto .request .RecruitBoardUpdateRequestDto ;
8- import com .somemore .domains .recruitboard .repository .RecruitBoardRepository ;
98import com .somemore .domains .recruitboard .service .validator .RecruitBoardValidator ;
109import com .somemore .domains .recruitboard .usecase .command .UpdateRecruitBoardUseCase ;
11- import com .somemore .global . exception . BadRequestException ;
10+ import com .somemore .domains . recruitboard . usecase . query . RecruitBoardQueryUseCase ;
1211import lombok .RequiredArgsConstructor ;
1312import org .springframework .stereotype .Service ;
1413import org .springframework .transaction .annotation .Transactional ;
1514
1615import java .time .LocalDateTime ;
1716import java .util .UUID ;
1817
19- import static com .somemore .global .exception .ExceptionMessage .NOT_EXISTS_RECRUIT_BOARD ;
20-
2118@ RequiredArgsConstructor
2219@ Transactional
2320@ Service
2421public class UpdateRecruitBoardService implements UpdateRecruitBoardUseCase {
2522
26- private final RecruitBoardRepository recruitBoardRepository ;
27- private final RecruitBoardValidator recruitBoardValidator ;
23+ private final RecruitBoardQueryUseCase recruitBoardQueryUseCase ;
2824 private final UpdateLocationUseCase updateLocationUseCase ;
25+ private final RecruitBoardValidator recruitBoardValidator ;
2926
3027 @ Override
31- public void updateRecruitBoard (RecruitBoardUpdateRequestDto dto , Long recruitBoardId , UUID centerId , String imgUrl ) {
32- RecruitBoard recruitBoard = getRecruitBoard ( recruitBoardId );
28+ public void updateRecruitBoard (RecruitBoardUpdateRequestDto dto , Long id , UUID centerId , String imgUrl ) {
29+ RecruitBoard recruitBoard = recruitBoardQueryUseCase . getById ( id );
3330 recruitBoardValidator .validateAuthor (recruitBoard , centerId );
3431 recruitBoardValidator .validateRecruitBoardTime (dto .volunteerStartDateTime (), dto .volunteerEndDateTime ());
3532
3633 recruitBoard .updateWith (dto , imgUrl );
3734 }
3835
3936 @ Override
40- public void updateRecruitBoardLocation (RecruitBoardLocationUpdateRequestDto requestDto , Long recruitBoardId ,
41- UUID centerId ) {
42- RecruitBoard recruitBoard = getRecruitBoard (recruitBoardId );
37+ public void updateRecruitBoardLocation (RecruitBoardLocationUpdateRequestDto requestDto , Long id , UUID centerId ) {
38+ RecruitBoard recruitBoard = recruitBoardQueryUseCase .getById (id );
4339 recruitBoardValidator .validateAuthor (recruitBoard , centerId );
4440
4541 updateLocationUseCase .updateLocation (requestDto .toLocationUpdateRequestDto (), recruitBoard .getLocationId ());
@@ -48,18 +44,11 @@ public void updateRecruitBoardLocation(RecruitBoardLocationUpdateRequestDto requ
4844 }
4945
5046 @ Override
51- public void updateRecruitBoardStatus (RecruitStatus status , Long recruitBoardId , UUID centerId ,
52- LocalDateTime currentDateTime ) {
53- RecruitBoard recruitBoard = getRecruitBoard (recruitBoardId );
47+ public void updateRecruitBoardStatus (RecruitStatus status , Long id , UUID centerId , LocalDateTime currentDateTime ) {
48+ RecruitBoard recruitBoard = recruitBoardQueryUseCase .getById (id );
5449 recruitBoardValidator .validateAuthor (recruitBoard , centerId );
5550
5651 recruitBoard .changeRecruitStatus (status , currentDateTime );
5752 }
5853
59- private RecruitBoard getRecruitBoard (Long recruitBoardId ) {
60- return recruitBoardRepository .findById (recruitBoardId ).orElseThrow (
61- () -> new BadRequestException (NOT_EXISTS_RECRUIT_BOARD .getMessage ())
62- );
63- }
64-
6554}
0 commit comments