package project.web.api; import kernel.web.BaseAction; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.web.bind.annotation.*; import project.data.DataService; import project.party.PartyService; import project.redis.RedisHandler; import project.syspara.SysparaService; import project.wallet.WalletGatherService; import project.wallet.WalletService; import project.wallet.internal.WalletGatherServiceImpl; import javax.servlet.http.HttpServletRequest; import java.io.IOException; /** * 资金钱包 */ @RestController @CrossOrigin public class WalletGatherController extends BaseAction { private Logger logger = LoggerFactory.getLogger(WalletGatherController.class); // @Autowired // protected WalletGatherService walletGatherService; @Autowired private JdbcTemplate jdbcTemplate; @Autowired private RedisHandler redisHandler; @Autowired private WalletService walletService; @Autowired private PartyService partyService; @Autowired private SysparaService sysparaService; @Autowired private DataService dataService; private final String action = "/api/walletGrther!"; /** * 获取登录用户的资金账号 * @param request * @return */ @GetMapping(action + "get.action") public Object get(HttpServletRequest request) throws IOException { String partyId = this.getLoginPartyId(); WalletGatherService walletGatherService = new WalletGatherServiceImpl(jdbcTemplate,redisHandler,walletService); return walletGatherService.getWalletGatherByPartyId(partyId,dataService); } @PostMapping(action + "transfer.action") public Object transfer(HttpServletRequest request) throws IOException { String partyId = this.getLoginPartyId(); String currency = request.getParameter("currency"); String fromTo = request.getParameter("fromTo"); String amount = request.getParameter("amount"); String safeword = request.getParameter("safeword"); WalletGatherService walletGatherService = new WalletGatherServiceImpl(jdbcTemplate,redisHandler,walletService); return walletGatherService.transfer(partyId,currency,fromTo,amount,safeword,partyService,sysparaService); } @GetMapping(action + "getParameter.action") public Object getParameter(HttpServletRequest request) throws IOException { String partyId = this.getLoginPartyId(); String currency = request.getParameter("currency"); String fromTo = request.getParameter("fromTo"); WalletGatherService walletGatherService = new WalletGatherServiceImpl(jdbcTemplate,redisHandler,walletService); return walletGatherService.getParameter(partyId,currency,fromTo); } }