Rev 22605 | Rev 22931 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
package com.spice.profitmandi.web.controller;import javax.servlet.http.HttpServletRequest;import org.slf4j.Logger;import org.slf4j.LoggerFactory;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.http.MediaType;import org.springframework.http.ResponseEntity;import org.springframework.stereotype.Controller;import org.springframework.transaction.annotation.Transactional;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RequestMethod;import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;import com.spice.profitmandi.common.model.ProfitMandiConstants;import com.spice.profitmandi.common.web.util.ResponseSender;import com.spice.profitmandi.dao.repository.transaction.UserWalletRepository;import com.spice.profitmandi.service.wallet.WalletService;import io.swagger.annotations.ApiImplicitParam;import io.swagger.annotations.ApiImplicitParams;import io.swagger.annotations.ApiOperation;@Controller@Transactional(rollbackFor=Throwable.class)public class WalletController {private static final Logger log=LoggerFactory.getLogger(WalletController.class);@AutowiredUserWalletRepository userWalletRepository;@AutowiredWalletService walletService;@AutowiredResponseSender<?> responseSender;@RequestMapping(value = ProfitMandiConstants.URL_MY_WALLET, method=RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)@ApiImplicitParams({@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token",required = true, dataType = "string", paramType = "header")})@ApiOperation(value = "")public ResponseEntity<?> getMyWallet(HttpServletRequest request){int userId = (int)request.getAttribute("userId");try{return responseSender.ok(walletService.getUserWalletByUserId(userId));}catch(ProfitMandiBusinessException profitMandiBusinessException){return responseSender.badRequest(profitMandiBusinessException);}}@RequestMapping(value = ProfitMandiConstants.URL_MY_WALLET_HISTORY, method=RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)@ApiImplicitParams({@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token",required = true, dataType = "string", paramType = "header")})public ResponseEntity<?> getMyWalletHistory(HttpServletRequest request){int userId = (int)request.getAttribute("userId");try{return responseSender.ok(walletService.getUserWalletHistoryByUserId(userId));}catch(ProfitMandiBusinessException profitMandiBusinessException){return responseSender.badRequest(profitMandiBusinessException);}}}