| 21464 |
kshitij.so |
1 |
package com.spice.profitmandi.web.controller;
|
|
|
2 |
|
|
|
3 |
import java.time.LocalDateTime;
|
|
|
4 |
|
|
|
5 |
import javax.servlet.http.HttpServletRequest;
|
|
|
6 |
|
|
|
7 |
import org.slf4j.Logger;
|
|
|
8 |
import org.slf4j.LoggerFactory;
|
|
|
9 |
import org.springframework.http.HttpStatus;
|
|
|
10 |
import org.springframework.http.MediaType;
|
|
|
11 |
import org.springframework.http.ResponseEntity;
|
|
|
12 |
import org.springframework.stereotype.Controller;
|
|
|
13 |
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
14 |
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
15 |
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
16 |
|
|
|
17 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
|
|
18 |
import com.spice.profitmandi.thrift.clients.TransactionClient;
|
|
|
19 |
import com.spice.profitmandi.web.model.ProfitMandiResponse;
|
|
|
20 |
import com.spice.profitmandi.web.model.ResponseStatus;
|
|
|
21 |
|
|
|
22 |
import in.shop2020.model.v1.order.DeviceNumberInfo;
|
|
|
23 |
import in.shop2020.model.v1.order.RechargeType;
|
|
|
24 |
import io.swagger.annotations.ApiImplicitParam;
|
|
|
25 |
import io.swagger.annotations.ApiImplicitParams;
|
|
|
26 |
import io.swagger.annotations.ApiOperation;
|
|
|
27 |
|
|
|
28 |
@Controller
|
|
|
29 |
public class RechargeController {
|
|
|
30 |
|
|
|
31 |
private static final Logger log=LoggerFactory.getLogger(RechargeController.class);
|
|
|
32 |
|
|
|
33 |
@RequestMapping(value = ProfitMandiConstants.URL_GET_SERVICE_PROVIDER, method=RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
34 |
@ApiImplicitParams({
|
|
|
35 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token",
|
|
|
36 |
required = true, dataType = "string", paramType = "header")
|
|
|
37 |
})
|
|
|
38 |
@ApiOperation(value = "")
|
|
|
39 |
public ResponseEntity<?> getServiceProvider(HttpServletRequest request, @RequestParam(value="deviceNumber") String deviceNumber, @RequestParam(value="rechargeType") String rechargeType){
|
|
|
40 |
DeviceNumberInfo deviceInfo = null;
|
|
|
41 |
TransactionClient tcl;
|
|
|
42 |
try {
|
|
|
43 |
tcl = new TransactionClient();
|
|
|
44 |
deviceInfo = tcl.getClient().getServiceProviderForDevice(RechargeType.valueOf(rechargeType), deviceNumber.substring(0,4));
|
|
|
45 |
} catch (Exception e) {
|
|
|
46 |
log.error("Unable to get service provider for Device number " + deviceNumber + " and rechargeType : " + rechargeType, e);
|
|
|
47 |
}
|
|
|
48 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString() , HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, deviceInfo);
|
|
|
49 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
|
|
50 |
|
|
|
51 |
}
|
|
|
52 |
}
|