Subversion Repositories SmartDukaan

Rev

Rev 22555 | Rev 22609 | 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;
21735 ashik.ali 17
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
22555 amit.gupta 18
import com.spice.profitmandi.dao.repository.transaction.UserWalletHistoryRepository;
19
import com.spice.profitmandi.dao.repository.transaction.UserWalletRepository;
22605 ashik.ali 20
import com.spice.profitmandi.service.wallet.WalletService;
21532 kshitij.so 21
 
22
import io.swagger.annotations.ApiImplicitParam;
23
import io.swagger.annotations.ApiImplicitParams;
24
import io.swagger.annotations.ApiOperation;
25
 
26
@Controller
22037 amit.gupta 27
@Transactional(rollbackFor=Throwable.class)
21532 kshitij.so 28
public class WalletController {
29
 
30
	private static final Logger log=LoggerFactory.getLogger(WalletController.class);
31
 
32
	@Autowired
22555 amit.gupta 33
	UserWalletRepository userWalletRepository;
22605 ashik.ali 34
 
21532 kshitij.so 35
	@Autowired
22605 ashik.ali 36
	WalletService walletService;
22555 amit.gupta 37
 
21532 kshitij.so 38
	@RequestMapping(value = ProfitMandiConstants.URL_MY_WALLET, method=RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
39
	@ApiImplicitParams({
40
		@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", 
41
				required = true, dataType = "string", paramType = "header")
42
	})
43
	@ApiOperation(value = "")
44
	public ResponseEntity<?> getMyWallet(HttpServletRequest request){
45
		int userId = (int)request.getAttribute("userId");
22605 ashik.ali 46
		try{
47
			return responseSender.ok(walletService.getUserWalletByUserId(userId));
48
		}catch(ProfitMandiBusinessException profitMandiBusinessException){
49
			return responseSender.badRequest(profitMandiBusinessException);
21532 kshitij.so 50
		}
51
	}
52
 
53
	@RequestMapping(value = ProfitMandiConstants.URL_MY_WALLET_HISTORY, method=RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
54
	@ApiImplicitParams({
55
		@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", 
56
				required = true, dataType = "string", paramType = "header")
57
	})
58
	public ResponseEntity<?> getMyWalletHistory(HttpServletRequest request){
59
		int userId = (int)request.getAttribute("userId");
22605 ashik.ali 60
		try{
61
			return responseSender.ok(walletService.getUserWalletHistoryByUserId(userId));
62
		}catch(ProfitMandiBusinessException profitMandiBusinessException){
63
			return responseSender.badRequest(profitMandiBusinessException);
21532 kshitij.so 64
		}
65
	}
66
 
67
}