diff --git a/src/main/java/com/Han2m/portLogistics/user/controller/GuestController.java b/src/main/java/com/Han2m/portLogistics/user/controller/GuestController.java index 79d2fad..61b94d4 100644 --- a/src/main/java/com/Han2m/portLogistics/user/controller/GuestController.java +++ b/src/main/java/com/Han2m/portLogistics/user/controller/GuestController.java @@ -26,7 +26,7 @@ public ResponseEntity getGuest(@PathVariable @Schema(description = Guest guest = guestService.find(id); - return ResponseEntity.ok(guest.toResGuestDto()); + return ResponseEntity.ok(new ResGuestDto(guest)); } @Operation(summary = "게스트 정보 등록하기") @PostMapping("/guest") @@ -34,7 +34,7 @@ public ResponseEntity registerGuest(@RequestBody ReqGuestDto reqGue Guest guest = guestService.registerGuest(reqGuestDto); - return ResponseEntity.ok(guest.toResGuestDto()); + return ResponseEntity.ok(new ResGuestDto(guest)); } @Operation(summary = "게스트 정보 수정하기") @@ -43,7 +43,7 @@ public ResponseEntity updateGuest(@PathVariable Long id, @RequestBo Guest guest = guestService.editGuestInfo(id, reqGuestDto); - return ResponseEntity.ok(guest.toResGuestDto()); + return ResponseEntity.ok(new ResGuestDto(guest)); } @Operation(summary = "게스트 정보 삭제하기") diff --git a/src/main/java/com/Han2m/portLogistics/user/controller/WorkerController.java b/src/main/java/com/Han2m/portLogistics/user/controller/WorkerController.java index badf9a7..de4c9ad 100644 --- a/src/main/java/com/Han2m/portLogistics/user/controller/WorkerController.java +++ b/src/main/java/com/Han2m/portLogistics/user/controller/WorkerController.java @@ -31,7 +31,7 @@ public ResponseEntity getWorker(@PathVariable @Schema(description Worker worker = workerService.find(id); - return ResponseEntity.ok(worker.toResWorkerDto()); + return ResponseEntity.ok(new ResWorkerDto(worker)); } @Operation(summary = "직원 정보 등록하기") @PostMapping( value = "/worker" ,consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) @@ -40,7 +40,7 @@ public ResponseEntity registerWorker(@Parameter(description = "직 Worker worker = workerService.registerWorker(faceImg,reqWorkerDto); - return ResponseEntity.ok(worker.toResWorkerDto()); + return ResponseEntity.ok(new ResWorkerDto(worker)); } @Operation(summary = "직원 정보 수정하기") @@ -49,7 +49,7 @@ public ResponseEntity updateWorker(@PathVariable @Schema(descripti @RequestPart ReqWorkerDto reqWorkerDto) throws IOException { Worker worker = workerService.editWorker(id,faceImg ,reqWorkerDto); - return ResponseEntity.ok(worker.toResWorkerDto()); + return ResponseEntity.ok(new ResWorkerDto(worker)); } diff --git a/src/main/java/com/Han2m/portLogistics/user/domain/Guest.java b/src/main/java/com/Han2m/portLogistics/user/domain/Guest.java index 7a04ffa..c94c74d 100644 --- a/src/main/java/com/Han2m/portLogistics/user/domain/Guest.java +++ b/src/main/java/com/Han2m/portLogistics/user/domain/Guest.java @@ -2,7 +2,6 @@ import com.Han2m.portLogistics.user.dto.req.ReqGuestDto; -import com.Han2m.portLogistics.user.dto.res.ResGuestDto; import jakarta.persistence.DiscriminatorValue; import jakarta.persistence.Entity; import jakarta.persistence.JoinColumn; @@ -12,7 +11,6 @@ import lombok.experimental.SuperBuilder; import java.time.LocalDate; -import java.util.stream.Collectors; @Entity @Getter @@ -51,20 +49,4 @@ public void updateGuest(ReqGuestDto reqGuestDto){ this.date = reqGuestDto.getDate(); } - - public ResGuestDto toResGuestDto(){ - return ResGuestDto.builder(). - personId(getPersonId()). - birth(getBirth()). - sex(getSex()). - name(getName()). - nationality(getNationality()). - phone(getPhone()). - goal(getGoal()). - reason(getReason()). - date(getDate()). - wharfs(getPersonWharfList().stream().map(PersonWharf::getWharf).map(Wharf::getName).collect(Collectors.toList())). - build(); - } - } diff --git a/src/main/java/com/Han2m/portLogistics/user/domain/Worker.java b/src/main/java/com/Han2m/portLogistics/user/domain/Worker.java index 85d55cc..bae028b 100644 --- a/src/main/java/com/Han2m/portLogistics/user/domain/Worker.java +++ b/src/main/java/com/Han2m/portLogistics/user/domain/Worker.java @@ -2,7 +2,6 @@ import com.Han2m.portLogistics.admin.domain.Account; import com.Han2m.portLogistics.user.dto.req.ReqWorkerDto; -import com.Han2m.portLogistics.user.dto.res.ResWorkerDto; import jakarta.persistence.*; import lombok.Getter; import lombok.NoArgsConstructor; @@ -10,7 +9,6 @@ import java.util.ArrayList; import java.util.List; -import java.util.stream.Collectors; @Entity @Getter @@ -43,17 +41,5 @@ public void updateWorker(ReqWorkerDto reqWorkerDto){ this.setBirth(reqWorkerDto.getBirth()); } - public ResWorkerDto toResWorkerDto(){ - return ResWorkerDto.builder(). - personId(getPersonId()). - birth(getBirth()). - faceUrl(getFaceUrl()). - sex(getSex()). - name(getName()). - nationality(getNationality()). - phone(getPhone()). - position(getPosition()). - wharfs(getPersonWharfList().stream().map(PersonWharf::getWharf).map(Wharf::getName).collect(Collectors.toList())). - build(); - } + } diff --git a/src/main/java/com/Han2m/portLogistics/user/dto/res/ResGuestDto.java b/src/main/java/com/Han2m/portLogistics/user/dto/res/ResGuestDto.java index 615537a..6e61c8c 100644 --- a/src/main/java/com/Han2m/portLogistics/user/dto/res/ResGuestDto.java +++ b/src/main/java/com/Han2m/portLogistics/user/dto/res/ResGuestDto.java @@ -1,5 +1,8 @@ package com.Han2m.portLogistics.user.dto.res; +import com.Han2m.portLogistics.user.domain.Guest; +import com.Han2m.portLogistics.user.domain.PersonWharf; +import com.Han2m.portLogistics.user.domain.Wharf; import com.fasterxml.jackson.annotation.JsonFormat; import lombok.AllArgsConstructor; import lombok.Builder; @@ -30,5 +33,17 @@ public class ResGuestDto{ private List wharfs; - + public ResGuestDto(Guest guest) { + this.nationality = guest.getNationality(); + this.name = guest.getName(); + this.sex = guest.getSex(); + this.birth = guest.getBirth(); + this.phone = guest.getPhone(); + this.personId = guest.getPersonId(); + this.date = guest.getDate(); + this.reason = guest.getReason(); + this.goal = guest.getGoal(); + this.workerId = guest.getPersonId(); + this.wharfs = guest.getPersonWharfList().stream().map(PersonWharf::getWharf).map(Wharf::getName).toList(); + } } \ No newline at end of file diff --git a/src/main/java/com/Han2m/portLogistics/user/dto/res/ResWorkerDto.java b/src/main/java/com/Han2m/portLogistics/user/dto/res/ResWorkerDto.java index 8955888..bf52051 100644 --- a/src/main/java/com/Han2m/portLogistics/user/dto/res/ResWorkerDto.java +++ b/src/main/java/com/Han2m/portLogistics/user/dto/res/ResWorkerDto.java @@ -1,5 +1,8 @@ package com.Han2m.portLogistics.user.dto.res; +import com.Han2m.portLogistics.user.domain.PersonWharf; +import com.Han2m.portLogistics.user.domain.Wharf; +import com.Han2m.portLogistics.user.domain.Worker; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; @@ -9,8 +12,8 @@ @Getter @Setter -@AllArgsConstructor @Builder +@AllArgsConstructor public class ResWorkerDto{ private String nationality; @@ -18,9 +21,20 @@ public class ResWorkerDto{ private Boolean sex; private String birth; private String phone; - private Long personId; + private Long workerId; private String position; private String faceUrl; private List wharfs; + public ResWorkerDto(Worker worker) { + this.nationality = worker.getNationality(); + this.name = worker.getName(); + this.sex = worker.getSex(); + this.birth = worker.getBirth(); + this.phone = worker.getPhone(); + this.workerId = worker.getPersonId(); + this.position = worker.getPosition(); + this.faceUrl = worker.getFaceUrl(); + this.wharfs = worker.getPersonWharfList().stream().map(PersonWharf::getWharf).map(Wharf::getName).toList(); + } }