Subversion Repositories SmartDukaan

Rev

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

Rev 21431 Rev 21440
Line 51... Line 51...
51
			shop.setCreateTimestamp(LocalDateTime.now());
51
			shop.setCreateTimestamp(LocalDateTime.now());
52
			shop.setUpdateTimestamp(LocalDateTime.now());
52
			shop.setUpdateTimestamp(LocalDateTime.now());
53
			shopRepository.persist(shop);
53
			shopRepository.persist(shop);
54
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("API_OK_1000"));
54
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("API_OK_1000"));
55
			return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
55
			return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
56
		}catch (ProfitMandiBusinessException pmbe) {
56
		}catch (ProfitMandiBusinessException profitMandiBusinessException) {
57
			LOGGER.error("ProfitMandi error: ", pmbe);
57
			LOGGER.error("ProfitMandi error: ",  profitMandiBusinessException);
58
			final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
58
			final Response response=new Response(profitMandiBusinessException.getRejectedType(), profitMandiBusinessException.getRejectedValue(),profitMandiBusinessException.getCode(), profitMandiBusinessException.getMessage());
59
			final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
59
			final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
60
			return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);
60
			return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);
61
		}
61
		}
62
	}
62
	}
63
	
63
	
Line 71... Line 71...
71
	public ResponseEntity<?> getById(HttpServletRequest request, @RequestParam(name = "id") int id){
71
	public ResponseEntity<?> getById(HttpServletRequest request, @RequestParam(name = "id") int id){
72
		LOGGER.info("requested url : "+request.getRequestURL().toString());
72
		LOGGER.info("requested url : "+request.getRequestURL().toString());
73
		try {
73
		try {
74
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, shopRepository.selectById(id));
74
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, shopRepository.selectById(id));
75
			return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
75
			return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
76
		}catch (ProfitMandiBusinessException pmbe) {
76
		}catch (ProfitMandiBusinessException profitMandiBusinessException) {
77
			LOGGER.error("ProfitMandi error: ", pmbe);
77
			LOGGER.error("ProfitMandi error: ",  profitMandiBusinessException);
78
			final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
78
			final Response response=new Response(profitMandiBusinessException.getRejectedType(), profitMandiBusinessException.getRejectedValue(),profitMandiBusinessException.getCode(), profitMandiBusinessException.getMessage());
79
			final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
79
			final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
80
			return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);
80
			return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);
81
		}
81
		}
82
	}
82
	}
83
	
83
	
Line 85... Line 85...
85
	public ResponseEntity<?> getByName(HttpServletRequest request, @RequestParam(name = "name") String name){
85
	public ResponseEntity<?> getByName(HttpServletRequest request, @RequestParam(name = "name") String name){
86
		LOGGER.info("requested url : "+request.getRequestURL().toString());
86
		LOGGER.info("requested url : "+request.getRequestURL().toString());
87
		try {
87
		try {
88
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, shopRepository.selectByName(name));
88
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, shopRepository.selectByName(name));
89
			return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
89
			return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
90
		}catch (ProfitMandiBusinessException pmbe) {
90
		}catch (ProfitMandiBusinessException profitMandiBusinessException) {
91
			LOGGER.error("ProfitMandi error: ", pmbe);
91
			LOGGER.error("ProfitMandi error: ",  profitMandiBusinessException);
92
			final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
92
			final Response response=new Response(profitMandiBusinessException.getRejectedType(), profitMandiBusinessException.getRejectedValue(),profitMandiBusinessException.getCode(), profitMandiBusinessException.getMessage());
93
			final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
93
			final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
94
			return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);
94
			return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);
95
		}
95
		}
96
	}
96
	}
97
	
97
	
Line 102... Line 102...
102
		LOGGER.info("requested url : "+request.getRequestURL().toString());
102
		LOGGER.info("requested url : "+request.getRequestURL().toString());
103
		try {
103
		try {
104
			shopRepository.deleteById(id);
104
			shopRepository.deleteById(id);
105
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("API_OK_1001"));
105
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("API_OK_1001"));
106
			return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
106
			return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
107
		}catch (ProfitMandiBusinessException pmbe) {
107
		}catch (ProfitMandiBusinessException profitMandiBusinessException) {
108
			LOGGER.error("ProfitMandi error: ", pmbe);
108
			LOGGER.error("ProfitMandi error: ",  profitMandiBusinessException);
109
			final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
109
			final Response response=new Response(profitMandiBusinessException.getRejectedType(), profitMandiBusinessException.getRejectedValue(),profitMandiBusinessException.getCode(), profitMandiBusinessException.getMessage());
110
			final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
110
			final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
111
			return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);
111
			return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);
112
		}
112
		}
113
	}
113
	}
114
	
114