| 21390 |
ashik.ali |
1 |
package com.spice.profitmandi.web.controller;
|
|
|
2 |
|
|
|
3 |
import javax.servlet.http.HttpServletRequest;
|
|
|
4 |
|
|
|
5 |
import org.slf4j.Logger;
|
|
|
6 |
import org.slf4j.LoggerFactory;
|
|
|
7 |
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
8 |
import org.springframework.http.ResponseEntity;
|
|
|
9 |
import org.springframework.stereotype.Controller;
|
|
|
10 |
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
11 |
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
12 |
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
13 |
|
|
|
14 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
|
|
15 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
|
|
16 |
import com.spice.profitmandi.dao.repository.AddressRepository;
|
| 21448 |
ashik.ali |
17 |
import com.spice.profitmandi.web.util.ResponseSender;
|
| 21390 |
ashik.ali |
18 |
|
|
|
19 |
@Controller
|
|
|
20 |
public class AddressController {
|
|
|
21 |
|
| 21448 |
ashik.ali |
22 |
@Autowired
|
|
|
23 |
ResponseSender<?> responseSender;
|
|
|
24 |
|
| 21390 |
ashik.ali |
25 |
private static final Logger LOGGER=LoggerFactory.getLogger(AddressController.class);
|
|
|
26 |
|
|
|
27 |
@Autowired
|
|
|
28 |
AddressRepository addressRepository;
|
|
|
29 |
|
|
|
30 |
@RequestMapping(value = ProfitMandiConstants.URL_ADDRESS_ALL, method=RequestMethod.GET)
|
|
|
31 |
public ResponseEntity<?> getAll(HttpServletRequest request){
|
|
|
32 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
| 21448 |
ashik.ali |
33 |
return responseSender.ok(addressRepository.selectAll());
|
| 21390 |
ashik.ali |
34 |
}
|
| 21426 |
ashik.ali |
35 |
|
| 21390 |
ashik.ali |
36 |
@RequestMapping(value = ProfitMandiConstants.URL_ADDRESS_ID, method=RequestMethod.GET)
|
| 21431 |
ashik.ali |
37 |
public ResponseEntity<?> getById(HttpServletRequest request, @RequestParam(name = "id") int id){
|
| 21390 |
ashik.ali |
38 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
|
|
39 |
try {
|
| 21448 |
ashik.ali |
40 |
return responseSender.ok(addressRepository.selectById(id));
|
| 21440 |
ashik.ali |
41 |
}catch (ProfitMandiBusinessException profitMandiBusinessException) {
|
|
|
42 |
LOGGER.error("ProfitMandi error: ", profitMandiBusinessException);
|
| 21448 |
ashik.ali |
43 |
return responseSender.badRequest(profitMandiBusinessException);
|
| 21390 |
ashik.ali |
44 |
}
|
|
|
45 |
}
|
|
|
46 |
|
|
|
47 |
|
|
|
48 |
}
|