| Line 6... |
Line 6... |
| 6 |
import com.spice.profitmandi.common.enumuration.SchemeType;
|
6 |
import com.spice.profitmandi.common.enumuration.SchemeType;
|
| 7 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
7 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 8 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
8 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 9 |
import com.spice.profitmandi.common.util.JWTUtil;
|
9 |
import com.spice.profitmandi.common.util.JWTUtil;
|
| 10 |
import com.spice.profitmandi.common.web.client.RestClient;
|
10 |
import com.spice.profitmandi.common.web.client.RestClient;
|
| - |
|
11 |
import com.spice.profitmandi.dao.entity.fofo.PincodePartner;
|
| 11 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
12 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
| 12 |
import com.spice.profitmandi.dao.repository.cs.CsService;
|
13 |
import com.spice.profitmandi.dao.repository.cs.CsService;
|
| 13 |
import com.spice.profitmandi.dao.repository.dtr.*;
|
14 |
import com.spice.profitmandi.dao.repository.dtr.*;
|
| - |
|
15 |
import com.spice.profitmandi.dao.repository.fofo.PincodePartnerRepository;
|
| 14 |
import com.spice.profitmandi.dao.repository.user.PromoterRepository;
|
16 |
import com.spice.profitmandi.dao.repository.user.PromoterRepository;
|
| 15 |
import com.spice.profitmandi.service.AuthService;
|
17 |
import com.spice.profitmandi.service.AuthService;
|
| 16 |
import com.spice.profitmandi.service.user.RetailerService;
|
18 |
import com.spice.profitmandi.service.user.RetailerService;
|
| 17 |
import org.apache.http.conn.HttpHostConnectException;
|
19 |
import org.apache.http.conn.HttpHostConnectException;
|
| 18 |
import org.apache.logging.log4j.LogManager;
|
20 |
import org.apache.logging.log4j.LogManager;
|
| Line 72... |
Line 74... |
| 72 |
@Autowired
|
74 |
@Autowired
|
| 73 |
private RestClient restClient;
|
75 |
private RestClient restClient;
|
| 74 |
@Autowired
|
76 |
@Autowired
|
| 75 |
private RetailerService retailerService;
|
77 |
private RetailerService retailerService;
|
| 76 |
|
78 |
|
| - |
|
79 |
@Autowired
|
| - |
|
80 |
private PincodePartnerRepository pincodePartnerRepository;
|
| - |
|
81 |
|
| 77 |
public String process(String token) throws ProfitMandiBusinessException {
|
82 |
public String process(String token) throws ProfitMandiBusinessException {
|
| 78 |
Map<String, String> params = new HashMap<>();
|
83 |
Map<String, String> params = new HashMap<>();
|
| 79 |
params.put(ProfitMandiConstants.ID_TOKEN, token);
|
84 |
params.put(ProfitMandiConstants.ID_TOKEN, token);
|
| 80 |
Map<String, String> headers = new HashMap<>();
|
85 |
Map<String, String> headers = new HashMap<>();
|
| 81 |
headers.put(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
|
86 |
headers.put(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
|
| Line 99... |
Line 104... |
| 99 |
public Map<String, Object> processStore(String storeCode) throws ProfitMandiBusinessException {
|
104 |
public Map<String, Object> processStore(String storeCode) throws ProfitMandiBusinessException {
|
| 100 |
Map<String, Object> responseMap = new HashMap<>();
|
105 |
Map<String, Object> responseMap = new HashMap<>();
|
| 101 |
int retailerId = retailerService.getStoreCodeRetailerMap().get(storeCode);
|
106 |
int retailerId = retailerService.getStoreCodeRetailerMap().get(storeCode);
|
| 102 |
int userId = userAccountRepository.selectUserIdByRetailerId(retailerId);
|
107 |
int userId = userAccountRepository.selectUserIdByRetailerId(retailerId);
|
| 103 |
List<Integer> roleIds = userRoleRepository.selectRoleIdsByUserId(userId);
|
108 |
List<Integer> roleIds = userRoleRepository.selectRoleIdsByUserId(userId);
|
| 104 |
|
- |
|
| - |
|
109 |
PincodePartner partnerPin = pincodePartnerRepository.selectPinCodeByPartnerId(retailerId);
|
| 105 |
String[] roleTypes = new String[roleIds.size()];
|
110 |
String[] roleTypes = new String[roleIds.size()];
|
| 106 |
int index = 0;
|
111 |
int index = 0;
|
| 107 |
for (int roleId : roleIds) {
|
112 |
for (int roleId : roleIds) {
|
| 108 |
roleTypes[index++] = String.valueOf(roleId);
|
113 |
roleTypes[index++] = String.valueOf(roleId);
|
| 109 |
}
|
114 |
}
|
| 110 |
responseMap.put(ProfitMandiConstants.TOKEN, JWTUtil.create(userId, retailerId, roleTypes));
|
115 |
responseMap.put(ProfitMandiConstants.TOKEN, JWTUtil.create(userId, retailerId, roleTypes));
|
| 111 |
responseMap.put(ProfitMandiConstants.REGISTERED, true);
|
116 |
responseMap.put(ProfitMandiConstants.REGISTERED, true);
|
| - |
|
117 |
responseMap.put(ProfitMandiConstants.PIN_CODE, partnerPin != null ? partnerPin.getPincode() : partnerPin);
|
| 112 |
return responseMap;
|
118 |
return responseMap;
|
| 113 |
}
|
119 |
}
|
| 114 |
}
|
120 |
}
|