| Line 23... |
Line 23... |
| 23 |
import com.spice.profitmandi.common.model.CustomCustomer;
|
23 |
import com.spice.profitmandi.common.model.CustomCustomer;
|
| 24 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
24 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 25 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
25 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
| 26 |
import com.spice.profitmandi.dao.entity.fofo.Customer;
|
26 |
import com.spice.profitmandi.dao.entity.fofo.Customer;
|
| 27 |
import com.spice.profitmandi.dao.entity.fofo.CustomerAddress;
|
27 |
import com.spice.profitmandi.dao.entity.fofo.CustomerAddress;
|
| - |
|
28 |
import com.spice.profitmandi.dao.repository.catalog.CustomerOfferRepository;
|
| 28 |
import com.spice.profitmandi.dao.repository.fofo.CustomerAddressRepository;
|
29 |
import com.spice.profitmandi.dao.repository.fofo.CustomerAddressRepository;
|
| 29 |
import com.spice.profitmandi.dao.repository.fofo.CustomerRepository;
|
30 |
import com.spice.profitmandi.dao.repository.fofo.CustomerRepository;
|
| 30 |
import com.spice.profitmandi.service.CustomerService;
|
31 |
import com.spice.profitmandi.service.CustomerService;
|
| 31 |
|
32 |
|
| 32 |
@Controller
|
33 |
@Controller
|
| Line 54... |
Line 55... |
| 54 |
customerAddressRepository.persist(customerAddress);
|
55 |
customerAddressRepository.persist(customerAddress);
|
| 55 |
return responseSender.ok(this.toCustomAddress(customerAddress));
|
56 |
return responseSender.ok(this.toCustomAddress(customerAddress));
|
| 56 |
|
57 |
|
| 57 |
}
|
58 |
}
|
| 58 |
|
59 |
|
| - |
|
60 |
@RequestMapping(value = "/customer/update/address", method = RequestMethod.POST)
|
| - |
|
61 |
public ResponseEntity<?> updateAddress(HttpServletRequest request, @RequestBody CustomAddress customAddress)
|
| - |
|
62 |
throws ProfitMandiBusinessException {
|
| - |
|
63 |
CustomerAddress customerAddress = customerAddressRepository.selectById(customAddress.getId());
|
| - |
|
64 |
|
| - |
|
65 |
customerAddress.setCity(customAddress.getCity());
|
| - |
|
66 |
customerAddress.setCountry(customAddress.getCountry());
|
| - |
|
67 |
customerAddress.setLandmark(customAddress.getLandmark());
|
| - |
|
68 |
customerAddress.setLine1(customAddress.getLine1());
|
| - |
|
69 |
customerAddress.setLine2(customAddress.getLine2());
|
| - |
|
70 |
customerAddress.setName(customAddress.getName());
|
| - |
|
71 |
customerAddress.setLastName(customAddress.getLastName());
|
| - |
|
72 |
customerAddress.setPhoneNumber(customAddress.getPhoneNumber());
|
| - |
|
73 |
customerAddress.setPinCode(customAddress.getPinCode());
|
| - |
|
74 |
customerAddress.setState(customAddress.getState());
|
| - |
|
75 |
return responseSender.ok(this.toCustomAddress(customerAddress));
|
| - |
|
76 |
|
| - |
|
77 |
}
|
| - |
|
78 |
|
| 59 |
@RequestMapping(value = "/customer/add", method = RequestMethod.POST)
|
79 |
@RequestMapping(value = "/customer/add", method = RequestMethod.POST)
|
| 60 |
public ResponseEntity<?> addCustomer(HttpServletRequest request, @RequestBody CustomCustomer customCustomer) throws ProfitMandiBusinessException {
|
80 |
public ResponseEntity<?> addCustomer(HttpServletRequest request, @RequestBody CustomCustomer customCustomer)
|
| - |
|
81 |
throws ProfitMandiBusinessException {
|
| 61 |
Customer customer = new Customer();
|
82 |
Customer customer = new Customer();
|
| 62 |
if(StringUtils.isEmpty(customCustomer.getFirstName())) {
|
83 |
if (StringUtils.isEmpty(customCustomer.getFirstName())) {
|
| 63 |
throw new ProfitMandiBusinessException("First Name", "Empty", "First Name required");
|
84 |
throw new ProfitMandiBusinessException("First Name", "Empty", "First Name required");
|
| 64 |
}
|
85 |
}
|
| 65 |
customer.setEmailId(customCustomer.getEmailId());
|
86 |
customer.setEmailId(customCustomer.getEmailId());
|
| 66 |
customer.setFirstName(customCustomer.getFirstName());
|
87 |
customer.setFirstName(customCustomer.getFirstName());
|
| 67 |
customer.setLastName(customCustomer.getLastName());
|
88 |
customer.setLastName(customCustomer.getLastName());
|
| Line 69... |
Line 90... |
| 69 |
customer = customerService.addCustomer(customer);
|
90 |
customer = customerService.addCustomer(customer);
|
| 70 |
customCustomer.setCustomerId(customer.getId());
|
91 |
customCustomer.setCustomerId(customer.getId());
|
| 71 |
return responseSender.ok(customCustomer);
|
92 |
return responseSender.ok(customCustomer);
|
| 72 |
|
93 |
|
| 73 |
}
|
94 |
}
|
| - |
|
95 |
|
| 74 |
@RequestMapping(value = "/customer/add-email", method = RequestMethod.POST)
|
96 |
@RequestMapping(value = "/customer/add-email", method = RequestMethod.POST)
|
| 75 |
public ResponseEntity<?> addEmail(HttpServletRequest request, @RequestBody CustomCustomer customCustomer) throws ProfitMandiBusinessException {
|
97 |
public ResponseEntity<?> addEmail(HttpServletRequest request, @RequestBody CustomCustomer customCustomer)
|
| - |
|
98 |
throws ProfitMandiBusinessException {
|
| 76 |
String emailId = customCustomer.getEmailId();
|
99 |
String emailId = customCustomer.getEmailId();
|
| 77 |
int customerId = customCustomer.getCustomerId();
|
100 |
int customerId = customCustomer.getCustomerId();
|
| 78 |
Customer customer = customerRepository.selectById(customerId);
|
101 |
Customer customer = customerRepository.selectById(customerId);
|
| 79 |
customer.setEmailId(emailId);
|
102 |
customer.setEmailId(emailId);
|
| 80 |
return this.getCustomerByMobileNumber(request, customer.getMobileNumber());
|
103 |
return this.getCustomerByMobileNumber(request, customer.getMobileNumber());
|
| 81 |
|
104 |
|
| 82 |
}
|
105 |
}
|
| 83 |
|
106 |
|
| 84 |
@RequestMapping(value = "/customer/mobileNumber", method = RequestMethod.GET)
|
107 |
@RequestMapping(value = "/customer/mobileNumber", method = RequestMethod.GET)
|
| 85 |
public ResponseEntity<?> getCustomerByMobileNumber(HttpServletRequest request,
|
108 |
public ResponseEntity<?> getCustomerByMobileNumber(HttpServletRequest request,
|
| 86 |
@RequestParam(name = ProfitMandiConstants.MOBILE_NUMBER) String mobileNumber)
|
109 |
@RequestParam(name = ProfitMandiConstants.MOBILE_NUMBER) String mobileNumber)
|