Skip to content

Commit

Permalink
[refactor] DTO 외부 종속 제거
Browse files Browse the repository at this point in the history
- Vendor 와 Customer 가 보여주고 싶은 PayAccount의 정보가 다를 수 있으므로 각 DTO 안에 종속된 PayAccount 정보를 가지도록 수정
  • Loading branch information
kimhyun5u committed Aug 17, 2024
1 parent 9713592 commit f9b6c80
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 97 deletions.
50 changes: 16 additions & 34 deletions src/main/java/camp/woowak/lab/customer/service/dto/CustomerDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,16 @@
import java.util.UUID;

import camp.woowak.lab.customer.domain.Customer;
import camp.woowak.lab.payaccount.service.dto.PayAccountDTO;
import camp.woowak.lab.payaccount.domain.PayAccount;
import lombok.Getter;

@Getter
public class CustomerDTO {
private UUID id;
private String name;
private String email;
private String phone;
private PayAccountDTO payAccount;

public CustomerDTO() {
}

public CustomerDTO(UUID id, String name, String email, String phone, PayAccountDTO payAccount) {
this.id = id;
this.name = name;
this.email = email;
this.phone = phone;
this.payAccount = payAccount;
}
private final UUID id;
private final String name;
private final String email;
private final String phone;
private final PayAccountDTO payAccount;

public CustomerDTO(Customer customer) {
this.id = customer.getId();
Expand All @@ -31,24 +22,15 @@ public CustomerDTO(Customer customer) {
this.payAccount = new PayAccountDTO(customer.getPayAccount());
}

public UUID getId() {
return id;
}

public String getName() {
return name;
}

public String getEmail() {
return email;
}

public String getPhone() {
return phone;
}
@Getter
public static class PayAccountDTO {
private final Long id;
private final Long balance;

public PayAccountDTO getPayAccount() {
return payAccount;
public PayAccountDTO(PayAccount payAccount) {
this.id = payAccount.getId();
this.balance = payAccount.getBalance();
}
}
}

This file was deleted.

50 changes: 16 additions & 34 deletions src/main/java/camp/woowak/lab/vendor/service/dto/VendorDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,17 @@

import java.util.UUID;

import camp.woowak.lab.payaccount.service.dto.PayAccountDTO;
import camp.woowak.lab.payaccount.domain.PayAccount;
import camp.woowak.lab.vendor.domain.Vendor;
import lombok.Getter;

@Getter
public class VendorDTO {
private UUID id;
private String name;
private String email;
private String phone;
private PayAccountDTO payAccount;

public VendorDTO() {
}

public VendorDTO(UUID id, String name, String email, String phone, PayAccountDTO payAccount) {
this.id = id;
this.name = name;
this.email = email;
this.phone = phone;
this.payAccount = payAccount;
}
private final UUID id;
private final String name;
private final String email;
private final String phone;
private final PayAccountDTO payAccount;

public VendorDTO(Vendor vendor) {
this.id = vendor.getId();
Expand All @@ -31,23 +22,14 @@ public VendorDTO(Vendor vendor) {
this.payAccount = new PayAccountDTO(vendor.getPayAccount());
}

public UUID getId() {
return id;
}

public String getName() {
return name;
}

public String getEmail() {
return email;
}

public String getPhone() {
return phone;
}
@Getter
public static class PayAccountDTO {
private final Long id;
private final Long balance;

public PayAccountDTO getPayAccount() {
return payAccount;
public PayAccountDTO(PayAccount payAccount) {
this.id = payAccount.getId();
this.balance = payAccount.getBalance();
}
}
}

0 comments on commit f9b6c80

Please sign in to comment.