| 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
|
| 22555 |
amit.gupta |
32 |
UserWalletRepository userWalletRepository;
|
| 22605 |
ashik.ali |
33 |
|
| 21532 |
kshitij.so |
34 |
@Autowired
|
| 22605 |
ashik.ali |
35 |
WalletService walletService;
|
| 22555 |
amit.gupta |
36 |
|
| 22609 |
ashik.ali |
37 |
@Autowired
|
|
|
38 |
ResponseSender<?> responseSender;
|
|
|
39 |
|
| 21532 |
kshitij.so |
40 |
@RequestMapping(value = ProfitMandiConstants.URL_MY_WALLET, method=RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
41 |
@ApiImplicitParams({
|
|
|
42 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token",
|
|
|
43 |
required = true, dataType = "string", paramType = "header")
|
|
|
44 |
})
|
|
|
45 |
@ApiOperation(value = "")
|
|
|
46 |
public ResponseEntity<?> getMyWallet(HttpServletRequest request){
|
|
|
47 |
int userId = (int)request.getAttribute("userId");
|
| 22605 |
ashik.ali |
48 |
try{
|
|
|
49 |
return responseSender.ok(walletService.getUserWalletByUserId(userId));
|
|
|
50 |
}catch(ProfitMandiBusinessException profitMandiBusinessException){
|
|
|
51 |
return responseSender.badRequest(profitMandiBusinessException);
|
| 21532 |
kshitij.so |
52 |
}
|
|
|
53 |
}
|
|
|
54 |
|
|
|
55 |
@RequestMapping(value = ProfitMandiConstants.URL_MY_WALLET_HISTORY, method=RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
56 |
@ApiImplicitParams({
|
|
|
57 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token",
|
|
|
58 |
required = true, dataType = "string", paramType = "header")
|
|
|
59 |
})
|
|
|
60 |
public ResponseEntity<?> getMyWalletHistory(HttpServletRequest request){
|
|
|
61 |
int userId = (int)request.getAttribute("userId");
|
| 22605 |
ashik.ali |
62 |
try{
|
|
|
63 |
return responseSender.ok(walletService.getUserWalletHistoryByUserId(userId));
|
|
|
64 |
}catch(ProfitMandiBusinessException profitMandiBusinessException){
|
|
|
65 |
return responseSender.badRequest(profitMandiBusinessException);
|
| 21532 |
kshitij.so |
66 |
}
|
|
|
67 |
}
|
|
|
68 |
|
|
|
69 |
}
|