Subversion Repositories SmartDukaan

Rev

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

Rev 23787 Rev 23798
Line 50... Line 50...
50
import com.spice.profitmandi.dao.repository.dtr.RoleRepository;
50
import com.spice.profitmandi.dao.repository.dtr.RoleRepository;
51
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
51
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
52
import com.spice.profitmandi.dao.repository.dtr.UserRepository;
52
import com.spice.profitmandi.dao.repository.dtr.UserRepository;
53
import com.spice.profitmandi.dao.repository.dtr.UserRoleRepository;
53
import com.spice.profitmandi.dao.repository.dtr.UserRoleRepository;
54
import com.spice.profitmandi.dao.repository.user.AddressRepository;
54
import com.spice.profitmandi.dao.repository.user.AddressRepository;
55
import com.spice.profitmandi.service.RoleManagerService;
55
import com.spice.profitmandi.service.authentication.RoleManager;
56
import com.spice.profitmandi.service.user.UserService;
56
import com.spice.profitmandi.service.user.UserService;
57
import com.spice.profitmandi.web.enumuration.UserStatus;
57
import com.spice.profitmandi.web.enumuration.UserStatus;
58
import com.spice.profitmandi.web.processor.GoogleLoginProcessor;
58
import com.spice.profitmandi.web.processor.GoogleLoginProcessor;
59
import com.spice.profitmandi.web.req.UserAddRoleRequest;
59
import com.spice.profitmandi.web.req.UserAddRoleRequest;
60
import com.spice.profitmandi.web.req.UserRequest;
60
import com.spice.profitmandi.web.req.UserRequest;
Line 111... Line 111...
111
 
111
 
112
	@Autowired
112
	@Autowired
113
	private UserService userService;
113
	private UserService userService;
114
	
114
	
115
	@Autowired
115
	@Autowired
116
	private RoleManagerService roleManagerService;
116
	private RoleManager roleManager;
117
	
117
	
118
	@Autowired
118
	@Autowired
119
	private RoleRepository roleRepository;
119
	private RoleRepository roleRepository;
120
 
120
 
121
	@RequestMapping(value = ProfitMandiConstants.URL_USER_GOOGLE_LOGIN, method = RequestMethod.POST)
121
	@RequestMapping(value = ProfitMandiConstants.URL_USER_GOOGLE_LOGIN, method = RequestMethod.POST)
Line 169... Line 169...
169
				String newToken = JWTUtil.create(user.getId(), roleIdArray);
169
				String newToken = JWTUtil.create(user.getId(), roleIdArray);
170
				responseMap.put("newAuthToken", newToken);
170
				responseMap.put("newAuthToken", newToken);
171
			}
171
			}
172
 
172
 
173
			Set<Integer> roleIdsSet = new HashSet<Integer>(roleIds);
173
			Set<Integer> roleIdsSet = new HashSet<Integer>(roleIds);
174
			if (roleManagerService.isRetailer(new HashSet<Integer>(roleIds))) {
174
			if (roleManager.isRetailer(new HashSet<Integer>(roleIds))) {
175
				UserCart uc = userAccountRepository.getUserCart(userInfo.getUserId());
175
				UserCart uc = userAccountRepository.getUserCart(userInfo.getUserId());
176
				Retailer retailer = retailerRepository.selectById(uc.getUserId());
176
				Retailer retailer = retailerRepository.selectById(uc.getUserId());
177
				com.spice.profitmandi.dao.entity.user.User saholicUser = userUserRepository.selectById(uc.getUserId());
177
				com.spice.profitmandi.dao.entity.user.User saholicUser = userUserRepository.selectById(uc.getUserId());
178
				if(saholicUser.getAddressId() != null){
178
				if(saholicUser.getAddressId() != null){
179
					Address address = addressRepository.selectById(saholicUser.getAddressId());
179
					Address address = addressRepository.selectById(saholicUser.getAddressId());
Line 182... Line 182...
182
				// if retailer is activated 1 then verified retailer
182
				// if retailer is activated 1 then verified retailer
183
				// else if migrated is 1 then old retailer
183
				// else if migrated is 1 then old retailer
184
				// also lets incoporte old process i.e is user is activated then also retailer is verified retailer
184
				// also lets incoporte old process i.e is user is activated then also retailer is verified retailer
185
				// else retailer is not verifed
185
				// else retailer is not verifed
186
				if (retailer.isActive() || user.isActivated()) {
186
				if (retailer.isActive() || user.isActivated()) {
187
					if (roleManagerService.isPartner(roleIdsSet)) {
187
					if (roleManager.isPartner(roleIdsSet)) {
188
						responseMap.put(ProfitMandiConstants.USER_STATUS, UserStatus.FOFO.getValue());
188
						responseMap.put(ProfitMandiConstants.USER_STATUS, UserStatus.FOFO.getValue());
189
					} else {
189
					} else {
190
						responseMap.put(ProfitMandiConstants.USER_STATUS, UserStatus.VERIFIED_RETAILER.getValue());
190
						responseMap.put(ProfitMandiConstants.USER_STATUS, UserStatus.VERIFIED_RETAILER.getValue());
191
					}
191
					}
192
				} else if (retailer.isMigrated()) {
192
				} else if (retailer.isMigrated()) {
193
					responseMap.put(ProfitMandiConstants.USER_STATUS, UserStatus.RETAILER.getValue());
193
					responseMap.put(ProfitMandiConstants.USER_STATUS, UserStatus.RETAILER.getValue());
194
				} else {
194
				} else {
195
					responseMap.put(ProfitMandiConstants.USER_STATUS, UserStatus.NOT_VERIFIED_RETAILER.getValue());
195
					responseMap.put(ProfitMandiConstants.USER_STATUS, UserStatus.NOT_VERIFIED_RETAILER.getValue());
196
				}
196
				}
197
			} else if (roleManagerService.isUser(roleIdsSet)) {
197
			} else if (roleManager.isUser(roleIdsSet)) {
198
				responseMap.put("userInfo", getRegisteredUserInfo(user));
198
				responseMap.put("userInfo", getRegisteredUserInfo(user));
199
				responseMap.put(ProfitMandiConstants.USER_STATUS, UserStatus.REGISTERED.getValue());
199
				responseMap.put(ProfitMandiConstants.USER_STATUS, UserStatus.REGISTERED.getValue());
200
			}
200
			}
201
		} else {
201
		} else {
202
			responseMap.put(ProfitMandiConstants.USER_STATUS, UserStatus.NOT_REGISTERED.getValue());
202
			responseMap.put(ProfitMandiConstants.USER_STATUS, UserStatus.NOT_REGISTERED.getValue());