Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 2 additions & 64 deletions account-service/src/main/java/demo/address/Address.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
@Entity
public class Address extends BaseEntity {

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String street1;
private String street2;
Expand All @@ -39,71 +41,7 @@ public Address(String street1, String street2, String state,
this.zipCode = zipCode;
}

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
public Long getId() {
return id;
}

public void setId(Long id) {
this.id = id;
}

public String getStreet1() {
return street1;
}

public void setStreet1(String street1) {
this.street1 = street1;
}

public String getStreet2() {
return street2;
}

public void setStreet2(String street2) {
this.street2 = street2;
}

public String getState() {
return state;
}

public void setState(String state) {
this.state = state;
}

public String getCity() {
return city;
}

public void setCity(String city) {
this.city = city;
}

public String getCountry() {
return country;
}

public void setCountry(String country) {
this.country = country;
}

public AddressType getAddressType() {
return addressType;
}

public void setAddressType(AddressType addressType) {
this.addressType = addressType;
}

public Integer getZipCode() {
return zipCode;
}

public void setZipCode(Integer zipCode) {
this.zipCode = zipCode;
}

@Override
public String toString() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,8 @@
@RequestMapping(path = "/v1")
public class AccountControllerV1 {

private AccountServiceV1 accountService;

@Autowired
public AccountControllerV1(AccountServiceV1 accountService) {
this.accountService = accountService;
}
private AccountServiceV1 accountService;

@RequestMapping(path = "/accounts")
public ResponseEntity getUserAccount() throws Exception {
Expand Down
15 changes: 4 additions & 11 deletions account-service/src/main/java/demo/api/v1/AccountServiceV1.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,22 @@
import demo.account.Account;
import demo.account.AccountRepository;
import demo.user.User;
import demo.user.UserClientV1;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.security.oauth2.client.OAuth2RestTemplate;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AccountServiceV1 {

@Autowired
private AccountRepository accountRepository;
private OAuth2RestTemplate oAuth2RestTemplate;

@Autowired
public AccountServiceV1(AccountRepository accountRepository,
@LoadBalanced OAuth2RestTemplate oAuth2RestTemplate) {
this.accountRepository = accountRepository;
this.oAuth2RestTemplate = oAuth2RestTemplate;
}
UserClientV1 userClientV1;

public List<Account> getUserAccounts() {
List<Account> account = null;
User user = oAuth2RestTemplate.getForObject("http://user-service/uaa/v1/me", User.class);
User user = userClientV1.getAuthenticatedUser();
if (user != null) {
account = accountRepository.findAccountsByUserId(user.getUsername());
}
Expand Down