| 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;
|
- |
|
| 4 |
import java.util.ArrayList;
|
3 |
import java.util.ArrayList;
|
| 5 |
import java.util.List;
|
4 |
import java.util.List;
|
| 6 |
import java.util.stream.Collectors;
|
5 |
import java.util.stream.Collectors;
|
| 7 |
|
6 |
|
| 8 |
import javax.servlet.http.HttpServletRequest;
|
7 |
import javax.servlet.http.HttpServletRequest;
|
| Line 25... |
Line 24... |
| 25 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
24 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
| 26 |
import com.spice.profitmandi.dao.entity.fofo.Customer;
|
25 |
import com.spice.profitmandi.dao.entity.fofo.Customer;
|
| 27 |
import com.spice.profitmandi.dao.entity.fofo.CustomerAddress;
|
26 |
import com.spice.profitmandi.dao.entity.fofo.CustomerAddress;
|
| 28 |
import com.spice.profitmandi.dao.repository.fofo.CustomerAddressRepository;
|
27 |
import com.spice.profitmandi.dao.repository.fofo.CustomerAddressRepository;
|
| 29 |
import com.spice.profitmandi.dao.repository.fofo.CustomerRepository;
|
28 |
import com.spice.profitmandi.dao.repository.fofo.CustomerRepository;
|
| - |
|
29 |
import com.spice.profitmandi.service.CustomerService;
|
| 30 |
|
30 |
|
| 31 |
@Controller
|
31 |
@Controller
|
| 32 |
@Transactional
|
32 |
@Transactional
|
| 33 |
public class CustomerController {
|
33 |
public class CustomerController {
|
| 34 |
|
34 |
|
| Line 39... |
Line 39... |
| 39 |
|
39 |
|
| 40 |
@Autowired
|
40 |
@Autowired
|
| 41 |
private CustomerRepository customerRepository;
|
41 |
private CustomerRepository customerRepository;
|
| 42 |
|
42 |
|
| 43 |
@Autowired
|
43 |
@Autowired
|
| - |
|
44 |
private CustomerService customerService;
|
| - |
|
45 |
|
| - |
|
46 |
@Autowired
|
| 44 |
private CustomerAddressRepository customerAddressRepository;
|
47 |
private CustomerAddressRepository customerAddressRepository;
|
| 45 |
|
48 |
|
| 46 |
@RequestMapping(value = "/customer/address", method = RequestMethod.POST)
|
49 |
@RequestMapping(value = "/customer/address", method = RequestMethod.POST)
|
| 47 |
public ResponseEntity<?> addAddress(HttpServletRequest request, @RequestParam int customerId,
|
50 |
public ResponseEntity<?> addAddress(HttpServletRequest request, @RequestParam int customerId,
|
| 48 |
@RequestBody CustomAddress customAddress) {
|
51 |
@RequestBody CustomAddress customAddress) {
|
| Line 50... |
Line 53... |
| 50 |
customerAddressRepository.persist(customerAddress);
|
53 |
customerAddressRepository.persist(customerAddress);
|
| 51 |
return responseSender.ok(this.toCustomAddress(customerAddress));
|
54 |
return responseSender.ok(this.toCustomAddress(customerAddress));
|
| 52 |
|
55 |
|
| 53 |
}
|
56 |
}
|
| 54 |
|
57 |
|
| - |
|
58 |
@RequestMapping(value = "/customer/add", method = RequestMethod.POST)
|
| - |
|
59 |
public ResponseEntity<?> addAddress(HttpServletRequest request, @RequestBody CustomCustomer customCustomer) {
|
| - |
|
60 |
Customer customer = new Customer();
|
| - |
|
61 |
customer.setEmailId(customCustomer.getEmailId());
|
| - |
|
62 |
customer.setFirstName(customCustomer.getFirstName());
|
| - |
|
63 |
customer.setLastName(customCustomer.getLastName());
|
| - |
|
64 |
customer.setMobileNumber(customCustomer.getMobileNumber());
|
| - |
|
65 |
customer = customerService.addCustomer(customer);
|
| - |
|
66 |
customCustomer.setCustomerId(customer.getId());
|
| - |
|
67 |
return responseSender.ok(customCustomer);
|
| - |
|
68 |
|
| - |
|
69 |
}
|
| - |
|
70 |
|
| 55 |
@RequestMapping(value = "/customer/mobileNumber", method = RequestMethod.GET)
|
71 |
@RequestMapping(value = "/customer/mobileNumber", method = RequestMethod.GET)
|
| 56 |
public ResponseEntity<?> getCustomerByMobileNumber(HttpServletRequest request,
|
72 |
public ResponseEntity<?> getCustomerByMobileNumber(HttpServletRequest request,
|
| 57 |
@RequestParam(name = ProfitMandiConstants.MOBILE_NUMBER) String mobileNumber)
|
73 |
@RequestParam(name = ProfitMandiConstants.MOBILE_NUMBER) String mobileNumber)
|
| 58 |
throws ProfitMandiBusinessException {
|
74 |
throws ProfitMandiBusinessException {
|
| 59 |
CustomCustomer customCustomer = null;
|
75 |
CustomCustomer customCustomer = null;
|