| Line 16... |
Line 16... |
| 16 |
import org.springframework.web.bind.annotation.RequestParam;
|
16 |
import org.springframework.web.bind.annotation.RequestParam;
|
| 17 |
|
17 |
|
| 18 |
import com.spice.profitmandi.common.ResponseCodeHolder;
|
18 |
import com.spice.profitmandi.common.ResponseCodeHolder;
|
| 19 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
19 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 20 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
20 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 21 |
import com.spice.profitmandi.dao.entity.Retailer;
|
- |
|
| 22 |
import com.spice.profitmandi.dao.entity.Shop;
|
21 |
import com.spice.profitmandi.dao.entity.Shop;
|
| 23 |
import com.spice.profitmandi.dao.repository.RetailerRepository;
|
22 |
import com.spice.profitmandi.dao.repository.RetailerRepository;
|
| 24 |
import com.spice.profitmandi.dao.repository.ShopRepository;
|
23 |
import com.spice.profitmandi.dao.repository.ShopRepository;
|
| 25 |
import com.spice.profitmandi.web.model.ProfitMandiResponse;
|
24 |
import com.spice.profitmandi.web.model.ProfitMandiResponse;
|
| 26 |
import com.spice.profitmandi.web.model.Response;
|
25 |
import com.spice.profitmandi.web.model.Response;
|
| Line 43... |
Line 42... |
| 43 |
@SuppressWarnings("unchecked")
|
42 |
@SuppressWarnings("unchecked")
|
| 44 |
final Map<String, Object> createShopMap = (Map<String, Object>)request.getAttribute(ProfitMandiConstants.CREATE_SHOP_MAP);
|
43 |
final Map<String, Object> createShopMap = (Map<String, Object>)request.getAttribute(ProfitMandiConstants.CREATE_SHOP_MAP);
|
| 45 |
request.removeAttribute(ProfitMandiConstants.CREATE_SHOP_MAP);
|
44 |
request.removeAttribute(ProfitMandiConstants.CREATE_SHOP_MAP);
|
| 46 |
|
45 |
|
| 47 |
try {
|
46 |
try {
|
| 48 |
final Retailer retailer = retailerRepository.selectById((int)createShopMap.get(ProfitMandiConstants.RETAILER_ID));
|
- |
|
| 49 |
Shop shop = new Shop();
|
47 |
Shop shop = new Shop();
|
| - |
|
48 |
shop.setRetailerId((int)createShopMap.get(ProfitMandiConstants.RETAILER_ID));
|
| 50 |
//shop.setRetailer(retailer);
|
49 |
//shop.setRetailer(retailer);
|
| 51 |
shop.setName(createShopMap.get(ProfitMandiConstants.NAME).toString());
|
50 |
shop.setName(createShopMap.get(ProfitMandiConstants.NAME).toString());
|
| 52 |
shop.setCreateTimestamp(LocalDateTime.now());
|
51 |
shop.setCreateTimestamp(LocalDateTime.now());
|
| 53 |
shop.setUpdateTimestamp(LocalDateTime.now());
|
52 |
shop.setUpdateTimestamp(LocalDateTime.now());
|
| 54 |
shopRepository.persist(shop);
|
53 |
shopRepository.persist(shop);
|
| Line 57... |
Line 56... |
| 57 |
}catch (ProfitMandiBusinessException pmbe) {
|
56 |
}catch (ProfitMandiBusinessException pmbe) {
|
| 58 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
57 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
| 59 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
58 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
| 60 |
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);
|
| 61 |
return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);
|
60 |
return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);
|
| 62 |
}catch (Exception e) {
|
- |
|
| 63 |
LOGGER.error("Internal Server Error : ",e);
|
- |
|
| 64 |
final Response response=new Response("","","", e.getMessage());
|
- |
|
| 65 |
final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
|
- |
|
| 66 |
return new ResponseEntity<>(chatOnResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
- |
|
| 67 |
}
|
61 |
}
|
| 68 |
}
|
62 |
}
|
| 69 |
|
63 |
|
| 70 |
@RequestMapping(value = ProfitMandiConstants.URL_SHOP_ALL, method=RequestMethod.GET)
|
64 |
@RequestMapping(value = ProfitMandiConstants.URL_SHOP_ALL, method=RequestMethod.GET)
|
| 71 |
public ResponseEntity<?> getAll(HttpServletRequest request){
|
65 |
public ResponseEntity<?> getAll(HttpServletRequest request){
|
| 72 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
66 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
| 73 |
try {
|
- |
|
| 74 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, shopRepository.selectAll());
|
67 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, shopRepository.selectAll());
|
| 75 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
68 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
| 76 |
}catch (Exception e) {
|
- |
|
| 77 |
LOGGER.error("Internal Server Error : ",e);
|
- |
|
| 78 |
final Response response=new Response("","","", e.getMessage());
|
- |
|
| 79 |
final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
|
- |
|
| 80 |
return new ResponseEntity<>(chatOnResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
- |
|
| 81 |
}
|
- |
|
| 82 |
}
|
69 |
}
|
| 83 |
@RequestMapping(value = ProfitMandiConstants.URL_SHOP_ID, method=RequestMethod.GET)
|
70 |
@RequestMapping(value = ProfitMandiConstants.URL_SHOP_ID, method=RequestMethod.GET)
|
| 84 |
public ResponseEntity<?> getById(HttpServletRequest request, @RequestParam(name = "id") int id){
|
71 |
public ResponseEntity<?> getById(HttpServletRequest request, @RequestParam(name = "id") long id){
|
| 85 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
72 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
| 86 |
try {
|
73 |
try {
|
| 87 |
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));
|
| 88 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
75 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
| 89 |
}catch (ProfitMandiBusinessException pmbe) {
|
76 |
}catch (ProfitMandiBusinessException pmbe) {
|
| 90 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
77 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
| 91 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
78 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
| 92 |
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);
|
| 93 |
return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);
|
80 |
return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);
|
| 94 |
}catch (Exception e) {
|
- |
|
| 95 |
LOGGER.error("Internal Server Error : ",e);
|
- |
|
| 96 |
final Response response=new Response("","","", e.getMessage());
|
- |
|
| 97 |
final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
|
- |
|
| 98 |
return new ResponseEntity<>(chatOnResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
- |
|
| 99 |
}
|
81 |
}
|
| 100 |
}
|
82 |
}
|
| 101 |
|
83 |
|
| 102 |
@RequestMapping(value = ProfitMandiConstants.URL_SHOP_NAME, method=RequestMethod.GET)
|
84 |
@RequestMapping(value = ProfitMandiConstants.URL_SHOP_NAME, method=RequestMethod.GET)
|
| 103 |
public ResponseEntity<?> getByName(HttpServletRequest request, @RequestParam(name = "name") String name){
|
85 |
public ResponseEntity<?> getByName(HttpServletRequest request, @RequestParam(name = "name") String name){
|
| Line 108... |
Line 90... |
| 108 |
}catch (ProfitMandiBusinessException pmbe) {
|
90 |
}catch (ProfitMandiBusinessException pmbe) {
|
| 109 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
91 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
| 110 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
92 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
| 111 |
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);
|
| 112 |
return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);
|
94 |
return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);
|
| 113 |
}catch (Exception e) {
|
- |
|
| 114 |
LOGGER.error("Internal Server Error : ",e);
|
- |
|
| 115 |
final Response response=new Response("","","", e.getMessage());
|
- |
|
| 116 |
final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
|
- |
|
| 117 |
return new ResponseEntity<>(chatOnResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
- |
|
| 118 |
}
|
95 |
}
|
| 119 |
}
|
96 |
}
|
| 120 |
|
97 |
|
| 121 |
|
98 |
|
| 122 |
|
99 |
|
| 123 |
@RequestMapping(value = ProfitMandiConstants.URL_SHOP_ID, method=RequestMethod.DELETE)
|
100 |
@RequestMapping(value = ProfitMandiConstants.URL_SHOP_ID, method=RequestMethod.DELETE)
|
| 124 |
public ResponseEntity<?> removeById(HttpServletRequest request, @RequestParam(name = "id") int id){
|
101 |
public ResponseEntity<?> removeById(HttpServletRequest request, @RequestParam(name = "id") long id){
|
| 125 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
102 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
| 126 |
try {
|
103 |
try {
|
| 127 |
shopRepository.deleteById(id);
|
104 |
shopRepository.deleteById(id);
|
| 128 |
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"));
|
| 129 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
106 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
| 130 |
}catch (ProfitMandiBusinessException pmbe) {
|
107 |
}catch (ProfitMandiBusinessException pmbe) {
|
| 131 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
108 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
| 132 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
109 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
| 133 |
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);
|
| 134 |
return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);
|
111 |
return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);
|
| 135 |
}catch (Exception e) {
|
- |
|
| 136 |
LOGGER.error("Internal Server error : ",e);
|
- |
|
| 137 |
final Response response=new Response("","","", e.getMessage());
|
- |
|
| 138 |
final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
|
- |
|
| 139 |
return new ResponseEntity<>(chatOnResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
- |
|
| 140 |
}
|
112 |
}
|
| 141 |
}
|
113 |
}
|
| 142 |
|
114 |
|
| 143 |
}
|
115 |
}
|