| Line 1... |
Line 1... |
| 1 |
package com.spice.profitmandi.web.controller;
|
1 |
package com.spice.profitmandi.web.controller;
|
| 2 |
|
2 |
|
| - |
|
3 |
import java.util.HashMap;
|
| - |
|
4 |
import java.util.Map;
|
| - |
|
5 |
|
| 3 |
import javax.servlet.http.HttpServletRequest;
|
6 |
import javax.servlet.http.HttpServletRequest;
|
| 4 |
|
7 |
|
| 5 |
import org.slf4j.Logger;
|
8 |
import org.slf4j.Logger;
|
| 6 |
import org.slf4j.LoggerFactory;
|
9 |
import org.slf4j.LoggerFactory;
|
| 7 |
import org.springframework.beans.factory.annotation.Autowired;
|
10 |
import org.springframework.beans.factory.annotation.Autowired;
|
| - |
|
11 |
import org.springframework.beans.factory.annotation.Value;
|
| 8 |
import org.springframework.http.ResponseEntity;
|
12 |
import org.springframework.http.ResponseEntity;
|
| 9 |
import org.springframework.stereotype.Controller;
|
13 |
import org.springframework.stereotype.Controller;
|
| 10 |
import org.springframework.transaction.annotation.Transactional;
|
14 |
import org.springframework.transaction.annotation.Transactional;
|
| - |
|
15 |
import org.springframework.web.bind.annotation.PathVariable;
|
| 11 |
import org.springframework.web.bind.annotation.RequestMapping;
|
16 |
import org.springframework.web.bind.annotation.RequestMapping;
|
| 12 |
import org.springframework.web.bind.annotation.RequestMethod;
|
17 |
import org.springframework.web.bind.annotation.RequestMethod;
|
| 13 |
import org.springframework.web.bind.annotation.RequestParam;
|
18 |
import org.springframework.web.bind.annotation.RequestParam;
|
| 14 |
|
19 |
|
| - |
|
20 |
import com.eclipsesource.json.Json;
|
| - |
|
21 |
import com.eclipsesource.json.JsonObject;
|
| - |
|
22 |
import com.spice.profitmandi.common.enumuration.SchemeType;
|
| 15 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
23 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 16 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
24 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| - |
|
25 |
import com.spice.profitmandi.common.web.client.RestClient;
|
| 17 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
26 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
| 18 |
import com.spice.profitmandi.dao.model.UserCart;
|
27 |
import com.spice.profitmandi.dao.model.UserCart;
|
| 19 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
28 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
| 20 |
import com.spice.profitmandi.dao.repository.user.AddressRepository;
|
29 |
import com.spice.profitmandi.dao.repository.user.AddressRepository;
|
| 21 |
|
30 |
|
| Line 24... |
Line 33... |
| 24 |
|
33 |
|
| 25 |
@Controller
|
34 |
@Controller
|
| 26 |
@Transactional(rollbackFor=Throwable.class)
|
35 |
@Transactional(rollbackFor=Throwable.class)
|
| 27 |
public class AddressController {
|
36 |
public class AddressController {
|
| 28 |
|
37 |
|
| - |
|
38 |
@Value("${python.api.host}")
|
| - |
|
39 |
private String host;
|
| - |
|
40 |
@Value("${python.api.port}")
|
| - |
|
41 |
private int port;
|
| - |
|
42 |
|
| 29 |
@Autowired
|
43 |
@Autowired
|
| 30 |
ResponseSender<?> responseSender;
|
44 |
ResponseSender<?> responseSender;
|
| 31 |
|
45 |
|
| 32 |
private static final Logger LOGGER=LoggerFactory.getLogger(AddressController.class);
|
46 |
private static final Logger LOGGER=LoggerFactory.getLogger(AddressController.class);
|
| 33 |
|
47 |
|
| Line 58... |
Line 72... |
| 58 |
}catch (ProfitMandiBusinessException profitMandiBusinessException) {
|
72 |
}catch (ProfitMandiBusinessException profitMandiBusinessException) {
|
| 59 |
LOGGER.error("ProfitMandi error: ", profitMandiBusinessException);
|
73 |
LOGGER.error("ProfitMandi error: ", profitMandiBusinessException);
|
| 60 |
return responseSender.badRequest(profitMandiBusinessException);
|
74 |
return responseSender.badRequest(profitMandiBusinessException);
|
| 61 |
}
|
75 |
}
|
| 62 |
}
|
76 |
}
|
| - |
|
77 |
|
| - |
|
78 |
@RequestMapping(value = "/pin-info/{pinCode}", method=RequestMethod.GET)
|
| - |
|
79 |
public ResponseEntity<?> getPinInfo(HttpServletRequest request, @PathVariable(value="pinCode") String pinCode){
|
| - |
|
80 |
try {
|
| - |
|
81 |
RestClient rc = new RestClient(SchemeType.HTTP, host, port);
|
| - |
|
82 |
Map<String, String> params = new HashMap<>();
|
| - |
|
83 |
String response = rc.get("pincodeValidation/" + pinCode, params);
|
| - |
|
84 |
JsonObject result_json = Json.parse(response).asObject();
|
| - |
|
85 |
return responseSender.ok(result_json);
|
| - |
|
86 |
}catch (ProfitMandiBusinessException profitMandiBusinessException) {
|
| - |
|
87 |
LOGGER.error("ProfitMandi error: ", profitMandiBusinessException);
|
| - |
|
88 |
return responseSender.badRequest(profitMandiBusinessException);
|
| - |
|
89 |
}
|
| 63 |
|
90 |
}
|
| 64 |
|
91 |
|
| 65 |
}
|
92 |
}
|