Subversion Repositories SmartDukaan

Rev

Rev 21278 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 21278 Rev 21390
Line 77... Line 77...
77
			return new ResponseEntity<>(chatOnResponse,HttpStatus.INTERNAL_SERVER_ERROR);
77
			return new ResponseEntity<>(chatOnResponse,HttpStatus.INTERNAL_SERVER_ERROR);
78
		}
78
		}
79
	}
79
	}
80
	
80
	
81
	@RequestMapping(value = ProfitMandiConstants.URL_ROLE_ID,method=RequestMethod.GET)
81
	@RequestMapping(value = ProfitMandiConstants.URL_ROLE_ID,method=RequestMethod.GET)
82
	public ResponseEntity<?> getById(HttpServletRequest request, @RequestParam(name = "id") long id){
82
	public ResponseEntity<?> getById(HttpServletRequest request, @RequestParam(name = "id") int id){
83
		LOGGER.info("requested url : "+request.getRequestURL().toString());
83
		LOGGER.info("requested url : "+request.getRequestURL().toString());
84
		try {
84
		try {
85
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, roleRepository.selectById(id));
85
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, roleRepository.selectById(id));
86
			return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
86
			return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
87
		}catch (ProfitMandiBusinessException pmbe) {
87
		}catch (ProfitMandiBusinessException pmbe) {
Line 136... Line 136...
136
			return new ResponseEntity<>(chatOnResponse, HttpStatus.INTERNAL_SERVER_ERROR);
136
			return new ResponseEntity<>(chatOnResponse, HttpStatus.INTERNAL_SERVER_ERROR);
137
		}
137
		}
138
	}
138
	}
139
	
139
	
140
	@RequestMapping(value = ProfitMandiConstants.URL_ROLE_ID,method=RequestMethod.DELETE)
140
	@RequestMapping(value = ProfitMandiConstants.URL_ROLE_ID,method=RequestMethod.DELETE)
141
	public ResponseEntity<?> deleteById(HttpServletRequest request, @RequestParam(name = "id") long id){
141
	public ResponseEntity<?> deleteById(HttpServletRequest request, @RequestParam(name = "id") int id){
142
		LOGGER.info("requested url : "+request.getRequestURL().toString());
142
		LOGGER.info("requested url : "+request.getRequestURL().toString());
143
		try {
143
		try {
144
			roleRepository.deleteById(id);
144
			roleRepository.deleteById(id);
145
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1001"));
145
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1001"));
146
			return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
146
			return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
Line 162... Line 162...
162
	public ResponseEntity<?> updateRole(HttpServletRequest request){
162
	public ResponseEntity<?> updateRole(HttpServletRequest request){
163
		LOGGER.info("requested url : "+request.getRequestURL().toString());
163
		LOGGER.info("requested url : "+request.getRequestURL().toString());
164
		final Map<String, Object> map = (Map<String, Object>)request.getAttribute("updateRoleMap");
164
		final Map<String, Object> map = (Map<String, Object>)request.getAttribute("updateRoleMap");
165
		request.removeAttribute("updateRoleMap");
165
		request.removeAttribute("updateRoleMap");
166
		try {
166
		try {
167
			roleRepository.updateById(map.get(ProfitMandiConstants.NAME).toString(), (RoleType)map.get(ProfitMandiConstants.TYPE), (Long)map.get(ProfitMandiConstants.ID));
167
			roleRepository.updateById(map.get(ProfitMandiConstants.NAME).toString(), (RoleType)map.get(ProfitMandiConstants.TYPE), (Integer)map.get(ProfitMandiConstants.ID));
168
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1000"));
168
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1000"));
169
			return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
169
			return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
170
		}catch (ProfitMandiBusinessException pmbe) {
170
		}catch (ProfitMandiBusinessException pmbe) {
171
			LOGGER.error("ProfitMandi error: ", pmbe);
171
			LOGGER.error("ProfitMandi error: ", pmbe);
172
			final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
172
			final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
Line 179... Line 179...
179
			return new ResponseEntity<>(chatOnResponse,HttpStatus.INTERNAL_SERVER_ERROR);
179
			return new ResponseEntity<>(chatOnResponse,HttpStatus.INTERNAL_SERVER_ERROR);
180
		}
180
		}
181
	}
181
	}
182
	
182
	
183
	@RequestMapping(value = ProfitMandiConstants.URL_ROLE_API_BY_ID_WITH_NAME, method = RequestMethod.PUT)
183
	@RequestMapping(value = ProfitMandiConstants.URL_ROLE_API_BY_ID_WITH_NAME, method = RequestMethod.PUT)
184
	public ResponseEntity<?> addApiByIdWithName(HttpServletRequest request, @RequestParam(name = "apiId") long id, @RequestParam(name = "roleName") String name){
184
	public ResponseEntity<?> addApiByIdWithName(HttpServletRequest request, @RequestParam(name = "apiId") int id, @RequestParam(name = "roleName") String name){
185
		LOGGER.info("requested url : "+request.getRequestURL().toString());
185
		LOGGER.info("requested url : "+request.getRequestURL().toString());
186
		try {
186
		try {
187
			roleRepository.addByIdWithName(id, name);
187
			roleRepository.addByIdWithName(id, name);
188
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1001"));
188
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1001"));
189
			return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
189
			return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
Line 219... Line 219...
219
			return new ResponseEntity<>(chatOnResponse,HttpStatus.INTERNAL_SERVER_ERROR);
219
			return new ResponseEntity<>(chatOnResponse,HttpStatus.INTERNAL_SERVER_ERROR);
220
		}
220
		}
221
	}
221
	}
222
	
222
	
223
	@RequestMapping(value = ProfitMandiConstants.URL_ROLE_API_BY_ID_WITH_ID, method = RequestMethod.PUT)
223
	@RequestMapping(value = ProfitMandiConstants.URL_ROLE_API_BY_ID_WITH_ID, method = RequestMethod.PUT)
224
	public ResponseEntity<?> addApiByIdWithId(HttpServletRequest request, @RequestParam(name = "apiId") long apiId, @RequestParam(name = "roleId") long roleId){
224
	public ResponseEntity<?> addApiByIdWithId(HttpServletRequest request, @RequestParam(name = "apiId") int apiId, @RequestParam(name = "roleId") int roleId){
225
		LOGGER.info("requested url : "+request.getRequestURL().toString());
225
		LOGGER.info("requested url : "+request.getRequestURL().toString());
226
		try {
226
		try {
227
			roleRepository.addByIdWithId(apiId, roleId);
227
			roleRepository.addByIdWithId(apiId, roleId);
228
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1001"));
228
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1001"));
229
			return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
229
			return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
Line 239... Line 239...
239
			return new ResponseEntity<>(chatOnResponse,HttpStatus.INTERNAL_SERVER_ERROR);
239
			return new ResponseEntity<>(chatOnResponse,HttpStatus.INTERNAL_SERVER_ERROR);
240
		}
240
		}
241
	}
241
	}
242
	
242
	
243
	@RequestMapping(value = ProfitMandiConstants.URL_ROLE_API_BY_NAME_WITH_ID, method = RequestMethod.PUT)
243
	@RequestMapping(value = ProfitMandiConstants.URL_ROLE_API_BY_NAME_WITH_ID, method = RequestMethod.PUT)
244
	public ResponseEntity<?> addApiByNameWithId(HttpServletRequest request, @RequestParam(name = "apiName") String name, @RequestParam(name = "roleId") long id){
244
	public ResponseEntity<?> addApiByNameWithId(HttpServletRequest request, @RequestParam(name = "apiName") String name, @RequestParam(name = "roleId") int id){
245
		LOGGER.info("requested url : "+request.getRequestURL().toString());
245
		LOGGER.info("requested url : "+request.getRequestURL().toString());
246
		try {
246
		try {
247
			roleRepository.addByNameWithId(name, id);
247
			roleRepository.addByNameWithId(name, id);
248
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1001"));
248
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1001"));
249
			return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
249
			return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
Line 260... Line 260...
260
		}
260
		}
261
	}
261
	}
262
	
262
	
263
	
263
	
264
	@RequestMapping(value = ProfitMandiConstants.URL_ROLE_API_BY_ID_WITH_NAME, method = RequestMethod.DELETE)
264
	@RequestMapping(value = ProfitMandiConstants.URL_ROLE_API_BY_ID_WITH_NAME, method = RequestMethod.DELETE)
265
	public ResponseEntity<?> removeApiByIdWithName(HttpServletRequest request, @RequestParam(name = "apiId") long id, @RequestParam(name = "roleName") String name){
265
	public ResponseEntity<?> removeApiByIdWithName(HttpServletRequest request, @RequestParam(name = "apiId") int id, @RequestParam(name = "roleName") String name){
266
		LOGGER.info("requested url : "+request.getRequestURL().toString());
266
		LOGGER.info("requested url : "+request.getRequestURL().toString());
267
		try {
267
		try {
268
			roleRepository.deleteByIdWithName(id, name);
268
			roleRepository.deleteByIdWithName(id, name);
269
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1002"));
269
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1002"));
270
			return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
270
			return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
Line 300... Line 300...
300
			return new ResponseEntity<>(chatOnResponse,HttpStatus.INTERNAL_SERVER_ERROR);
300
			return new ResponseEntity<>(chatOnResponse,HttpStatus.INTERNAL_SERVER_ERROR);
301
		}
301
		}
302
	}
302
	}
303
	
303
	
304
	@RequestMapping(value = ProfitMandiConstants.URL_ROLE_API_BY_ID_WITH_ID, method = RequestMethod.DELETE)
304
	@RequestMapping(value = ProfitMandiConstants.URL_ROLE_API_BY_ID_WITH_ID, method = RequestMethod.DELETE)
305
	public ResponseEntity<?> removeApiByIdWithId(HttpServletRequest request, @RequestParam(name = "apiId") long apiId, @RequestParam(name = "roleId") long roleId){
305
	public ResponseEntity<?> removeApiByIdWithId(HttpServletRequest request, @RequestParam(name = "apiId") int apiId, @RequestParam(name = "roleId") int roleId){
306
		LOGGER.info("requested url : "+request.getRequestURL().toString());
306
		LOGGER.info("requested url : "+request.getRequestURL().toString());
307
		try {
307
		try {
308
			roleRepository.deleteByIdWithId(apiId, roleId);
308
			roleRepository.deleteByIdWithId(apiId, roleId);
309
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1002"));
309
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1002"));
310
			return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
310
			return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
Line 320... Line 320...
320
			return new ResponseEntity<>(chatOnResponse,HttpStatus.INTERNAL_SERVER_ERROR);
320
			return new ResponseEntity<>(chatOnResponse,HttpStatus.INTERNAL_SERVER_ERROR);
321
		}
321
		}
322
	}
322
	}
323
	
323
	
324
	@RequestMapping(value = ProfitMandiConstants.URL_ROLE_API_BY_NAME_WITH_ID, method = RequestMethod.DELETE)
324
	@RequestMapping(value = ProfitMandiConstants.URL_ROLE_API_BY_NAME_WITH_ID, method = RequestMethod.DELETE)
325
	public ResponseEntity<?> removeApiByNameWithId(HttpServletRequest request, @RequestParam(name = "apiName") String name, @RequestParam(name = "roleId") long id){
325
	public ResponseEntity<?> removeApiByNameWithId(HttpServletRequest request, @RequestParam(name = "apiName") String name, @RequestParam(name = "roleId") int id){
326
		LOGGER.info("requested url : "+request.getRequestURL().toString());
326
		LOGGER.info("requested url : "+request.getRequestURL().toString());
327
		try {
327
		try {
328
			roleRepository.deleteByNameWithId(name, id);
328
			roleRepository.deleteByNameWithId(name, id);
329
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1002"));
329
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("ROL_OK_1002"));
330
			return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
330
			return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);