| Line 105... |
Line 105... |
| 105 |
customCustomer.setEmailId(customer.getEmailId());
|
105 |
customCustomer.setEmailId(customer.getEmailId());
|
| 106 |
customCustomer.setFirstName(customer.getFirstName());
|
106 |
customCustomer.setFirstName(customer.getFirstName());
|
| 107 |
customCustomer.setLastName(customer.getLastName());
|
107 |
customCustomer.setLastName(customer.getLastName());
|
| 108 |
customCustomer.setMobileNumber(customer.getMobileNumber());
|
108 |
customCustomer.setMobileNumber(customer.getMobileNumber());
|
| 109 |
LOGGER.info(customer.getCustomerAddress());
|
109 |
LOGGER.info(customer.getCustomerAddress());
|
| 110 |
List<CustomerAddress> customerAddresses = customer.getCustomerAddress().stream()
|
110 |
List<CustomerAddress> customerAddresses = customer.getCustomerAddress().stream().filter(c -> Boolean.TRUE.equals(c.getActive())).collect(Collectors.toList());
|
| 111 |
.sorted((CustomerAddress c1, CustomerAddress c2) -> {
|
- |
|
| 112 |
return c1.getCreateTimestamp().isBefore(c2.getCreateTimestamp()) ? 1 : -1;
|
- |
|
| 113 |
}).limit(5).collect(Collectors.toList());
|
- |
|
| 114 |
LOGGER.info(customerAddresses);
|
111 |
LOGGER.info(customerAddresses);
|
| 115 |
if (!customerAddresses.isEmpty()) {
|
112 |
if (!customerAddresses.isEmpty()) {
|
| 116 |
List<CustomAddress> customAddresses = new ArrayList<>();
|
113 |
List<CustomAddress> customAddresses = new ArrayList<>();
|
| 117 |
for (CustomerAddress customerAddress : customerAddresses) {
|
114 |
for (CustomerAddress customerAddress : customerAddresses) {
|
| 118 |
customAddresses.add(this.toCustomAddress(customerAddress));
|
115 |
customAddresses.add(this.toCustomAddress(customerAddress));
|
| Line 136... |
Line 133... |
| 136 |
customAddress.setLastName(customerAddress.getLastName());
|
133 |
customAddress.setLastName(customerAddress.getLastName());
|
| 137 |
customAddress.setPhoneNumber(customerAddress.getPhoneNumber());
|
134 |
customAddress.setPhoneNumber(customerAddress.getPhoneNumber());
|
| 138 |
customAddress.setPinCode(customerAddress.getPinCode());
|
135 |
customAddress.setPinCode(customerAddress.getPinCode());
|
| 139 |
customAddress.setState(customerAddress.getState());
|
136 |
customAddress.setState(customerAddress.getState());
|
| 140 |
customAddress.setId(customerAddress.getId());
|
137 |
customAddress.setId(customerAddress.getId());
|
| - |
|
138 |
customAddress.setDefaultAddress(customerAddress.getDefault());
|
| 141 |
return customAddress;
|
139 |
return customAddress;
|
| 142 |
}
|
140 |
}
|
| 143 |
|
141 |
|
| 144 |
@RequestMapping(value = "/customer/add", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
142 |
@RequestMapping(value = "/customer/add", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 145 |
@ApiImplicitParams({
|
143 |
@ApiImplicitParams({
|
| Line 162... |
Line 160... |
| 162 |
|
160 |
|
| 163 |
@RequestMapping(value = "/customer/address", method = RequestMethod.POST)
|
161 |
@RequestMapping(value = "/customer/address", method = RequestMethod.POST)
|
| 164 |
public ResponseEntity<?> addAddress(HttpServletRequest request, @RequestParam int customerId,
|
162 |
public ResponseEntity<?> addAddress(HttpServletRequest request, @RequestParam int customerId,
|
| 165 |
@RequestBody CustomAddress customAddress) {
|
163 |
@RequestBody CustomAddress customAddress) {
|
| 166 |
CustomerAddress customerAddress = this.toCustomerAddress(customerId, customAddress);
|
164 |
CustomerAddress customerAddress = this.toCustomerAddress(customerId, customAddress);
|
| - |
|
165 |
customerAddress.setActive(true);
|
| 167 |
customerAddressRepository.persist(customerAddress);
|
166 |
customerAddressRepository.persist(customerAddress);
|
| 168 |
return responseSender.ok(this.toCustomAddress(customerAddress));
|
167 |
return responseSender.ok(this.toCustomAddress(customerAddress));
|
| 169 |
|
168 |
|
| 170 |
}
|
169 |
}
|
| 171 |
|
170 |
|