新版仿ok交易所-后端
1
zyy
2025-12-22 4363803b4107bb7698391de0867236ce553e8f50
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
79
80
81
82
83
84
85
86
87
88
89
90
package com.yami.trading.security.common.enums;
 
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
 
/**
 * @program: trading-order-master
 * @description: 充值币种
 * @create: 2025-08-06 16:05
 **/
public enum CryptoCurrencyEnum {
    /*USDT_TRC20("usdt", "TRC20","usdt_trc20"),
    USDT_ERC20("usdt", "ERC20","usdt_erc20"),
    ETH("eth", "ETH","eth"),
    BTC("btc", "BTC","btc"),
    USDC_ERC20("usdc", "ERC20(1)","usdc_erc20(1)"),
    USDC_ERC202("usdc", "ERC20(2)","usdc_erc20(2)"),
    USDC_TRC20("usdc", "TRC20","usdc_trc20");*/
 
    USDT_TRC20("usdt", "TRC20","USDT-TRC20", "usdt"),
    USDT_ERC20("usdt", "ERC20","USDT-ERC20", "usdt"),
    ETH("eth", "ETH","ETH", "ethusdt"),
    BTC("btc", "BTC","BTC", "btcusdt"),
    USDC_ERC20("usdc", "ERC20","USDC", "usdcusdt"),
    USDC_TRC20("usdc", "TRC20","USDCTRC20", "usdcusdt");
 
 
    private final String coin;
    private final String chain;
    private final String name;
    private final String symbol;
 
    CryptoCurrencyEnum(String coin, String chain,String name, String symbol) {
        this.coin = coin;
        this.chain = chain;
        this.name = name;
        this.symbol = symbol;
    }
 
    public String getSymbol() {
        return symbol;
    }
 
    public String getCoin() {
        return coin;
    }
 
    public String getChain() {
        return chain;
    }
 
    public String getName() {
        return name;
    }
 
    // 可选:根据代码获取枚举值的方法
    public static CryptoCurrencyEnum fromCoin(String coin,String chain) {
        for (CryptoCurrencyEnum currency : values()) {
            if (currency.getCoin().equals(coin) && currency.getChain().equals(chain)) {
                return currency;
            }
        }
        throw new IllegalArgumentException("没找到对应的币种: " + coin);
    }
 
    /**
     * 获取所有枚举值(返回 List)
     */
    public static List<CryptoCurrencyEnum> getAll() {
        return Arrays.asList(values());
    }
 
    /**
     * 获取所有枚举值(按 coin 分组,返回 Map<String, List<CryptoCurrencyEnum>>)
     */
    public static Map<String, List<CryptoCurrencyEnum>> getAllGroupedByCoin() {
        return Arrays.stream(values())
                .collect(Collectors.groupingBy(CryptoCurrencyEnum::getCoin));
    }
 
    /**
     * 获取所有枚举值(按 chain 分组,返回 Map<String, List<CryptoCurrencyEnum>>)
     */
    public static Map<String, List<CryptoCurrencyEnum>> getAllGroupedByChain() {
        return Arrays.stream(values())
                .collect(Collectors.groupingBy(CryptoCurrencyEnum::getChain));
    }
}