Subversion Repositories SmartDukaan

Rev

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

Rev 26398 Rev 26590
Line 31... Line 31...
31
import com.spice.profitmandi.dao.entity.dtr.User;
31
import com.spice.profitmandi.dao.entity.dtr.User;
32
import com.spice.profitmandi.dao.entity.user.Promoter;
32
import com.spice.profitmandi.dao.entity.user.Promoter;
33
import com.spice.profitmandi.dao.enumuration.dtr.Gender;
33
import com.spice.profitmandi.dao.enumuration.dtr.Gender;
34
import com.spice.profitmandi.dao.enumuration.dtr.SocialType;
34
import com.spice.profitmandi.dao.enumuration.dtr.SocialType;
35
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
35
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
-
 
36
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
36
import com.spice.profitmandi.dao.repository.dtr.SocialUserRepository;
37
import com.spice.profitmandi.dao.repository.dtr.SocialUserRepository;
37
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
38
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
38
import com.spice.profitmandi.dao.repository.dtr.UserRepository;
39
import com.spice.profitmandi.dao.repository.dtr.UserRepository;
39
import com.spice.profitmandi.dao.repository.dtr.UserRoleRepository;
40
import com.spice.profitmandi.dao.repository.dtr.UserRoleRepository;
40
import com.spice.profitmandi.dao.repository.user.PromoterRepository;
41
import com.spice.profitmandi.dao.repository.user.PromoterRepository;
41
import com.spice.profitmandi.service.AuthService;
42
import com.spice.profitmandi.service.AuthService;
-
 
43
import com.spice.profitmandi.service.user.RetailerService;
42
 
44
 
43
@Component
45
@Component
44
public class GoogleLoginProcessor {
46
public class GoogleLoginProcessor {
45
 
47
 
46
	private static final String V1_HOST_NAME = "content.googleapis.com";
48
	private static final String V1_HOST_NAME = "content.googleapis.com";
Line 64... Line 66...
64
	com.spice.profitmandi.dao.repository.user.UserRepository userUserRepository;
66
	com.spice.profitmandi.dao.repository.user.UserRepository userUserRepository;
65
 
67
 
66
	@Autowired
68
	@Autowired
67
	private AuthRepository authRepository;
69
	private AuthRepository authRepository;
68
 
70
 
-
 
71
	
69
	@Autowired
72
	@Autowired
70
	private UserRoleRepository userRoleRepository;
73
	private UserRoleRepository userRoleRepository;
71
 
74
 
72
	@Autowired
75
	@Autowired
73
	private PromoterRepository promoterRepository;
76
	private PromoterRepository promoterRepository;
Line 75... Line 78...
75
	@Autowired
78
	@Autowired
76
	private UserAccountRepository userAccountRepository;
79
	private UserAccountRepository userAccountRepository;
77
 
80
 
78
	@Autowired
81
	@Autowired
79
	private RestClient restClient;
82
	private RestClient restClient;
-
 
83
	@Autowired
-
 
84
	private RetailerService retailerService;
80
 
85
 
81
	public Map<String, Object> process(GoogleLoginRequest googleLoginRequest) throws ProfitMandiBusinessException {
86
	public Map<String, Object> process(GoogleLoginRequest googleLoginRequest) throws ProfitMandiBusinessException {
82
		LOGGER.info("1");
87
		LOGGER.info("1");
83
		Map<String, String> params = new HashMap<>();
88
		Map<String, String> params = new HashMap<>();
84
		params.put(ProfitMandiConstants.ACCESS_TOKEN, googleLoginRequest.getToken());
89
		params.put(ProfitMandiConstants.ACCESS_TOKEN, googleLoginRequest.getToken());
Line 298... Line 303...
298
			throw new ProfitMandiBusinessException("", "", "VE_1001");
303
			throw new ProfitMandiBusinessException("", "", "VE_1001");
299
		} catch (IOException ioException) {
304
		} catch (IOException ioException) {
300
			throw new ProfitMandiBusinessException("", "", "VE_1001");
305
			throw new ProfitMandiBusinessException("", "", "VE_1001");
301
		}
306
		}
302
	}
307
	}
-
 
308
 
-
 
309
	public Map<String, Object>  processStore(String storeCode) throws ProfitMandiBusinessException {
-
 
310
		Map<String, Object> responseMap = new HashMap<>();
-
 
311
		int retailerId = retailerService.getStoreCodeRetailerMap().get(storeCode);
-
 
312
		int userId = userAccountRepository.selectUserIdByRetailerId(retailerId);
-
 
313
		List<Integer> roleIds = userRoleRepository.selectRoleIdsByUserId(userId);
-
 
314
		
-
 
315
		String[] roleTypes = new String[roleIds.size()];
-
 
316
		int index = 0;
-
 
317
		for (int roleId : roleIds) {
-
 
318
			roleTypes[index++] = String.valueOf(roleId);
-
 
319
		}
-
 
320
		responseMap.put(ProfitMandiConstants.TOKEN, JWTUtil.create(userId, retailerId, roleTypes));
-
 
321
		responseMap.put(ProfitMandiConstants.REGISTERED, true);
-
 
322
		return responseMap;
-
 
323
	}
303
}
324
}