| Line 10... |
Line 10... |
| 10 |
|
10 |
|
| 11 |
import org.slf4j.Logger;
|
11 |
import org.slf4j.Logger;
|
| 12 |
import org.slf4j.LoggerFactory;
|
12 |
import org.slf4j.LoggerFactory;
|
| 13 |
import org.springframework.beans.factory.annotation.Autowired;
|
13 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 14 |
import org.springframework.beans.factory.annotation.Value;
|
14 |
import org.springframework.beans.factory.annotation.Value;
|
| 15 |
import org.springframework.http.HttpStatus;
|
- |
|
| 16 |
import org.springframework.http.ResponseEntity;
|
15 |
import org.springframework.http.ResponseEntity;
|
| 17 |
import org.springframework.stereotype.Controller;
|
16 |
import org.springframework.stereotype.Controller;
|
| 18 |
import org.springframework.transaction.annotation.Transactional;
|
17 |
import org.springframework.transaction.annotation.Transactional;
|
| 19 |
import org.springframework.web.bind.annotation.RequestBody;
|
18 |
import org.springframework.web.bind.annotation.RequestBody;
|
| 20 |
import org.springframework.web.bind.annotation.RequestMapping;
|
19 |
import org.springframework.web.bind.annotation.RequestMapping;
|
| Line 27... |
Line 26... |
| 27 |
import com.eclipsesource.json.JsonValue;
|
26 |
import com.eclipsesource.json.JsonValue;
|
| 28 |
import com.google.gson.Gson;
|
27 |
import com.google.gson.Gson;
|
| 29 |
import com.spice.profitmandi.common.ResponseCodeHolder;
|
28 |
import com.spice.profitmandi.common.ResponseCodeHolder;
|
| 30 |
import com.spice.profitmandi.common.enumuration.SchemeType;
|
29 |
import com.spice.profitmandi.common.enumuration.SchemeType;
|
| 31 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
30 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| - |
|
31 |
import com.spice.profitmandi.common.model.GoogleLoginRequest;
|
| 32 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
32 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 33 |
import com.spice.profitmandi.common.model.ProfitMandiResponse;
|
- |
|
| 34 |
import com.spice.profitmandi.common.model.RegisteredUserInfo;
|
33 |
import com.spice.profitmandi.common.model.RegisteredUserInfo;
|
| 35 |
import com.spice.profitmandi.common.model.ResponseStatus;
|
- |
|
| 36 |
import com.spice.profitmandi.common.model.UserInfo;
|
34 |
import com.spice.profitmandi.common.model.UserInfo;
|
| 37 |
import com.spice.profitmandi.common.util.JWTUtil;
|
35 |
import com.spice.profitmandi.common.util.JWTUtil;
|
| 38 |
import com.spice.profitmandi.common.web.client.RestClient;
|
36 |
import com.spice.profitmandi.common.web.client.RestClient;
|
| 39 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
37 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
| 40 |
import com.spice.profitmandi.dao.entity.dtr.Permission;
|
38 |
import com.spice.profitmandi.dao.entity.dtr.Permission;
|
| Line 67... |
Line 65... |
| 67 |
@Controller
|
65 |
@Controller
|
| 68 |
@Transactional(rollbackFor=Throwable.class)
|
66 |
@Transactional(rollbackFor=Throwable.class)
|
| 69 |
public class UserController {
|
67 |
public class UserController {
|
| 70 |
|
68 |
|
| 71 |
@Autowired
|
69 |
@Autowired
|
| 72 |
ResponseSender<?> responseSender;
|
70 |
private ResponseSender<?> responseSender;
|
| 73 |
|
71 |
|
| 74 |
private static final Logger LOGGER = LoggerFactory.getLogger(UserController.class);
|
72 |
private static final Logger LOGGER = LoggerFactory.getLogger(UserController.class);
|
| 75 |
|
73 |
|
| 76 |
@Value("${notifications.api.host}")
|
74 |
@Value("${notifications.api.host}")
|
| 77 |
private String nodeHost;
|
75 |
private String nodeHost;
|
| Line 106... |
Line 104... |
| 106 |
private GoogleLoginProcessor googleLoginProcessor;
|
104 |
private GoogleLoginProcessor googleLoginProcessor;
|
| 107 |
|
105 |
|
| 108 |
@Autowired
|
106 |
@Autowired
|
| 109 |
private UserService userService;
|
107 |
private UserService userService;
|
| 110 |
|
108 |
|
| 111 |
@SuppressWarnings("unchecked")
|
- |
|
| 112 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_GOOGLE_LOGIN, method = RequestMethod.POST)
|
109 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_GOOGLE_LOGIN, method = RequestMethod.POST)
|
| 113 |
public ResponseEntity<?> googleLogin(HttpServletRequest request) {
|
110 |
public ResponseEntity<?> googleLogin(HttpServletRequest request, @RequestBody GoogleLoginRequest googleLoginRequest) throws ProfitMandiBusinessException{
|
| 114 |
LOGGER.info("requested url : " + request.getRequestURL().toString());
|
111 |
LOGGER.info("requested url : " + request.getRequestURL().toString());
|
| 115 |
final Map<String, Object> googleLoginMap = (Map<String, Object>) request
|
- |
|
| 116 |
.getAttribute(ProfitMandiConstants.GOOGLE_LOGIN_MAP);
|
- |
|
| 117 |
request.removeAttribute(ProfitMandiConstants.GOOGLE_LOGIN_MAP);
|
- |
|
| 118 |
try {
|
- |
|
| 119 |
return responseSender.ok(googleLoginProcessor.process(googleLoginMap));
|
112 |
return responseSender.ok(googleLoginProcessor.process(googleLoginRequest));
|
| 120 |
} catch (ProfitMandiBusinessException profitMandiBusinessException) {
|
- |
|
| 121 |
LOGGER.error("ProfitMandi error: ", profitMandiBusinessException);
|
- |
|
| 122 |
return responseSender.badRequest(profitMandiBusinessException);
|
- |
|
| 123 |
}
|
- |
|
| 124 |
}
|
113 |
}
|
| 125 |
|
114 |
|
| 126 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_TOKEN_IS_EXPIRED, method = RequestMethod.GET)
|
115 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_TOKEN_IS_EXPIRED, method = RequestMethod.GET)
|
| 127 |
public ResponseEntity<?> tokenIsExpired(HttpServletRequest request, @RequestParam(name = "token") String token) {
|
116 |
public ResponseEntity<?> tokenIsExpired(HttpServletRequest request, @RequestParam(name = "token") String token) throws ProfitMandiBusinessException{
|
| 128 |
LOGGER.info("requested url : " + request.getRequestURL().toString());
|
117 |
LOGGER.info("requested url : " + request.getRequestURL().toString());
|
| 129 |
try {
|
- |
|
| 130 |
return responseSender.ok(JWTUtil.isExpired(token));
|
118 |
return responseSender.ok(JWTUtil.isExpired(token));
|
| 131 |
|
- |
|
| 132 |
} catch (ProfitMandiBusinessException profitMandiBusinessException) {
|
- |
|
| 133 |
LOGGER.error("ProfitMandi error: ", profitMandiBusinessException);
|
- |
|
| 134 |
return responseSender.badRequest(profitMandiBusinessException);
|
- |
|
| 135 |
}
|
- |
|
| 136 |
}
|
119 |
}
|
| 137 |
|
120 |
|
| 138 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_DETAIL_BY_TOKEN, method = RequestMethod.GET)
|
121 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_DETAIL_BY_TOKEN, method = RequestMethod.GET)
|
| 139 |
@ApiImplicitParams({
|
122 |
@ApiImplicitParams({
|
| 140 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
123 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
| Line 218... |
Line 201... |
| 218 |
|
201 |
|
| 219 |
@RequestMapping(value = ProfitMandiConstants.URL_USER, method = RequestMethod.POST)
|
202 |
@RequestMapping(value = ProfitMandiConstants.URL_USER, method = RequestMethod.POST)
|
| 220 |
@ApiImplicitParams({
|
203 |
@ApiImplicitParams({
|
| 221 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
204 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
| 222 |
public ResponseEntity<?> createUser(HttpServletRequest request, @RequestBody UserRequest userRequest)
|
205 |
public ResponseEntity<?> createUser(HttpServletRequest request, @RequestBody UserRequest userRequest)
|
| 223 |
throws Throwable {
|
206 |
throws ProfitMandiBusinessException {
|
| 224 |
LOGGER.info("requested url : " + request.getRequestURL().toString());
|
207 |
LOGGER.info("requested url : " + request.getRequestURL().toString());
|
| 225 |
User user = new User();
|
208 |
User user = new User();
|
| 226 |
user.setFirstName(userRequest.getFirstName());
|
209 |
user.setFirstName(userRequest.getFirstName());
|
| 227 |
user.setLastName(userRequest.getLastName());
|
210 |
user.setLastName(userRequest.getLastName());
|
| 228 |
user.setCity(userRequest.getCity());
|
211 |
user.setCity(userRequest.getCity());
|
| Line 237... |
Line 220... |
| 237 |
user.setGroup_id(1);
|
220 |
user.setGroup_id(1);
|
| 238 |
user.setStatus(1);
|
221 |
user.setStatus(1);
|
| 239 |
user.setActivated(false);
|
222 |
user.setActivated(false);
|
| 240 |
user.setCreateTimestamp(LocalDateTime.now());
|
223 |
user.setCreateTimestamp(LocalDateTime.now());
|
| 241 |
user.setUpdateTimestamp(LocalDateTime.now());
|
224 |
user.setUpdateTimestamp(LocalDateTime.now());
|
| 242 |
try {
|
- |
|
| 243 |
userRepository.persist(user);
|
225 |
userRepository.persist(user);
|
| 244 |
UserRole userRole = new UserRole();
|
226 |
UserRole userRole = new UserRole();
|
| 245 |
userRole.setRoleType(RoleType.USER);
|
227 |
userRole.setRoleType(RoleType.USER);
|
| 246 |
userRole.setUserId(user.getId());
|
228 |
userRole.setUserId(user.getId());
|
| 247 |
userRoleRepository.persist(userRole);
|
229 |
userRoleRepository.persist(userRole);
|
| 248 |
return responseSender.ok(ResponseCodeHolder.getMessage("USR_OK_1000"));
|
230 |
return responseSender.ok(ResponseCodeHolder.getMessage("USR_OK_1000"));
|
| 249 |
} catch (ProfitMandiBusinessException profitMandiBusinessException) {
|
- |
|
| 250 |
LOGGER.error("ProfitMandi error: ", profitMandiBusinessException);
|
- |
|
| 251 |
return responseSender.badRequest(profitMandiBusinessException);
|
- |
|
| 252 |
}
|
231 |
|
| 253 |
}
|
232 |
}
|
| 254 |
|
233 |
|
| 255 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_ALL, method = RequestMethod.GET)
|
234 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_ALL, method = RequestMethod.GET)
|
| 256 |
public ResponseEntity<?> getAll(HttpServletRequest request,
|
235 |
public ResponseEntity<?> getAll(HttpServletRequest request,
|
| 257 |
@RequestParam(name = ProfitMandiConstants.PAGE_NUMBER) int pageNumber,
|
236 |
@RequestParam(name = ProfitMandiConstants.PAGE_NUMBER) int pageNumber,
|
| Line 259... |
Line 238... |
| 259 |
LOGGER.info("requested url : " + request.getRequestURL().toString());
|
238 |
LOGGER.info("requested url : " + request.getRequestURL().toString());
|
| 260 |
return responseSender.ok(userRepository.selectAll(pageNumber, pageSize));
|
239 |
return responseSender.ok(userRepository.selectAll(pageNumber, pageSize));
|
| 261 |
}
|
240 |
}
|
| 262 |
|
241 |
|
| 263 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_ID, method = RequestMethod.GET)
|
242 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_ID, method = RequestMethod.GET)
|
| 264 |
public ResponseEntity<?> getById(HttpServletRequest request, @RequestParam(name = "id") int id) {
|
243 |
public ResponseEntity<?> getById(HttpServletRequest request, @RequestParam(name = "id") int id) throws ProfitMandiBusinessException{
|
| 265 |
LOGGER.info("requested url : " + request.getRequestURL().toString());
|
244 |
LOGGER.info("requested url : " + request.getRequestURL().toString());
|
| 266 |
try {
|
- |
|
| 267 |
return responseSender.ok(userRepository.selectById(id));
|
245 |
return responseSender.ok(userRepository.selectById(id));
|
| 268 |
} catch (ProfitMandiBusinessException profitMandiBusinessException) {
|
- |
|
| 269 |
LOGGER.error("ProfitMandi error: ", profitMandiBusinessException);
|
- |
|
| 270 |
return responseSender.badRequest(profitMandiBusinessException);
|
- |
|
| 271 |
}
|
- |
|
| 272 |
}
|
246 |
}
|
| 273 |
|
247 |
|
| 274 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_MOBILE_NUMBER, method = RequestMethod.GET)
|
248 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_MOBILE_NUMBER, method = RequestMethod.GET)
|
| 275 |
public ResponseEntity<?> getByMobileNumber(HttpServletRequest request,
|
249 |
public ResponseEntity<?> getByMobileNumber(HttpServletRequest request,
|
| 276 |
@RequestParam(name = "mobileNumber") String mobileNumber) {
|
250 |
@RequestParam(name = "mobileNumber") String mobileNumber) throws ProfitMandiBusinessException{
|
| 277 |
LOGGER.info("requested url : " + request.getRequestURL().toString());
|
251 |
LOGGER.info("requested url : " + request.getRequestURL().toString());
|
| 278 |
try {
|
- |
|
| 279 |
return responseSender.ok(userRepository.selectByMobileNumber(mobileNumber));
|
252 |
return responseSender.ok(userRepository.selectByMobileNumber(mobileNumber));
|
| 280 |
} catch (ProfitMandiBusinessException profitMandiBusinessException) {
|
- |
|
| 281 |
LOGGER.error("ProfitMandi error: ", profitMandiBusinessException);
|
- |
|
| 282 |
return responseSender.badRequest(profitMandiBusinessException);
|
- |
|
| 283 |
}
|
- |
|
| 284 |
}
|
253 |
}
|
| 285 |
|
254 |
|
| 286 |
@ApiImplicitParams({
|
255 |
@ApiImplicitParams({
|
| 287 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
256 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
| 288 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_ACTIVATE, method = RequestMethod.POST)
|
257 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_ACTIVATE, method = RequestMethod.POST)
|
| Line 296... |
Line 265... |
| 296 |
@ApiImplicitParams({
|
265 |
@ApiImplicitParams({
|
| 297 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
266 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
| 298 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_NOTIFICATIONS, method = RequestMethod.GET)
|
267 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_NOTIFICATIONS, method = RequestMethod.GET)
|
| 299 |
public ResponseEntity<?> getNofitications(HttpServletRequest request,
|
268 |
public ResponseEntity<?> getNofitications(HttpServletRequest request,
|
| 300 |
@RequestParam(name = "androidId") String androidId, @RequestParam(name = "pageNumber") int pageNumber,
|
269 |
@RequestParam(name = "androidId") String androidId, @RequestParam(name = "pageNumber") int pageNumber,
|
| 301 |
@RequestParam(name = "pageSize") int pageSize) throws Throwable {
|
270 |
@RequestParam(name = "pageSize") int pageSize) throws ProfitMandiBusinessException{
|
| 302 |
int userId = (int) request.getAttribute("userId");
|
271 |
int userId = (int) request.getAttribute("userId");
|
| 303 |
String restResponse = null;
|
272 |
String restResponse = null;
|
| 304 |
Map<String, String> params = new HashMap<>();
|
273 |
Map<String, String> params = new HashMap<>();
|
| 305 |
|
274 |
|
| 306 |
String uri = "/getAllNotifications";
|
275 |
String uri = "/getAllNotifications";
|
| 307 |
params.put("user_id", userId + "");
|
276 |
params.put("user_id", userId + "");
|
| 308 |
params.put("android_id", androidId);
|
277 |
params.put("android_id", androidId);
|
| 309 |
params.put("limit", pageSize + "");
|
278 |
params.put("limit", pageSize + "");
|
| 310 |
params.put("offset", "" + ((pageNumber - 1) * pageSize));
|
279 |
params.put("offset", "" + ((pageNumber - 1) * pageSize));
|
| 311 |
try {
|
- |
|
| 312 |
RestClient rc = new RestClient(SchemeType.HTTP, nodeHost, nodePort);
|
280 |
RestClient rc = new RestClient(SchemeType.HTTP, nodeHost, nodePort);
|
| 313 |
restResponse = rc.get(uri, params);
|
281 |
restResponse = rc.get(uri, params);
|
| 314 |
} catch (Exception e) {
|
- |
|
| 315 |
LOGGER.error("Unable to data from node server", e);
|
- |
|
| 316 |
return responseSender.internalServerError(e);
|
- |
|
| 317 |
}
|
282 |
|
| 318 |
|
283 |
|
| 319 |
JsonArray result_json = Json.parse(restResponse).asArray();
|
284 |
JsonArray result_json = Json.parse(restResponse).asArray();
|
| 320 |
|
285 |
|
| 321 |
List<Notification> notifications = new ArrayList<>();
|
286 |
List<Notification> notifications = new ArrayList<>();
|
| 322 |
|
287 |
|
| Line 341... |
Line 306... |
| 341 |
LOGGER.info("requested url : " + request.getRequestURL().toString());
|
306 |
LOGGER.info("requested url : " + request.getRequestURL().toString());
|
| 342 |
return responseSender.ok(userRepository.isExistByMobileNumber(mobileNumber));
|
307 |
return responseSender.ok(userRepository.isExistByMobileNumber(mobileNumber));
|
| 343 |
}
|
308 |
}
|
| 344 |
|
309 |
|
| 345 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_EMAIL_ID, method = RequestMethod.GET)
|
310 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_EMAIL_ID, method = RequestMethod.GET)
|
| 346 |
public ResponseEntity<?> getByEmailId(HttpServletRequest request, @RequestParam(name = "emailId") String emailId) {
|
311 |
public ResponseEntity<?> getByEmailId(HttpServletRequest request, @RequestParam(name = "emailId") String emailId) throws ProfitMandiBusinessException{
|
| 347 |
LOGGER.info("requested url : " + request.getRequestURL().toString());
|
312 |
LOGGER.info("requested url : " + request.getRequestURL().toString());
|
| 348 |
try {
|
- |
|
| 349 |
return responseSender.ok(userRepository.selectByEmailId(emailId));
|
313 |
return responseSender.ok(userRepository.selectByEmailId(emailId));
|
| 350 |
} catch (ProfitMandiBusinessException profitMandiBusinessException) {
|
- |
|
| 351 |
LOGGER.error("ProfitMandi error: ", profitMandiBusinessException);
|
- |
|
| 352 |
return responseSender.badRequest(profitMandiBusinessException);
|
- |
|
| 353 |
}
|
- |
|
| 354 |
}
|
314 |
}
|
| 355 |
|
315 |
|
| 356 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_ROLE_ADD, method = RequestMethod.POST)
|
316 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_ROLE_ADD, method = RequestMethod.POST)
|
| 357 |
public ResponseEntity<?> addRole(HttpServletRequest request, @RequestBody UserAddRoleRequest userAddRoleRequest) {
|
317 |
public ResponseEntity<?> addRole(HttpServletRequest request, @RequestBody UserAddRoleRequest userAddRoleRequest) throws ProfitMandiBusinessException{
|
| 358 |
LOGGER.info("requested url : " + request.getRequestURL().toString());
|
318 |
LOGGER.info("requested url : " + request.getRequestURL().toString());
|
| 359 |
try {
|
- |
|
| 360 |
User user = userRepository.selectById(userAddRoleRequest.getUserId());
|
319 |
User user = userRepository.selectById(userAddRoleRequest.getUserId());
|
| 361 |
|
320 |
|
| 362 |
/*
|
- |
|
| 363 |
* Role role = null; try { role =
|
- |
|
| 364 |
* roleRepository.selectByNameAndType(userAddRoleRequest.getRole().
|
- |
|
| 365 |
* getName(), userAddRoleRequest.getRole().getType()); } catch
|
- |
|
| 366 |
* (ProfitMandiBusinessException profitMandiBusinessException) {
|
- |
|
| 367 |
* role = new Role();
|
- |
|
| 368 |
* role.setName(userAddRoleRequest.getRole().getName());
|
- |
|
| 369 |
* role.setType(userAddRoleRequest.getRole().getType());
|
- |
|
| 370 |
* roleRepository.persist(role); }
|
- |
|
| 371 |
*/
|
- |
|
| 372 |
Permission permission = new Permission();
|
321 |
Permission permission = new Permission();
|
| 373 |
permission.setType(userAddRoleRequest.getPermissionType());
|
322 |
permission.setType(userAddRoleRequest.getPermissionType());
|
| 374 |
permission.setRoleType(userAddRoleRequest.getRoleType());
|
323 |
permission.setRoleType(userAddRoleRequest.getRoleType());
|
| 375 |
permissionRepository.persist(permission);
|
324 |
permissionRepository.persist(permission);
|
| 376 |
UserRole userRole = new UserRole();
|
325 |
UserRole userRole = new UserRole();
|
| 377 |
userRole.setRoleType(userAddRoleRequest.getRoleType());
|
326 |
userRole.setRoleType(userAddRoleRequest.getRoleType());
|
| 378 |
userRole.setUserId(user.getId());
|
327 |
userRole.setUserId(user.getId());
|
| 379 |
userRoleRepository.persist(userRole);
|
328 |
userRoleRepository.persist(userRole);
|
| 380 |
return responseSender.ok("");
|
329 |
return responseSender.ok("");
|
| 381 |
} catch (ProfitMandiBusinessException profitMandiBusinessException) {
|
- |
|
| 382 |
LOGGER.error("ProfitMandi error: ", profitMandiBusinessException);
|
- |
|
| 383 |
return responseSender.badRequest(profitMandiBusinessException);
|
- |
|
| 384 |
}
|
- |
|
| 385 |
}
|
330 |
}
|
| 386 |
|
331 |
|
| 387 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_ROLE_REMOVE, method = RequestMethod.DELETE)
|
332 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_ROLE_REMOVE, method = RequestMethod.DELETE)
|
| 388 |
public ResponseEntity<?> removeRole(HttpServletRequest request, @RequestParam(name = "roleType") RoleType roleType,
|
333 |
public ResponseEntity<?> removeRole(HttpServletRequest request, @RequestParam(name = "roleType") RoleType roleType,
|
| 389 |
@RequestParam(name = "userId") int userId) {
|
334 |
@RequestParam(name = "userId") int userId) throws ProfitMandiBusinessException{
|
| 390 |
LOGGER.info("requested url : " + request.getRequestURL().toString());
|
335 |
LOGGER.info("requested url : " + request.getRequestURL().toString());
|
| 391 |
try {
|
- |
|
| 392 |
userRepository.selectById(userId);
|
336 |
userRepository.selectById(userId);
|
| 393 |
userRoleRepository.deleteByUserAndRoleType(userId, roleType);
|
337 |
userRoleRepository.deleteByUserAndRoleType(userId, roleType);
|
| 394 |
permissionRepository.deleteByRoleType(roleType);
|
338 |
permissionRepository.deleteByRoleType(roleType);
|
| 395 |
return responseSender.ok("");
|
339 |
return responseSender.ok("");
|
| 396 |
} catch (ProfitMandiBusinessException profitMandiBusinessException) {
|
- |
|
| 397 |
LOGGER.error("ProfitMandi error: ", profitMandiBusinessException);
|
- |
|
| 398 |
return responseSender.badRequest(profitMandiBusinessException);
|
- |
|
| 399 |
}
|
- |
|
| 400 |
}
|
340 |
}
|
| 401 |
|
341 |
|
| 402 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_ROLE_ALL, method = RequestMethod.GET)
|
342 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_ROLE_ALL, method = RequestMethod.GET)
|
| 403 |
public ResponseEntity<?> getAllRoles(HttpServletRequest request, @RequestParam(name = "id") int id) {
|
343 |
public ResponseEntity<?> getAllRoles(HttpServletRequest request, @RequestParam(name = "id") int id) {
|
| 404 |
LOGGER.info("requested url : " + request.getRequestURL().toString());
|
344 |
LOGGER.info("requested url : " + request.getRequestURL().toString());
|
| Line 408... |
Line 348... |
| 408 |
@RequestMapping(value = ProfitMandiConstants.URL_ADMIN_TOKEN, method = RequestMethod.POST)
|
348 |
@RequestMapping(value = ProfitMandiConstants.URL_ADMIN_TOKEN, method = RequestMethod.POST)
|
| 409 |
public ResponseEntity<?> getAdminToken(HttpServletRequest request,
|
349 |
public ResponseEntity<?> getAdminToken(HttpServletRequest request,
|
| 410 |
@RequestParam(name = "adminToken") String adminToken, @RequestParam(name = "emailId") String emailId) {
|
350 |
@RequestParam(name = "adminToken") String adminToken, @RequestParam(name = "emailId") String emailId) {
|
| 411 |
LOGGER.info("requested url : " + request.getRequestURL().toString());
|
351 |
LOGGER.info("requested url : " + request.getRequestURL().toString());
|
| 412 |
if (!adminToken.equals(validAdminToken)) {
|
352 |
if (!adminToken.equals(validAdminToken)) {
|
| 413 |
final ProfitMandiResponse<?> profitMandiResponse = new ProfitMandiResponse<>(LocalDateTime.now(),
|
- |
|
| 414 |
request.getRequestURL().toString(), HttpStatus.FORBIDDEN.toString(), HttpStatus.FORBIDDEN,
|
- |
|
| 415 |
ResponseStatus.FAILURE, null);
|
353 |
return responseSender.forbidden(null);
|
| 416 |
return new ResponseEntity<>(profitMandiResponse, HttpStatus.FORBIDDEN);
|
- |
|
| 417 |
}
|
354 |
}
|
| 418 |
|
355 |
|
| 419 |
Map<String, Object> responseMap = new HashMap<>(2);
|
356 |
Map<String, Object> responseMap = new HashMap<>(2);
|
| 420 |
try {
|
357 |
try {
|
| 421 |
User user = userRepository.selectByEmailId(emailId);
|
358 |
User user = userRepository.selectByEmailId(emailId);
|