Subversion Repositories SmartDukaan

Rev

Rev 35435 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 35435 Rev 35458
Line 163... Line 163...
163
        String email = loginRequest.getEmail() != null ? loginRequest.getEmail() : googleLoginProcessor.process(loginRequest.getToken());
163
        String email = loginRequest.getEmail() != null ? loginRequest.getEmail() : googleLoginProcessor.process(loginRequest.getToken());
164
        return responseSender.ok(getAuthTokenMap(email, loginRequest));
164
        return responseSender.ok(getAuthTokenMap(email, loginRequest));
165
    }
165
    }
166
 
166
 
167
    @RequestMapping(value = "/user/token/unregistered", method = RequestMethod.GET)
167
    @RequestMapping(value = "/user/token/unregistered", method = RequestMethod.GET)
168
    @Transactional(readOnly = true)
-
 
169
    public ResponseEntity<?> unregisteredToken() throws Exception {
168
    public ResponseEntity<?> unregisteredToken() throws Exception {
170
        Map<String, Object> responseMap = new HashMap<>();
169
        Map<String, Object> responseMap = new HashMap<>();
171
        responseMap.put(ProfitMandiConstants.TOKEN, jwtUtil.create());
170
        responseMap.put(ProfitMandiConstants.TOKEN, jwtUtil.create());
172
        responseMap.put(ProfitMandiConstants.REGISTERED, false);
171
        responseMap.put(ProfitMandiConstants.REGISTERED, false);
173
        return responseSender.ok(responseMap);
172
        return responseSender.ok(responseMap);
174
    }
173
    }
175
 
174
 
176
    @RequestMapping(value = ProfitMandiConstants.URL_B2B_APP_VERSION, method = RequestMethod.GET)
175
    @RequestMapping(value = ProfitMandiConstants.URL_B2B_APP_VERSION, method = RequestMethod.GET)
177
    @Transactional(readOnly = true)
-
 
178
    public ResponseEntity<?> checkForUpdate(HttpServletRequest request, @RequestParam int version) {
176
    public ResponseEntity<?> checkForUpdate(HttpServletRequest request, @RequestParam int version) {
179
        Map<String, Object> responseMap = new HashMap<>();
177
        Map<String, Object> responseMap = new HashMap<>();
180
        responseMap.put("appVersion", ProfitMandiConstants.B2B_APP_VERSION);
178
        responseMap.put("appVersion", ProfitMandiConstants.B2B_APP_VERSION);
181
        responseMap.put("appUrl", ProfitMandiConstants.B2B_APP_URL);
179
        responseMap.put("appUrl", ProfitMandiConstants.B2B_APP_URL);
182
        if (version == ProfitMandiConstants.B2B_APP_VERSION) {
180
        if (version == ProfitMandiConstants.B2B_APP_VERSION) {
Line 268... Line 266...
268
 
266
 
269
        return responseMap;
267
        return responseMap;
270
    }
268
    }
271
 
269
 
272
    @RequestMapping(value = "/store/token/{storeCode}", method = RequestMethod.GET)
270
    @RequestMapping(value = "/store/token/{storeCode}", method = RequestMethod.GET)
273
    @Transactional(readOnly = true)
-
 
274
    public ResponseEntity<?> googleLogin(HttpServletRequest request, @PathVariable String storeCode)
271
    public ResponseEntity<?> googleLogin(HttpServletRequest request, @PathVariable String storeCode)
275
            throws ProfitMandiBusinessException {
272
            throws ProfitMandiBusinessException {
276
        LOGGER.info("StoreCode {}", storeCode);
273
        LOGGER.info("StoreCode {}", storeCode);
277
        return responseSender.ok(googleLoginProcessor.processStore(storeCode));
274
        return responseSender.ok(googleLoginProcessor.processStore(storeCode));
278
    }
275
    }
Line 292... Line 289...
292
        }
289
        }
293
        return responseSender.ok(false);
290
        return responseSender.ok(false);
294
    }
291
    }
295
 
292
 
296
    @RequestMapping(value = ProfitMandiConstants.URL_USER_TOKEN_IS_EXPIRED, method = RequestMethod.GET)
293
    @RequestMapping(value = ProfitMandiConstants.URL_USER_TOKEN_IS_EXPIRED, method = RequestMethod.GET)
297
    @Transactional(readOnly = true)
-
 
298
    public ResponseEntity<?> tokenIsExpired(HttpServletRequest request, @RequestParam(name = "token") String token)
294
    public ResponseEntity<?> tokenIsExpired(HttpServletRequest request, @RequestParam(name = "token") String token)
299
            throws ProfitMandiBusinessException {
295
            throws ProfitMandiBusinessException {
300
        LOGGER.info("requested url : " + request.getRequestURL().toString());
296
        LOGGER.info("requested url : " + request.getRequestURL().toString());
301
        return responseSender.ok(jwtUtil.isExpired(token));
297
        return responseSender.ok(jwtUtil.isExpired(token));
302
    }
298
    }
303
 
299
 
304
        @RequestMapping(value = ProfitMandiConstants.URL_USER_DETAIL_BY_TOKEN, method = RequestMethod.GET)
300
        @RequestMapping(value = ProfitMandiConstants.URL_USER_DETAIL_BY_TOKEN, method = RequestMethod.GET)
305
    @ApiImplicitParams({
301
    @ApiImplicitParams({
306
            @ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
302
            @ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
307
    @Transactional(readOnly = true)
-
 
308
    public ResponseEntity<?> tokenInfo(HttpServletRequest request) throws Throwable {
303
    public ResponseEntity<?> tokenInfo(HttpServletRequest request) throws Throwable {
309
        Map<String, Object> responseMap = new HashMap<>();
304
        Map<String, Object> responseMap = new HashMap<>();
310
        UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
305
        UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
311
        LOGGER.info("userinfo1 {}", userInfo);
306
        LOGGER.info("userinfo1 {}", userInfo);
312
 
307
 
Line 482... Line 477...
482
        return responseSender.ok(ResponseCodeHolder.getMessage("USR_OK_1000"));
477
        return responseSender.ok(ResponseCodeHolder.getMessage("USR_OK_1000"));
483
 
478
 
484
    }
479
    }
485
 
480
 
486
    @RequestMapping(value = ProfitMandiConstants.URL_USER_ID, method = RequestMethod.GET)
481
    @RequestMapping(value = ProfitMandiConstants.URL_USER_ID, method = RequestMethod.GET)
487
    @Transactional(readOnly = true)
-
 
488
    public ResponseEntity<?> getById(HttpServletRequest request, @RequestParam(name = "id") int id)
482
    public ResponseEntity<?> getById(HttpServletRequest request, @RequestParam(name = "id") int id)
489
            throws ProfitMandiBusinessException {
483
            throws ProfitMandiBusinessException {
490
        LOGGER.info("requested url : " + request.getRequestURL().toString());
484
        LOGGER.info("requested url : " + request.getRequestURL().toString());
491
        return responseSender.ok(userRepository.selectById(id));
485
        return responseSender.ok(userRepository.selectById(id));
492
    }
486
    }
493
 
487
 
494
    @RequestMapping(value = ProfitMandiConstants.URL_USER_MOBILE_NUMBER, method = RequestMethod.GET)
488
    @RequestMapping(value = ProfitMandiConstants.URL_USER_MOBILE_NUMBER, method = RequestMethod.GET)
495
    @Transactional(readOnly = true)
-
 
496
    public ResponseEntity<?> getByMobileNumber(HttpServletRequest request,
489
    public ResponseEntity<?> getByMobileNumber(HttpServletRequest request,
497
                                               @RequestParam(name = "mobileNumber") String mobileNumber) throws ProfitMandiBusinessException {
490
                                               @RequestParam(name = "mobileNumber") String mobileNumber) throws ProfitMandiBusinessException {
498
        LOGGER.info("requested url : " + request.getRequestURL().toString());
491
        LOGGER.info("requested url : " + request.getRequestURL().toString());
499
        return responseSender.ok(userRepository.selectByMobileNumber(mobileNumber));
492
        return responseSender.ok(userRepository.selectByMobileNumber(mobileNumber));
500
    }
493
    }
Line 549... Line 542...
549
     * n.getStatus().equals("referrer") || n.getStatus().equals("seen")) {
542
     * n.getStatus().equals("referrer") || n.getStatus().equals("seen")) {
550
     * n.setSeen(true); } return n; }
543
     * n.setSeen(true); } return n; }
551
     */
544
     */
552
 
545
 
553
    @RequestMapping(value = ProfitMandiConstants.URL_USER_IS_EXIST_MOBILE_NUMBER, method = RequestMethod.GET)
546
    @RequestMapping(value = ProfitMandiConstants.URL_USER_IS_EXIST_MOBILE_NUMBER, method = RequestMethod.GET)
554
    @Transactional(readOnly = true)
-
 
555
    public ResponseEntity<?> isMobileNumberExist(HttpServletRequest request,
547
    public ResponseEntity<?> isMobileNumberExist(HttpServletRequest request,
556
                                                 @RequestParam(name = "mobileNumber") String mobileNumber) {
548
                                                 @RequestParam(name = "mobileNumber") String mobileNumber) {
557
        LOGGER.info("requested url : " + request.getRequestURL().toString());
549
        LOGGER.info("requested url : " + request.getRequestURL().toString());
558
        return responseSender.ok(userRepository.isExistByMobileNumber(mobileNumber));
550
        return responseSender.ok(userRepository.isExistByMobileNumber(mobileNumber));
559
    }
551
    }
560
 
552
 
561
    @RequestMapping(value = ProfitMandiConstants.URL_USER_EMAIL_ID, method = RequestMethod.GET)
553
    @RequestMapping(value = ProfitMandiConstants.URL_USER_EMAIL_ID, method = RequestMethod.GET)
562
    @Transactional(readOnly = true)
-
 
563
    public ResponseEntity<?> getByEmailId(HttpServletRequest request, @RequestParam(name = "emailId") String emailId)
554
    public ResponseEntity<?> getByEmailId(HttpServletRequest request, @RequestParam(name = "emailId") String emailId)
564
            throws ProfitMandiBusinessException {
555
            throws ProfitMandiBusinessException {
565
        LOGGER.info("requested url : " + request.getRequestURL().toString());
556
        LOGGER.info("requested url : " + request.getRequestURL().toString());
566
        User user = null;
557
        User user = null;
567
        try {
558
        try {
Line 571... Line 562...
571
        }
562
        }
572
        return responseSender.ok(user);
563
        return responseSender.ok(user);
573
    }
564
    }
574
 
565
 
575
    @RequestMapping(value = ProfitMandiConstants.URL_USER_ROLE_ALL, method = RequestMethod.GET)
566
    @RequestMapping(value = ProfitMandiConstants.URL_USER_ROLE_ALL, method = RequestMethod.GET)
576
    @Transactional(readOnly = true)
-
 
577
    public ResponseEntity<?> getAllRoles(HttpServletRequest request, @RequestParam(name = "id") int id) {
567
    public ResponseEntity<?> getAllRoles(HttpServletRequest request, @RequestParam(name = "id") int id) {
578
        LOGGER.info("requested url : " + request.getRequestURL().toString());
568
        LOGGER.info("requested url : " + request.getRequestURL().toString());
579
        return responseSender.ok(userRoleRepository.selectRolesByUserId(id));
569
        return responseSender.ok(userRoleRepository.selectRolesByUserId(id));
580
    }
570
    }
581
 
571
 
582
    @ApiImplicitParams({
572
    @ApiImplicitParams({
583
            @ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
573
            @ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
584
    @RequestMapping(value = ProfitMandiConstants.URL_USER_SECONDRY_EMAIL_ID_AND_FOFO_STORE_CODE, method = RequestMethod.GET)
574
    @RequestMapping(value = ProfitMandiConstants.URL_USER_SECONDRY_EMAIL_ID_AND_FOFO_STORE_CODE, method = RequestMethod.GET)
585
    @Transactional(readOnly = true)
-
 
586
    public ResponseEntity<?> getSecondryEmailAndStoreCode(HttpServletRequest request)
575
    public ResponseEntity<?> getSecondryEmailAndStoreCode(HttpServletRequest request)
587
            throws ProfitMandiBusinessException {
576
            throws ProfitMandiBusinessException {
588
        LOGGER.info("requested url : " + request.getRequestURL().toString());
577
        LOGGER.info("requested url : " + request.getRequestURL().toString());
589
        int userId = (int) request.getAttribute(ProfitMandiConstants.USER_ID);
578
        int userId = (int) request.getAttribute(ProfitMandiConstants.USER_ID);
590
        return responseSender.ok(userService.getEmailsAndFofoStoreCodeByUserId(userId));
579
        return responseSender.ok(userService.getEmailsAndFofoStoreCodeByUserId(userId));
Line 633... Line 622...
633
    }
622
    }
634
 
623
 
635
    @RequestMapping(value = "/getPartners", method = RequestMethod.GET)
624
    @RequestMapping(value = "/getPartners", method = RequestMethod.GET)
636
    @ApiImplicitParams({
625
    @ApiImplicitParams({
637
            @ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
626
            @ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
638
    @Transactional(readOnly = true)
-
 
639
    public ResponseEntity<?> getPartners(HttpServletRequest request, @RequestParam(name = "gmailId") String gmailId,
627
    public ResponseEntity<?> getPartners(HttpServletRequest request, @RequestParam(name = "gmailId") String gmailId,
640
                                         @RequestParam(value = "offset") int offset, @RequestParam(value = "limit") int limit)
628
                                         @RequestParam(value = "offset") int offset, @RequestParam(value = "limit") int limit)
641
            throws ProfitMandiBusinessException {
629
            throws ProfitMandiBusinessException {
642
        AuthUser authUser = authRepository.selectByGmailId(gmailId);
630
        AuthUser authUser = authRepository.selectByGmailId(gmailId);
643
 
631
 
Line 776... Line 764...
776
    }
764
    }
777
 
765
 
778
    @RequestMapping(value = "/user/refferalAmount", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
766
    @RequestMapping(value = "/user/refferalAmount", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
779
    @ApiImplicitParams({
767
    @ApiImplicitParams({
780
            @ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
768
            @ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
781
    @Transactional(readOnly = true)
-
 
782
    public ResponseEntity<?> RefferalAmount(HttpServletRequest request, @RequestParam String refereeEmail)
769
    public ResponseEntity<?> RefferalAmount(HttpServletRequest request, @RequestParam String refereeEmail)
783
            throws Exception {
770
            throws Exception {
784
        LocalDateTime ldt = LocalDate.now().atStartOfDay().withDayOfMonth(16);
771
        LocalDateTime ldt = LocalDate.now().atStartOfDay().withDayOfMonth(16);
785
        DateRangeModel drm = new DateRangeModel();
772
        DateRangeModel drm = new DateRangeModel();
786
        List<RefferalEarningModel> refferAmountModel = new ArrayList<RefferalEarningModel>();
773
        List<RefferalEarningModel> refferAmountModel = new ArrayList<RefferalEarningModel>();
Line 926... Line 913...
926
    }
913
    }
927
 
914
 
928
    @RequestMapping(value = "/user/getReferals", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
915
    @RequestMapping(value = "/user/getReferals", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
929
    @ApiImplicitParams({
916
    @ApiImplicitParams({
930
            @ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
917
            @ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
931
    @Transactional(readOnly = true)
-
 
932
    public ResponseEntity<?> getReferals(HttpServletRequest request, @RequestParam RefferalStatus status)
918
    public ResponseEntity<?> getReferals(HttpServletRequest request, @RequestParam RefferalStatus status)
933
            throws Exception {
919
            throws Exception {
934
        int userId = (int) request.getAttribute("userId");
920
        int userId = (int) request.getAttribute("userId");
935
 
921
 
936
        User user = userRepository.selectById(userId);
922
        User user = userRepository.selectById(userId);
Line 941... Line 927...
941
    }
927
    }
942
 
928
 
943
    @RequestMapping(value = "/user/partnerTarget", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
929
    @RequestMapping(value = "/user/partnerTarget", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
944
    @ApiImplicitParams({
930
    @ApiImplicitParams({
945
            @ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
931
            @ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
946
    @Transactional(readOnly = true)
-
 
947
    public ResponseEntity<?> PartnerTarget(HttpServletRequest request) throws Exception {
932
    public ResponseEntity<?> PartnerTarget(HttpServletRequest request) throws Exception {
948
        int userId = (int) request.getAttribute(ProfitMandiConstants.USER_ID);
933
        int userId = (int) request.getAttribute(ProfitMandiConstants.USER_ID);
949
        int retailerId = userAccountRepository.selectRetailerIdByUserId(userId);
934
        int retailerId = userAccountRepository.selectRetailerIdByUserId(userId);
950
        PartnerType partnerType = partnerTypeChangeService.getTypeOnDate(retailerId, LocalDate.now());
935
        PartnerType partnerType = partnerTypeChangeService.getTypeOnDate(retailerId, LocalDate.now());
951
 
936
 
Line 953... Line 938...
953
    }
938
    }
954
 
939
 
955
    @RequestMapping(value = "/user/authUser", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
940
    @RequestMapping(value = "/user/authUser", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
956
    @ApiImplicitParams({
941
    @ApiImplicitParams({
957
            @ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
942
            @ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
958
    @Transactional(readOnly = true)
-
 
959
    public ResponseEntity<?> authUserDetail(HttpServletRequest request, @RequestParam int userId) throws Exception {
943
    public ResponseEntity<?> authUserDetail(HttpServletRequest request, @RequestParam int userId) throws Exception {
960
        User user = userRepository.selectById(userId);
944
        User user = userRepository.selectById(userId);
961
        AuthUser authUser = authRepository.selectByEmailOrMobile(user.getEmailId());
945
        AuthUser authUser = authRepository.selectByEmailOrMobile(user.getEmailId());
962
        return responseSender.ok(authUser);
946
        return responseSender.ok(authUser);
963
    }
947
    }