Subversion Repositories SmartDukaan

Rev

Rev 22609 | Rev 23037 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
21532 kshitij.so 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.MediaType;
9
import org.springframework.http.ResponseEntity;
10
import org.springframework.stereotype.Controller;
21702 ashik.ali 11
import org.springframework.transaction.annotation.Transactional;
21532 kshitij.so 12
import org.springframework.web.bind.annotation.RequestMapping;
13
import org.springframework.web.bind.annotation.RequestMethod;
14
 
15
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
16
import com.spice.profitmandi.common.model.ProfitMandiConstants;
22609 ashik.ali 17
import com.spice.profitmandi.common.web.util.ResponseSender;
22555 amit.gupta 18
import com.spice.profitmandi.dao.repository.transaction.UserWalletRepository;
22605 ashik.ali 19
import com.spice.profitmandi.service.wallet.WalletService;
21532 kshitij.so 20
 
21
import io.swagger.annotations.ApiImplicitParam;
22
import io.swagger.annotations.ApiImplicitParams;
23
import io.swagger.annotations.ApiOperation;
24
 
25
@Controller
22037 amit.gupta 26
@Transactional(rollbackFor=Throwable.class)
21532 kshitij.so 27
public class WalletController {
28
 
29
	private static final Logger log=LoggerFactory.getLogger(WalletController.class);
30
 
31
	@Autowired
22931 ashik.ali 32
	private WalletService walletService;
22605 ashik.ali 33
 
21532 kshitij.so 34
	@Autowired
22931 ashik.ali 35
	private ResponseSender<?> responseSender;
22555 amit.gupta 36
 
21532 kshitij.so 37
	@RequestMapping(value = ProfitMandiConstants.URL_MY_WALLET, method=RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
38
	@ApiImplicitParams({
39
		@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", 
40
				required = true, dataType = "string", paramType = "header")
41
	})
42
	@ApiOperation(value = "")
22931 ashik.ali 43
	public ResponseEntity<?> getMyWallet(HttpServletRequest request) throws ProfitMandiBusinessException{
21532 kshitij.so 44
		int userId = (int)request.getAttribute("userId");
22931 ashik.ali 45
		return responseSender.ok(walletService.getUserWalletByUserId(userId));
21532 kshitij.so 46
	}
47
 
48
	@RequestMapping(value = ProfitMandiConstants.URL_MY_WALLET_HISTORY, method=RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
49
	@ApiImplicitParams({
50
		@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", 
51
				required = true, dataType = "string", paramType = "header")
52
	})
22931 ashik.ali 53
	public ResponseEntity<?> getMyWalletHistory(HttpServletRequest request) throws ProfitMandiBusinessException{
21532 kshitij.so 54
		int userId = (int)request.getAttribute("userId");
22931 ashik.ali 55
		return responseSender.ok(walletService.getUserWalletHistoryByUserId(userId));
21532 kshitij.so 56
	}
57
 
58
}