| Line 5... |
Line 5... |
| 5 |
|
5 |
|
| 6 |
import javax.servlet.http.HttpServletRequest;
|
6 |
import javax.servlet.http.HttpServletRequest;
|
| 7 |
|
7 |
|
| 8 |
import org.slf4j.Logger;
|
8 |
import org.slf4j.Logger;
|
| 9 |
import org.slf4j.LoggerFactory;
|
9 |
import org.slf4j.LoggerFactory;
|
| - |
|
10 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 10 |
import org.springframework.http.HttpStatus;
|
11 |
import org.springframework.http.HttpStatus;
|
| 11 |
import org.springframework.http.ResponseEntity;
|
12 |
import org.springframework.http.ResponseEntity;
|
| 12 |
import org.springframework.stereotype.Controller;
|
13 |
import org.springframework.stereotype.Controller;
|
| 13 |
import org.springframework.web.bind.annotation.RequestMapping;
|
14 |
import org.springframework.web.bind.annotation.RequestMapping;
|
| 14 |
import org.springframework.web.bind.annotation.RequestMethod;
|
15 |
import org.springframework.web.bind.annotation.RequestMethod;
|
| Line 18... |
Line 19... |
| 18 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
19 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 19 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
20 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 20 |
import com.spice.profitmandi.dao.entity.Api;
|
21 |
import com.spice.profitmandi.dao.entity.Api;
|
| 21 |
import com.spice.profitmandi.dao.enumuration.Method;
|
22 |
import com.spice.profitmandi.dao.enumuration.Method;
|
| 22 |
import com.spice.profitmandi.dao.repository.ApiRepository;
|
23 |
import com.spice.profitmandi.dao.repository.ApiRepository;
|
| 23 |
import com.spice.profitmandi.dao.repository.ApiRepositoryImpl;
|
- |
|
| 24 |
import com.spice.profitmandi.web.model.ProfitMandiResponse;
|
24 |
import com.spice.profitmandi.web.model.ProfitMandiResponse;
|
| 25 |
import com.spice.profitmandi.web.model.Response;
|
25 |
import com.spice.profitmandi.web.model.Response;
|
| 26 |
import com.spice.profitmandi.web.model.ResponseStatus;
|
26 |
import com.spice.profitmandi.web.model.ResponseStatus;
|
| 27 |
|
27 |
|
| 28 |
@Controller
|
28 |
@Controller
|
| 29 |
public class ApiController {
|
29 |
public class ApiController {
|
| 30 |
|
30 |
|
| 31 |
private static final Logger LOGGER=LoggerFactory.getLogger(ApiController.class);
|
31 |
private static final Logger LOGGER=LoggerFactory.getLogger(ApiController.class);
|
| 32 |
|
32 |
|
| - |
|
33 |
@Autowired
|
| 33 |
private ApiRepository apiRepository = ApiRepositoryImpl.getInstance();
|
34 |
ApiRepository apiRepository;
|
| 34 |
|
35 |
|
| 35 |
@RequestMapping(value = ProfitMandiConstants.URL_API, method=RequestMethod.POST)
|
36 |
@RequestMapping(value = ProfitMandiConstants.URL_API, method=RequestMethod.POST)
|
| 36 |
public ResponseEntity<?> createApi(HttpServletRequest request){
|
37 |
public ResponseEntity<?> createApi(HttpServletRequest request){
|
| 37 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
38 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
| 38 |
final Api api = (Api)request.getAttribute(ProfitMandiConstants.API);
|
39 |
final Api api = (Api)request.getAttribute(ProfitMandiConstants.API);
|
| Line 53... |
Line 54... |
| 53 |
final Response response=new Response("","","", e.getMessage());
|
54 |
final Response response=new Response("","","", e.getMessage());
|
| 54 |
final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
|
55 |
final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
|
| 55 |
return new ResponseEntity<>(chatOnResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
56 |
return new ResponseEntity<>(chatOnResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
| 56 |
}
|
57 |
}
|
| 57 |
}
|
58 |
}
|
| - |
|
59 |
|
| 58 |
@RequestMapping(value = ProfitMandiConstants.URL_API_ALL,method=RequestMethod.GET)
|
60 |
@RequestMapping(value = ProfitMandiConstants.URL_API_ALL,method=RequestMethod.GET)
|
| 59 |
public ResponseEntity<?> getAll(HttpServletRequest request){
|
61 |
public ResponseEntity<?> getAll(HttpServletRequest request){
|
| 60 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
62 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
| 61 |
try {
|
63 |
try {
|
| 62 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, apiRepository.selectAll());
|
64 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, apiRepository.selectAll());
|