Subversion Repositories SmartDukaan

Rev

Rev 21464 | Rev 21505 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 21464 Rev 21468
Line 1... Line 1...
1
package com.spice.profitmandi.web.controller;
1
package com.spice.profitmandi.web.controller;
2
 
2
 
3
import java.time.LocalDateTime;
3
import java.time.LocalDateTime;
-
 
4
import java.util.ArrayList;
-
 
5
import java.util.List;
-
 
6
import java.util.Map;
4
 
7
 
5
import javax.servlet.http.HttpServletRequest;
8
import javax.servlet.http.HttpServletRequest;
6
 
9
 
7
import org.slf4j.Logger;
10
import org.slf4j.Logger;
8
import org.slf4j.LoggerFactory;
11
import org.slf4j.LoggerFactory;
Line 13... Line 16...
13
import org.springframework.web.bind.annotation.RequestMapping;
16
import org.springframework.web.bind.annotation.RequestMapping;
14
import org.springframework.web.bind.annotation.RequestMethod;
17
import org.springframework.web.bind.annotation.RequestMethod;
15
import org.springframework.web.bind.annotation.RequestParam;
18
import org.springframework.web.bind.annotation.RequestParam;
16
 
19
 
17
import com.spice.profitmandi.common.model.ProfitMandiConstants;
20
import com.spice.profitmandi.common.model.ProfitMandiConstants;
-
 
21
import com.spice.profitmandi.common.util.Utils;
18
import com.spice.profitmandi.thrift.clients.TransactionClient;
22
import com.spice.profitmandi.thrift.clients.TransactionClient;
19
import com.spice.profitmandi.web.model.ProfitMandiResponse;
23
import com.spice.profitmandi.web.model.ProfitMandiResponse;
20
import com.spice.profitmandi.web.model.ResponseStatus;
24
import com.spice.profitmandi.web.model.ResponseStatus;
21
 
25
 
-
 
26
import in.shop2020.model.v1.order.DenominationType;
22
import in.shop2020.model.v1.order.DeviceNumberInfo;
27
import in.shop2020.model.v1.order.DeviceNumberInfo;
-
 
28
import in.shop2020.model.v1.order.RechargeDenomination;
23
import in.shop2020.model.v1.order.RechargeType;
29
import in.shop2020.model.v1.order.RechargeType;
24
import io.swagger.annotations.ApiImplicitParam;
30
import io.swagger.annotations.ApiImplicitParam;
25
import io.swagger.annotations.ApiImplicitParams;
31
import io.swagger.annotations.ApiImplicitParams;
26
import io.swagger.annotations.ApiOperation;
32
import io.swagger.annotations.ApiOperation;
27
 
33
 
Line 45... Line 51...
45
		} catch (Exception e) {
51
		} catch (Exception e) {
46
			log.error("Unable to get service provider for Device number " + deviceNumber + " and rechargeType : " +  rechargeType, e);
52
			log.error("Unable to get service provider for Device number " + deviceNumber + " and rechargeType : " +  rechargeType, e);
47
		}
53
		}
48
		final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString() , HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, deviceInfo);
54
		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);
55
		return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
50
		
-
 
51
	}
56
	}
-
 
57
	
-
 
58
	@RequestMapping(value = ProfitMandiConstants.URL_GET_ALL_DENOMINATIONS, method=RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE)
-
 
59
	@ApiImplicitParams({
-
 
60
		@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", 
-
 
61
				required = true, dataType = "string", paramType = "header")
-
 
62
	})
-
 
63
	@ApiOperation(value = "")
-
 
64
	public ResponseEntity<?> getAllDenominations(HttpServletRequest request, @RequestParam(value="operatorId") long operatorId, @RequestParam(value="circleCode") String circleCode, @RequestParam(value="denominationType") String denominationType){
-
 
65
		List<RechargeDenomination> rechargeDenominations = new ArrayList<RechargeDenomination>();
-
 
66
		TransactionClient tcl;
-
 
67
		try {
-
 
68
			tcl = new TransactionClient();
-
 
69
			rechargeDenominations =  tcl.getClient().getRechargeDenominations(operatorId, circleCode, DenominationType.valueOf(denominationType));
-
 
70
		} catch (Exception e) {
-
 
71
			log.error("Unable to get rechargeDenominations for operatorId " + operatorId + " and circleCode : " +  circleCode + " and DenominationType : " + denominationType, e);
-
 
72
		}
-
 
73
		final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString() , HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, rechargeDenominations);
-
 
74
		return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
-
 
75
	}
-
 
76
	
-
 
77
	@RequestMapping(value = ProfitMandiConstants.URL_MOBILE_OPERATORS, method=RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE)
-
 
78
	@ApiImplicitParams({
-
 
79
		@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", 
-
 
80
				required = true, dataType = "string", paramType = "header")
-
 
81
	})
-
 
82
	@ApiOperation(value = "")
-
 
83
	public ResponseEntity<?> getAllMobileOperators(HttpServletRequest request){
-
 
84
		Map<Long, String> mobileProviderMap = Utils.getMobileProvidersMap();
-
 
85
		final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString() , HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, mobileProviderMap);
-
 
86
		return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
-
 
87
	}
-
 
88
	
-
 
89
	@RequestMapping(value = ProfitMandiConstants.URL_DTH_OPERATORS, method=RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE)
-
 
90
	@ApiImplicitParams({
-
 
91
		@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", 
-
 
92
				required = true, dataType = "string", paramType = "header")
-
 
93
	})
-
 
94
	@ApiOperation(value = "")
-
 
95
	public ResponseEntity<?> getAllDTHOperators(HttpServletRequest request){
-
 
96
		Map<Long, String> dthProviderMap = Utils.getDthProvidersMap();
-
 
97
		final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString() , HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, dthProviderMap);
-
 
98
		return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
-
 
99
	}
-
 
100
 
52
}
101
}