Subversion Repositories SmartDukaan

Rev

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

Rev 26817 Rev 26833
Line 96... Line 96...
96
	private static final LocalTime CUTOFF_TIME = LocalTime.of(15, 0);
96
	private static final LocalTime CUTOFF_TIME = LocalTime.of(15, 0);
97
 
97
 
98
	private static final List<Integer> TAG_IDS = Arrays.asList(4);
98
	private static final List<Integer> TAG_IDS = Arrays.asList(4);
99
 
99
 
100
	private static final int DEFAULT_STORE = 171912487;
100
	private static final int DEFAULT_STORE = 171912487;
101
	
101
 
102
	@Autowired
102
	@Autowired
103
	CustomerAddressRepository customerAddressRepository;
103
	CustomerAddressRepository customerAddressRepository;
104
 
104
 
105
	@Value("${python.api.host}")
105
	@Value("${python.api.host}")
106
	private String host;
106
	private String host;
107
	
107
 
108
	@Autowired
108
	@Autowired
109
	CustomerService customerService;
109
	CustomerService customerService;
110
 
110
 
111
	@Value("${python.api.port}")
111
	@Value("${python.api.port}")
112
	private int port;
112
	private int port;
Line 354... Line 354...
354
	}
354
	}
355
 
355
 
356
	@RequestMapping(value = "/store/otp/generateOTP", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
356
	@RequestMapping(value = "/store/otp/generateOTP", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
357
	public ResponseEntity<?> generateOtp(HttpServletRequest request, @RequestParam String mobile) throws Exception {
357
	public ResponseEntity<?> generateOtp(HttpServletRequest request, @RequestParam String mobile) throws Exception {
358
 
358
 
359
		return responseSender.ok(otpProcessor.generateOtp(mobile, OtpType.PREBOOKING_ORDER));
359
		return responseSender.ok(otpProcessor.generateOtp(mobile, OtpType.REGISTRATION));
360
 
360
 
361
	}
361
	}
362
 
362
 
363
	@RequestMapping(value = "/store/checkmobile/{mobile}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
363
	@RequestMapping(value = "/store/checkmobile/{mobile}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
364
	public ResponseEntity<?> checkRegistrationUsingMobile(HttpServletRequest request, @PathVariable String mobile) throws Exception {
364
	public ResponseEntity<?> checkRegistrationUsingMobile(HttpServletRequest request, @PathVariable String mobile)
-
 
365
			throws Exception {
365
		try {
366
		try {
366
			Customer customer = customerRepository.selectByMobileNumber(mobile);
367
			Customer customer = customerRepository.selectByMobileNumber(mobile);
367
			customer.setPasswordExist(StringUtils.isNotEmpty(customer.getPassword()));
368
			customer.setPasswordExist(StringUtils.isNotEmpty(customer.getPassword()));
368
			return responseSender.ok(new CustomerModel(true, customer));
369
			return responseSender.ok(new CustomerModel(true, customer));
369
		} catch (Exception e) {
370
		} catch (Exception e) {
370
			return responseSender.ok(new CustomerModel(false, null));
371
			return responseSender.ok(new CustomerModel(false, null));
371
		}
372
		}
372
	}
373
	}
373
	
374
 
374
	@RequestMapping(value = "/store/signin", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
375
	@RequestMapping(value = "/store/signin", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
375
	public ResponseEntity<?> signIn(HttpServletRequest request, @RequestBody UserModel userModel) throws Exception {
376
	public ResponseEntity<?> signIn(HttpServletRequest request, @RequestBody UserModel userModel) throws Exception {
376
		if(customerService.authenticate(userModel.getMobile(), userModel.getPassword())) {
377
		if (customerService.authenticate(userModel.getMobile(), userModel.getPassword())) {
377
			return responseSender.ok(true);
378
			return responseSender.ok(true);
378
		} else {
379
		} else {
379
			return responseSender.ok(false);
380
			return responseSender.ok(false);
380
		}
381
		}
381
	}
382
	}
382
 
383
 
-
 
384
	@RequestMapping(value = "/store/register", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
-
 
385
	public ResponseEntity<?> register(HttpServletRequest request, @RequestBody UserModel userModel) throws Exception {
-
 
386
		Customer customer = new Customer();
-
 
387
		customer.setPassword(userModel.getPassword());
-
 
388
		customer.setEmailId(userModel.getEmail());
-
 
389
		customer.setFirstName(userModel.getFirstName());
-
 
390
		customer.setLastName(userModel.getLastName());
-
 
391
		return responseSender.ok(customerService.addCustomer(customer));
-
 
392
	}
-
 
393
 
383
	@RequestMapping(value = "/store/confirmOrder", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
394
	@RequestMapping(value = "/store/confirmOrder", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
384
	public ResponseEntity<?> confirmCart(HttpServletRequest request,
395
	public ResponseEntity<?> confirmCart(HttpServletRequest request,
385
			@RequestBody CreatePendingOrderRequest createPendingOrderRequest) throws Exception {
396
			@RequestBody CreatePendingOrderRequest createPendingOrderRequest) throws Exception {
386
		UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
397
		UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
387
		Integer storeId = userInfo.getRetailerId();
398
		Integer storeId = userInfo.getRetailerId();
Line 642... Line 653...
642
				dealResponse.add(ffdr);
653
				dealResponse.add(ffdr);
643
			}
654
			}
644
		}
655
		}
645
		return dealResponse;
656
		return dealResponse;
646
	}
657
	}
647
	
-
 
648
 
658
 
649
	@RequestMapping(value = "/store/addresses/{customerId}", method=RequestMethod.GET)
659
	@RequestMapping(value = "/store/addresses/{customerId}", method = RequestMethod.GET)
650
	public ResponseEntity<?> getAll(HttpServletRequest request, @PathVariable int customerId) throws Throwable{
660
	public ResponseEntity<?> getAll(HttpServletRequest request, @PathVariable int customerId) throws Throwable {
651
		return responseSender.ok(customerAddressRepository.selectByCustomerId(customerId));
661
		return responseSender.ok(customerAddressRepository.selectByCustomerId(customerId));
652
	}
662
	}
653
	
-
 
654
	
663
 
655
	@RequestMapping(value = "/store/address", method=RequestMethod.POST)
664
	@RequestMapping(value = "/store/address", method = RequestMethod.POST)
656
	public ResponseEntity<?> addAddress(HttpServletRequest request, @RequestBody CustomerAddress customerAddress) throws Throwable{
665
	public ResponseEntity<?> addAddress(HttpServletRequest request, @RequestBody CustomerAddress customerAddress)
-
 
666
			throws Throwable {
657
		customerAddressRepository.persist(customerAddress);
667
		customerAddressRepository.persist(customerAddress);
658
		return responseSender.ok(customerAddress);
668
		return responseSender.ok(customerAddress);
659
	}
669
	}
660
 
670
 
661
}
671
}
662
 
672
 
663
class UserModel {
673
class UserModel {
-
 
674
	@JsonProperty(required = true)
664
	private String mobile;
675
	private String mobile;
-
 
676
	@JsonProperty(required = true)
665
	private String password;
677
	private String password;
-
 
678
	@JsonProperty(required = false)
-
 
679
	private String firstName;
-
 
680
	@JsonProperty(required = false)
-
 
681
	private String lastName;
-
 
682
	@JsonProperty(required = false)
-
 
683
	private String email;
-
 
684
 
666
	@Override
685
	@Override
667
	public String toString() {
686
	public String toString() {
668
		return "UserModel [mobile=" + mobile + ", password=" + password + "]";
687
		return "UserModel [mobile=" + mobile + ", password=" + password + "]";
669
	}
688
	}
-
 
689
 
670
	public String getMobile() {
690
	public String getMobile() {
671
		return mobile;
691
		return mobile;
672
	}
692
	}
-
 
693
 
673
	public void setMobile(String mobile) {
694
	public void setMobile(String mobile) {
674
		this.mobile = mobile;
695
		this.mobile = mobile;
675
	}
696
	}
-
 
697
 
676
	public String getPassword() {
698
	public String getPassword() {
677
		return password;
699
		return password;
678
	}
700
	}
-
 
701
 
679
	public void setPassword(String password) {
702
	public void setPassword(String password) {
680
		this.password = password;
703
		this.password = password;
681
	}
704
	}
-
 
705
 
-
 
706
	public String getFirstName() {
-
 
707
		return firstName;
-
 
708
	}
-
 
709
 
-
 
710
	public void setFirstName(String firstName) {
-
 
711
		this.firstName = firstName;
-
 
712
	}
-
 
713
 
-
 
714
	public String getLastName() {
-
 
715
		return lastName;
-
 
716
	}
-
 
717
 
-
 
718
	public void setLastName(String lastName) {
-
 
719
		this.lastName = lastName;
-
 
720
	}
-
 
721
 
-
 
722
	public String getEmail() {
-
 
723
		return email;
-
 
724
	}
-
 
725
 
-
 
726
	public void setEmail(String email) {
-
 
727
		this.email = email;
-
 
728
	}
-
 
729
 
682
}
730
}
683
 
731
 
684
class CustomerModel {
732
class CustomerModel {
685
 
733
 
686
	@JsonProperty(required = false)
734
	@JsonProperty(required = false)