zj
2025-02-17 76bc979b654c23be393c9c46c9e3099cdd3785ec
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
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);
    }
 
 
}