Subversion Repositories SmartDukaan

Rev

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

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