Subversion Repositories SmartDukaan

Rev

Rev 26806 | Rev 26817 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 26806 Rev 26807
Line 1... Line 1...
1
package com.spice.profitmandi.web.controller;
1
package com.spice.profitmandi.web.controller;
2
 
2
 
3
import java.time.temporal.ChronoField;
3
import java.time.temporal.ChronoField;
4
import java.util.ArrayList;
4
import java.util.ArrayList;
5
import java.util.List;
5
import java.util.List;
-
 
6
import java.util.stream.Collectors;
6
 
7
 
7
import javax.servlet.http.HttpServletRequest;
8
import javax.servlet.http.HttpServletRequest;
8
 
9
 
9
import org.apache.logging.log4j.LogManager;
10
import org.apache.logging.log4j.LogManager;
10
import org.apache.logging.log4j.Logger;
11
import org.apache.logging.log4j.Logger;
Line 63... Line 64...
63
			customCustomer.setCustomerId(customer.getId());
64
			customCustomer.setCustomerId(customer.getId());
64
			customCustomer.setEmailId(customer.getEmailId());
65
			customCustomer.setEmailId(customer.getEmailId());
65
			customCustomer.setFirstName(customer.getFirstName());
66
			customCustomer.setFirstName(customer.getFirstName());
66
			customCustomer.setLastName(customer.getLastName());
67
			customCustomer.setLastName(customer.getLastName());
67
			customCustomer.setMobileNumber(customer.getMobileNumber());
68
			customCustomer.setMobileNumber(customer.getMobileNumber());
-
 
69
			LOGGER.info(customer.getCustomerAddress());
-
 
70
			List<CustomerAddress> customerAddresses = customer.getCustomerAddress().stream()
68
			customer.getCustomerAddress().stream().sorted((CustomerAddress c1, CustomerAddress c2) -> {
71
					.sorted((CustomerAddress c1, CustomerAddress c2) -> {
69
				return c1.getCreateTimestamp().get(ChronoField.INSTANT_SECONDS)
72
						return c1.getCreateTimestamp().isBefore(c2.getCreateTimestamp()) ? 1 : -1;
70
						- c2.getCreateTimestamp().get(ChronoField.INSTANT_SECONDS);
73
					}).limit(5).collect(Collectors.toList());
71
			}).limit(5);
74
			LOGGER.info(customerAddresses);
72
			if (!customer.getCustomerAddress().isEmpty()) {
75
			if (!customerAddresses.isEmpty()) {
73
				List<CustomAddress> customAddresses = new ArrayList<>();
76
				List<CustomAddress> customAddresses = new ArrayList<>();
74
				for (CustomerAddress customerAddress : customer.getCustomerAddress()) {
77
				for (CustomerAddress customerAddress : customerAddresses) {
75
					customAddresses.add(this.toCustomAddress(customerAddress));
78
					customAddresses.add(this.toCustomAddress(customerAddress));
76
				}
79
				}
77
				customCustomer.setAddresses(customAddresses);
80
				customCustomer.setAddresses(customAddresses);
78
			}
81
			}
79
		} catch (Exception e) {
82
		} catch (Exception e) {
-
 
83
			e.printStackTrace();
80
		}
84
		}
81
		return responseSender.ok(customCustomer);
85
		return responseSender.ok(customCustomer);
82
	}
86
	}
83
 
87
 
84
	private CustomAddress toCustomAddress(CustomerAddress customerAddress) {
88
	private CustomAddress toCustomAddress(CustomerAddress customerAddress) {