zyy
2025-08-25 9022a1683dee2eb8bf113abf301b36556b5fa873
src/main/java/com/nq/enums/EStockType.java
@@ -1,8 +1,7 @@
package com.nq.enums;
import com.nq.constant.StockConstant;
import lombok.Data;
import com.nq.utils.PropertiesUtil;
/**
 * 股票类型
@@ -11,8 +10,18 @@
public enum EStockType {
    IN("IN","印度股票","14", StockConstant.HTTP_API,StockConstant.KEY),
    US("US","美国股票","5",StockConstant.US_API_URL,StockConstant.US_KEY);
    US("US","美国股票","5",PropertiesUtil.getProperty("US_HTTP_API"),PropertiesUtil.getProperty("US_KEY"),"USD","$"),
    HK("HK","香港股票","39",PropertiesUtil.getProperty("HK_HTTP_API"),PropertiesUtil.getProperty("HK_KEY"),"HKD","HK$"),
    IN("IN","印度股票","14", PropertiesUtil.getProperty("JS_IN_HTTP_URL"),PropertiesUtil.getProperty("JS_IN_KEY"),"INR","₹"),
    //MX("MEX","墨西哥股票","7",PropertiesUtil.getProperty("MX_HTTP_API"),PropertiesUtil.getProperty("MX_KEY"),"MXN","MX$"),
    TW("TW","台湾股票","46",PropertiesUtil.getProperty("TW_HTTP_API"),PropertiesUtil.getProperty("TW_KEY"),"TWD","NT$");
    private String code;
    private String typeDesc;
    public String contryId;
@@ -20,20 +29,64 @@
    public String stockUrl;
    public  String stockKey;
    private String symbol;
    EStockType(String code, String typeDesc, String contryId, String stockUrl, String stockKey) {
    private String symbol1;
    public static EStockType getDefault() {
        return US; // 指定默认
    }
    EStockType(String code, String typeDesc, String contryId, String stockUrl, String stockKey,String  symbol,String symbol1) {
        this.code = code;
        this.typeDesc = typeDesc;
        this.contryId = contryId;
        this.stockUrl = stockUrl;
        this.stockKey = stockKey;
        this.symbol = symbol;
        this.symbol1 = symbol1;
    }
    public static EStockType getEStockTypeByCode(String code){
        if(EStockType.US.getCode().equals(code)){
            return US;
        }else if(EStockType.HK.getCode().equals(code)){
            return HK;
        }else if(EStockType.IN.getCode().equals(code)){
            return IN;
        }else if(EStockType.TW.getCode().equals(code)){
            return TW;
        }else{
            return  IN;
            return US;
        }
    }
    public static boolean isExistByCode(String code){
        if(EStockType.US.getCode().equals(code)){
            return true;
        }else if(EStockType.HK.getCode().equals(code)){
            return true;
        }else if(EStockType.IN.getCode().equals(code)){
            return true;
        }else if(EStockType.TW.getCode().equals(code)){
            return true;
        }else{
            return false;
        }
    }
    //根据货币获取类型
    public static EStockType getEStockTypeBySymbol(String symbol){
        if(EStockType.US.getSymbol().equals(symbol)){
            return US;
        }else if(EStockType.HK.getSymbol().equals(symbol)){
            return HK;
        }else if(EStockType.IN.getSymbol().equals(symbol)){
            return IN;
        }else if(EStockType.TW.getSymbol().equals(symbol)){
            return TW;
        }else{
            return null;
        }
    }
@@ -53,6 +106,22 @@
        return code;
    }
    public String getSymbol() {
        return symbol;
    }
    public void setSymbol(String symbol) {
        this.symbol = symbol;
    }
    public String getSymbol1() {
        return symbol1;
    }
    public void setSymbol1(String symbol1) {
        this.symbol1 = symbol1;
    }
    public String getTypeDesc() {
        return typeDesc;
    }