Skip to content

Commit

Permalink
transaction read only 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
mintaek22 committed Oct 13, 2023
1 parent 45f7b49 commit 0267403
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 14 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ public ResGuestDto editGuestInfo(Long id, ReqGuestDto updatedReqGuestDTO) {
return new ResGuestDto(guest);
}

@Transactional(readOnly = true)
public ResGuestDto getGuestById(Long id) {

Guest guest = guestRepository.findById(id).orElseThrow(EntityNotFoundException::new);
Expand All @@ -103,11 +104,13 @@ public void deleteGuest(Long id) {
}).orElseThrow(EntityNotFoundException::new);
}

@Transactional(readOnly = true)
public Page<ResGuestDto> getAllGuests(Pageable pageable) {
Page<Guest> guests = guestRepository.findAll(pageable);
return guests.map(ResGuestDto::new);
}

@Transactional(readOnly = true)
public List<ResGuestDto> searchGuestByName(String name) {
List<Guest> guests = guestRepository.findByName(name);
return guests.stream().map(ResGuestDto::new).collect(Collectors.toList());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,13 @@ public ResStatusDto registerWorkerOut(Long id, Long wharfId){
}



@Transactional(readOnly = true)
public List<ResStatusDto> getAllWorkerInWharf(){
List<Status> statuses = statusRepository.findByOutTimeIsNull();
return statuses.stream().map(ResStatusDto::new).collect(Collectors.toList());
}

@Transactional(readOnly = true)
public List<ResStatusDto> getWorkerInWharf(Long wharfId){
List<Status> statuses = statusRepository.findByOutTimeIsNullAndWharfWharfId(wharfId);
return statuses.stream().map(ResStatusDto::new).collect(Collectors.toList());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class WorkerService {


// Worker 조회
@Transactional(readOnly = true)
public ResWorkerDto getWorkerById(Long id) {

Worker worker = workerRepository.findById(id).orElseThrow(EntityNotFoundException::new);
Expand Down Expand Up @@ -123,12 +124,13 @@ public ResWorkerDto registerWorkerUrl(Worker worker, String faceUrl) {
return new ResWorkerDto(worker);
}


@Transactional(readOnly = true)
public Page<ResWorkerDto> getAllWorkers(Pageable pageable) {
Page<Worker> workers = workerRepository.findAll(pageable);
return workers.map(ResWorkerDto::new);
}

@Transactional(readOnly = true)
public List<ResWorkerDto> searchWorkerByName(String name) {
List<Worker> workers = workerRepository.findByName(name);
return workers.stream().map(ResWorkerDto::new).collect(Collectors.toList());
Expand Down

0 comments on commit 0267403

Please sign in to comment.