Subversion Repositories SmartDukaan

Rev

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

Rev 21368 Rev 21404
Line 82... Line 82...
82
			final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
82
			final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
83
			return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
83
			return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
84
		}
84
		}
85
	}
85
	}
86
	
86
	
87
	@RequestMapping(value = ProfitMandiConstants.URL_USER_TOKEN_DETAIL, method=RequestMethod.GET)
-
 
88
	public ResponseEntity<?> tokenDetail(HttpServletRequest request, @RequestParam(name = "token") String token){
-
 
89
		LOGGER.info("requested url : "+request.getRequestURL().toString());
-
 
90
		try {
-
 
91
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, userRepository.selectById(JWTUtil.getUserId(token)));
-
 
92
			return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
-
 
93
		}catch (ProfitMandiBusinessException pmbe) {
-
 
94
			LOGGER.error("ProfitMandi error: ", pmbe);
-
 
95
			final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
-
 
96
			final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
-
 
97
			return new ResponseEntity<>(profitMandiResponse,HttpStatus.BAD_REQUEST);
-
 
98
		}catch (Exception e) {
-
 
99
			LOGGER.error("Internal Server Error: ", e);
-
 
100
			final Response response=new Response("","","", e.getMessage());
-
 
101
			final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
-
 
102
			return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
-
 
103
		}
-
 
104
	}
-
 
105
	
-
 
106
	@RequestMapping(value = ProfitMandiConstants.URL_USER, method=RequestMethod.POST)
87
	@RequestMapping(value = ProfitMandiConstants.URL_USER, method=RequestMethod.POST)
107
	public ResponseEntity<?> createUser(HttpServletRequest request, @RequestBody UserRequest userRequest){
88
	public ResponseEntity<?> createUser(HttpServletRequest request, @RequestBody UserRequest userRequest){
108
		LOGGER.info("requested url : "+request.getRequestURL().toString());
89
		LOGGER.info("requested url : "+request.getRequestURL().toString());
109
		User user = new User();
90
		User user = new User();
110
		user.setFirstName(userRequest.getFirstName());
91
		user.setFirstName(userRequest.getFirstName());
Line 152... Line 133...
152
			return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
133
			return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
153
		}
134
		}
154
	}
135
	}
155
	
136
	
156
	@RequestMapping(value = ProfitMandiConstants.URL_USER_ID,method=RequestMethod.GET)
137
	@RequestMapping(value = ProfitMandiConstants.URL_USER_ID,method=RequestMethod.GET)
157
	public ResponseEntity<?> getById(HttpServletRequest request, @RequestParam(name = "id") long id){
138
	public ResponseEntity<?> getById(HttpServletRequest request, @RequestParam(name = "id") int id){
158
		LOGGER.info("requested url : "+request.getRequestURL().toString());
139
		LOGGER.info("requested url : "+request.getRequestURL().toString());
159
		try {
140
		try {
160
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, userRepository.selectById(id));
141
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, userRepository.selectById(id));
161
			return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
142
			return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
162
		}catch (ProfitMandiBusinessException pmbe) {
143
		}catch (ProfitMandiBusinessException pmbe) {
Line 210... Line 191...
210
			return new ResponseEntity<>(profitMandiResponse, HttpStatus.INTERNAL_SERVER_ERROR);
191
			return new ResponseEntity<>(profitMandiResponse, HttpStatus.INTERNAL_SERVER_ERROR);
211
		}
192
		}
212
	}
193
	}
213
	
194
	
214
	@RequestMapping(value = ProfitMandiConstants.URL_USER_ROLE_BY_ID_WITH_ID, method = RequestMethod.PUT)
195
	@RequestMapping(value = ProfitMandiConstants.URL_USER_ROLE_BY_ID_WITH_ID, method = RequestMethod.PUT)
215
	public ResponseEntity<?> addRoleByIdWithId(HttpServletRequest request, @RequestParam(name = "roleId") long roleId, @RequestParam(name = "userId") long userId){
196
	public ResponseEntity<?> addRoleByIdWithId(HttpServletRequest request, @RequestParam(name = "roleId") int roleId, @RequestParam(name = "userId") int userId){
216
		LOGGER.info("requested url : "+request.getRequestURL().toString());
197
		LOGGER.info("requested url : "+request.getRequestURL().toString());
217
		try {
198
		try {
218
			userRepository.addRoleByIdWithId(roleId, userId);
199
			userRepository.addRoleByIdWithId(roleId, userId);
219
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1001"));
200
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1001"));
220
			return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
201
			return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
Line 232... Line 213...
232
	}
213
	}
233
	
214
	
234
	
215
	
235
	
216
	
236
	@RequestMapping(value = ProfitMandiConstants.URL_USER_ROLE_BY_ID_WITH_MOBILE_NUMBER, method = RequestMethod.PUT)
217
	@RequestMapping(value = ProfitMandiConstants.URL_USER_ROLE_BY_ID_WITH_MOBILE_NUMBER, method = RequestMethod.PUT)
237
	public ResponseEntity<?> addRoleByIdWithMobileNumber(HttpServletRequest request, @RequestParam(name = "roleId") long id, @RequestParam(name = "mobileNumber") String mobileNumber){
218
	public ResponseEntity<?> addRoleByIdWithMobileNumber(HttpServletRequest request, @RequestParam(name = "roleId") int id, @RequestParam(name = "mobileNumber") String mobileNumber){
238
		LOGGER.info("requested url : "+request.getRequestURL().toString());
219
		LOGGER.info("requested url : "+request.getRequestURL().toString());
239
		try {
220
		try {
240
			userRepository.addRoleByIdWithMobileNumber(id, mobileNumber);
221
			userRepository.addRoleByIdWithMobileNumber(id, mobileNumber);
241
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1001"));
222
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1001"));
242
			return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
223
			return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
Line 252... Line 233...
252
			return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
233
			return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
253
		}
234
		}
254
	}
235
	}
255
	
236
	
256
	@RequestMapping(value = ProfitMandiConstants.URL_USER_ROLE_BY_ID_WITH_EMAIL_ID, method = RequestMethod.PUT)
237
	@RequestMapping(value = ProfitMandiConstants.URL_USER_ROLE_BY_ID_WITH_EMAIL_ID, method = RequestMethod.PUT)
257
	public ResponseEntity<?> addRoleByIdWithEmailId(HttpServletRequest request, @RequestParam(name = "roleId") long id, @RequestParam(name = "emailId") String emailId){
238
	public ResponseEntity<?> addRoleByIdWithEmailId(HttpServletRequest request, @RequestParam(name = "roleId") int id, @RequestParam(name = "emailId") String emailId){
258
		LOGGER.info("requested url : "+request.getRequestURL().toString());
239
		LOGGER.info("requested url : "+request.getRequestURL().toString());
259
		try {
240
		try {
260
			userRepository.addRoleByIdWithEmailId(id, emailId);
241
			userRepository.addRoleByIdWithEmailId(id, emailId);
261
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1001"));
242
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1001"));
262
			return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
243
			return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
Line 272... Line 253...
272
			return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
253
			return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
273
		}
254
		}
274
	}
255
	}
275
	
256
	
276
	@RequestMapping(value = ProfitMandiConstants.URL_USER_ROLE_BY_NAME_WITH_ID, method = RequestMethod.PUT)
257
	@RequestMapping(value = ProfitMandiConstants.URL_USER_ROLE_BY_NAME_WITH_ID, method = RequestMethod.PUT)
277
	public ResponseEntity<?> addRoleByNameWithId(HttpServletRequest request, @RequestParam(name = "roleName") String roleName, @RequestParam(name = "userId") long id){
258
	public ResponseEntity<?> addRoleByNameWithId(HttpServletRequest request, @RequestParam(name = "roleName") String roleName, @RequestParam(name = "userId") int id){
278
		LOGGER.info("requested url : "+request.getRequestURL().toString());
259
		LOGGER.info("requested url : "+request.getRequestURL().toString());
279
		try {
260
		try {
280
			userRepository.addRoleByNameWithId(roleName, id);
261
			userRepository.addRoleByNameWithId(roleName, id);
281
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1001"));
262
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1001"));
282
			return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
263
			return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
Line 333... Line 314...
333
			return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
314
			return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
334
		}
315
		}
335
	}
316
	}
336
	
317
	
337
	@RequestMapping(value = ProfitMandiConstants.URL_USER_ROLE_BY_ID_WITH_ID, method = RequestMethod.DELETE)
318
	@RequestMapping(value = ProfitMandiConstants.URL_USER_ROLE_BY_ID_WITH_ID, method = RequestMethod.DELETE)
338
	public ResponseEntity<?> removeRoleByIdWithId(HttpServletRequest request, @RequestParam(name = "roleId") long roleId, @RequestParam(name = "userId") long userId){
319
	public ResponseEntity<?> removeRoleByIdWithId(HttpServletRequest request, @RequestParam(name = "roleId") int roleId, @RequestParam(name = "userId") int userId){
339
		LOGGER.info("requested url : "+request.getRequestURL().toString());
320
		LOGGER.info("requested url : "+request.getRequestURL().toString());
340
		try {
321
		try {
341
			userRepository.deleteRoleByIdWithId(roleId, userId);
322
			userRepository.deleteRoleByIdWithId(roleId, userId);
342
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1001"));
323
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1001"));
343
			return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
324
			return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
Line 355... Line 336...
355
	}
336
	}
356
	
337
	
357
	
338
	
358
	
339
	
359
	@RequestMapping(value = ProfitMandiConstants.URL_USER_ROLE_BY_ID_WITH_MOBILE_NUMBER, method = RequestMethod.DELETE)
340
	@RequestMapping(value = ProfitMandiConstants.URL_USER_ROLE_BY_ID_WITH_MOBILE_NUMBER, method = RequestMethod.DELETE)
360
	public ResponseEntity<?> removeRoleByIdWithMobileNumber(HttpServletRequest request, @RequestParam(name = "roleId") long id, @RequestParam(name = "mobileNumber") String mobileNumber){
341
	public ResponseEntity<?> removeRoleByIdWithMobileNumber(HttpServletRequest request, @RequestParam(name = "roleId") int id, @RequestParam(name = "mobileNumber") String mobileNumber){
361
		LOGGER.info("requested url : "+request.getRequestURL().toString());
342
		LOGGER.info("requested url : "+request.getRequestURL().toString());
362
		try {
343
		try {
363
			userRepository.deleteRoleByIdWithMobileNumber(id, mobileNumber);
344
			userRepository.deleteRoleByIdWithMobileNumber(id, mobileNumber);
364
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1001"));
345
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1001"));
365
			return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
346
			return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
Line 375... Line 356...
375
			return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
356
			return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
376
		}
357
		}
377
	}
358
	}
378
	
359
	
379
	@RequestMapping(value = ProfitMandiConstants.URL_USER_ROLE_BY_ID_WITH_EMAIL_ID, method = RequestMethod.DELETE)
360
	@RequestMapping(value = ProfitMandiConstants.URL_USER_ROLE_BY_ID_WITH_EMAIL_ID, method = RequestMethod.DELETE)
380
	public ResponseEntity<?> removeRoleByIdWithEmailId(HttpServletRequest request, @RequestParam(name = "roleId") long id, @RequestParam(name = "emailId") String emailId){
361
	public ResponseEntity<?> removeRoleByIdWithEmailId(HttpServletRequest request, @RequestParam(name = "roleId") int id, @RequestParam(name = "emailId") String emailId){
381
		LOGGER.info("requested url : "+request.getRequestURL().toString());
362
		LOGGER.info("requested url : "+request.getRequestURL().toString());
382
		try {
363
		try {
383
			userRepository.deleteRoleByIdWithEmailId(id, emailId);
364
			userRepository.deleteRoleByIdWithEmailId(id, emailId);
384
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1001"));
365
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1001"));
385
			return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
366
			return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
Line 395... Line 376...
395
			return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
376
			return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
396
		}
377
		}
397
	}
378
	}
398
	
379
	
399
	@RequestMapping(value = ProfitMandiConstants.URL_USER_ROLE_BY_NAME_WITH_ID, method = RequestMethod.DELETE)
380
	@RequestMapping(value = ProfitMandiConstants.URL_USER_ROLE_BY_NAME_WITH_ID, method = RequestMethod.DELETE)
400
	public ResponseEntity<?> removeRoleByNameWithId(HttpServletRequest request, @RequestParam(name = "roleName") String roleName, @RequestParam(name = "userId") long id){
381
	public ResponseEntity<?> removeRoleByNameWithId(HttpServletRequest request, @RequestParam(name = "roleName") String roleName, @RequestParam(name = "userId") int id){
401
		LOGGER.info("requested url : "+request.getRequestURL().toString());
382
		LOGGER.info("requested url : "+request.getRequestURL().toString());
402
		try {
383
		try {
403
			userRepository.deleteRoleByNameWithId(roleName, id);
384
			userRepository.deleteRoleByNameWithId(roleName, id);
404
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1001"));
385
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1001"));
405
			return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
386
			return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);