Subversion Repositories SmartDukaan

Rev

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

Rev 26783 Rev 26784
Line 67... Line 67...
67
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
67
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
68
import com.spice.profitmandi.dao.repository.fofo.CustomerRepository;
68
import com.spice.profitmandi.dao.repository.fofo.CustomerRepository;
69
import com.spice.profitmandi.dao.repository.fofo.PendingOrderService;
69
import com.spice.profitmandi.dao.repository.fofo.PendingOrderService;
70
import com.spice.profitmandi.dao.repository.fofo.PincodePartnerRepository;
70
import com.spice.profitmandi.dao.repository.fofo.PincodePartnerRepository;
71
import com.spice.profitmandi.dao.repository.inventory.ItemAvailabilityCacheRepository;
71
import com.spice.profitmandi.dao.repository.inventory.ItemAvailabilityCacheRepository;
-
 
72
import com.spice.profitmandi.service.CustomerService;
72
import com.spice.profitmandi.service.authentication.RoleManager;
73
import com.spice.profitmandi.service.authentication.RoleManager;
73
import com.spice.profitmandi.service.inventory.FofoAvailabilityInfo;
74
import com.spice.profitmandi.service.inventory.FofoAvailabilityInfo;
74
import com.spice.profitmandi.service.inventory.FofoCatalogResponse;
75
import com.spice.profitmandi.service.inventory.FofoCatalogResponse;
75
import com.spice.profitmandi.service.scheme.SchemeService;
76
import com.spice.profitmandi.service.scheme.SchemeService;
76
import com.spice.profitmandi.service.user.RetailerService;
77
import com.spice.profitmandi.service.user.RetailerService;
Line 96... Line 97...
96
 
97
 
97
	private static final int DEFAULT_STORE = 171912487;
98
	private static final int DEFAULT_STORE = 171912487;
98
 
99
 
99
	@Value("${python.api.host}")
100
	@Value("${python.api.host}")
100
	private String host;
101
	private String host;
-
 
102
	
-
 
103
	@Autowired
-
 
104
	CustomerService customerService;
101
 
105
 
102
	@Value("${python.api.port}")
106
	@Value("${python.api.port}")
103
	private int port;
107
	private int port;
104
 
108
 
105
	// This is now unused as we are not supporting multiple companies.
109
	// This is now unused as we are not supporting multiple companies.
Line 349... Line 353...
349
 
353
 
350
		return responseSender.ok(otpProcessor.generateOtp(mobile, OtpType.PREBOOKING_ORDER));
354
		return responseSender.ok(otpProcessor.generateOtp(mobile, OtpType.PREBOOKING_ORDER));
351
 
355
 
352
	}
356
	}
353
 
357
 
354
	@RequestMapping(value = "/store/login/{mobile}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
358
	@RequestMapping(value = "/store/checkmobile/{mobile}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
355
	public ResponseEntity<?> checkRegistrationUsingMobile(HttpServletRequest request, @PathVariable String mobile) throws Exception {
359
	public ResponseEntity<?> checkRegistrationUsingMobile(HttpServletRequest request, @PathVariable String mobile) throws Exception {
356
		try {
360
		try {
357
			Customer customer = customerRepository.selectByMobileNumber(mobile);
361
			Customer customer = customerRepository.selectByMobileNumber(mobile);
358
			customer.setPasswordExist(StringUtils.isNotEmpty(customer.getPassword()));
362
			customer.setPasswordExist(StringUtils.isNotEmpty(customer.getPassword()));
359
			return responseSender.ok(new CustomerModel(true, customer));
363
			return responseSender.ok(new CustomerModel(true, customer));
360
		} catch (Exception e) {
364
		} catch (Exception e) {
361
			return responseSender.ok(new CustomerModel(false, null));
365
			return responseSender.ok(new CustomerModel(false, null));
362
		}
366
		}
363
	}
367
	}
-
 
368
	
-
 
369
	@RequestMapping(value = "/store/signin", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
-
 
370
	public ResponseEntity<?> signIn(HttpServletRequest request, @RequestBody UserModel userModel) throws Exception {
-
 
371
		if(customerService.authenticate(userModel.getMobile(), userModel.getPassword())) {
-
 
372
			return responseSender.ok(true);
-
 
373
		} else {
-
 
374
			return responseSender.ok(false);
-
 
375
		}
-
 
376
	}
364
 
377
 
365
	@RequestMapping(value = "/store/confirmOrder", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
378
	@RequestMapping(value = "/store/confirmOrder", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
366
	public ResponseEntity<?> confirmCart(HttpServletRequest request,
379
	public ResponseEntity<?> confirmCart(HttpServletRequest request,
367
			@RequestBody CreatePendingOrderRequest createPendingOrderRequest) throws Exception {
380
			@RequestBody CreatePendingOrderRequest createPendingOrderRequest) throws Exception {
368
		UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
381
		UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
Line 627... Line 640...
627
		return dealResponse;
640
		return dealResponse;
628
	}
641
	}
629
 
642
 
630
}
643
}
631
 
644
 
-
 
645
class UserModel {
-
 
646
	private String mobile;
-
 
647
	private String password;
-
 
648
	@Override
-
 
649
	public String toString() {
-
 
650
		return "UserModel [mobile=" + mobile + ", password=" + password + "]";
-
 
651
	}
-
 
652
	public String getMobile() {
-
 
653
		return mobile;
-
 
654
	}
-
 
655
	public void setMobile(String mobile) {
-
 
656
		this.mobile = mobile;
-
 
657
	}
-
 
658
	public String getPassword() {
-
 
659
		return password;
-
 
660
	}
-
 
661
	public void setPassword(String password) {
-
 
662
		this.password = password;
-
 
663
	}
-
 
664
	
-
 
665
	
-
 
666
}
-
 
667
 
632
class CustomerModel {
668
class CustomerModel {
633
 
669
 
634
	@JsonProperty(required = false)
670
	@JsonProperty(required = false)
635
	private Customer customer;
671
	private Customer customer;
636
	@JsonProperty(required = true)
672
	@JsonProperty(required = true)