package quant.rich.emoney.tushare;

import java.time.LocalDateTime;

import lombok.Data;
import lombok.experimental.Accessors;

@Data
@Accessors(chain=true)
public class StockInfo implements ITsStockInfo {

    private String tsCode;
    private String name;
    private LocalDateTime listDate;
    private LocalDateTime delistDate;
    
    public Integer getGoodsId() {
        if (tsCode.endsWith("SH")) {
            return Integer.valueOf(tsCode.substring(0, 6));
        }
        if (tsCode.endsWith("SZ") || tsCode.endsWith("BJ")) {
            return Integer.valueOf("1" + tsCode.substring(0, 6));
        }
        throw new RuntimeException("无法将指定的 tsCode " + tsCode + " 转换成 goodsId");
    }
}
