| Line 1... |
Line 1... |
| 1 |
package com.spice.profitmandi.service;
|
1 |
package com.spice.profitmandi.service.user;
|
| 2 |
|
2 |
|
| 3 |
import java.time.LocalDateTime;
|
3 |
import java.time.LocalDateTime;
|
| 4 |
import java.util.HashMap;
|
4 |
import java.util.HashMap;
|
| 5 |
import java.util.Map;
|
5 |
import java.util.Map;
|
| 6 |
|
6 |
|
| 7 |
import org.hibernate.Criteria;
|
7 |
import org.hibernate.Criteria;
|
| 8 |
import org.hibernate.Session;
|
8 |
import org.hibernate.Session;
|
| 9 |
import org.hibernate.SessionFactory;
|
9 |
import org.hibernate.SessionFactory;
|
| 10 |
import org.hibernate.criterion.Restrictions;
|
10 |
import org.hibernate.criterion.Restrictions;
|
| 11 |
import org.springframework.beans.factory.annotation.Autowired;
|
11 |
import org.springframework.beans.factory.annotation.Autowired;
|
| - |
|
12 |
import org.springframework.beans.factory.annotation.Qualifier;
|
| 12 |
import org.springframework.stereotype.Component;
|
13 |
import org.springframework.stereotype.Component;
|
| 13 |
import org.springframework.transaction.annotation.Transactional;
|
14 |
import org.springframework.transaction.annotation.Transactional;
|
| 14 |
|
15 |
|
| 15 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
16 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 16 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
17 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 17 |
import com.spice.profitmandi.dao.entity.dtr.ActivationCode;
|
18 |
import com.spice.profitmandi.dao.entity.dtr.ActivationCode;
|
| 18 |
import com.spice.profitmandi.dao.entity.dtr.Retailer;
|
19 |
import com.spice.profitmandi.dao.entity.dtr.Retailer;
|
| - |
|
20 |
import com.spice.profitmandi.dao.entity.dtr.Role;
|
| 19 |
import com.spice.profitmandi.dao.entity.dtr.User;
|
21 |
import com.spice.profitmandi.dao.entity.dtr.User;
|
| 20 |
import com.spice.profitmandi.dao.entity.dtr.UserAccount;
|
22 |
import com.spice.profitmandi.dao.entity.dtr.UserAccount;
|
| 21 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
23 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
| 22 |
import com.spice.profitmandi.dao.enumuration.dtr.AccountType;
|
24 |
import com.spice.profitmandi.dao.enumuration.dtr.AccountType;
|
| 23 |
import com.spice.profitmandi.dao.enumuration.dtr.RoleType;
|
25 |
import com.spice.profitmandi.dao.enumuration.dtr.RoleType;
|
| 24 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
26 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| 25 |
import com.spice.profitmandi.dao.repository.dtr.RetailerRepository;
|
27 |
import com.spice.profitmandi.dao.repository.dtr.RetailerRepository;
|
| - |
|
28 |
import com.spice.profitmandi.dao.repository.dtr.RoleRepository;
|
| 26 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
29 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
| 27 |
import com.spice.profitmandi.dao.repository.dtr.UserRepository;
|
30 |
import com.spice.profitmandi.dao.repository.dtr.UserRepository;
|
| 28 |
import com.spice.profitmandi.dao.repository.dtr.UserRoleRepository;
|
31 |
import com.spice.profitmandi.dao.repository.dtr.UserRoleRepository;
|
| 29 |
import com.spice.profitmandi.thrift.clients.TransactionClient;
|
32 |
import com.spice.profitmandi.thrift.clients.TransactionClient;
|
| 30 |
|
33 |
|
| Line 36... |
Line 39... |
| 36 |
|
39 |
|
| 37 |
@Autowired
|
40 |
@Autowired
|
| 38 |
private SessionFactory sessionFactory;
|
41 |
private SessionFactory sessionFactory;
|
| 39 |
|
42 |
|
| 40 |
@Autowired
|
43 |
@Autowired
|
| - |
|
44 |
@Qualifier(value = "userRepository")
|
| 41 |
private UserRepository userRepository;
|
45 |
private UserRepository userRepository;
|
| 42 |
|
46 |
|
| 43 |
@Autowired
|
47 |
@Autowired
|
| 44 |
private RetailerRepository retailerRepo;
|
48 |
private RetailerRepository retailerRepo;
|
| 45 |
|
49 |
|
| Line 50... |
Line 54... |
| 50 |
private UserAccountRepository userAccountRepository;
|
54 |
private UserAccountRepository userAccountRepository;
|
| 51 |
|
55 |
|
| 52 |
@Autowired
|
56 |
@Autowired
|
| 53 |
private UserRoleRepository userRoleRepository;
|
57 |
private UserRoleRepository userRoleRepository;
|
| 54 |
|
58 |
|
| - |
|
59 |
@Autowired
|
| - |
|
60 |
private RoleRepository roleRepository;
|
| - |
|
61 |
|
| 55 |
|
62 |
|
| 56 |
@SuppressWarnings("deprecation")
|
63 |
@SuppressWarnings("deprecation")
|
| 57 |
@Override
|
64 |
@Override
|
| 58 |
public boolean updateActivation(int userId, int retailerId, String activationCode) throws Throwable {
|
65 |
public boolean updateActivation(int userId, int retailerId, String activationCode) throws Throwable {
|
| 59 |
|
66 |
|
| Line 100... |
Line 107... |
| 100 |
|
107 |
|
| 101 |
@Override
|
108 |
@Override
|
| 102 |
public Map<String, String> getEmailsAndFofoStoreCodeByUserId(int userId) throws ProfitMandiBusinessException {
|
109 |
public Map<String, String> getEmailsAndFofoStoreCodeByUserId(int userId) throws ProfitMandiBusinessException {
|
| 103 |
User user = userRepository.selectById(userId);
|
110 |
User user = userRepository.selectById(userId);
|
| 104 |
UserAccount userAccount = userAccountRepository.selectByUserIdType(userId, AccountType.saholic);
|
111 |
UserAccount userAccount = userAccountRepository.selectByUserIdType(userId, AccountType.saholic);
|
| - |
|
112 |
Role role = roleRepository.selectByName(RoleType.FOFO.toString());
|
| 105 |
Map<String, String> map = new HashMap<>();
|
113 |
Map<String, String> map = new HashMap<>();
|
| 106 |
map.put(ProfitMandiConstants.EMAIL_ID, user.getEmailId());
|
114 |
map.put(ProfitMandiConstants.EMAIL_ID, user.getEmailId());
|
| 107 |
map.put(ProfitMandiConstants.SECONDRY_EMAIL_ID, user.getSecondryEmailId());
|
115 |
map.put(ProfitMandiConstants.SECONDRY_EMAIL_ID, user.getSecondryEmailId());
|
| 108 |
userRoleRepository.selectByUserIdAndRoleType(userId, RoleType.FOFO);
|
116 |
userRoleRepository.selectByUserIdAndRoleId(userId, role.getId());
|
| 109 |
FofoStore fofoStore = fofoStoreRepository.selectByRetailerId(userAccount.getAccountKey());
|
117 |
FofoStore fofoStore = fofoStoreRepository.selectByRetailerId(userAccount.getAccountKey());
|
| 110 |
map.put(ProfitMandiConstants.CODE, fofoStore.getCode());
|
118 |
map.put(ProfitMandiConstants.CODE, fofoStore.getCode());
|
| 111 |
return map;
|
119 |
return map;
|
| 112 |
}
|
120 |
}
|
| - |
|
121 |
|
| 113 |
}
|
122 |
}
|